Skip to content

CSP "unsafe-eval" error because of render_sync.js use of function constructor #14

@christianvoigt

Description

@christianvoigt

Hi, me again. :)

I am using viz.js in a "web view" in VSCode (basically a browser window within the editor). Under certain conditions this leads to the following CSP error: Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'nonce-...'".

I do not want to add "unsafe-eval" to the CSP as this is not recommended. The error is caused by the following code in render_sync.js:

return new Function("body","return function "+A+'() {\n    "use strict";    return body.apply(this, arguments);\n};

I am not sure where this is coming from, but typically code like this is added by a bundler (in your case Rollup). I previously thought that this was caused by my own use of webpack, as webpack is known to cause this problem (see here and here for webpack-specific discussions).

Could you take a look at this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions