Expanded config for more options

This commit is contained in:
PearlDragon 2025-04-15 14:19:01 -06:00
parent affb9f5a0d
commit 4b35c9fe09
3 changed files with 30 additions and 30 deletions

View File

@ -5,6 +5,10 @@
# script-src 'self' example.com;object-src 'none';
# upgrade-insecure-requests"
# Note: embedded single quotes are required
xFrameOptions: SAMEORIGIN
contentSecurityPolicy:
useDefaults: false
directives:
default-src: [ "'self'" ]
base-uri: [ "'self'" ]
font-src:

View File

@ -7,11 +7,5 @@ module.exports = (path) => {
const csppolicy = fs.readFileSync(path, 'utf8')
const csp = YAML.parse(csppolicy)
return helmet({
contentSecurityPolicy: {
useDefaults: false,
directives: csp,
},
xFrameOptions: 'SAMEORIGIN',
})
return helmet(csp)
}

View File

@ -19,6 +19,8 @@ describe('Rapid configurable Content Security Policy middleware', () => {
fs.writeFileSync(
customPolicyPath,
`
contentSecurityPolicy:
directives:
default-src: ["'self'"]
script-src: ["'self'", "https://cdn.example.com"]
`,