Skip to content

Commit 5685c0e

Browse files
authored
enh(csp) add missing directives / keywords (#4191)
1 parent 224d7fe commit 5685c0e

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

CHANGES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ New Grammars:
44

55
- added 3rd party Aiken grammar to SUPPORTED_LANGUAGES [Josh Marchand][]
66

7+
Core Grammars:
8+
9+
- enh(csp) add missing directives / keywords from MDN (7 more) [Max Liashuk][]
10+
711
CONTRIBUTORS
8-
[Josh Marchand][https://github.com/yHSJ]
12+
13+
[Josh Marchand]: https://github.com/yHSJ
14+
[Max Liashuk]: https://github.com/probil
915

1016
## Version 11.11.1
1117

src/languages/csp.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default function(hljs) {
1515
"child-src",
1616
"connect-src",
1717
"default-src",
18+
"fenced-frame-src",
1819
"font-src",
1920
"form-action",
2021
"frame-ancestors",
@@ -24,10 +25,16 @@ export default function(hljs) {
2425
"media-src",
2526
"object-src",
2627
"plugin-types",
28+
"report-to",
2729
"report-uri",
30+
"require-trusted-types-for",
2831
"sandbox",
2932
"script-src",
33+
"script-src-attr",
34+
"script-src-elem",
3035
"style-src",
36+
"style-src-attr",
37+
"style-src-elem",
3138
"trusted-types",
3239
"unsafe-hashes",
3340
"worker-src"

test/detect/csp/default.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
Content-Security-Policy:
22
default-src 'self';
33
style-src 'self' css.example.com;
4+
style-src-attr 'none';
5+
style-src-elem https://example.com/;
46
img-src *.example.com;
7+
fenced-frame-src https://example.com/;
8+
report-to name-of-endpoint;
9+
require-trusted-types-for 'script';
10+
script-src 'self';
11+
script-src-attr 'none';
12+
script-src-elem https://example.com/;
513
script-src 'unsafe-eval' 'self' js.example.com 'nonce-Nc3n83cnSAd3wc3Sasdfn939hc3'

test/markup/csp/default.expect.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<span class="hljs-attribute">Content-Security-Policy</span>:
22
<span class="hljs-keyword">default-src</span> <span class="hljs-string">&#x27;self&#x27;</span>;
33
<span class="hljs-keyword">style-src</span> <span class="hljs-string">&#x27;self&#x27;</span> css.example.com;
4+
<span class="hljs-keyword">style-src-attr</span> <span class="hljs-string">&#x27;none&#x27;</span>;
5+
<span class="hljs-keyword">style-src-elem</span> https://example.com/;
46
<span class="hljs-keyword">img-src</span> *.example.com;
7+
<span class="hljs-keyword">fenced-frame-src</span> https://example.com/;
8+
<span class="hljs-keyword">report-to</span> name-of-endpoint;
9+
<span class="hljs-keyword">require-trusted-types-for</span> <span class="hljs-string">&#x27;script&#x27;</span>;
10+
<span class="hljs-keyword">script-src</span> <span class="hljs-string">&#x27;self&#x27;</span>;
11+
<span class="hljs-keyword">script-src-attr</span> <span class="hljs-string">&#x27;none&#x27;</span>;
12+
<span class="hljs-keyword">script-src-elem</span> https://example.com/;
513
<span class="hljs-keyword">script-src</span> <span class="hljs-string">&#x27;unsafe-eval&#x27;</span> <span class="hljs-string">&#x27;self&#x27;</span> js.example.com <span class="hljs-string">&#x27;nonce-Nc3n83cnSAd3wc3Sasdfn939hc3&#x27;</span>

test/markup/csp/default.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
Content-Security-Policy:
22
default-src 'self';
33
style-src 'self' css.example.com;
4+
style-src-attr 'none';
5+
style-src-elem https://example.com/;
46
img-src *.example.com;
7+
fenced-frame-src https://example.com/;
8+
report-to name-of-endpoint;
9+
require-trusted-types-for 'script';
10+
script-src 'self';
11+
script-src-attr 'none';
12+
script-src-elem https://example.com/;
513
script-src 'unsafe-eval' 'self' js.example.com 'nonce-Nc3n83cnSAd3wc3Sasdfn939hc3'

0 commit comments

Comments
 (0)