Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
oxc-parser
Advanced tools
magic-string
on the Rust side exposed through N-API.The parser alone does not fully check for syntax errors that are associated with semantic data (symbols and scopes). The full compiler is needed for such case, as the compiler does an additional semantic pass.
With this caveat, oxc-parser
is best suited for parser plugins,
where you need quick access to ESM information, as well as fast magic-string
operations.
import oxc from './index.js';
// The emoji makes the span of `import.meta.url` to be different in UTF8 and UTF16.
const code = 'const url: String = /* 🤨 */ import.meta.url;';
// File extension is used to determine which dialect to parse source as.
const filename = 'test.tsx';
const result = oxc.parseSync(filename, code);
// or `await oxc.parseAsync(filename, code)`
// An array of errors, if any.
console.log(result.errors);
// AST and comments.
console.log(result.program, result.comments);
// ESM information - imports, exports, `import.meta`s.
console.log(result.module);
// A `magic-string` instance for accessing and manipulating the source text.
// All returned spans are in UTF8 offsets, which cannot be used directly on our JavaScript.
// JavaScript string lengths are in UTF16 offsets.
const ms = result.magicString;
for (const span of result.module.importMetas) {
// Extra methods for access the source text through spans with UTF8 offsets.
console.log(ms.getSourceText(span.start, span.end)); // prints `import.meta`
console.log(ms.getLineColumnNumber(span.start)); // prints `{ line: 0, column: 20 }`
console.log(code.substring(ms.getUtf16ByteOffset(span.start)).startsWith('import.meta.url')); // prints `true`
}
FAQs
Oxc Parser Node API
The npm package oxc-parser receives a total of 6,801 weekly downloads. As such, oxc-parser popularity was classified as popular.
We found that oxc-parser 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.