Changeset 251861 in webkit


Ignore:
Timestamp:
Oct 31, 2019 10:52:49 AM (4 years ago)
Author:
achristensen@apple.com
Message:

Use SecurityOriginData in NetworkProcess where possible without other changes
https://bugs.webkit.org/show_bug.cgi?id=203615

Reviewed by Brady Eidson.

Source/WebCore:

  • page/SecurityOrigin.cpp:

(WebCore::SecurityOrigin::SecurityOrigin):
(WebCore::SecurityOrigin::isolatedCopy const):

  • page/SecurityOrigin.h:
  • page/SecurityOriginData.h:

(WebCore::SecurityOriginData::encode const):

  • page/csp/ContentSecurityPolicy.cpp:

(WebCore::ContentSecurityPolicy::allowFrameAncestors const):

  • page/csp/ContentSecurityPolicy.h:
  • page/csp/ContentSecurityPolicyDirectiveList.cpp:

(WebCore::urlFromOrigin):
(WebCore::checkFrameAncestors):
(WebCore::ContentSecurityPolicyDirectiveList::violatedDirectiveForFrameAncestorOrigins const):

  • page/csp/ContentSecurityPolicyDirectiveList.h:

Source/WebKit:

  • NetworkProcess/NetworkResourceLoadParameters.cpp:

(WebKit::NetworkResourceLoadParameters::encode const):

  • NetworkProcess/NetworkResourceLoadParameters.h:
  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::shouldInterruptLoadForXFrameOptions):

  • WebProcess/Network/WebLoaderStrategy.cpp:

