From 3f5441314b09593ba9968c71d06a080b8a928a2c Mon Sep 17 00:00:00 2001 From: Esther Date: Sun, 3 Jan 2021 23:28:30 +0000 Subject: [PATCH] Added Helmet CSP --- app.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app.js b/app.js index f957e98..b55996a 100644 --- a/app.js +++ b/app.js @@ -27,6 +27,21 @@ if (process.env.NODE_ENV === 'production') { } app.use(helmet()); +app.use( + helmet.contentSecurityPolicy({ + directives: { + defaultSrc: ["'self'"], + scriptSrc: ["'self'", "'unsafe-inline'", "''unsafe-eval'", "https://hcaptcha.com", "https://*.hcaptcha.com", "https://cdn.ravenjs.com/"], + imgSrc: ["'self'", "https://blog.pastel.codes", "https://static.ghost.org", "https://secure.gravatar.com"], + styleSrc: ["'self'", "'unsafe-inline'", "https://hcaptcha.com", "https://*.hcaptcha.com"], + fontSrc: ["'self'", "data:"], + frameSrc: ["https://hcaptcha.com", "https://*.hcaptcha.com"], + objectSrc: ["'none'"], + upgradeInsecureRequests: [], + }, + }) + ); + app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(cookieParser());