Skip to content
Myr

feat(secure-headers): support CSP TrustedTypePolicy (#4500)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* feat(secure-headers): support TrustedTypePolicy * ci: apply automated fixes ---------

authored by RosApr · committed by GitHub · parent cea3fb0 · Browse files · 2 files+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

Diff stats

2 files+5 added−1 removed

  • tests:+3 added−1 removed
  • other:+2 added−0 removed

2 files+5 added−1 removed

modified:src/middleware/secure-headers/index.test.ts+3 added-1 removed
243 unmodified lines
244 objectSrc: ["'none'"],245 scriptSrc: ["'self'"],246 scriptSrcAttr: ["'none'"],247 styleSrc: ["'self'", 'https:', "'unsafe-inline'"],248 requireTrustedTypesFor: ["'script'"],249 trustedTypes: ["'none'"],250 },251 })252 )253
3 unmodified lines
257 })258259 const res = await app.request('/test')260 expect(res.headers.get(cspHeaderName)).toEqual(259 "default-src 'self'; base-uri 'self'; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; script-src-attr 'none'; style-src 'self' https: 'unsafe-inline'"261 "default-src 'self'; base-uri 'self'; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; script-src-attr 'none'; style-src 'self' https: 'unsafe-inline'; require-trusted-types-for 'script'; trusted-types 'none'"262 )263 })264265 it('CSP Setting one only', async () => {
218 unmodified lines
modified:src/middleware/secure-headers/secure-headers.ts+2 added
36 unmodified lines
37 styleSrcAttr?: ContentSecurityPolicyOptionValue38 styleSrcElem?: ContentSecurityPolicyOptionValue39 upgradeInsecureRequests?: ContentSecurityPolicyOptionValue40 workerSrc?: ContentSecurityPolicyOptionValue41 requireTrustedTypesFor?: ContentSecurityPolicyOptionValue42 trustedTypes?: ContentSecurityPolicyOptionValue43}4445interface ReportToOptions {46 group: string
287 unmodified lines