You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<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">
17
20
</a>
18
21
</p>
19
22
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.
23
24
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
26
26
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.
28
28
29
-
## Feature Highlight
29
+
## 💡 Features
30
30
- 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
- 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
39
56
40
57
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).
41
58
@@ -45,7 +62,7 @@ $ npm i @nodesecure/js-x-ray
45
62
$ yarn add @nodesecure/js-x-ray
46
63
```
47
64
48
-
## Usage example
65
+
## 👀 Usage example
49
66
50
67
Create a local `.js` file with the following content:
51
68
```js
@@ -109,7 +126,7 @@ The `NpmTarball` class uses JS-X-Ray under the hood, and `ManifestManager` locat
109
126
110
127
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.
0 commit comments