-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for CSP nonces #110
Conversation
both/either style/script src options
index.js
Outdated
|
||
|
||
/** | ||
* Outputs all security headers based on configuration | ||
* @param {Object} options The configuration object. | ||
*/ | ||
var lusca = module.exports = function (options) { | ||
var headers = []; | ||
var headers = [], nonce; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we separate the declarations?
index.js
Outdated
nonce = true; | ||
} | ||
|
||
//if (key === 'csp' && lusca[key](config) && lusca[key](config)[styleNonce]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove the dead code?
index.js
Outdated
@@ -46,6 +58,7 @@ var lusca = module.exports = function (options) { | |||
return; | |||
} | |||
header(req, res, next); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change this from
header(req, res, next)
return
to
return header(req, res, next);
@@ -27,6 +29,22 @@ module.exports = function (options) { | |||
} | |||
|
|||
return function csp(req, res, next) { | |||
if (styleNonce) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can split these if statements into util functions for easier testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meh, it hurts the readability imo. also forces the res object to be passed around more than is necessary
both/either style/script src options