Add trusted-types and require-trusted-types-for CSP Directive#486
Merged
Add trusted-types and require-trusted-types-for CSP Directive#486
Conversation
lgarron
approved these changes
Jun 21, 2022
Contributor
lgarron
left a comment
There was a problem hiding this comment.
Looks good to me!
A few small optional nits.
spec/lib/secure_headers/headers/content_security_policy_spec.rb
Outdated
Show resolved
Hide resolved
| expect(csp.value).to eq("trusted-types blahblahpolicy") | ||
| end | ||
|
|
||
| it "allows duplicate policy names in trusted-types directive" do |
Contributor
There was a problem hiding this comment.
Would it make sense to test 'none' explicitly as well?
Contributor
Author
There was a problem hiding this comment.
yes, probably. I'll add that
Co-authored-by: Lucas Garron <lgarron@chromium.org>
1163c40 to
071c580
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All PRs:
Adding a new CSP directive
This PR adds support for the TrustedTypes CSP directives,
require-trusted-types-forand 'trusted-types'.Is the directive supported by any user agent? If so, which?
TrustedTypes are available in Chrome 83, Edge 83 and a polyfill exists for browsers that don't currently support.
What does it do?
require-trusted-types-fordisallows using strings with DOM XSS injection sink functions (functions like Document.write, Element.InnerHtml), and requires matching types created by Trusted Type policies.What are the valid values for the directive
require-trusted-types-foronly allowsscript.trusted-typesallows a list of strings, including one'allow-duplicates'which allows multiples of the same named policy to be created.