Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A tiny JavaScript interpreter written in TypeScript
Note: This project was originally developed for use in YouTube.js.
npm install jintr
Execute some JavaScript code:
// const Jinter = require('jintr').default;
import { Jinter } from 'jintr';
const code = `
function sayHiTo(person) {
console.log('Hi ' + person + '!');
}
sayHiTo('mom');
`
const jinter = new Jinter();
jinter.evaluate(code);
Inject your own functions, objects, etc:
import { Jinter } from 'jintr';
const jinter = new Jinter();
const code = `
console.log(new SomeClass().a);
console.log('hello'.toArray());
function myFn() {
console.log('[myFn]: Who called me?');
}
myFn();
`;
class SomeClass {
constructor() {
this.a = 'this is a test';
}
}
jinter.defineObject('SomeClass', SomeClass);
// Ex: str.toArray();
jinter.visitor.on('toArray', (node, visitor) => {
if (node.type === 'CallExpression' && node.callee.type === 'MemberExpression') {
const obj = visitor.visitNode(node.callee.object);
return obj.split('');
}
});
// Intercept function calls
jinter.visitor.on('myFn', (node) => {
if (node.type == 'CallExpression')
console.info('myFn was called!');
return '__continue_exec';
});
jinter.evaluate(code);
For more examples see /test
and /examples
.
evaluate(input: string)
Evaluates the given JavaScript code.
visitor
The node visitor. This is responsible for walking the AST and executing the nodes.
scope
Represents the global scope of the program.
Distributed under the MIT License.
3.0.2 (2024-10-28)
!=
op (97e17f9)!==
op (475fc89)>>>
op (7cfdfdf)^
op (faa1904)ForOfStatement
node (203d3ae)in
op (3f2d00d)instanceof
op (c11f440)parseScript
(654d06d)typeof
op (5836fec)IfStatement
& WhileStatement
(5179eee)ExpressionStatement
(7e43562)LICENSE
file (94b6bb0)FAQs
A tiny JavaScript interpreter written in TypeScript.
We found that jintr 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.