Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
es-host-wrapper
Advanced tools
Es-host-wrapper is a library for executing ECMAScript code uniformly across any ECMAScript host environment. Es-host-wrapper consists of a wrapper around the various ways of executing a host and processing its output (called a Runner) and a runtime library for host-agnostic scripts to use.
npm install es-host-wrapper
Host | Supported Platforms | Download | Notes |
---|---|---|---|
Browsers | Any | Errors reported from Microsoft Edge are all of type Error. | |
Node | Any | https://nodejs.org | |
ch | Windows | Built from source | Chakra console host. |
d8 | Any | Built from source | v8 console host. Errors are reported on stdout. Use $.setGlobal to set properties of global objects in other realms. |
jsshell | Any | Download | |
JSC | Mac | Built from source¹ | |
Nashorn | Any | Built from source |
1: Also available on your Mac system at /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc
.
const runner = js.getRunner('path/to/d8.exe', 'd8');
runner.exec(`
print(1+1);
`).then(result => console.log(result.stdout));
Gets an instance of a runner for a particular host type. Supported host types:
Creating a runner may start the host (eg. for the browser, creating the host executes the browser process).
You can pass command line arguments to the host process using the arguments option. It is an array of strings as you might pass to Node's spawn API.
Executes code
in the host. Returns a result object.
An object with the following keys:
print
).The error object is similar to the error object you get in the host itself. Namely, it has the following keys:
Prints str
to stdout.
A reference to the global object.
Creates a new realm, returning that realm's runtime library ($).
For example, creating two nested realms:
$sub = $.createRealm();
$subsub = $sub.createRealm();
Creates a new realm and evals code
in that realm. If an error is thrown, it will be passed to the onError callback.
Creates a new script and evals code
in that realm. If an error is thrown, it will be passed to the onError callback.
Scripts are different from eval in that lexical bindings go into the global lexical contour rather than being scoped to the eval.
Sets a global property name to value.
FAQs
Invoke ECMAScript scripts in any command line JS engine.
We found that es-host-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.