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

Unified Diff: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.h

Issue 2896833002: Added validation of the policy specified in the 'csp' attribute (Closed)
Patch Set: Fixed incomplete validation. Added more tests inspired by existing source parsing tests. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.h
diff --git a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.h b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.h
index 5d0c7bfbefe330c0e72ffccf82066662ef06b67c..d31cabe46522efece74d631668124853444d2408 100644
--- a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.h
+++ b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.h
@@ -126,7 +126,11 @@ class CORE_EXPORT ContentSecurityPolicy
kCheckReportOnly
};
- static ContentSecurityPolicy* Create() { return new ContentSecurityPolicy(); }
+ static ContentSecurityPolicy* Create(
+ SecurityViolationReportingPolicy reporting_policy =
+ SecurityViolationReportingPolicy::kReport) {
+ return new ContentSecurityPolicy(reporting_policy);
Mike West 2017/05/29 07:46:21 I don't think you need this, because we only colle
+ }
~ContentSecurityPolicy();
DECLARE_TRACE();
@@ -432,6 +436,8 @@ class CORE_EXPORT ContentSecurityPolicy
bool HasHeaderDeliveredPolicy() const { return header_delivered_; }
+ bool IsValid() const { return is_valid; }
+
private:
FRIEND_TEST_ALL_PREFIXES(ContentSecurityPolicyTest, NonceInline);
FRIEND_TEST_ALL_PREFIXES(ContentSecurityPolicyTest, NonceSinglePolicy);
@@ -443,7 +449,7 @@ class CORE_EXPORT ContentSecurityPolicy
FRIEND_TEST_ALL_PREFIXES(FrameFetchContextTest,
PopulateResourceRequestChecksReportOnlyCSP);
- ContentSecurityPolicy();
+ ContentSecurityPolicy(SecurityViolationReportingPolicy);
void ApplyPolicySideEffectsToExecutionContext();
@@ -468,6 +474,7 @@ class CORE_EXPORT ContentSecurityPolicy
CSPDirectiveListVector policies_;
ConsoleMessageVector console_messages_;
bool header_delivered_{false};
+ SecurityViolationReportingPolicy reporting_policy_;
HashSet<unsigned, AlreadyHashed> violation_reports_sent_;
@@ -485,6 +492,7 @@ class CORE_EXPORT ContentSecurityPolicy
Member<CSPSource> self_source_;
String self_protocol_;
+ bool is_valid;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698