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

CSP compatibility #621

Closed
rictic opened this issue Sep 9, 2021 · 3 comments · Fixed by #734
Closed

CSP compatibility #621

rictic opened this issue Sep 9, 2021 · 3 comments · Fixed by #734

Comments

@rictic
Copy link

rictic commented Sep 9, 2021

Currently, nyc instrument index.js grabs the global object with (Function('return this'))(), but since that's technically evalling a string, that throws an error when run with some CSP configs.

The use case we have is that we're moving towards running all of our tests with trusted types enforced, so that we can catch some insecure coding practices when tests run. While we could turn this off when coverage is enabled, if it's an easy fix it seems better and more robust for the coverage configuration to be as similar as possible to the normal test configuration.

Locally I've patched istanbul to instead do:

typeof globalThis === 'undefined' ? (Function('return this'))() : globalThis;

And that seems to work well

@himself65
Copy link
Contributor

any update?

@SimenB
Copy link
Member

SimenB commented Oct 4, 2023

@himself65
Copy link
Contributor

Thank u so much

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

Successfully merging a pull request may close this issue.

4 participants