Skip to content

Conversation

@KyFaSt
Copy link
Contributor

@KyFaSt KyFaSt commented Jun 8, 2022

All PRs:

  • Has tests
  • Documentation updated

Adding a new CSP directive

This PR adds support for the TrustedTypes CSP directives, require-trusted-types-for and '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-for disallows 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-for only allows script.
    trusted-types allows a list of strings, including one 'allow-duplicates' which allows multiples of the same named policy to be created.

@KyFaSt KyFaSt requested a review from a team June 8, 2022 16:35
@KyFaSt KyFaSt changed the title Kyfast add trusted types Add trusted-types and require-trusted-types-for CSP Directive Jun 8, 2022
Copy link
Contributor

@lgarron lgarron left a 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.

expect(csp.value).to eq("trusted-types blahblahpolicy")
end

it "allows duplicate policy names in trusted-types directive" do
Copy link
Contributor

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?

Copy link
Contributor Author

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

@KyFaSt KyFaSt force-pushed the kyfast-add-trusted-types branch from 1163c40 to 071c580 Compare June 28, 2022 13:29
@KyFaSt KyFaSt merged commit 494b75f into main Aug 2, 2022
@KyFaSt KyFaSt deleted the kyfast-add-trusted-types branch August 2, 2022 13:51
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.

4 participants