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

Improve Trusted Types test coverage over eval and Function constructor #49461

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

lukewarlow
Copy link
Member

@lukewarlow lukewarlow commented Dec 2, 2024

  • Add tests for multi-argument function constructor calls

  • Add tests for exotic Function types (e.g. generators)

  • Add more tests for the CSP sample prefix-stripping behaviour

  • Fixed default policy sample test for Function constructor to match spec. (Chromium is non-spec compliant currently).

- Add tests for multi-argument function constructor calls

- Add tests for exotic Function types (e.g. generators)

- Add more tests for the CSP sample prefix-stripping behaviour

- Fixed default policy sample test for Function constructor to match spec. (Chromium is non-spec compliant currently).
@lukewarlow lukewarlow force-pushed the trusted-types-eval-Function-extensive branch from b37b2fd to 44fd27b Compare December 2, 2024 16:26
@lukewarlow lukewarlow merged commit 2cb65c5 into master Dec 2, 2024
19 checks passed
@lukewarlow lukewarlow deleted the trusted-types-eval-Function-extensive branch December 2, 2024 18:51
}, `Unsafe indirect eval violation sample is clipped to ${trimmedSampleLength} characters.`);

const functionBody = "return '1234567890123456789012345678901234567890';";
const sampleWithoutFunctionPrefix = `(a,b\n) {\nreturn ${functionBody}\n}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukewarlow I hadn't checked the change again after approving, but sampleWithoutFunctionPrefix should not have the return statement, since it's already in functionBody.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies I should have spotted that! (None of the browsers currently pass this test so didn't actually run it to double check).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants