Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
pifke.org/estree
Go (Golang) implementation of the ESTree Specification, an Abstract Syntax Tree for working with Javascript code.
ESTree allows interoperability between software which parses, manipulates, and/or executes Javascript code. Examples include transpilers, minifiers, and front-end frameworks.
This library provides type-checked objects representing AST nodes, which can be serialized to and from JSON in the format used by compilers such as Acorn, Babel, Typescript, etc.
The following Javascript:
function hello(name) {
var greeting = "Hello";
console.log(greeting + " " + name);
}
...can be represented as:
Program{
Body: []DirectiveOrStatement{
FunctionDeclaration{
ID: Identifier{Name: "hello"},
Params: []Pattern{
Identifier{Name: "name"},
},
Body: FunctionBody{
Body: []DirectiveOrStatement{
VariableDeclaration{
Declarations: []VariableDeclarator{
VariableDeclarator{
ID: Identifier{Name: "greeting"},
Init: StringLiteral{Value: "Hello"},
},
},
Kind: Var,
},
ExpressionStatement{
Expression: CallExpression{
Callee: MemberExpression{
Object: Identifier{Name: "console"},
Property: Identifier{Name: "log"},
},
Arguments: []Expression{
BinaryExpression{
Left: BinaryExpression{
Left: Identifier{Name: "greeting"},
Operator: Add,
Right: StringLiteral{Value: " "},
},
Operator: Add,
Right: Identifier{Name: "name"},
},
},
},
},
},
},
},
},
}
Only the ES5 nodes have been implemented so far. The remainder are coming very soon.
I'll declare this library 1.0 once I have some real-world experience using it; I built this with a particular project in mind, so this will hopefully also be soon.
If you use this library in your own code, please use the canonical URL in your Go code, instead of Github:
go get pifke.org/estree
As opposed to the pifke.org URL, I make no guarantee this Github repository will exist or be up-to-date in the future.
MIT (Expat), see LICENSE.txt. If for some reason you'd like to use this code and that doesn't work for you, please contact me.
The ESTree Specification itself is Copyright Mozilla Contributors and ESTree Contributors, Creative Commons Sharealike.
Dave Pifke. My email address is my first name "at" my last name "dot org."
I'm @dave@pifke.social in the Fediverse,
@dave:pifke.chat
in Matrix, and dpifke
on Freenode. My PGP key is
available from my web site.
FAQs
Unknown package
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
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.