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

Make the code more CSP friendly #21

Closed
tdelmas opened this issue Feb 16, 2020 · 0 comments · Fixed by #22
Closed

Make the code more CSP friendly #21

tdelmas opened this issue Feb 16, 2020 · 0 comments · Fixed by #22

Comments

@tdelmas
Copy link

tdelmas commented Feb 16, 2020

The current version use the Function constructor which make the code incompatible with a secure CSP.

https://github.com/stackgl/gl-shader/blob/master/lib/create-uniforms.js#L9 :
For example:

//Binds a function and returns a value
function identity(x) {
  var c = new Function('y', 'return function(){return y}')
  return c(x)
}

Could probably be replaced by something like:

//Binds a function and returns a value
function identity(x) {
  return function (){return x}
}

The two only other functions using Function are makeGetter and makeSetter.

Related: plotly/plotly.js#897

(sorry @mikolalysenko I feel like I spam you but it's just a coincidence if it's again one of your repository! And I think it's important to document which code can or cannot be used in a secure manner in a browser)

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

Successfully merging a pull request may close this issue.

1 participant