-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make runtime work within CSP restriction. #112
Comments
I think the only offending line is Line 403 in df79c26
GeneratorFunction declaration from getting minified.
|
Interesting. I guess worst case I can change the runtime before including in my app. I'm not sure which minifier you're using, but isn't there a way to just specify a whitelist of identifiers to not munge (perhaps in a comment block)? |
Yeah, that's always possible, but it depends on particular minifier interfaces, whereas this technique works everywhere. Does CSP support comments to ignore certain code? |
I've never heard of such a feature in CSP. I highly doubt that a comment can ever ignore valid code. |
I mean something like |
No, in chrome apps, CSP is not optional. It's a hard security requirement of the platform. |
Now with the workaround in my code from #111 https://github.com/creationix/jsconfbr2014/blob/cec50ac2060dc91fd7e371f2293099bff24c02f5/app-src/main.js and a hand modified runtime, I finally can author chrome apps on a chromebook using tedit and generators! Here is my sample app using generators. https://github.com/creationix/jsconfbr2014/blob/cec50ac2060dc91fd7e371f2293099bff24c02f5/app-src/main.js |
Maybe it makes sense to recommend people use https://github.com/facebook/regenerator/blob/master/runtime/min.js, and just make sure |
Idea from benjamn/ast-types#72 (comment): either don't minify https://github.com/facebook/regenerator/blob/master/runtime.js, or make sure you minify it in such a way that |
@benjamn: Are you comparing the name so that the check works in environments that natively support generators (and
work well enough? |
When Regenerator is in use, genFun.constructor will usually be strictly equal to the GeneratorFunction function, but it could also be the native GeneratorFunction constructor or a foreign non-native GeneratorFunction somehow created by a different instance of runtime.js, and the most reliable way to identify those two (rare) possibilities is by name (see The native GeneratorFunction.name should be "GeneratorFunction", but if the runtime has been minified, a foreign non-native GeneratorFunction may be identifiable only by the .displayName property that we set here. Though it might seem better to set .name to "GeneratorFunction", that property is not writable in some browsers. Another approach (tried in #63) was to create the GeneratorFunction constructor by evaluating a string (in an attempt to thwart minification), but that had the unfortunate side effect of violating CSP: #112. Fixes #156.
In particular, I want to use regenerator to write chrome packaged apps like my tedit editor. But as soon as I tried this I realized that the runtime uses eval somewhere.
Is this a hard requirement of the runtime, or can it be modified to work without using eval (or it's variants like new Function, etc)?
I would love to use this for authoring chrome apps, but the last road-block is the runtime triggering CSP violations
The text was updated successfully, but these errors were encountered: