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.
This module converts JavaScript objects to an equivalent abstract syntax tree representation, compatible with the Mozilla Parser API. You can use it to generate JavaScript source code from objects, using escodegen.
Install with npm:
npm install to-ast
Here's a simple example:
var toAST = require('to-ast');
var escodegen = require('escodegen');
// get an AST from a number...
toAST(2) //=> { type: 'Literal', value: 2 }
// or if you want a source string...
escodegen.generate(toAST(2)) //=> '2'
Most built-in JavaScript types as supported out of the box, but if you want to override the behavior for
your particular object, you can provide a toAST
method on your object:
var toAST = require('to-ast');
var escodegen = require('escodegen');
function Person(name) {
this.name = name;
}
Person.prototype.toAST = function() {
return {
type: 'NewExpression',
callee: { type: 'Identifier', name: 'Person' },
arguments: [{ type: 'Literal', value: this.name }]
};
};
escodegen.generate(toAST(new Person('Devon'))) //=> "new Person('Devon')"
MIT
FAQs
Converts JavaScript objects to equivalent ASTs
The npm package to-ast receives a total of 111,055 weekly downloads. As such, to-ast popularity was classified as popular.
We found that to-ast 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.
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.