Skip to content

Commit 92132a3

Browse files
authored
Enhance readme v2 (#503)
* docs: add missing js-x-ray-ai workspace * docs: add contributors section docs: move benchmarks & workspaces into contributors section * docs: revamp project introduction docs: add missing hostnames docs: add SLSA level 3 badge
2 parents 667cccf + f470a2b commit 92132a3

File tree

1 file changed

+57
-26
lines changed

1 file changed

+57
-26
lines changed

README.md

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,47 @@
1212
<a href="https://api.securityscorecards.dev/projects/github.com/NodeSecure/js-x-ray">
1313
<img src="https://api.securityscorecards.dev/projects/github.com/NodeSecure/js-x-ray/badge?style=for-the-badge" alt="ossf scorecard">
1414
</a>
15+
<a href="https://slsa.dev/spec/v1.0/levels#build-l3">
16+
<img src="https://img.shields.io/badge/SLSA-level%203-green?style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABMlBMVEXvMQDvMADwMQDwMADwMADvMADvMADwMADwMQDvMQDvMQDwMADwMADvMADwMADwMADwMQDvMQDvMQDwMQDvMQDwMQDwMADwMADwMQDwMADwMADvMADvMQDvMQDwMADwMQDwMADvMQDwMADwMQDwMADwMADwMADwMADwMADwMADvMQDvMQDwMADwMQDwMADvMQDvMQDwMADvMQDvMQDwMADwMQDwMQDwMQDvMQDwMADvMADwMADwMQDvMQDwMADwMQDwMQDwMQDwMQDvMQDvMQDvMADwMADvMADvMADvMADwMQDwMQDvMADvMQDvMQDvMADvMADvMQDwMQDvMQDvMADvMADvMADvMQDwMQDvMQDvMQDvMADvMADwMADvMQDvMQDvMQDvMADwMADwMQDwMAAAAAA/HoSwAAAAY3RSTlMpsvneQlQrU/LQSWzvM5DzmzeF9Pi+N6vvrk9HuP3asTaPgkVFmO3rUrMjqvL6d0LLTVjI/PuMQNSGOWa/6YU8zNuDLihJ0e6aMGzl8s2IT7b6lIFkRj1mtvQ0eJW95rG0+Sid59x/AAAAAWJLR0Rltd2InwAAAAlwSFlzAAAOwwAADsMBx2+oZAAAAAd0SU1FB+YHGg0tGLrTaD4AAACqSURBVAjXY2BgZEqGAGYWVjYGdg4oj5OLm4eRgZcvBcThFxAUEk4WYRAVE09OlpCUkpaRTU6WY0iWV1BUUlZRVQMqUddgSE7W1NLS1gFp0NXTB3KTDQyNjE2Sk03NzC1A3GR1SytrG1s7e4dkBogtjk7OLq5uyTCuu4enl3cyhOvj66fvHxAIEmYICg4JDQuPiAQrEmGIio6JjZOFOjSegSHBBMpOToxPAgCJfDZC/m2KHgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wNy0yNlQxMzo0NToyNCswMDowMC8AywoAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDctMjZUMTM6NDU6MjQrMDA6MDBeXXO2AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAABJRU5ErkJggg==" alt="slsa level3">
17+
</a>
1518
<a href="https://github.com/NodeSecure/js-x-ray/actions?query=workflow%3A%22Node.js+CI%22">
1619
<img src="https://img.shields.io/github/actions/workflow/status/NodeSecure/js-x-ray/node.js.yml?style=for-the-badge" alt="github ci workflow">
1720
</a>
1821
</p>
1922

20-
JavaScript AST analysis. This package has been created to export the [NodeSecure](https://github.com/NodeSecure/cli) AST analysis to enable better code evolution and allow better access to developers and researchers.
21-
22-
The goal is to quickly identify dangerous code and patterns for developers and security researchers. Interpreting the results of this tool will still require you to have basic knowledge of secure coding.
23+
**JS-X-Ray** is a JavaScript & TypeScript [SAST](https://github.com/resources/articles/what-is-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](https://github.com/NodeSecure/cli), JS-X-Ray has become an independent and serious option for supply chain protection.
2324

24-
## Goals
25-
The objective of the project is to detect potentially suspicious JavaScript code. The target is code that is added or injected for malicious purposes.
25+
## 🔎 How It Works
2626

27-
Most of the time hackers will try to hide the behaviour of their code as much as possible to avoid being spotted or easily understood. The work of the library is to understand and analyze these patterns that will allow us to detect malicious code.
27+
JS-X-Ray parses code into an **Abstract Syntax Tree (AST)** using [Meriyah](https://github.com/meriyah/meriyah) 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.
2828

29-
## Feature Highlight
29+
## 💡 Features
3030
- Retrieve required dependencies and files for Node.js
31-
- Detect unsafe regular expressions
32-
- Get warnings when the AST analysis detects a problem or is unable to follow a statement
33-
- Highlight common attack patterns and API usages
34-
- Follow the usage of dangerous Node.js globals
35-
- Detect obfuscated code and, when possible, the tool that has been used
36-
- Detect potential performance issues related to usage of synchronous API from Node.js core.
37-
38-
## Getting Started
31+
- Track `require()`, `import`, and dynamic imports with full tracing capabilities
32+
- Detect untraceable and malicious import patterns
33+
- Scan entire projects with multi-file analysis capabilities
34+
- Extract infrastructure components (URLs, IPs, hostnames, emails)
35+
- Detect malicious code patterns
36+
- Obfuscated code with tool identification (freejsobfuscator, jsfuck, jjencode, obfuscator.io, morse, Trojan Source)
37+
- Data exfiltration and unauthorized system information collection
38+
- Suspicious files with excessive encoded literals
39+
- Identify vulnerable code patterns
40+
- Unsafe statements (`eval()`, `Function()` constructor)
41+
- ReDoS vulnerabilities in regular expressions
42+
- SQL injection vulnerabilities
43+
- Unsafe shell commands in `spawn()` or `exec()` calls
44+
- `process.env` serialization attempts
45+
- Flag weak cryptographic usage
46+
- Deprecated algorithms (MD5, SHA1, MD4, MD2, RIPEMD160)
47+
- Detect code quality issues
48+
- Monkey-patching of built-in prototypes
49+
- Encoded literals (hex, Unicode, base64)
50+
- Suspicious URLs and links
51+
- Short identifier lengths (obfuscation indicators)
52+
- Synchronous I/O and logging usage (optional)
53+
- Configurable sensitivity modes (conservative/aggressive) and extensible probe system
54+
55+
## 💃 Getting Started
3956

4057
This package is available in the Node package repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).
4158

@@ -45,7 +62,7 @@ $ npm i @nodesecure/js-x-ray
4562
$ yarn add @nodesecure/js-x-ray
4663
```
4764

48-
## Usage example
65+
## 👀 Usage example
4966

5067
Create a local `.js` file with the following content:
5168
```js
@@ -109,7 +126,7 @@ The `NpmTarball` class uses JS-X-Ray under the hood, and `ManifestManager` locat
109126

110127
Alternatively, you can use `EntryFilesAnalyser` directly for multi-file analysis. See the [EntryFilesAnalyser API documentation](./workspaces/js-x-ray/docs/EntryFilesAnalyser.md) for more details.
111128

112-
## API
129+
## 📚 API
113130

114131
- [AstAnalyser](./workspaces/js-x-ray/docs/AstAnalyser.md)
115132
- [EntryFilesAnalyser](./workspaces/js-x-ray/docs/EntryFilesAnalyser.md)
@@ -236,13 +253,35 @@ Click on the warning **name** for detailed documentation and examples.
236253
> [!NOTE]
237254
> Warnings marked with ⚠️ are optional and must be explicitly enabled (see [Optional Warnings](#optional-warnings) section).
238255
239-
## Workspaces
256+
## Contributors guide
257+
258+
If you are a developer **looking to contribute** to the project, you must first read the [CONTRIBUTING](./CONTRIBUTING.md) guide.
259+
260+
Once you have finished your development, check that the tests (and linter) are still good by running the following script:
261+
262+
```bash
263+
$ npm run check
264+
```
265+
266+
> [!CAUTION]
267+
> In case you introduce a new feature or fix a bug, make sure to include tests for it as well.
268+
269+
### Benchmarks
270+
271+
The performance of js-x-ray is measured and tracked using [mitata](https://github.com/evanwashere/mitata).
272+
273+
To run the benchmarks:
274+
1. Navigate to `workspaces/js-x-ray`.
275+
2. Run `npm run bench`.
276+
277+
### Workspaces
240278

241279
Click on one of the links to access the documentation of the workspace:
242280

243281
| name | package and link |
244282
| --- | --- |
245283
| js-x-ray | [@nodesecure/js-x-ray](./workspaces/js-x-ray) |
284+
| js-x-ray-ai | [@nodesecure/js-x-ray-ai](./workspaces/js-x-ray-ai) |
246285
| estree-ast-utils | [@nodesecure/estree-ast-utils](./workspaces/estree-ast-utils) |
247286
| tracer | [@nodesecure/tracer](./workspaces/tracer) |
248287
| sec-literal | [@nodesecure/sec-literal](./workspaces/sec-literal) |
@@ -255,14 +294,6 @@ $ npm i @nodesecure/estree-ast-util
255294
$ yarn add @nodesecure/estree-ast-util
256295
```
257296

258-
## Benchmarks
259-
260-
The performance of js-x-ray is measured and tracked using [mitata](https://github.com/evanwashere/mitata).
261-
262-
To run the benchmarks:
263-
1. Navigate to `workspaces/js-x-ray`.
264-
2. Run `npm run bench`.
265-
266297
## Contributors ✨
267298

268299
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

0 commit comments

Comments
 (0)