Skip to content
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

Allow to pass nonce option to getBrowserTimingHeader. #266

Merged
merged 2 commits into from
Jul 9, 2018

Conversation

joaovieira
Copy link
Contributor

CHANGE LOG

  • Allow to pass nonce to getBrowserTimingHeader()

INTERNAL LINKS

https://discuss.newrelic.com/t/content-security-policy-and-browser-injection/2629/42

NOTES

getBrowserTimingHeader generates an inline script tag. This is generally a bad practice if you want to protect your page with HTTP Content-Security-Policy (CSP) header. In the situations you do require it you should generate and pass a nonce UUID which tells the browser those scripts are allowed to be executed.

This PR adds an option to add a nonce attribute to the generated <script> tag.

Currently we're injecting the nonce in the middle of the returned string header with String.substr() - which is not ideal.

@NatalieWolfe
Copy link
Contributor

Thanks for the contribution, @joaovieira! This looks great, so I'll pull it into our dev repo and make sure it gets released soon.

@lykkin lykkin merged commit 5b23afa into newrelic:master Jul 9, 2018
@NatalieWolfe
Copy link
Contributor

@joaovieira This was released in 4.3.0. Please try it out and let us know if it works! Thanks again for contributing this feature.

@joaovieira
Copy link
Contributor Author

@NatalieWolfe sorry for the delay. Just tested it and worked perfectly. Thanks for the update!

@ccope
Copy link

ccope commented Mar 14, 2019

For others who see this, the nonce header is set on the script tag returned by this function, but that script generates another script tag which loads from New Relic's servers. So you still need to whitelist them in your CSP string.

bizob2828 pushed a commit to bizob2828/node-newrelic that referenced this pull request Apr 19, 2024
Co-authored-by: jsumners-nr <gh-actions-jsumners-nr@github.com>
bizob2828 pushed a commit to bizob2828/node-newrelic that referenced this pull request Apr 23, 2024
Co-authored-by: jsumners-nr <gh-actions-jsumners-nr@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants