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

babel-plugin-istanbul no CSP compatibel #212

Closed
msteller-connyun opened this issue Jul 3, 2019 · 3 comments · Fixed by #227
Closed

babel-plugin-istanbul no CSP compatibel #212

msteller-connyun opened this issue Jul 3, 2019 · 3 comments · Fixed by #227

Comments

@msteller-connyun
Copy link

Hey,

as soon I add the istanbul plugin to my babel configuration

      {
        test: /\.js$/,
        include: [/node_modules\/*\/src/, /src/],
        use: {
          loader: 'babel-loader',
           ...
            cacheDirectory: true,
            env: {
              test: {
                plugins: ['istanbul',]
              }
            }
          }
        }
      },

A new Function is added to the code:

  var global = new Function("return this")()

which violates our CSP rules.

@coreyfarrell
Copy link
Member

This will ultimately be addressed via #208. This will allow options coverageGlobalScopeFunc: false, coverageGlobalScope: 'window' - which should cause the instrumented code to set global as follows:

var global = window

coreyfarrell added a commit to coreyfarrell/babel-plugin-istanbul that referenced this issue Oct 8, 2019
This adds support for:
* coverageVariable
* coverageGlobalScope
* coverageGlobalScopeFunc
* ignoreClassMethods

Fixes istanbuljs#208, fixes istanbuljs#212
coreyfarrell added a commit that referenced this issue Oct 8, 2019
This adds support for:
* coverageVariable
* coverageGlobalScope
* coverageGlobalScopeFunc
* ignoreClassMethods

Fixes #208, fixes #212
@praveen7557
Copy link

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 'self' 'wasm-unsafe-eval'".

getting the above error because of var global = new Function("return this")(), anyway to solve this?

@just-toby
Copy link

just-toby commented Mar 29, 2023

coverageGlobalScopeFunc: false, coverageGlobalScope: 'window'

setting these options causes another babel plugin (vanilla-extract) to fail with this error: ReferenceError: window is not defined. does anyone know a workaround?

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.

4 participants