@@ -15,49 +15,95 @@ const testsForDefaults: HintTest[] = [
15
15
name : `Non HTML resource is served without unneeded headers` ,
16
16
serverConfig : {
17
17
'/' : {
18
- content : htmlPage ,
18
+ content : generateHTMLPage ( undefined , '<img src="test.svg"/><script src="test.js"></script><embed src="test.pdf" type="application/pdf">' ) ,
19
19
headers : {
20
+ 'Content-Security-Policy' : 'default-src "none"' ,
20
21
'Content-Type' : 'text/html; charset=utf-8' ,
21
- 'X-Frame-Options' : 'SAMEORIGIN'
22
+ 'X-Content-Security-Policy' : 'default-src "none"' ,
23
+ 'X-WebKit-CSP' : 'default-src "none"'
24
+ }
25
+ } ,
26
+ '/test.js' : {
27
+ headers : {
28
+ 'Content-Security-Policy' : 'default-src "none"' ,
29
+ 'Content-Type' : 'application/javascript; charset=utf-8' ,
30
+ 'X-Content-Security-Policy' : 'default-src "none"' ,
31
+ 'X-WebKit-CSP' : 'default-src "none"'
32
+ }
33
+ } ,
34
+ '/test.pdf' : {
35
+ headers : {
36
+ 'Content-Security-Policy' : 'default-src "none"' ,
37
+ 'Content-Type' : 'application/pdf' ,
38
+ 'X-Content-Security-Policy' : 'default-src "none"' ,
39
+ 'X-WebKit-CSP' : 'default-src "none"'
22
40
}
23
41
} ,
24
- '/test.js' : { headers : { 'Content-Type' : 'application/javascript; charset=utf-8' } }
42
+ '/test.svg' : {
43
+ headers : {
44
+ 'Content-Security-Policy' : 'default-src "none"' ,
45
+ 'Content-Type' : 'image/svg+xml' ,
46
+ 'X-Content-Security-Policy' : 'default-src "none"' ,
47
+ 'X-WebKit-CSP' : 'default-src "none"'
48
+ }
49
+ }
25
50
}
26
51
} ,
27
52
{
28
- name : `Non HTML resource is specified as a data URI` ,
29
- serverConfig : { '/' : generateHTMLPage ( undefined , '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==">' ) }
53
+ name : `Non HTML resource is served without unneeded headers and with application/xhtml+xml content type` ,
54
+ serverConfig : {
55
+ '/' : {
56
+ content : generateHTMLPage ( undefined , '<script src="test.js"></script>' ) ,
57
+ headers : {
58
+ 'Content-Security-Policy' : 'default-src "none"' ,
59
+ 'Content-Type' : 'application/xhtml+xml; charset=utf-8' ,
60
+ 'X-Content-Security-Policy' : 'default-src "none"' ,
61
+ 'X-WebKit-CSP' : 'default-src "none"'
62
+ }
63
+ } ,
64
+ '/test.js' : {
65
+ headers : {
66
+ 'Content-Security-Policy' : 'default-src "none"' ,
67
+ 'Content-Type' : 'application/javascript; charset=utf-8' ,
68
+ 'X-Content-Security-Policy' : 'default-src "none"' ,
69
+ 'X-WebKit-CSP' : 'default-src "none"'
70
+ }
71
+ }
72
+ }
30
73
} ,
31
74
{
32
- name : `Non HTML resource is served with unneeded header` ,
33
- reports : [ { message : generateMessage ( [ 'content-security-policy' ] ) } ] ,
75
+ name : `Non HTML resource is served without unneeded headers and with text/xml content type` ,
34
76
serverConfig : {
35
77
'/' : {
36
- content : htmlPage ,
78
+ content : generateHTMLPage ( undefined , '<script src="test.js"></script>' ) ,
37
79
headers : {
38
- 'Content-Type' : 'text/html; charset=utf-8' ,
39
- 'X-Frame-Options' : 'SAMEORIGIN'
80
+ 'Content-Security-Policy' : 'default-src "none"' ,
81
+ 'Content-Type' : 'text/xml; charset=utf-8' ,
82
+ 'X-Content-Security-Policy' : 'default-src "none"' ,
83
+ 'X-WebKit-CSP' : 'default-src "none"'
40
84
}
41
85
} ,
42
86
'/test.js' : {
43
87
headers : {
44
88
'Content-Security-Policy' : 'default-src "none"' ,
45
- 'Content-Type' : 'application/javascript; charset=utf-8'
89
+ 'Content-Type' : 'application/javascript; charset=utf-8' ,
90
+ 'X-Content-Security-Policy' : 'default-src "none"' ,
91
+ 'X-WebKit-CSP' : 'default-src "none"'
46
92
}
47
93
}
48
94
}
49
95
} ,
96
+ {
97
+ name : `Non HTML resource is specified as a data URI` ,
98
+ serverConfig : { '/' : generateHTMLPage ( undefined , '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==">' ) }
99
+ } ,
50
100
{
51
101
name : `Non HTML resource is served with multiple unneeded headers` ,
52
102
reports : [
53
103
{
54
104
message : generateMessage ( [
55
- 'content-security-policy' ,
56
105
'feature-policy' ,
57
- 'x-content-security-policy' ,
58
- 'x-frame-options' ,
59
106
'x-ua-compatible' ,
60
- 'x-webkit-csp' ,
61
107
'x-xss-protection'
62
108
] )
63
109
}
@@ -68,7 +114,6 @@ const testsForDefaults: HintTest[] = [
68
114
headers : {
69
115
'Content-Type' : 'text/html; charset=utf-8' ,
70
116
'X-Content-Security-Policy' : 'default-src "none"' ,
71
- 'X-Frame-Options' : 'DENY' ,
72
117
'X-UA-Compatible' : 'IE=Edge' ,
73
118
'X-WebKit-CSP' : 'default-src "none"' ,
74
119
'X-XSS-Protection' : '1; mode=block'
@@ -80,7 +125,6 @@ const testsForDefaults: HintTest[] = [
80
125
'Content-Type' : 'application/javascript; charset=utf-8' ,
81
126
'Feature-Policy' : `geolocation 'self'` ,
82
127
'X-Content-Security-Policy' : 'default-src "none"' ,
83
- 'X-Frame-Options' : 'DENY' ,
84
128
'X-UA-Compatible' : 'IE=Edge' ,
85
129
'X-WebKit-CSP' : 'default-src "none"' ,
86
130
'X-XSS-Protection' : '1; mode=block'
@@ -138,7 +182,6 @@ const testsForIgnoreConfigs: HintTest[] = [
138
182
headers : {
139
183
'Content-Type' : 'text/html; charset=utf-8' ,
140
184
'Feature-Policy' : `geolocation 'self'` ,
141
- 'X-Frame-Options' : 'SAMEORIGIN' ,
142
185
'X-UA-Compatible' : 'IE=Edge'
143
186
}
144
187
} ,
@@ -159,7 +202,6 @@ const testsForIncludeConfigs: HintTest[] = [
159
202
reports : [
160
203
{
161
204
message : generateMessage ( [
162
- 'content-security-policy' ,
163
205
'x-test-1' ,
164
206
'x-ua-compatible'
165
207
] )
@@ -170,7 +212,6 @@ const testsForIncludeConfigs: HintTest[] = [
170
212
content : htmlPage ,
171
213
headers : {
172
214
'Content-Type' : 'text/html; charset=utf-8' ,
173
- 'X-Frame-Options' : 'SAMEORIGIN' ,
174
215
'X-Test-1' : 'test' ,
175
216
'X-Test-2' : 'test'
176
217
}
@@ -193,7 +234,6 @@ const testsForConfigs: HintTest[] = [
193
234
reports : [
194
235
{
195
236
message : generateMessage ( [
196
- 'content-security-policy' ,
197
237
'x-test-1' ,
198
238
'x-ua-compatible'
199
239
] )
@@ -204,7 +244,6 @@ const testsForConfigs: HintTest[] = [
204
244
content : htmlPage ,
205
245
headers : {
206
246
'Content-Type' : 'text/html; charset=utf-8' ,
207
- 'X-Frame-Options' : 'SAMEORIGIN' ,
208
247
'X-Test-1' : 'test' ,
209
248
'X-Test-2' : 'test'
210
249
}
@@ -223,11 +262,11 @@ const testsForConfigs: HintTest[] = [
223
262
] ;
224
263
225
264
testHint ( hintPath , testsForDefaults ) ;
226
- testHint ( hintPath , testsForIgnoreConfigs , { hintOptions : { ignore : [ 'Content-Security-Policy' , ' X-UA-Compatible', 'X-Test-1' ] } } ) ;
227
- testHint ( hintPath , testsForIncludeConfigs , { hintOptions : { include : [ 'Content-Security-Policy' , ' X-Test-1', 'X-Test-2' ] } } ) ;
265
+ testHint ( hintPath , testsForIgnoreConfigs , { hintOptions : { ignore : [ 'X-UA-Compatible' , 'X-Test-1' ] } } ) ;
266
+ testHint ( hintPath , testsForIncludeConfigs , { hintOptions : { include : [ 'X-Test-1' , 'X-Test-2' ] } } ) ;
228
267
testHint ( hintPath , testsForConfigs , {
229
268
hintOptions : {
230
- ignore : [ 'X-Frame-Options' , 'X- Test-2', 'X-Test-3' ] ,
269
+ ignore : [ 'X-Test-2' , 'X-Test-3' ] ,
231
270
include : [ 'X-Test-1' , 'X-Test-2' , 'X-UA-Compatible' ]
232
271
}
233
272
} ) ;
0 commit comments