Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Issue 22254005: UMA data collector for cross-site documents(XSD) (Closed)

Created:
7 years, 4 months ago by dsjang
Modified:
7 years, 3 months ago
CC:
chromium-reviews, joi+watch-content_chromium.org, darin-cc_chromium.org, jam
Base URL:
https://chromium.googlesource.com/chromium/src.git@lkgr
Visibility:
Public.

Description

UMA data collector for cross-site documents(XSD) Intercept cross-site documents and apply a couple of blocking filters to measure how our cross-site document blocking policy affects the renderer behavior. This doesn't actually block anything, but just records UMA data about how these filters work. It does three things: 1) whitelists legitimate XSDs (responses with whitelisted mime types or with valid CORS headers) 2) applies an appropriate content sniffing algorithm depending on the mime type of the response, 3) if it is sniffed as a blocked document, reports its status code and the context (img, script, etc) where the request is originally issued to measure the compatibility impact of the blocking. BUG=268640 Related Doc: https://docs.google.com/a/google.com/document/d/1nB3GruRqQmtA7OPZZAhWOsZDvfWpYpKQXE3cxGxTVfs/edit Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=219383

Patch Set 1 #

Total comments: 41

Patch Set 2 : The formatting of weburlloader_impl.cc is reverted #

Patch Set 3 : feedback applied, scheme whitelisting is switched to blacklisting # #

Patch Set 4 : switched to using UMA_HISTOGRAM_ENUMERATION from COUNTS #

Total comments: 19

Patch Set 5 : UMA Bucket names are reorganized. #

Total comments: 56

Patch Set 6 : Comments & style have been updated. #

Total comments: 133

Patch Set 7 : Change the way that static globals are handled #

Patch Set 8 : Merge lkgr into local branch #

Total comments: 63

Patch Set 9 : "X-Content-Type-Options: nosniff" rule is added. #

Total comments: 8

Patch Set 10 : Revise comments and use lowercaseequls for "nosniff" value #

Total comments: 14

Patch Set 11 : Move from /webkit to /content and include <!-- for HTML sniffing #

Patch Set 12 : Converted into Peer wrapping real Peer in IPCResourceLoaderBridge #

Patch Set 13 : nitpick change #

Patch Set 14 : a problem with refcounted is fixed #

Total comments: 14

Patch Set 15 : ResourceDispatcher uses SiteIsolationPolicy as the outermost Peer #

Total comments: 8

Patch Set 16 : SiteIsolationPolicy turns static again #

Patch Set 17 : blocking code gets simpler and testcase is moved to /content #

Total comments: 60

Patch Set 18 : Comments and naming are improved #

Patch Set 19 : Names are corrected #

Total comments: 2

Patch Set 20 : Blocking code is moved to SiteIsolationPolicy from ResourceDispatcher. #

Total comments: 4

Patch Set 21 : Comments are updated to be better #

Patch Set 22 : Fix copyright notice. #

Patch Set 23 : Disable tests on Android #

Patch Set 24 : fix compile error #

Total comments: 13
Unified diffs Side-by-side diffs Delta from patch set Stats (+1180 lines, -9 lines) Patch
M content/browser/renderer_host/render_process_host_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -0 lines 0 comments Download
M content/child/request_extra_data.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +3 lines, -0 lines 0 comments Download
M content/child/request_extra_data.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +2 lines, -0 lines 0 comments Download
M content/child/resource_dispatcher.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 chunks +7 lines, -0 lines 0 comments Download
M content/child/resource_dispatcher.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 12 chunks +41 lines, -6 lines 0 comments Download
M content/child/resource_dispatcher_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +2 lines, -1 line 0 comments Download
A content/child/site_isolation_policy.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +179 lines, -0 lines 1 comment Download
A content/child/site_isolation_policy.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +561 lines, -0 lines 12 comments Download
A content/child/site_isolation_policy_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +106 lines, -0 lines 0 comments Download
A content/child/site_isolation_policy_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +125 lines, -0 lines 0 comments Download
M content/content_child.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +2 lines, -0 lines 0 comments Download
M content/content_tests.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2 chunks +2 lines, -0 lines 0 comments Download
M content/public/common/content_switches.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2 chunks +2 lines, -1 line 0 comments Download
M content/public/common/content_switches.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +6 lines, -0 lines 0 comments Download
M content/renderer/render_frame_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/cross_site_document_request.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +81 lines, -0 lines 0 comments Download
A content/test/data/cross_site_document_request_target.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +39 lines, -0 lines 0 comments Download
A content/test/data/site_isolation/comment_js.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +2 lines, -0 lines 0 comments Download
A content/test/data/site_isolation/comment_valid.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +2 lines, -0 lines 0 comments Download
A content/test/data/site_isolation/html.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/img.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/img.json View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/img.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/img.xml View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/js.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/js.json View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/js.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/js.xml View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/json.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/valid.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/valid.json View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/valid.xml View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
A content/test/data/site_isolation/xml.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
M net/tools/testserver/testserver.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +1 line, -0 lines 0 comments Download
M webkit/child/resource_loader_bridge.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 38 (0 generated)
dsjang
7 years, 4 months ago (2013-08-05 23:15:52 UTC) #1
dsjang
Disruptive formatting in weburlloader_impl.cc has been reverted.
7 years, 4 months ago (2013-08-06 16:48:59 UTC) #2
nasko
A bunch of comments. I will review the weburlloader_impl.cc in the properly formatted way later. ...
7 years, 4 months ago (2013-08-06 17:29:27 UTC) #3
dsjang
Nasko's feedback has been applied. Scheme whitelisting is switched to blacklisting(http,https). https://codereview.chromium.org/22254005/diff/1/webkit/child/site_isolation_policy.cc File webkit/child/site_isolation_policy.cc (right): ...
7 years, 4 months ago (2013-08-07 00:19:06 UTC) #4
Charlie Reis
Just from an initial glance, I think we need to step back and talk about ...
7 years, 4 months ago (2013-08-07 21:02:02 UTC) #5
dsjang
Bucket names are reorganized. https://codereview.chromium.org/22254005/diff/20001/content/renderer/render_frame_impl.cc File content/renderer/render_frame_impl.cc (right): https://codereview.chromium.org/22254005/diff/20001/content/renderer/render_frame_impl.cc#newcode76 content/renderer/render_frame_impl.cc:76: using webkit_glue::SiteIsolationPolicy; On 2013/08/07 21:02:02, ...
7 years, 4 months ago (2013-08-08 21:21:00 UTC) #6
Charlie Reis
I'm only up to the macros, but here's my review comments so far. I can ...
7 years, 4 months ago (2013-08-09 00:39:02 UTC) #7
dsjang
https://codereview.chromium.org/22254005/diff/26001/content/renderer/render_frame_impl.cc File content/renderer/render_frame_impl.cc (right): https://codereview.chromium.org/22254005/diff/26001/content/renderer/render_frame_impl.cc#newcode621 content/renderer/render_frame_impl.cc:621: // Calling this will do bookkeeping of an object ...
7 years, 4 months ago (2013-08-09 01:31:23 UTC) #8
Charlie Reis
Thanks! More comments on the rest below. I agree with Nasko that it would help ...
7 years, 4 months ago (2013-08-09 18:48:38 UTC) #9
nasko
Looks much better! The one thing I haven't done is verify your state machine for ...
7 years, 4 months ago (2013-08-09 19:07:28 UTC) #10
dsjang
Change the way that static globals are handled to be compatible with Clang++ rules & ...
7 years, 4 months ago (2013-08-12 22:56:17 UTC) #11
Charlie Reis
Thanks for all the changes. Looks like there were some missed comments from last time, ...
7 years, 4 months ago (2013-08-13 00:53:19 UTC) #12
dsjang
More test cases are added and code formatting & comments are improved. https://codereview.chromium.org/22254005/diff/32001/webkit/child/site_isolation_policy_unittest.cc File webkit/child/site_isolation_policy_unittest.cc ...
7 years, 4 months ago (2013-08-13 20:54:48 UTC) #13
Charlie Reis
LGTM with nits. I think you can send it to Darin once these are fixed. ...
7 years, 4 months ago (2013-08-13 21:09:03 UTC) #14
dsjang
darin: the goal of this CL is described in detail at the end of this ...
7 years, 4 months ago (2013-08-13 21:49:52 UTC) #15
darin (slow to review)
https://codereview.chromium.org/22254005/diff/77001/webkit/child/site_isolation_policy.cc File webkit/child/site_isolation_policy.cc (right): https://codereview.chromium.org/22254005/diff/77001/webkit/child/site_isolation_policy.cc#newcode122 webkit/child/site_isolation_policy.cc:122: #define SITE_ISOLATION_POLICY_COUNT_BLOCK(BUCKET_PREFIX) \ nit: Can you do all of ...
7 years, 4 months ago (2013-08-14 05:23:26 UTC) #16
dsjang
As darin suggested, site_isolation_policy.cc is moved to /content/child. I'd like to get reviews about the ...
7 years, 4 months ago (2013-08-14 20:47:03 UTC) #17
dsjang
SiteIsolationPolicy is converted to a ResourceLoaderBridge::Peer which wraps the original Peer used by IPCResourceLoaderBridge. The ...
7 years, 4 months ago (2013-08-16 17:52:40 UTC) #18
Charlie Reis
Just a few minor comments while we wait for Darin's thoughts on the approach. https://codereview.chromium.org/22254005/diff/159001/content/child/request_extra_data.h ...
7 years, 4 months ago (2013-08-19 16:20:05 UTC) #19
dsjang
https://codereview.chromium.org/22254005/diff/159001/content/child/request_extra_data.h File content/child/request_extra_data.h (right): https://codereview.chromium.org/22254005/diff/159001/content/child/request_extra_data.h#newcode51 content/child/request_extra_data.h:51: WebKit::WebString frame_origin_; The first object we get from WebKit ...
7 years, 4 months ago (2013-08-19 21:37:17 UTC) #20
darin (slow to review)
If I were writing this patch, I probably wouldn't attempt chaining ResourceLoaderBridge::Peer objects because of ...
7 years, 4 months ago (2013-08-20 23:47:05 UTC) #21
dsjang
SiteIsolationPolicy is converted into a purely static class, a command-line argument --cross-site-document-blocking is added to ...
7 years, 4 months ago (2013-08-21 18:49:56 UTC) #22
dsjang
Blocking logic gets simpler, and test cases for SiteIsolationPolicy are moved to /content from /chrome.
7 years, 4 months ago (2013-08-22 00:15:11 UTC) #23
Charlie Reis
On one hand, this CL is a bit larger due to including the blocking logic ...
7 years, 4 months ago (2013-08-22 18:23:29 UTC) #24
dsjang
Comments and naming are improved https://codereview.chromium.org/22254005/diff/208001/content/child/resource_dispatcher.cc File content/child/resource_dispatcher.cc (right): https://codereview.chromium.org/22254005/diff/208001/content/child/resource_dispatcher.cc#newcode102 content/child/resource_dispatcher.cc:102: // The security origin ...
7 years, 4 months ago (2013-08-22 19:05:54 UTC) #25
darin (slow to review)
https://codereview.chromium.org/22254005/diff/161002/content/child/resource_dispatcher.cc File content/child/resource_dispatcher.cc (right): https://codereview.chromium.org/22254005/diff/161002/content/child/resource_dispatcher.cc#newcode425 content/child/resource_dispatcher.cc:425: perhaps another option here is to call a method ...
7 years, 4 months ago (2013-08-22 21:50:42 UTC) #26
dsjang
Blocking code is moved to SiteIsolationPolicy from ResourceDispatcher https://codereview.chromium.org/22254005/diff/161002/content/child/resource_dispatcher.cc File content/child/resource_dispatcher.cc (right): https://codereview.chromium.org/22254005/diff/161002/content/child/resource_dispatcher.cc#newcode425 content/child/resource_dispatcher.cc:425: On ...
7 years, 4 months ago (2013-08-22 22:30:19 UTC) #27
darin (slow to review)
OK, looks better. Thanks! Deferring to Charlie on most of this review. Integration code LGTM. ...
7 years, 4 months ago (2013-08-22 22:45:34 UTC) #28
Charlie Reis
LGTM with the changes below. https://codereview.chromium.org/22254005/diff/123003/content/child/site_isolation_policy.cc File content/child/site_isolation_policy.cc (right): https://codereview.chromium.org/22254005/diff/123003/content/child/site_isolation_policy.cc#newcode168 content/child/site_isolation_policy.cc:168: //alternative_data->insert(0, " "); This ...
7 years, 4 months ago (2013-08-22 23:05:22 UTC) #29
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dsjang@chromium.org/22254005/226001
7 years, 4 months ago (2013-08-23 01:30:55 UTC) #30
commit-bot: I haz the power
Retried try job too often on chromium_presubmit for step(s) presubmit http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=chromium_presubmit&number=22074
7 years, 4 months ago (2013-08-23 01:47:04 UTC) #31
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dsjang@chromium.org/22254005/95002
7 years, 4 months ago (2013-08-23 01:50:06 UTC) #32
commit-bot: I haz the power
The commit queue went berserk retrying too often for a seemingly flaky test on builder ...
7 years, 4 months ago (2013-08-23 12:18:13 UTC) #33
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dsjang@chromium.org/22254005/159004
7 years, 4 months ago (2013-08-23 19:24:54 UTC) #34
commit-bot: I haz the power
Sorry for I got bad news for ya. Compile failed with a clobber build on ...
7 years, 4 months ago (2013-08-23 19:51:22 UTC) #35
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dsjang@chromium.org/22254005/239001
7 years, 4 months ago (2013-08-23 20:30:54 UTC) #36
commit-bot: I haz the power
Change committed as 219383
7 years, 4 months ago (2013-08-23 23:55:41 UTC) #37
awong
7 years, 3 months ago (2013-08-26 20:31:40 UTC) #38
Message was sent while issue was closed.
Most of this these are style comments.  Please start a new CL for these
comments.

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
File content/child/site_isolation_policy.cc (right):

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:45: }  // anonymous namespace
nit:

}  // namespace

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:51: GURL& frame_origin,
non-const refs are not allowed in function signatures by style guide. Please
remove all uses of non-const references.

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:257: "Not a blockable mime type. This
mime type shouldn't reach here.";
Also output the mime_type.
NOTREACHED() << "Not a blockable mime type: " << resp_data.canonical_mime_type;

