loophole

WebJar for loophole

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

loophole
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

loophole
WebJar for loophole
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/atom/loophole

Download loophole

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/loophole/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>loophole</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/loophole/
implementation 'org.webjars.npm:loophole:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/loophole/
implementation ("org.webjars.npm:loophole:1.1.0")
'org.webjars.npm:loophole:jar:1.1.0'
<dependency org="org.webjars.npm" name="loophole" rev="1.1.0">
  <artifact name="loophole" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='loophole', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "loophole" % "1.1.0"
[org.webjars.npm/loophole "1.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Eval Loophole Build Status

This is a hack to enable third-party libraries that depend on a limited subset of eval semantics to work in Atom with a content security policy that forbids calls to eval.

{allowUnsafeEval, allowUnsafeNewFunction} = require 'loophole'

allowUnsafeEval ->
  crazyLibrary.exploitLoophole() # allows `eval(...)`

allowUnsafeNewFunction ->
  crazyLibrary.exploitLoophole() # allows `new Function(...)`

You can also use the exported Function constructor directly:

{Function} = require 'loophole'
f = new Function("return 1 + 1;")

How?

allowUnsafeEval replaces eval with a call to vm.runInThisContext, which won't perfectly emulate eval but is good enough in certain circumstances, like compiling PEG.js grammars.

allowUnsafeNewFunction temporarily replaces global.Function with loophole.Function, which passes the source of the desired function to vm.runInThisContext.

Why?

If there's a loophole, why even enable CSP? It still prevents developers from accidentally invoking eval with legacy libraries. For example, did you know that jQuery runs eval when you pass it content with script tags? If you want eval, you'll need to explicitly ask for it.

org.webjars.npm

Atom

Free and open source text editor, brought to you by GitHub

Versions

Version
1.1.0