Index: content/common/content_security_policy/content_security_policy.cc |
diff --git a/content/common/content_security_policy/content_security_policy.cc b/content/common/content_security_policy/content_security_policy.cc |
index 87b035eb1c2ef44916452f1ea3e186ae29f75d64..c0ba794acc8ac375f99305c5bc60c5e28bad8281 100644 |
--- a/content/common/content_security_policy/content_security_policy.cc |
+++ b/content/common/content_security_policy/content_security_policy.cc |
@@ -44,6 +44,16 @@ void ReportViolation(CSPContext* context, |
const GURL& url, |
bool is_redirect, |
const SourceLocation& source_location) { |
+ GURL safe_url = context->IsOriginSafeToUseInCspViolation(url::Origin(url)) |
alexmos
2017/05/10 22:33:08
It feels like we actually want to ask this questio
arthursonzogni
2017/05/11 13:06:23
Yes, that is what I did initially. But even if the
alexmos
2017/05/12 01:37:19
Yeah, it's hard, and I guess it also depends on wh
arthursonzogni
2017/05/15 12:20:46
Thanks for "ShouldSanitizeDataInCspViolation".
I w
|
+ ? url |
+ : url.GetOrigin(); |
alexmos
2017/05/10 22:33:08
Both of these checks could use a comment explainin
arthursonzogni
2017/05/11 13:06:23
Done.
|
+ |
+ SourceLocation safe_source_location = |
+ context->IsOriginSafeToUseInCspViolation( |
+ url::Origin(GURL(source_location.url))) |
+ ? source_location |
+ : SourceLocation(); |
alexmos
2017/05/10 22:33:08
Interesting, so we clear it out entirely? This do
arthursonzogni
2017/05/11 13:06:23
I think we have to clear the line/column numbers b
alexmos
2017/05/12 01:37:19
I'll leave this up to Mike. I agree it seems more
|
+ |
// We should never have a violation against `child-src` or `default-src` |
// directly; the effective directive should always be one of the explicit |
// fetch directives. |
@@ -60,7 +70,7 @@ void ReportViolation(CSPContext* context, |
else if (directive_name == CSPDirective::FrameSrc) |
message << "Refused to frame '"; |
- message << ElideURLForReportViolation(url) |
+ message << ElideURLForReportViolation(safe_url) |
<< "' because it violates the following Content Security Policy " |
"directive: \"" |
<< directive.ToString() << "\"."; |
@@ -75,9 +85,9 @@ void ReportViolation(CSPContext* context, |
context->ReportContentSecurityPolicyViolation(CSPViolationParams( |
CSPDirective::NameToString(directive.name), |
- CSPDirective::NameToString(directive_name), message.str(), url, |
+ CSPDirective::NameToString(directive_name), message.str(), safe_url, |
policy.report_endpoints, policy.header.header_value, policy.header.type, |
- is_redirect, source_location)); |
+ is_redirect, safe_source_location)); |
} |
bool AllowDirective(CSPContext* context, |