Commit 4473c0ae authored by Antonio Sartori's avatar Antonio Sartori Committed by Chromium LUCI CQ

CSP: Separate parsing and applying in Blink CSP code

This is a small refactoring of the code in blink::CSPDirectiveList
which is parsing new Content Security Policies. This change separates
the raw parsing of the policies from the side effects (applying the
policies and storing state).

This is part of a project to harmonize the CSP code in Blink and in
services/network, and will make it easier to synchronize Content
Security Policies between the two.

Bug: 1021462,1149272
Change-Id: Iace800247ef6165a47adef2601d336a09e930897
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601368
Commit-Queue: Antonio Sartori <antoniosartori@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843562}
parent 4d4c8638
......@@ -100,9 +100,7 @@ class CORE_EXPORT CSPDirectiveList final
const String& sample,
const String& sample_prefix) const;
bool StrictMixedContentChecking() const {
return strict_mixed_content_checking_enforced_;
}
bool StrictMixedContentChecking() const { return block_all_mixed_content_; }
void ReportMixedContent(const KURL& blocked_url,
ResourceRequest::RedirectStatus) const;
......@@ -166,6 +164,7 @@ class CORE_EXPORT CSPDirectiveList final
FRIEND_TEST_ALL_PREFIXES(CSPDirectiveListTest, IsMatchingNoncePresent);
FRIEND_TEST_ALL_PREFIXES(CSPDirectiveListTest, OperativeDirectiveGivenType);
void ApplyParsedDirectives();
bool ParseDirective(const UChar* begin,
const UChar* end,
String* name,
......@@ -175,11 +174,10 @@ class CORE_EXPORT CSPDirectiveList final
void ParseAndAppendReportEndpoints(const String& value);
void ParsePluginTypes(const String& name, const String& value);
void AddDirective(const String& name, const String& value);
void ApplySandboxPolicy(const String& name, const String& sandbox_policy);
void ApplyTreatAsPublicAddress();
void EnforceStrictMixedContentChecking(const String& name,
const String& value);
void EnableInsecureRequestsUpgrade(const String& name, const String& value);
void ParseSandboxPolicy(const String& name, const String& sandbox_policy);
void ParseTreatAsPublicAddress();
void ParseBlockAllMixedContent(const String& name, const String& value);
void ParseUpgradeInsecureRequests(const String& name, const String& value);
CSPDirectiveName FallbackDirective(CSPDirectiveName current_directive,
CSPDirectiveName original_directive) const;
......@@ -279,9 +277,9 @@ class CORE_EXPORT CSPDirectiveList final
HashMap<CSPDirectiveName, String> raw_directives_;
bool has_sandbox_policy_;
network::mojom::blink::WebSandboxFlags sandbox_flags_;
bool strict_mixed_content_checking_enforced_;
bool block_all_mixed_content_;
bool upgrade_insecure_requests_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment