-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Remove eval and Function from build to support strict CSP #6872
Comments
There are, unfortunately, some eval usage right now that I don't know if we can easily get rid of. One such example is using |
For me, the report is coming from webpack code trying to load the modules.
Which I believe is the compiled version of
This issue in Webpack webpack/webpack#4094 kind of implies that it should be possible to resolve, but to be honest I am no webpack expert. If I have some time I may do some reading. |
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix angular#2796 Fix angular#7226 Fix angular#7290 Related to angular#6872
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix angular#2796 Fix angular#7226 Fix angular#7290 Related to angular#6872
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix angular#2796 Fix angular#7226 Fix angular#7290 Related to angular#6872
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix #2796 Fix #7226 Fix #7290 Related to #6872
+1 for getting rid of |
+1 - There's a single call to eval.call(...) in scripts.bundle.js that prevents proper use of a CSP response header in Angular apps. |
Beside AOT, any temporary fix for this guys? |
@filipesilva Is this fixable ? |
Any news on this? |
@clydin can you weigh in with the results from when you tested CSP last pleast? |
@darrenmothersele I was still able to create a WebExtension, I just couldn't get it accepted into the Firefox store. You might be able to set the |
Scary article regarding CSP being absolutely necessary: https://medium.com/@david.gilbertson/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5 |
With a production build and the removal of the reflection polyfills (these are not needed if using AOT which is enabled by default for production builds), Also, please note that nothing in this issue precludes the use of CSP as a whole. |
Even with AOT styles created in Components are rendered as inline. Is it intended? If yes I will rewrite it of course. |
Lovely, Angular5 trying to use angular5-social-login and I get the problem with the pages that are running the code in their component, won't be showing, CSP cries hard. Google Auth would be nice to be possible to use properly in Angular5. |
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix angular#2796 Fix angular#7226 Fix angular#7290 Related to angular#6872
My current work around is this
Basically just remove the evals. The code still seems to work. |
With 6.0, removing the reflect polyfill is all that is required for |
Hi, I'm using Angular CLI 7.0.6 and still get the unsafe eval error, when I'm building with ng build. When I use ng build --prod everything works fine. Is there anything I can do about that or is this problem still not solved yet? |
This is intended behavior. Development builds are setup to aid in development and debugging and should not be deployed. |
Also of note for anyone watching this thread, with 7.0+ the reflect polyfill is automatically removed for production builds(assuming the default of AOT enabled). There are now no longer any manual steps needed for a strict CSP scripts configuration. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Versions.
Repro steps.
Create
src/manifest.json
with:Add
manifest.json
to theapps[0].assets
in the.angular-cli.json
.Repo available here https://github.com/saulshanabrook/test-csp
The log given by the failure.
Regular build:
Production build:
Desired functionality.
We should be able to build the project with no CSP errors. That means eliminating all uses of
eval
andFunction
. This is needed in order for Mozilla to let any Angular 2 apps be submitted as extensions on their store. For example, I got this response when trying to submit an extension:Mention any other details that might be useful.
Moved from #1279 (comment).
This might be blocked on Angular core angular/angular#6361 angular/angular#1744.
The text was updated successfully, but these errors were encountered: