-
Notifications
You must be signed in to change notification settings - Fork 385
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
es6-shim breaks Chrome App CSP #301
Comments
It's definitely an eval statement, and it's the only way to reliably get the global object in any environment. Are there no CSP directives that can allow for it? I'm definitely open to another alternative to reliably get the global object if you can suggest one. |
There are CSP directives to allow for If there's not a clear fix, for now would it make sense to add a caveat to the README indicating that the module will conflict with Content Security Policy in Chrome extensions/apps, and suggest the appropriate fixes (CSP directive or sandboxing)? |
@ljharb What are the target platforms (general) for es6-shim? Just browser and node, right? (I'm looking for ways around |
+1 Ran into this problem today. |
The target platforms for Additional platforms are always ideally supported but the decision what to support or not is generally on a case by case basis. #259 specifically was to support |
Skimming the previous issues, this is a summary of my understanding:
Unless I'm missing something on that table, it sounds like checking |
That definitely seems like it would work :-) In addition, the es*-shims always assume they're the first to run, so shadowing/tampering with global objects isn't much of a concern. However, we don't have any node-webkit nor great web worker code coverage, and I'm worried about adding untested code paths. It's really a shame that If someone were able to prepare a PR that could add test coverage for (one idea that pops in my head to ensure correctness is testing that |
IIRC, you'll get both |
can somebody explain me, why (using |
When |
@ljharb , not loader context, but the context of the |
Hmm. It appears that since the initial commit (https://github.com/paulmillr/es6-shim/blame/a57577fdd71cd6726fec6354a1ab296bdd885209/es6-shim.js#L12) the shim's been using "window || global", and over time, evolved to check "self", then to use the current eval approach. @Yaffle If the |
|
This also breaks Firefox OS CSP for privileged apps. |
CSP is quite handy and — in addition to being used in Chrome apps and Firefox OS — many web applications also use it. We're one of them and just ran into this. Would anthonyryan1's method work? [https://github.com//issues/301#issuecomment-64966395] |
@sandstrom See my response right below it: #301 (comment) |
I think I've got a possible fix here - https://gist.github.com/stewart/321560330b152dfde649. Didn't cause any issues in the environments I tested in, but maybe I'm missing something? |
@stewart What did you test it on? It would need to work back to IE 6, in node 0.6 and later, all io.js versions, node-webkit/nw.js, web workers, the node |
The one major drawback to my approach that the CSP-violating version doesn't have is that if On the other hand, a situation like that is easier to work around for developers than a CSP-violating dependency, and relatively easy for the library to detect (check if Travis indicates at least Node/iojs support about on par with |
I'm less concerned about browsers and node (where |
I don't have test harnesses available for either at present, but I'll see about getting something worked together over the weekend, unless someone else beats me to it.
|
Thanks! |
I've worked on this with @rwaldron and @jugglinmike in person, and we've found a non-eval approach that seems to work in browsers, workers, node-webkit, and node. In order to unblock Chrome apps from having CSP issues, I'm going to go ahead with this change. Please let me know if this change has broken anything. |
@ljharb this throws an error when running using WSH. |
Thanks, that's good to know - what is the thrown error? If you can provide me with various exceptions that the shim throws (as separate issues, please) I'll do my best to fix them! |
|
Perfect, that's exactly what it's supposed to do :-) It appears that in WSH, the only option is to get I'd suggest then that in wsh, users need to do something like |
@ljharb ,
|
@Yaffle Try the latest commit in WSH - please file a new issue for me if there's any further issues. |
@ljharb , well... it works with
|
@Yaffle Can you please file an issue for 1 and 2? 3 is expected and desired. |
@ljharb Using |
Unless sandboxed,
es6-shim
cannot run inside of Chrome Apps right now due to this line, which triggers the CSP, and is functionally aneval()
statement.I'm unsure if the best fix is reverting ceeb51c, or if a better solution can be found.
The text was updated successfully, but these errors were encountered: