-
Notifications
You must be signed in to change notification settings - Fork 253
Add trusted-types and require-trusted-types-for CSP Directive #486
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
Conversation
lgarron
left a comment
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.
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 |
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.
Would it make sense to test 'none' explicitly as well?
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.
yes, probably. I'll add that
Co-authored-by: Lucas Garron <lgarron@chromium.org>
1163c40 to
071c580
Compare
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.