From b612683c66ef53ef0c7e07f648b8691e802e0e6f Mon Sep 17 00:00:00 2001 From: Antonio Sartori Date: Wed, 6 Sep 2023 09:14:17 +0000 Subject: [PATCH 1/4] [editorial] Turn algorithms into prose and make them clickable --- index.bs | 1207 +++++++++++++++++++++++++++++------------------------- 1 file changed, 642 insertions(+), 565 deletions(-) diff --git a/index.bs b/index.bs index c87b4f39a2..a9e06791d4 100644 --- a/index.bs +++ b/index.bs @@ -19,7 +19,7 @@ Boilerplate: feedback-header off !Participate: File an issue (open issues) !Tests: web-platform-tests content-security-policy/ (ongoing work) Markup Shorthands: css off, markdown on -At Risk: The [[#is-element-nonceable]] algorithm. +At Risk: The [=determine whether element is nonceable=] algorithm. The following injected string will use a duplicate attribute to attempt to - bypass the [[#is-element-nonceable]] algorithm check: + bypass the [=determine whether element is nonceable=] algorithm check:
     Hello, <script src='https://evil.com/evil.js' x="" x=
@@ -5010,7 +5087,7 @@ this algorithm returns normally if compilation is allowed, and throws a
       
         Content-Security-Policy: img-src 'none'; script-src 'none'; font-src 'none'
       
- + Supplementing this policy with `default-src 'none'` would improve the page's robustness against this kind of attack. From 20d0ccc6b73ffde84bd20ccb889765f0cf7d7687 Mon Sep 17 00:00:00 2001 From: Antonio Sartori Date: Wed, 4 Oct 2023 16:26:37 +0000 Subject: [PATCH 2/4] should be -> is --- index.bs | 157 +++++++++++++++++++++++++++---------------------------- 1 file changed, 78 insertions(+), 79 deletions(-) diff --git a/index.bs b/index.bs index a9e06791d4..2ec363d64c 100644 --- a/index.bs +++ b/index.bs @@ -608,20 +608,20 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 1. A pre-request check, which takes a request and a policy as an argument, and is executed - to [=determine whether a request should be blocked by Content Security + to [=determine whether a request is blocked by Content Security Policy=]. This algorithm returns "`Allowed`" unless otherwise specified. 2. A post-request check, which takes a request, a response, and a policy as arguments, - and is executed to [=determine whether a response should be blocked by Content Security + and is executed to [=determine whether a response is blocked by Content Security Policy=]. This algorithm returns "`Allowed`" unless otherwise specified. 3. An inline check, which takes an {{Element}}, a type string, a policy, and a source string as arguments, and is executed when [=determining whether element's inline - type behavior should be blocked by Content Security Policy=] and when - [=determining whether a navigation request should be blocked by Content + type behavior is blocked by Content Security Policy=] and when + [=determining whether a navigation request is blocked by Content Security Policy=] for `javascript:` requests. This algorithm returns "`Allowed`" unless otherwise specified. @@ -635,20 +635,20 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 5. A pre-navigation check, which takes a request, a navigation type string ("`form-submission`" or "`other`"), and a policy as arguments, and is executed when - [=determining whether a navigation request should be blocked by Content + [=determining whether a navigation request is blocked by Content Security Policy=]. It returns "`Allowed`" unless otherwise specified. 6. A navigation response check, which takes a request, a navigation type string ("`form-submission`" or "`other`"), a response, a navigable, a check type string ("`source`" or "`response`"), and a policy as arguments, - and is executed when [=determining whether a navigation response should be + and is executed when [=determining whether a navigation response is blocked by Content Security Policy=]. It returns "`Allowed`" unless otherwise specified. 8. A webrtc pre-connect check, which takes a [=/policy=], and is executed when [=determining whether RTC connections - should be blocked by Content Security policy=]. It returns "`Allowed`" + are blocked by Content Security policy=]. It returns "`Allowed`" unless otherwise specified.

Source Lists

@@ -1024,18 +1024,18 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ A number of directives control resource loading in one way or another. This specification provides algorithms which allow Fetch to make - decisions about whether or not a particular request should be blocked - or allowed, and about whether a particular response should be replaced + decisions about whether or not a particular request is blocked + or allowed, and about whether a particular response is replaced with a network error. - 1. [=Determine whether a request should be blocked by Content Security Policy=] + 1. [=Determine whether a request is blocked by Content Security Policy=] is called as part of step 2.4 of the Main Fetch algorithm. This allows directives' pre-request checks to be executed against each request before it hits the network, and against each redirect that a request might go through on its way to reaching a resource. - 2. [=Determine whether a response should be blocked by Content Security Policy=] + 2. [=Determine whether a response is blocked by Content Security Policy=] is called as part of step 11 of the Main Fetch algorithm. This allows directives' post-request checks to be executed on the response delivered from the network @@ -1065,10 +1065,10 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ request=] given |request|, and |policy|.

- Should |request| be blocked by Content Security Policy? + Is |request| blocked by Content Security Policy?

- To determine whether a request should be blocked by Content + To determine whether a request is blocked by Content Security Policy, given a request |request|, execute the following steps, which return `Blocked` or `Allowed` and report violations based on |request|'s [=request/policy container=]'s [=policy container/CSP @@ -1098,10 +1098,10 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 4. Return |result|.

- Should |response| to |request| be blocked by Content Security Policy? + Is |response| to |request| blocked by Content Security Policy?

- To determine whether a response should be blocked by Content + To determine whether a response is blocked by Content Security Policy, given a response |response| and a request |request|, execute the following steps, which return `Blocked` or `Allowed` and report violations based on |request|'s @@ -1153,13 +1153,13 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 4. Run `CSP` initialization for a document is called during the create and initialize a new `Document` object algorithm. - 5. [=Determine whether element's inline type behavior should be blocked by + 5. [=Determine whether element's inline type behavior is blocked by Content Security Policy=] is called during the prepare the script element and update a `style` block algorithms in order to determine whether or not an inline script or style block is allowed to execute/render. - 6. [=Determine whether element's inline type behavior should be blocked by + 6. [=Determine whether element's inline type behavior is blocked by Content Security Policy=] is called during handling of inline event handlers (like `onclick`) and inline `style` attributes in order to determine whether or not they ought to be allowed to execute/render. @@ -1178,10 +1178,10 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ <{base}>'s set the frozen base URL algorithm to ensure that the <{base/href}> attribute's value is valid. - 10. [=Determine whether a navigation request should be blocked by Content + 10. [=Determine whether a navigation request is blocked by Content Security Policy=] is called during the create navigation params by fetching algorithm, and [=determine whether a navigation - response should be blocked by Content Security Policy=] is called during + response is blocked by Content Security Policy=] is called during the attempt to populate the history entry's document algorithm to apply directive's navigation checks, as well as inline checks for navigations to `javascript:` URLs. @@ -1225,10 +1225,10 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 3. Return null.

- Should |element|'s inline |type| behavior be blocked by Content Security Policy? + Is |element|'s inline |type| behavior blocked by Content Security Policy?

- To determine whether element's inline type behavior should be + To determine whether element's inline type behavior is blocked by Content Security Policy, given an {{Element}} |element|, a string |type|, and a string |source|, execute the following steps, which return "`Allowed`" if the element is allowed to have inline definition of a @@ -1278,11 +1278,10 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/

- Should |navigation request| of |type| be blocked - by Content Security Policy? + Is |navigation request| of |type| blocked by Content Security Policy?

- To determine whether a navigation request should be blocked by + To determine whether a navigation request is blocked by Content Security Policy, given a request |navigation request| and a string |type| (either "`form-submission`" or "`other`"), execute the following steps, which return "`Blocked`" if the active policy @@ -1347,11 +1346,11 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/

- Should |navigation response| to |navigation request| of |type| - in |target| be blocked by Content Security Policy? + Is |navigation response| to |navigation request| of |type| + in |target| blocked by Content Security Policy?

- To determine whether a navigation response should be blocked by + To determine whether a navigation response is blocked by Content Security Policy, given a request |navigation request|, a response |navigation response|, a [=/CSP list=] |response CSP list|, a string |type| (either "`form-submission`" or "`other`"), and a @@ -1443,14 +1442,14 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/

Integration with WebRTC

The [=administratively-prohibited=] algorithm calls [=determine whether RTC - connections should be blocked by Content Security Policy=] when invoked, and + connections are blocked by Content Security Policy=] when invoked, and prohibits all candidates if it returns "`Blocked`".

- Should RTC connections be blocked for |global|? + Are RTC connections blocked for |global|?

- To determine whether RTC connections should be blocked by Content + To determine whether RTC connections are blocked by Content Security Policy, given a [=/global object=] |global|, execute the following steps, which return "`Blocked`" if the active policy for |global| blocks RTC connections, and "`Allowed`" otherwise. @@ -2051,7 +2050,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `child-src` and |policy| is "`No`", return "`Allowed`". 3. Return the result of executing the pre-request @@ -2071,7 +2070,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `child-src` and |policy| is "`No`", return "`Allowed`". 3. Return the result of executing the post-request @@ -2146,7 +2145,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `connect-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether request matches source list=], @@ -2167,7 +2166,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `connect-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether response matches source list=], @@ -2193,9 +2192,9 @@ return normally if compilation is allowed, and throws a script-src 'self'`, script requests will use `'self'` as the source list to match against. Other requests will use `'none'`. This is spelled out in more detail in the algorithms to determine whether a request or - a response should be blocked by Content Security Policy. + whether a request is blocked by Content Security Policy">request or + a response is blocked by Content Security Policy.
Resource hints such as <{link/rel/prefetch}> and <{link/rel/preconnect}> generate requests that @@ -2275,7 +2274,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `default-src` and |policy| is "`No`", return "`Allowed`". 3. Return the result of executing the @@ -2295,7 +2294,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `default-src` and |policy| is "`No`", return "`Allowed`". 3. Return the result of executing the @@ -2316,7 +2315,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for inline checks=], given |type|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `default-src` and |policy| is "`No`", return "`Allowed`". 3. Otherwise, return the result of executing the @@ -2369,7 +2368,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `font-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether request matches source list=], @@ -2390,7 +2389,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `font-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether response matches source list=], @@ -2438,7 +2437,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `frame-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether request matches source list=], @@ -2459,7 +2458,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `frame-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether response matches source list=], @@ -2510,7 +2509,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `img-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether request matches source list=], @@ -2531,7 +2530,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `img-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether response matches source list=], @@ -2578,7 +2577,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `manifest-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether request matches source list=], @@ -2599,7 +2598,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `manifest-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether response matches source list=], @@ -2649,7 +2648,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `media-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether request matches source list=], @@ -2670,7 +2669,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `media-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether response matches source list=], @@ -2741,7 +2740,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `object-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether request matches source list=], @@ -2762,7 +2761,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `object-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether response matches source list=], @@ -2795,13 +2794,13 @@ return normally if compilation is allowed, and throws a The `script-src` directive governs six things: 1. Script requests MUST be allowed when [=determining whether - a request should be blocked by Content Security Policy=]. + a request is blocked by Content Security Policy=]. 2. Script responses MUST be allowed when [=determining whether a response - should be blocked by Content Security Policy=]. + is blocked by Content Security Policy=]. 3. Inline <{script}> blocks MUST be allowed when [=determining whether - element's inline type behavior should be blocked by Content Security + element's inline type behavior is blocked by Content Security Policy=]. Their behavior will be blocked unless every policy allows inline script, either implicitly by not specifying a `script-src` (or `default-src`) directive, or explicitly, by specifying "`unsafe-inline`", @@ -2838,7 +2837,7 @@ return normally if compilation is allowed, and throws a WebAssembly and does not affect JavaScript. 6. Navigation to `javascript:` URLs MUST be allowed when [=determining - whether element's inline type behavior should be blocked by Content + whether element's inline type behavior is blocked by Content Security Policy=]. Such navigations will only execute script if every policy allows inline script, as per #3 above. @@ -2853,7 +2852,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `script-src` and |policy| is "`No`", return "`Allowed`". 3. Return the result of [=running script directives pre-request check=], @@ -2871,7 +2870,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `script-src` and |policy| is "`No`", return "`Allowed`". 3. Return the result of [=running script directives post-request check=], @@ -2891,7 +2890,7 @@ return normally if compilation is allowed, and throws a 2. Let |name| be the result of [=getting the effective directive for inline checks=], given |type|. - 3. If the result of [=determining whether directive should execute=], given + 3. If the result of [=determining whether directive executes=], given |name|, `script-src` and |policy| is "`No`", return "`Allowed`". 4. If the result of [=determining whether element matches source list=], @@ -2932,7 +2931,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `script-src-elem` and |policy| is "`No`", return "`Allowed`". 3. Return the result of [=running script directives pre-request check=], @@ -2950,7 +2949,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `script-src-elem` and |policy| is "`No`", return "`Allowed`". 3. Return the result of [=running script directives post-request check=], @@ -2970,7 +2969,7 @@ return normally if compilation is allowed, and throws a 2. Let |name| be the result of [=getting the effective directive for inline checks=], given |type|. - 3. If the result of [=determining whether directive should execute=], given + 3. If the result of [=determining whether directive executes=], given |name|, `script-src-elem`, and |policy| is "`No`", return "`Allowed`". 4. If the result of [=determining whether element matches source list=], @@ -3005,7 +3004,7 @@ return normally if compilation is allowed, and throws a 2. Let |name| be the result of [=getting the effective directive for inline checks=], given |type|. - 3. If the result of [=determining whether directive should execute=], given + 3. If the result of [=determining whether directive executes=], given |name|, `script-src-attr` and |policy| is "`No`", return "`Allowed`". 4. If the result of [=determining whether element matches source list=], @@ -3028,7 +3027,7 @@ return normally if compilation is allowed, and throws a The `style-src` directive governs several things: 1. Style requests MUST be allowed when [=determining - whether a request should be blocked by Content Security Policy=]. This + whether a request is blocked by Content Security Policy=]. This includes: 1. Stylesheet requests originating from a <{link}> element. @@ -3038,10 +3037,10 @@ return normally if compilation is allowed, and throws a field [[!RFC8288]]. 2. Responses to style requests MUST be allowed when [=determining - whether a response should be blocked by Content Security Policy=]. + whether a response is blocked by Content Security Policy=]. 3. Inline <{style}> blocks MUST be allowed when [=determining whether - element's inline type behavior should be blocked by Content Security + element's inline type behavior is blocked by Content Security Policy=]. The styles will be blocked unless every policy allows inline style, either implicitly by not specifying a `style-src` (or `default-src`) directive, or explicitly, by specifying "`unsafe-inline`", @@ -3073,7 +3072,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `style-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether nonce matches source list=], given @@ -3099,7 +3098,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `style-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether nonce matches source list=], given @@ -3126,7 +3125,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |type|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `style-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether element matches source list=], @@ -3164,7 +3163,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `style-src-elem` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether nonce matches source list=], given @@ -3190,7 +3189,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `style-src-elem` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether nonce matches source list=], given @@ -3217,7 +3216,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for inline checks=], given |type|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `style-src-elem` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether element matches source list=], @@ -3249,7 +3248,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for inline checks=], given |type|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `style-src-attr` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether element matches source list=], @@ -3362,7 +3361,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `worker-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether request matches source list=], @@ -3383,7 +3382,7 @@ return normally if compilation is allowed, and throws a 1. Let |name| be the result of [=getting the effective directive for request=], given |request|. - 2. If the result of [=determining whether directive should execute=], given + 2. If the result of [=determining whether directive executes=], given |name|, `worker-src` and |policy| is "`No`", return "`Allowed`". 3. If the result of [=determining whether response matches source list=], @@ -4535,16 +4534,16 @@ return normally if compilation is allowed, and throws a 2. Return `<< >>`.

- Should fetch directive execute + Does fetch directive execute

This algorithm is used for fetch directives to decide whether a directive - should execute or defer to a different directive that is better suited. + executes or defer to a different directive that is better suited. For example: if the |effective directive name| is `worker-src` (meaning that we are currently checking a worker request), a `default-src` directive - should not execute if a `worker-src` or `script-src` directive exists. + does not execute if a `worker-src` or `script-src` directive exists. - To determine whether directive should execute, given a string + To determine whether directive executes, given a string |effective directive name|, a string |directive name| and a policy |policy|, execute the following steps. From 8b0441a854b165be27ca5c5a6dfe46ad89dc6aaf Mon Sep 17 00:00:00 2001 From: Antonio Sartori Date: Thu, 5 Oct 2023 07:33:52 +0000 Subject: [PATCH 3/4] return booleans on exported algorithms --- index.bs | 58 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/index.bs b/index.bs index 2ec363d64c..a9f9e5fcb3 100644 --- a/index.bs +++ b/index.bs @@ -1070,13 +1070,13 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ To determine whether a request is blocked by Content Security Policy, given a request |request|, execute the - following steps, which return `Blocked` or `Allowed` and report violations + following steps, which return a [=boolean=] and report violations based on |request|'s [=request/policy container=]'s [=policy container/CSP list=]. 1. Let |CSP list| be |request|'s [=request/policy container=]'s [=policy container/CSP list=]. - 2. Let |result| be "`Allowed`". + 2. Let |blocked| be false. 3. For each |policy| of |CSP list|: @@ -1093,9 +1093,9 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 2. [=Report a violation=], given |violation|. - 3. Set |result| to "`Blocked`". + 3. Set |blocked| to true. - 4. Return |result|. + 4. Return |blocked|.

Is |response| to |request| blocked by Content Security Policy? @@ -1104,12 +1104,12 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ To determine whether a response is blocked by Content Security Policy, given a response |response| and a request |request|, execute the following steps, which return - `Blocked` or `Allowed` and report violations based on |request|'s + a [=boolean=] and report violations based on |request|'s [=request/policy container=]'s [=policy container/CSP list=]. 1. Let |CSP list| be |request|'s [=request/policy container=]'s [=policy container/CSP list=]. - 2. Let |result| be "`Allowed`". + 2. Let |blocked| be false. 3. For each |policy| of |CSP list|: @@ -1124,13 +1124,13 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 2. [=Report a violation=], given |violation|. 3. If |policy|'s disposition is "`enforce`", - then set |result| to "`Blocked`". + then set |blocked| to true. Note: This portion of the check verifies that the page can load the response. That is, that a Service Worker hasn't substituted a file which would violate the page's CSP. - 4. Return |result|. + 4. Return |blocked|.

@@ -1231,9 +1231,9 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ To determine whether element's inline type behavior is blocked by Content Security Policy, given an {{Element}} |element|, a string |type|, and a string |source|, execute the following steps, which - return "`Allowed`" if the element is allowed to have inline definition of a + return false if the element is allowed to have inline definition of a particular type of behavior (script execution, style application, event - handlers, etc.), and "`Blocked`" otherwise. + handlers, etc.), and true otherwise. Note: The valid values for |type| are "`script`", "`script attribute`", "`style`", and "`style attribute`". @@ -1241,7 +1241,7 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/
    1. Assert: |element| is not null. - 2. Let |result| be "`Allowed`". + 2. Let |blocked| be false. 3. For each |policy| of |element|'s {{Document}}'s global object's CSP list: @@ -1272,9 +1272,9 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 7. [=Report a violation=], given |violation|. 8. If |policy|'s disposition is "`enforce`", then - set |result| to "`Blocked`". + set |blocked| to true. - 4. Return |result|. + 4. Return |blocked|.

@@ -1284,11 +1284,11 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ To determine whether a navigation request is blocked by Content Security Policy, given a request |navigation request| and a string |type| (either "`form-submission`" or "`other`"), - execute the following steps, which return "`Blocked`" if the active policy - blocks the navigation, and "`Allowed`" otherwise. + execute the following steps, which return true if the active policy + blocks the navigation, and false otherwise.
    - 1. Let |result| be "`Allowed`". + 1. Let |blocked| be false. 2. For each |policy| of |navigation request|'s policy container's CSP list: @@ -1310,9 +1310,9 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 4. [=Report a violation=], given |violation|. 5. If |policy|'s disposition is "`enforce`", then - set |result| to "`Blocked`". + set |blocked| to true. - 3. If |result| is "`Allowed`", and if |navigation request|'s + 3. If |blocked| is false, and if |navigation request|'s current URL's scheme is `javascript`: 1. For each |policy| of |navigation request|'s client's @@ -1340,9 +1340,9 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 5. [=Report a violation=], given |violation|. 6. If |policy|'s disposition is "`enforce`", then - set |result| to "`Blocked`". + set |blocked| to true. - 4. Return |result|. + 4. Return |blocked|.

@@ -1355,11 +1355,11 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ request|, a response |navigation response|, a [=/CSP list=] |response CSP list|, a string |type| (either "`form-submission`" or "`other`"), and a navigable |target|, execute the following steps, which return - "`Blocked`" if the active policy blocks the navigation, and "`Allowed`" + true if the active policy blocks the navigation, and false otherwise.
    - 1. Let |result| be "`Allowed`". + 1. Let |blocked| be false. 2. For each |policy| of |response CSP list|: @@ -1386,7 +1386,7 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 4. [=Report a violation=], given |violation|. 5. If |policy|'s disposition is "`enforce`", then - set |result| to "`Blocked`". + set |blocked| to true. 3. For each |policy| of |navigation request|'s policy container's CSP list: @@ -1412,9 +1412,9 @@ spec: WebRTC; urlPrefix: https://www.w3.org/TR/webrtc/ 4. [=Report a violation=], given |violation|. 5. If |policy|'s disposition is "`enforce`", then - set |result| to "`Blocked`". + set |blocked| to true. - 4. Return |result|. + 4. Return |blocked|.

@@ -3419,8 +3419,8 @@ return normally if compilation is allowed, and throws a To determine whether base is allowed for document, given a {{URL}} |base|, and a {{Document}} |document|, execute the following steps, - which return "`Allowed`" if |base| may be used as the value of a <{base}> - element's <{base/href}> attribute, and "`Blocked`" otherwise. + which return false if |base| may be used as the value of a <{base}> + element's <{base/href}> attribute, and true otherwise. 1. For each |policy| of |document|'s global object's csp list: @@ -3447,12 +3447,12 @@ return normally if compilation is allowed, and throws a 3. [=Report a violation=], given |violation|. 4. If |policy|'s disposition is "`enforce`", - return "`Blocked`". + return true. Note: We compare against the fallback base URL in order to deal correctly with things like an iframe `srcdoc` `Document` which has been sandboxed into an opaque origin. - 2. Return "`Allowed`". + 2. Return false.

`sandbox`

From 6148b8a90e52eee7b628f7160147bf05d5b029d9 Mon Sep 17 00:00:00 2001 From: Antonio Sartori Date: Thu, 5 Oct 2023 09:24:09 +0000 Subject: [PATCH 4/4] Always include articles in algorithm definitions --- index.bs | 194 +++++++++++++++++++++++++++---------------------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/index.bs b/index.bs index a9f9e5fcb3..f5013441a2 100644 --- a/index.bs +++ b/index.bs @@ -19,7 +19,7 @@ Boilerplate: feedback-header off !Participate: File an issue (open issues) !Tests: web-platform-tests content-security-policy/ (ongoing work) Markup Shorthands: css off, markdown on -At Risk: The [=determine whether element is nonceable=] algorithm. +At Risk: The [=determine whether an element is nonceable=] algorithm.
The following injected string will use a duplicate attribute to attempt to - bypass the [=determine whether element is nonceable=] algorithm check: + bypass the [=determine whether an element is nonceable=] algorithm check:
     Hello, <script src='https://evil.com/evil.js' x="" x=