Skip to content

Commit

Permalink
Remove unsafe-eval from our default CSP
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego committed Apr 5, 2021
1 parent cf22394 commit 986d827
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/server/csp/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const config = {
schema: schema.object({
rules: schema.arrayOf(schema.string(), {
defaultValue: [
`script-src 'unsafe-eval' 'self'`,
`script-src 'self'`,
`worker-src blob: 'self'`,
`style-src 'unsafe-inline' 'self'`,
],
Expand Down
12 changes: 6 additions & 6 deletions src/core/server/csp/csp_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe('CspConfig', () => {
test('DEFAULT', () => {
expect(CspConfig.DEFAULT).toMatchInlineSnapshot(`
CspConfig {
"header": "script-src 'unsafe-eval' 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self'",
"header": "script-src 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self'",
"rules": Array [
"script-src 'unsafe-eval' 'self'",
"script-src 'self'",
"worker-src blob: 'self'",
"style-src 'unsafe-inline' 'self'",
],
Expand All @@ -40,9 +40,9 @@ describe('CspConfig', () => {
test('defaults from config', () => {
expect(new CspConfig()).toMatchInlineSnapshot(`
CspConfig {
"header": "script-src 'unsafe-eval' 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self'",
"header": "script-src 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self'",
"rules": Array [
"script-src 'unsafe-eval' 'self'",
"script-src 'self'",
"worker-src blob: 'self'",
"style-src 'unsafe-inline' 'self'",
],
Expand All @@ -55,9 +55,9 @@ describe('CspConfig', () => {
test('creates from partial config', () => {
expect(new CspConfig({ strict: false, warnLegacyBrowsers: false })).toMatchInlineSnapshot(`
CspConfig {
"header": "script-src 'unsafe-eval' 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self'",
"header": "script-src 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self'",
"rules": Array [
"script-src 'unsafe-eval' 'self'",
"script-src 'self'",
"worker-src blob: 'self'",
"style-src 'unsafe-inline' 'self'",
],
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/general/csp.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function ({ getService }) {

const entries = Array.from(parsed.entries());
expect(entries).to.eql([
['script-src', ["'unsafe-eval'", "'self'"]],
['script-src', ["'self'"]],
['worker-src', ['blob:', "'self'"]],
['style-src', ["'unsafe-inline'", "'self'"]],
]);
Expand Down

0 comments on commit 986d827

Please sign in to comment.