Skip to content

NodeSecure/js-x-ray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

654 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

@nodesecure/js-x-ray

npm version license ossf scorecard slsa level3 github ci workflow

JS-X-Ray is a JavaScript & TypeScript SAST for identifying malicious patterns, security vulnerabilities, and code anomalies. Think of it as ESLint, but dedicated to security analysis. Originally created for NodeSecure CLI, JS-X-Ray has become an independent and serious option for supply chain protection.

๐Ÿ”Ž How It Works

JS-X-Ray parses JS or TS code into an Abstract Syntax Tree (AST) with no extensive usage of RegEx or Semgrep rules. This enables variable tracing, dynamic import resolution, and detection of sophisticated obfuscation that pattern-matching tools miss. The tradeoff is that JS-X-Ray is purely dedicated to the JavaScript/TypeScript ecosystem.

๐Ÿ’ก Features

  • Track require(), import, and dynamic imports with full variable tracing
  • Detect obfuscated code and identify the tool used (jsfuck, jjencode, obfuscator.io, and more)
  • Flag malicious patterns: data exfiltration, process.env serialization, unsafe shell commands
  • Detect vulnerable code: eval(), Function() constructor, ReDoS-prone regexes, SQL injection
  • Flag weak cryptographic algorithms (MD5, SHA1, etc.)
  • Extract infrastructure indicators: URLs, IPs, hostnames, emails
  • Configurable sensitivity modes (conservative/aggressive) and extensible probe system
  • Supports both JavaScript and TypeScript

๐Ÿ’ƒ Getting Started

These packages are available in the Node package repository and can be easily installed with npm or yarn.

$ npm i @nodesecure/js-x-ray
# or
$ yarn add @nodesecure/js-x-ray

๐Ÿ‘€ Usage

import { AstAnalyser } from "@nodesecure/js-x-ray";

const scanner = new AstAnalyser();

const { warnings, dependencies } = await scanner.analyseFile("./file.js");

console.log(dependencies);
console.dir(warnings, { depth: null });

For the full API documentation, warning catalog, and advanced usage, see the @nodesecure/js-x-ray package README.

Workspaces

๐Ÿฅ Contributors guide

If you are a developer looking to contribute to the project, you must first read the CONTRIBUTING guide.

Once you have finished your development, check that the tests (and linter) are still good by running the following script:

$ npm run check

Caution

In case you introduce a new feature or fix a bug, make sure to include tests for it as well.

Internal APIs

For contributors working on the JS-X-Ray internals, the following resources document low-level utilities and AST manipulation patterns:

Benchmarks

The performance of js-x-ray is measured and tracked using mitata.

To run the benchmarks:

  1. Navigate to workspaces/js-x-ray.
  2. Run npm run bench.

The benchmark results are stored in workspaces/js-x-ray/benchmark/report.json. Do not edit this file manually; it is automatically updated on every pull request.

Contributors โœจ

All Contributors

Thanks goes to these wonderful people (emoji key):

Gentilhomme
Gentilhomme

๐Ÿ’ป ๐Ÿ“– ๐Ÿ‘€ ๐Ÿ›ก๏ธ ๐Ÿ›
Nicolas Hallaert
Nicolas Hallaert

๐Ÿ“–
Antoine
Antoine

๐Ÿ’ป
Mathieu
Mathieu

๐Ÿ’ป
Vincent Dhennin
Vincent Dhennin

๐Ÿ’ป โš ๏ธ
Tony Gorez
Tony Gorez

๐Ÿ’ป ๐Ÿ“– โš ๏ธ
PierreD
PierreD

โš ๏ธ ๐Ÿ’ป
Franck Hallaert
Franck Hallaert

๐Ÿ’ป
Maji
Maji

๐Ÿ’ป
Michaรซl Zasso
Michaรซl Zasso

๐Ÿ’ป ๐Ÿ›
Kouadio Fabrice Nguessan
Kouadio Fabrice Nguessan

๐Ÿšง ๐Ÿ’ป
Jean
Jean

โš ๏ธ ๐Ÿ’ป ๐Ÿ“–
tchapacan
tchapacan

๐Ÿ’ป โš ๏ธ
mkarkkainen
mkarkkainen

๐Ÿ’ป
FredGuiou
FredGuiou

๐Ÿ“– ๐Ÿ’ป
Madina
Madina

๐Ÿ’ป
SairussDev
SairussDev

๐Ÿ’ป
Abdou-Raouf ATARMLA
Abdou-Raouf ATARMLA

๐Ÿ’ป
Clement Gombauld
Clement Gombauld

๐Ÿ’ป โš ๏ธ
Ajฤy
Ajฤy

๐Ÿ’ป
Michael Mior
Michael Mior

๐Ÿ“–
Hamed Mohamed
Hamed Mohamed

๐Ÿ’ป
Elie Patrice
Elie Patrice

โš ๏ธ
HoyeongJeon
HoyeongJeon

๐Ÿ’ป
Anne-Flore
Anne-Flore

๐Ÿ’ป

License

MIT

About

JavaScript & Node.js open-source SAST scanner. A static analyser for detecting most common malicious patterns ๐Ÿ”ฌ.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors

โšก