Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
eshost-cli
Advanced tools
eshost-cli makes it easy to run and compare ECMAScript code uniformly across a number of runtimes. Support for runtimes is provided by the library eshost. Every host is initialized with the eshost runtime API available which provides a uniform way to print, create realms, and eval code.
See eshost's supported hosts for a list of hosts, download/build locations, and other information.
See --help
output for the full details. Basic usage:
eshost --add <host name> <host type> <host path> --args <optional arguments>
.jsvu
-installed hosts using eshost --configure-jsvu
.-e
: eshost -e "[1,2,3].length"
.-x
: eshost -x "foo = 42; print(foo);"
eshost path/to/script.js
.-m
:
eshost -me "foo = 42"
(this example should result in errors!)eshost -mx "foo = 42; print(foo);"
(this example should result in errors!).mjs
extension: eshost file.mjs
; or by using the -m
option: eshost -m file.js
On Linux and macOS:
# Engine262
git clone https://github.com/devsnek/engine262.git;
cd engine262 && npm install && npm run build && npm link;
cd ~/
# QuickJS
wget https://bellard.org/quickjs/quickjs-2019-09-18.tar.xz;
tar -xf quickjs-2019-09-18.tar.xz;
cd quickjs-2019-09-18 && make;
if [ -f "$PWD/run-test262" ]; then ln -s $PWD/run-test262 /usr/local/bin/qjs-for-eshost; fi;
# Everything else...
npm install -g jsvu;
export PATH="${HOME}/.jsvu:${PATH}";
jsvu --engines=chakra,hermes,javascriptcore,spidermonkey,v8,xs
export ESHOST_PATH_CHAKRA=`which chakra`;
export ESHOST_PATH_ENGINE262=`which engine262`;
export ESHOST_PATH_JAVASCRIPTCORE=`which javascriptcore`;
export ESHOST_PATH_QUICKJS=`which qjs-for-eshost`;
export ESHOST_PATH_SPIDERMONKEY=`which spidermonkey`;
export ESHOST_PATH_V8=`which v8`;
export ESHOST_PATH_XS=`which xs`;
npm install -g eshost;
eshost --add "chakra" ch $ESHOST_PATH_CHAKRA;
eshost --add "engine262" engine262 $ESHOST_PATH_ENGINE262;
eshost --add "javascriptcore" jsc $ESHOST_PATH_JAVASCRIPTCORE;
eshost --add "quickjs" qjs $ESHOST_PATH_QUICKJS;
eshost --add "spidermonkey" jsshell $ESHOST_PATH_SPIDERMONKEY;
eshost --add "v8" d8 $ESHOST_PATH_V8;
eshost --add "xs" xs $ESHOST_PATH_XS;
On Windows:
git clone https://github.com/devsnek/engine262.git
cd .\engine262
npm install
npm run build
npm link
set NPM_GLOBAL_MODULE_PATH=%APPDATA%\npm\
set PATH=%PATH;%NPM_GLOBAL_MODULE_PATH%
where engine262
npm install jsvu
jsvu --os=win64 --engines="chakra,spidermonkey,v8,xs"
set PATH=%PATH;%USERPROFILE%\.jsvu\
set ESHOST_CHAKRA=%USERPROFILE%\.jsvu\chakra.cmd
set ESHOST_ENGINE262=%NPM_GLOBAL_MODULE_PATH%\engine262.cmd
set ESHOST_SPIDERMONKEY=%USERPROFILE%\.jsvu\spidermonkey.cmd
set ESHOST_V8=%USERPROFILE%\.jsvu\v8.cmd
set ESHOST_XS=%USERPROFILE%\.jsvu\xs.cmd
npm install -g eshost;
eshost --add "chakra" ch %ESHOST_CHAKRA%
eshost --add "engine262" engine262 %ESHOST_ENGINE262%
eshost --add "spidermonkey" jsshell %ESHOST_SPIDERMONKEY%
eshost --add "v8" d8 %ESHOST_V8%
eshost --add "xs" xs %ESHOST_XS%
$ npm install -g eshost-cli
$ eshost --help
$ eshost --add <name> <type> <path to host executable> --args <optional arguments>
$ eshost -e "Map.length"
#### chakra
0
#### engine262
0
#### javascriptcore
0
#### spidermonkey
0
#### v8
0
#### xs
0
$ eshost --configure-jsvu --jsvu-prefix jsvu
$ eshost --tags jsvu-web -itsx "let a = 40+2; print(a)"
## Source
let a = 40+2; print(a)
┌──────────┬────┐
│ jsvu-ch │ 42 │
│ jsvu-jsc │ │
│ jsvu-sm │ │
│ jsvu-v8 │ │
└──────────┴────┘
Files containing the imported modules must be located in the same directory that the "entry point" file is located. Please read and accept the following examples.
Executing a program with module dependencies, where the entry point is a ".mjs" file:
mkdir entry-point-mjs;
cd entry-point-mjs;
echo "export var a = 1;" >> export.mjs
echo "import {a} from './export.mjs'; print(a);" >> import.mjs
eshost --host="engine262,javascriptcore,spidermonkey,v8,xs" import.mjs
#### engine262
1
#### javascriptcore
1
#### spidermonkey
1
#### v8
1
#### xs
1
Executing a program with module dependencies, where the entry point is a ".js" file (Notice the use of the -m
flag, this is required for ".js" files):
mkdir entry-point-js;
cd entry-point-js;
echo "export var a = 1;" >> export.mjs
echo "import {a} from './export.mjs'; print(a);" >> import.js
eshost --host="engine262,javascriptcore,spidermonkey,v8,xs" -m import.js
#### engine262
1
#### javascriptcore
1
#### spidermonkey
1
#### v8
1
#### xs
1
Executing a multi-line program with module dependencies is not yet supported. Support is in progress.
You can --list
, --add
, --edit
, and --delete
hosts. Adding a host requires a name, type, and path to the runtime executable. You can optionally pass arguments using --args
. The same host can be added multiple times with different --args
which makes it easy to compare the output of runtimes given different options (e.g. by turning language features on and off).
Console hosts are either provided by the browser vendors or, more likely, built from source. The jsvu
CLI makes it easy to install and update the most common JavaScript engine binaries.
Host types are those provided by eshost, namely:
Host Type | All Acceptable type Values |
---|---|
ChakraCore | chakra , ch |
Engine262 | engine262 |
JavaScriptCore | javascriptcore , jsc |
Nashorn | nashorn |
Node | node |
QuickJS | qjs 1 |
SpiderMonkey | jsshell , spidermonkey , sm |
V8 | d8 , v8 |
XS | xs |
~/.jsvu/quickjs
WITH ESHOST-CLI. The main quickjs
binary does not support the eshost runtime API. For more, see Install and Configure Hosts.Host Type | All Acceptable type Values |
---|---|
chrome | chrome |
edge | edge |
firefox | firefox |
safari | safari |
FAQs
Run scripts in any ECMAScript host
The npm package eshost-cli receives a total of 8 weekly downloads. As such, eshost-cli popularity was classified as not popular.
We found that eshost-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.