
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Evaluate arbitrary JavaScript from Python, using a NodeJS sidecar process.
This combines:
nodejs-bin
project, which
bundles NodeJS (with npm
and npx
) into a PyPI package, andhttp-eval
project, which runs a
JavaScript evaluation server on a Unix domain socket.Table of Contents
pip install nodejs-eval
nodejs-eval
is distributed under the terms of the
MIT license.
JavaScript code is evaluated as a function body within a synchronous or asynchronous JavaScript function, within an ECMAScript module.
Note that the NodeJS evaluator always only supports async
mode on the Python
side. However, the supplied JavaScript code can be either sync or async.
from nodejs_eval import evaluator
async with evaluator() as e:
result = await e.run("return 6*7;")
assert result == 42
from nodejs_eval import evaluator
async with evaluator() as e:
result = await e.run_async(
"""
await new Promise(r => setTimeout(r, 2000));
return 6*7;
""")
assert result == 42
this
Evaluations run with a consistent JavaScript this
context, so state can be
stored on it:
from nodejs_eval import evaluator
async with evaluator() as e:
await e.run("this.x = 6*7;")
result = await e.run("return this.x;")
assert result == 42
await import()
Because code is executed within an ECMAScript module, you can use
the dynamic async import()
to import other modules.
This is easiest done in async
mode:
from nodejs_eval import evaluator
async with evaluator() as e:
result = await e.run_async(
"""
const os = await import("os");
return os.cpus();
"""
)
assert len(result) > 0
FAQs
Evaluate arbitrary JavaScript from Python using a NodeJS sidecar
We found that nodejs-eval demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.