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

Content security policy - script-src: unsafe-eval #175

Open
AlejandroE opened this issue Jan 6, 2022 · 1 comment
Open

Content security policy - script-src: unsafe-eval #175

AlejandroE opened this issue Jan 6, 2022 · 1 comment

Comments

@AlejandroE
Copy link

Using the npm package in a web project with unsafe-eval disabled at CSP level errors with:

Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' 
is not an allowed source of script in the following 
Content Security Policy directive: "script-src 'self' cdn.xxxxx.com".
    at new Function (<anonymous>)
    at tearOffGetter (internalAdmin.js:97912)
    at tearOff (internalAdmin.js:97914)
    at installTearOff (internalAdmin.js:97926)
    at installInstanceTearOff (internalAdmin.js:97928)
    at internalAdmin.js:97936
    at installTearOffs (internalAdmin.js:107733)
    at dartProgram (internalAdmin.js:107792)
    at Object.<anonymous> (internalAdmin.js:108537)
    at Object../node_modules/gltf-validator/gltf_validator.dart.js (internalAdmin.js:108538)

The dart compiler comes with a flag disabling dynamic code generation with the specific purpose of satisfying CSP restrictions:

https://dart.dev/tools/dart2js#:~:text=generated%20from%20packages.-,%2D%2Dcsp,-Disables%20dynamic%20generation

Could this flag be added to the build process that publishes the npm package?

@lexaknyazev
Copy link
Member

A few years ago this flag was causing a significant code size increase, so we chose not to use it.

I'll reevaluate its effects for the next validator release. At the very least, we should give users a choice.

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

No branches or pull requests

2 participants