Changeset 145331 in webkit


Ignore:
Timestamp:
Mar 10, 2013 12:57:08 PM (11 years ago)
Author:
mkwst@chromium.org
Message:

XSSAuditor doesn't need a copy of the original document URL.
https://bugs.webkit.org/show_bug.cgi?id=111944

Reviewed by Adam Barth.

When creating an XSSInfo object in response to detecting reflected XSS
on a page, the Auditor was passing in a copy of the document's
original URL for reporting. It doesn't look like we need this, as
XSSInfo's only consumer, XSSAuditorDelegate, runs on the main thread
with access to the document. We can obtain access to the same
information by reading the URL directly from the delegate's Document
object if and when we need it.

  • html/parser/XSSAuditorDelegate.cpp:

(WebCore::XSSAuditorDelegate::didBlockScript):

Read the document's URL directly in order to create a violation
report.

(WebCore::XSSInfo::isSafeToSendToAnotherThread):

  • html/parser/XSSAuditorDelegate.h:

(WebCore::XSSInfo::create):
(WebCore::XSSInfo::XSSInfo):

  • html/parser/XSSAuditor.cpp:

(WebCore::XSSAuditor::init):
(WebCore::XSSAuditor::filterToken):
(WebCore::XSSAuditor::isSafeToSendToAnotherThread):

  • html/parser/XSSAuditor.h:

Remove the copied original URL from both XSSInfo objects and the
XSSAuditor.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r145327 r145331  
     12013-03-10  Mike West  <mkwst@chromium.org>
     2
     3        XSSAuditor doesn't need a copy of the original document URL.
     4        https://bugs.webkit.org/show_bug.cgi?id=111944
     5
     6        Reviewed by Adam Barth.
     7
     8        When creating an XSSInfo object in response to detecting reflected XSS
     9        on a page, the Auditor was passing in a copy of the document's
     10        original URL for reporting. It doesn't look like we need this, as
     11        XSSInfo's only consumer, XSSAuditorDelegate, runs on the main thread
     12        with access to the document. We can obtain access to the same
     13        information by reading the URL directly from the delegate's Document
     14        object if and when we need it.
     15
     16        * html/parser/XSSAuditorDelegate.cpp:
     17        (WebCore::XSSAuditorDelegate::didBlockScript):
     18            Read the document's URL directly in order to create a violation
     19            report.
     20        (WebCore::XSSInfo::isSafeToSendToAnotherThread):
     21        * html/parser/XSSAuditorDelegate.h:
     22        (WebCore::XSSInfo::create):
     23        (WebCore::XSSInfo::XSSInfo):
     24        * html/parser/XSSAuditor.cpp:
     25        (WebCore::XSSAuditor::init):
     26        (WebCore::XSSAuditor::filterToken):
     27        (WebCore::XSSAuditor::isSafeToSendToAnotherThread):
     28        * html/parser/XSSAuditor.h:
     29            Remove the copied original URL from both XSSInfo objects and the
     30            XSSAuditor.
     31
    1322013-03-10  Andreas Kling  <akling@apple.com>
    233
  • trunk/Source/WebCore/html/parser/XSSAuditor.cpp

    r145115 r145331  
    313313    }
    314314
    315     if (!m_reportURL.isEmpty()) {
    316         // May need these for reporting later on.
    317         m_originalURL = m_documentURL.string().isolatedCopy();
     315    if (!m_reportURL.isEmpty())
    318316        m_originalHTTPBody = httpBodyAsString;
    319     }
    320317}
    321318
     
    338335    if (didBlockScript) {
    339336        bool didBlockEntirePage = (m_xssProtection == ContentSecurityPolicy::BlockReflectedXSS);
    340         OwnPtr<XSSInfo> xssInfo = XSSInfo::create(m_reportURL, m_originalURL, m_originalHTTPBody, didBlockEntirePage);
     337        OwnPtr<XSSInfo> xssInfo = XSSInfo::create(m_reportURL, m_originalHTTPBody, didBlockEntirePage);
    341338        if (!m_reportURL.isEmpty()) {
    342339            m_reportURL = KURL();
    343             m_originalURL = String();
    344340            m_originalHTTPBody = String();
    345341        }
     
    732728{
    733729    return m_documentURL.isSafeToSendToAnotherThread()
    734         && m_originalURL.isSafeToSendToAnotherThread()
    735730        && m_originalHTTPBody.isSafeToSendToAnotherThread()
    736731        && m_decodedURL.isSafeToSendToAnotherThread()
  • trunk/Source/WebCore/html/parser/XSSAuditor.h

    r145115 r145331  
    106106    ContentSecurityPolicy::ReflectedXSSDisposition m_xssProtection;
    107107
    108     String m_originalURL;
    109108    String m_originalHTTPBody;
    110109    String m_decodedURL;
  • trunk/Source/WebCore/html/parser/XSSAuditorDelegate.cpp

    r145115 r145331  
    4444{
    4545    return m_reportURL.isSafeToSendToAnotherThread()
    46         && m_originalURL.isSafeToSendToAnotherThread()
    4746        && m_originalHTTPBody.isSafeToSendToAnotherThread();
    4847}
     
    7473    if (!xssInfo.m_reportURL.isEmpty()) {
    7574        RefPtr<InspectorObject> reportDetails = InspectorObject::create();
    76         reportDetails->setString("request-url", xssInfo.m_originalURL);
     75        reportDetails->setString("request-url", m_document->url().string());
    7776        reportDetails->setString("request-body", xssInfo.m_originalHTTPBody);
    7877
  • trunk/Source/WebCore/html/parser/XSSAuditorDelegate.h

    r145115 r145331  
    4040class XSSInfo {
    4141public:
    42     static PassOwnPtr<XSSInfo> create(const KURL& reportURL, const String& originalURL, const String& originalHTTPBody, bool didBlockEntirePage)
     42    static PassOwnPtr<XSSInfo> create(const KURL& reportURL, const String& originalHTTPBody, bool didBlockEntirePage)
    4343    {
    44         return adoptPtr(new XSSInfo(reportURL, originalURL, originalHTTPBody, didBlockEntirePage));
     44        return adoptPtr(new XSSInfo(reportURL, originalHTTPBody, didBlockEntirePage));
    4545    }
    4646
     
    4848
    4949    KURL m_reportURL;
    50     String m_originalURL;
    5150    String m_originalHTTPBody;
    5251    bool m_didBlockEntirePage;
     
    5453
    5554private:
    56     XSSInfo(const KURL& reportURL, const String& originalURL, const String& originalHTTPBody, bool didBlockEntirePage)
     55    XSSInfo(const KURL& reportURL, const String& originalHTTPBody, bool didBlockEntirePage)
    5756        : m_reportURL(reportURL)
    58         , m_originalURL(originalURL)
    5957        , m_originalHTTPBody(originalHTTPBody)
    6058        , m_didBlockEntirePage(didBlockEntirePage)
Note: See TracChangeset for help on using the changeset viewer.