(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):

Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r251857 r251861  
     12019-10-31  Alex Christensen  <achristensen@webkit.org>
     2
     3        Use SecurityOriginData in NetworkProcess where possible without other changes
     4        https://bugs.webkit.org/show_bug.cgi?id=203615
     5
     6        Reviewed by Brady Eidson.
     7
     8        * page/SecurityOrigin.cpp:
     9        (WebCore::SecurityOrigin::SecurityOrigin):
     10        (WebCore::SecurityOrigin::isolatedCopy const):
     11        * page/SecurityOrigin.h:
     12        * page/SecurityOriginData.h:
     13        (WebCore::SecurityOriginData::encode const):
     14        * page/csp/ContentSecurityPolicy.cpp:
     15        (WebCore::ContentSecurityPolicy::allowFrameAncestors const):
     16        * page/csp/ContentSecurityPolicy.h:
     17        * page/csp/ContentSecurityPolicyDirectiveList.cpp:
     18        (WebCore::urlFromOrigin):
     19        (WebCore::checkFrameAncestors):
     20        (WebCore::ContentSecurityPolicyDirectiveList::violatedDirectiveForFrameAncestorOrigins const):
     21        * page/csp/ContentSecurityPolicyDirectiveList.h:
     22
    1232019-10-31  Zalan Bujtas  <zalan@apple.com>
    224
  • trunk/Source/WebCore/page/SecurityOrigin.cpp

    r250739 r251861  
    172172}
    173173
    174 SecurityOrigin::SecurityOrigin(const SecurityOrigin* other)
    175     : m_data { other->m_data.isolatedCopy() }
    176     , m_domain { other->m_domain.isolatedCopy() }
    177     , m_filePath { other->m_filePath.isolatedCopy() }
    178     , m_isUnique { other->m_isUnique }
    179     , m_universalAccess { other->m_universalAccess }
    180     , m_domainWasSetInDOM { other->m_domainWasSetInDOM }
    181     , m_canLoadLocalResources { other->m_canLoadLocalResources }
    182     , m_storageBlockingPolicy { other->m_storageBlockingPolicy }
    183     , m_enforcesFilePathSeparation { other->m_enforcesFilePathSeparation }
    184     , m_needsStorageAccessFromFileURLsQuirk { other->m_needsStorageAccessFromFileURLsQuirk }
    185     , m_isPotentiallyTrustworthy { other->m_isPotentiallyTrustworthy }
    186     , m_isLocal { other->m_isLocal }
     174SecurityOrigin::SecurityOrigin(const SecurityOrigin& other)
     175    : m_data { other.m_data.isolatedCopy() }
     176    , m_domain { other.m_domain.isolatedCopy() }
     177    , m_filePath { other.m_filePath.isolatedCopy() }
     178    , m_isUnique { other.m_isUnique }
     179    , m_universalAccess { other.m_universalAccess }
     180    , m_domainWasSetInDOM { other.m_domainWasSetInDOM }
     181    , m_canLoadLocalResources { other.m_canLoadLocalResources }
     182    , m_storageBlockingPolicy { other.m_storageBlockingPolicy }
     183    , m_enforcesFilePathSeparation { other.m_enforcesFilePathSeparation }
     184    , m_needsStorageAccessFromFileURLsQuirk { other.m_needsStorageAccessFromFileURLsQuirk }
     185    , m_isPotentiallyTrustworthy { other.m_isPotentiallyTrustworthy }
     186    , m_isLocal { other.m_isLocal }
    187187{
    188188}
     
    219219Ref<SecurityOrigin> SecurityOrigin::isolatedCopy() const
    220220{
    221     return adoptRef(*new SecurityOrigin(this));
     221    return adoptRef(*new SecurityOrigin(*this));
    222222}
    223223
  • trunk/Source/WebCore/page/SecurityOrigin.h

    r244853 r251861  
    222222    SecurityOrigin();
    223223    explicit SecurityOrigin(const URL&);
    224     explicit SecurityOrigin(const SecurityOrigin*);
     224    explicit SecurityOrigin(const SecurityOrigin&);
    225225
    226226    // FIXME: Rename this function to something more semantic.
  • trunk/Source/WebCore/page/SecurityOriginData.h

    r239461 r251861  
    9898void SecurityOriginData::encode(Encoder& encoder) const
    9999{
     100    ASSERT(!isEmpty());
    100101    encoder << protocol;
    101102    encoder << host;
  • trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp

    r251425 r251861  
    509509}
    510510
    511 bool ContentSecurityPolicy::allowFrameAncestors(const Vector<RefPtr<SecurityOrigin>>& ancestorOrigins, const URL& url, bool overrideContentSecurityPolicy) const
     511bool ContentSecurityPolicy::allowFrameAncestors(const Vector<SecurityOriginData>& ancestorOrigins, const URL& url, bool overrideContentSecurityPolicy) const
    512512{
    513513    if (overrideContentSecurityPolicy)
  • trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h

    r251425 r251861  
    100100
    101101    bool allowFrameAncestors(const Frame&, const URL&, bool overrideContentSecurityPolicy = false) const;
    102     WEBCORE_EXPORT bool allowFrameAncestors(const Vector<RefPtr<SecurityOrigin>>& ancestorOrigins, const URL&, bool overrideContentSecurityPolicy = false) const;
     102    WEBCORE_EXPORT bool allowFrameAncestors(const Vector<SecurityOriginData>& ancestorOrigins, const URL&, bool overrideContentSecurityPolicy = false) const;
    103103    WEBCORE_EXPORT bool overridesXFrameOptions() const;
    104104
  • trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp

    r248846 r251861  
    8080}
    8181
     82static inline URL urlFromOrigin(const SecurityOriginData& origin)
     83{
     84    return { URL { }, origin.toString() };
     85}
     86
    8287static inline bool checkFrameAncestors(ContentSecurityPolicySourceListDirective* directive, const Frame& frame)
    8388{
     
    9398}
    9499
    95 static inline bool checkFrameAncestors(ContentSecurityPolicySourceListDirective* directive, const Vector<RefPtr<SecurityOrigin>>& ancestorOrigins)
     100static inline bool checkFrameAncestors(ContentSecurityPolicySourceListDirective* directive, const Vector<SecurityOriginData>& ancestorOrigins)
    96101{
    97102    if (!directive)
     
    99104    bool didReceiveRedirectResponse = false;
    100105    for (auto& origin : ancestorOrigins) {
    101         URL originURL = urlFromOrigin(*origin);
     106        URL originURL = urlFromOrigin(origin);
    102107        if (!originURL.isValid() || !directive->allows(originURL, didReceiveRedirectResponse, ContentSecurityPolicySourceListDirective::ShouldAllowEmptyURLIfSourceListIsNotNone::No))
    103108            return false;
     
    259264}
    260265
    261 const ContentSecurityPolicyDirective* ContentSecurityPolicyDirectiveList::violatedDirectiveForFrameAncestorOrigins(const Vector<RefPtr<SecurityOrigin>>& ancestorOrigins) const
     266const ContentSecurityPolicyDirective* ContentSecurityPolicyDirectiveList::violatedDirectiveForFrameAncestorOrigins(const Vector<SecurityOriginData>& ancestorOrigins) const
    262267{
    263268    if (checkFrameAncestors(m_frameAncestors.get(), ancestorOrigins))
  • trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.h

    r244589 r251861  
    6363    const ContentSecurityPolicyDirective* violatedDirectiveForFrame(const URL&, bool didReceiveRedirectResponse) const;
    6464    const ContentSecurityPolicyDirective* violatedDirectiveForFrameAncestor(const Frame&) const;
    65     const ContentSecurityPolicyDirective* violatedDirectiveForFrameAncestorOrigins(const Vector<RefPtr<SecurityOrigin>>&) const;
     65    const ContentSecurityPolicyDirective* violatedDirectiveForFrameAncestorOrigins(const Vector<SecurityOriginData>&) const;
    6666    const ContentSecurityPolicyDirective* violatedDirectiveForImage(const URL&, bool didReceiveRedirectResponse) const;
    6767#if ENABLE(APPLICATION_MANIFEST)
  • trunk/Source/WebKit/ChangeLog

    r251859 r251861  
     12019-10-31  Alex Christensen  <achristensen@webkit.org>
     2
     3        Use SecurityOriginData in NetworkProcess where possible without other changes
     4        https://bugs.webkit.org/show_bug.cgi?id=203615
     5
     6        Reviewed by Brady Eidson.
     7
     8        * NetworkProcess/NetworkResourceLoadParameters.cpp:
     9        (WebKit::NetworkResourceLoadParameters::encode const):
     10        * NetworkProcess/NetworkResourceLoadParameters.h:
     11        * NetworkProcess/NetworkResourceLoader.cpp:
     12        (WebKit::NetworkResourceLoader::shouldInterruptLoadForXFrameOptions):
     13        * WebProcess/Network/WebLoaderStrategy.cpp:
     14        (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
     15
    1162019-10-31  Alex Christensen  <achristensen@webkit.org>
    217
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp

    r251155 r251861  
    9393        encoder << *sourceOrigin;
    9494    encoder << static_cast<bool>(topOrigin);
    95     if (sourceOrigin)
     95    if (topOrigin)
    9696        encoder << *topOrigin;
    9797    encoder << options;
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h

    r251155 r251861  
    5959    WebCore::PreflightPolicy preflightPolicy { WebCore::PreflightPolicy::Consider };
    6060    bool shouldEnableCrossOriginResourcePolicy { false };
    61     Vector<RefPtr<WebCore::SecurityOrigin>> frameAncestorOrigins;
     61    Vector<WebCore::SecurityOriginData> frameAncestorOrigins;
    6262    bool isHTTPSUpgradeEnabled { false };
    6363
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r251786 r251861  
    411411    case XFrameOptionsSameOrigin: {
    412412        auto origin = SecurityOrigin::create(url);
    413         auto topFrameOrigin = m_parameters.frameAncestorOrigins.last();
    414         if (!origin->isSameSchemeHostPort(*topFrameOrigin))
    415             return true;
    416413        for (auto& ancestorOrigin : m_parameters.frameAncestorOrigins) {
    417             if (!origin->isSameSchemeHostPort(*ancestorOrigin))
     414            if (!origin->isSameSchemeHostPort(ancestorOrigin.securityOrigin()))
    418415                return true;
    419416        }
  • trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp

    r251585 r251861  
    337337
    338338    if (resourceLoader.options().mode == FetchOptions::Mode::Navigate) {
    339         Vector<RefPtr<SecurityOrigin>> frameAncestorOrigins;
     339        Vector<SecurityOriginData> frameAncestorOrigins;
    340340        for (auto* frame = resourceLoader.frame()->tree().parent(); frame; frame = frame->tree().parent())
    341             frameAncestorOrigins.append(makeRefPtr(frame->document()->securityOrigin()));
     341            frameAncestorOrigins.append(frame->document()->securityOrigin().data());
    342342        loadParameters.frameAncestorOrigins = WTFMove(frameAncestorOrigins);
    343343    }
Note: See TracChangeset for help on using the changeset viewer.