Skip to content

Avoid reaching out to numeric in global namespace in compiled code. #45

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

Closed
wants to merge 2 commits into from

Conversation

jwmerrill
Copy link

This replaces calls to javascript's Function() with calls to the new numeric.compile(), which is a wrapper that closures in the numeric object so that methods on it can be used inside compiled code. The motivation here is to allow using numeric without globally exporting the numeric symbol.

Done in collaboration with @ehberger.

This replaces calls to javascript's Function() with calls to the new numeric.compile(), which is a wrapper that closures in the numeric object so that methods on it can be used inside compiled code. The motivation here is to allow using numeric without globally exporting the `numeric` symbol.
@Pomax
Copy link

Pomax commented Apr 18, 2015

Any site with CSP in place to prevent illegal code injection will not allow eval and new Function (they are considered equivalent from a security perspective), so this PR would prevent numeric.js from working for sites that employ CSP.

And, unfortunately, the sites that need CSP the most are sites that deal with user-generated content, such as "notebook" websites where users can write their own numeric programs and run them, or things like jsfiddle/jsbin/codepen/etc.

This patch would make numeric.js unusable on those sites, so I'd strongly advise to find a solution that does not involve Function at all.

@jwmerrill
Copy link
Author

@Pomax note that Numeric already uses the Function constructor all over the place, e.g.

return Function('x','accum','_s','_k',

so I don't believe this PR would change anything from the perspective of CSP.

@Pomax
Copy link

Pomax commented Apr 20, 2015

Perhaps not, but it would certainly be another thing to then also rewrite in order to keep numeric.js usable in a CSP enabled web landscape.

@Pomax
Copy link

Pomax commented Jun 12, 2017

can this PR be closed? it's from quite a few years ago and I can't remove it from my pulls/mentioned even though I would really love to stop seeing it there =)

@jwmerrill jwmerrill closed this Jun 12, 2017
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 this pull request may close these issues.

2 participants