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

Use of new Function violates Chrome App CSP #487

Closed
mendelk opened this issue Aug 16, 2016 · 3 comments
Closed

Use of new Function violates Chrome App CSP #487

mendelk opened this issue Aug 16, 2016 · 3 comments
Assignees
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@mendelk
Copy link

mendelk commented Aug 16, 2016

In this commit, this line was added:

customScheme: new Function('node', ''),

However, this violates the Chrome App contentSecurityPolicy:

You can’t use string-to-JavaScript methods like eval() and new Function().

Meaning, that the player won't work in Chrome Apps without workarounds (and Chrome Extensions as well, though it's a bit easier to work around in that case).

Is there any way this can be changed? Thanks! 😄

@joeyparrish joeyparrish added the type: bug Something isn't working correctly label Aug 16, 2016
@joeyparrish joeyparrish added this to the v2.0.0 milestone Aug 16, 2016
@joeyparrish
Copy link
Member

This was added as a work-around for a compiler issue.

When we merge configuration changes from the app into the running config, we check types to make sure that everything is correctly-typed. For functions, this means checking the number of arguments.

We used to have this:

  customScheme: function(node) {},

But this only worked in uncompiled mode. The compiler would strip out unused arguments from the anonymous function, which caused the check on the number of arguments to fail.

We started using new Function('node', '') so the compiler would not "optimize" it. In reality, we don't need to convert a string to a function at all.

So yes, we can change this. I don't yet know what other work-around we should use, but we will investigate our options.

@mendelk
Copy link
Author

mendelk commented Aug 16, 2016

Thanks @joeyparrish. I understand that Chrome Apps and Extensions are niche use cases, so any work you put into supporting these is greatly appreciated!

@joeyparrish
Copy link
Member

No worries. We should be able to support this.

@ismena ismena self-assigned this Aug 25, 2016
@shaka-project shaka-project locked and limited conversation to collaborators Mar 22, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

4 participants