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.
esast-util-from-estree
Advanced tools
esast utility to transform from estree.
This package applies some transforms to a cloned, given estree to make it compatible with unist. It:
.bigint
attributes
, selfClosing
from JSXOpeningFragment
The transform applied by this utility is often optional: estrees can be used in most places where esast can be used, and vice versa. But, if you come from a unist background and want to deal with JavaScript, or want to use unist utilities with JavaScript, this helps a lot.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install esast-util-from-estree
In Deno with esm.sh
:
import {fromEstree} from 'https://esm.sh/esast-util-from-estree@2'
In browsers with esm.sh
:
<script type="module">
import {fromEstree} from 'https://esm.sh/esast-util-from-estree@2?bundle'
</script>
import {parse} from 'acorn'
import {fromEstree} from './index.js'
// Make acorn support comments and positional info.
/** @type {Array<import('acorn').Comment>} */
const comments = []
/** @type {import('estree').Program} */
// @ts-expect-error: acorn looks like estree.
const estree = parse(
'export function x() { /* Something senseless */ console.log(/(?:)/ + 1n) }',
{
sourceType: 'module',
ecmaVersion: 'latest',
locations: true,
onComment: comments
}
)
estree.comments = comments
const esast = fromEstree(estree)
console.log(esast)
Yields:
{
type: 'Program',
body: [
{
type: 'ExportNamedDeclaration',
declaration: [Object],
specifiers: [],
source: null,
position: [Object]
}
],
sourceType: 'module',
comments: [
{
type: 'Block',
value: ' Something senseless ',
position: [Object]
}
],
position: {
start: {line: 1, column: 1, offset: 0},
end: {line: 1, column: 75, offset: 74}
}
}
This package exports the identifier fromEstree
.
There is no default export.
fromEstree(estree[, options])
Turn an estree into an esast.
estree
(EstreeNode
)
— estreeoptions
(Options
, optional)
— configurationClean clone of estree
(UnistNode
).
Options
Configuration (TypeScript Type).
dirty
(boolean
, default: false
)
— leave discouraged fields in the treeThis package is fully typed with TypeScript.
It exports the additional type Options
.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
esast-util-from-estree@^2
, compatible with Node.js 16.
See contributing.md
in syntax-tree/.github
for
ways to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
FAQs
esast utility to transform from estree
The npm package esast-util-from-estree receives a total of 243,456 weekly downloads. As such, esast-util-from-estree popularity was classified as popular.
We found that esast-util-from-estree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
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.