Skip to content

Make the code more CSP friendly #21

Closed

Description

@tdelmas

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions