Skip to content

Commit 79d20c4

Browse files
authored
docs: add a new section on how to scan a complete NPM/Node.js project (#492)
1 parent 4674d38 commit 79d20c4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,32 @@ The analysis will return: `http` (in try), `crypto`, `util` and `fs`.
8383
> [!TIP]
8484
> There are also a lot of suspicious code examples in the `./workspaces/js-x-ray/examples` directory. Feel free to try the tool on these files.
8585
86+
### Scanning a complete project
87+
88+
By itself, JS-X-Ray does not provide utilities to walk and scan a complete project. However, NodeSecure has packages to achieve that:
89+
90+
```ts
91+
import { ManifestManager } from "@nodesecure/mama";
92+
import { NpmTarball } from "@nodesecure/tarball";
93+
94+
const mama = await ManifestManager.fromPackageJSON(
95+
"./path/to/package.json"
96+
);
97+
const extractor = new NpmTarball(mama);
98+
99+
const {
100+
composition, // Project composition (files, dependencies, extensions)
101+
conformance, // License conformance (SPDX)
102+
code // JS-X-Ray analysis results
103+
} = await extractor.scanFiles();
104+
105+
console.log(code);
106+
```
107+
108+
The `NpmTarball` class uses JS-X-Ray under the hood, and `ManifestManager` locates entry (input) files for analysis.
109+
110+
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.
111+
86112
## API
87113

88114
- [AstAnalyser](./workspaces/js-x-ray/docs/AstAnalyser.md)

0 commit comments

Comments
 (0)