Skip to content

Commit 8611220

Browse files
committed
enh(csp) add missing directives / keywords
1 parent 62f8a60 commit 8611220

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

src/languages/csp.js

+7
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

+8
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

+8
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

+8
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)