You don't need the "shouldn't reach here" because the assert itself already says
thsi.

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:261: const CommandLine& command_line =
*CommandLine::ForCurrentProcess();
Might as well keep this a pointer so it doesn't look like a local.

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:277: #undef
SITE_ISOLATION_POLICY_COUNT_NOTBLOCK
How bad does this look if you expand out the macros?

Using macros often has long term consequences.  Aside from being hard to read,
it breaks code analysis tools, refactoring tools, and often makes debugging/
crash parts harder because it messes with the line numbers.

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:358: std::string access_control_origin) {
Should this be const std::string&?

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:383: bool
SiteIsolationPolicy::SniffForHTML(const char* data, size_t length) {
Converting all these functions to taking a StringPiece seems like a safer
api...though we should double check that the copy behavior of StringPiece.

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:393: const char* html_signatures[] =
{"<!DOCTYPE html",  // HTML5 spec
General locally scoped constants should be declared static.

As is, this directs the compiler to, per function invocation, perform one memcpy
copy of the array onto the stack.

Also, constants should be named kHtmlSignatures as per style guide.

Please fix here and elsewhere.

Also, I think this is better formatted as

const char* kHtmlSignatures {
    "<!DOCTYPE html",  // HTML5 spec
    ...
};

The alignment is easier to read.

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:413: return true;
with a linebreak in the conditional, use braces.

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:429: return SniffForHTML(data + skipped,
length - skipped);
This recursion is based on data from the user (the network in this case).  How
are you bounding the recursion depth?

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:543: if (strncmp(data + i, "var ", 4) ==
0)
For safe use of strncmp, your "n" should always be based on the minmal size of
the two buffers.

In particular, if one of your buffers is known to be null-terminated and is
constant, then setting "n" to that size doesn't increase safety at all.

Here, length - i, is the conceptually correct "n" for safety (though that still
needs to be paired with a length > sizeof(kVar) check otherwise data with value
"va" would match).

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.cc:551:
CR_DEFINE_STATIC_LOCAL(RequestIdToMetaDataMap, metadata_map_, ());
This variable is declared like a static local, but really you're using it as a
global.  Would a LazyInstance declared at the top of this file be more
appropriate?

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
File content/child/site_isolation_policy.h (right):

https://codereview.chromium.org/22254005/diff/239001/content/child/site_isola...
content/child/site_isolation_policy.h:81: struct ResponseMetaData {
Is there a reason for these types to be public?

For that matter...for each of the private functions, unless you need to expose
it for testing, can they made to be file-local to the implementation?

Powered by Google App Engine
This is Rietveld 408576698