@nodesecure/scanner 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,94 +1,95 @@
1
- # NodeSecure Scanner
2
- ![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/NodeSecure/scanner/master/package.json&query=$.version&label=Version)
3
- [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/NodeSecure/scanner/commit-activity)
4
- [![Security Responsible Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/nodejs/security-wg/blob/master/processes/responsible_disclosure_template.md
5
- )
6
- [![mit](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/NodeSecure/scanner/blob/master/LICENSE)
7
- ![build](https://img.shields.io/github/workflow/status/NodeSecure/scanner/Node.js%20CI)
8
-
9
- ⚡️ Run a static analysis of your module's dependencies.
10
-
11
- ## Requirements
12
-
13
- - [Node.js](https://nodejs.org/en/) version 16 or higher
14
-
15
- ## Getting Started
16
-
17
- 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).
18
-
19
- ```bash
20
- $ npm i @nodesecure/scanner
21
- # or
22
- $ yarn add @nodesecure/scanner
23
- ```
24
-
25
- ## Usage example
26
-
27
- ```js
28
- import * as scanner from "@nodesecure/scanner";
29
- import fs from "fs/promises";
30
-
31
- // CONSTANTS
32
- const kPackagesToAnalyze = ["mocha", "cacache", "is-wsl"];
33
-
34
- const payloads = await Promise.all(
35
- kPackagesToAnalyze.map((name) => scanner.from(name))
36
- );
37
-
38
- const promises = [];
39
- for (let i = 0; i < kPackagesToAnalyze.length; i++) {
40
- const data = JSON.stringify(payloads[i], null, 2);
41
-
42
- promises.push(fs.writeFile(`${kPackagesToAnalyze[i]}.json`, data));
43
- }
44
- await Promise.allSettled(promises);
45
- ```
46
-
47
- ## API
48
-
49
- See `types/api.d.ts` for a complete TypeScript definition.
50
-
51
- ```ts
52
- function cwd(path: string, options?: Scanner.Options): Promise<Scanner.Payload>;
53
- function from(packageName: string, options?: Scanner.Options): Promise<Scanner.Payload>;
54
- function verify(packageName: string): Promise<Scanner.VerifyPayload>;
55
- ```
56
-
57
- `Options` is described with the following TypeScript interface:
58
-
59
- ```ts
60
- interface Options {
61
- readonly maxDepth?: number;
62
- readonly usePackageLock?: boolean;
63
- readonly vulnerabilityStrategy: Strategy.Kind;
64
- readonly forceRootAnalysis?: boolean;
65
- readonly fullLockMode?: boolean;
66
- }
67
- ```
68
-
69
- ## Contributors ✨
70
-
71
- <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
72
- [![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
73
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
74
-
75
- Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
76
-
77
- <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
78
- <!-- prettier-ignore-start -->
79
- <!-- markdownlint-disable -->
80
- <table>
81
- <tr>
82
- <td align="center"><a href="https://www.linkedin.com/in/thomas-gentilhomme/"><img src="https://avatars.githubusercontent.com/u/4438263?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gentilhomme</b></sub></a><br /><a href="https://github.com/NodeSecure/scanner/commits?author=fraxken" title="Code">💻</a> <a href="https://github.com/NodeSecure/scanner/commits?author=fraxken" title="Documentation">📖</a> <a href="https://github.com/NodeSecure/scanner/pulls?q=is%3Apr+reviewed-by%3Afraxken" title="Reviewed Pull Requests">👀</a> <a href="#security-fraxken" title="Security">🛡️</a> <a href="https://github.com/NodeSecure/scanner/issues?q=author%3Afraxken" title="Bug reports">🐛</a></td>
83
- <td align="center"><a href="http://tonygo.dev"><img src="https://avatars.githubusercontent.com/u/22824417?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tony Gorez</b></sub></a><br /><a href="https://github.com/NodeSecure/scanner/commits?author=tony-go" title="Code">💻</a> <a href="https://github.com/NodeSecure/scanner/commits?author=tony-go" title="Documentation">📖</a> <a href="https://github.com/NodeSecure/scanner/pulls?q=is%3Apr+reviewed-by%3Atony-go" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/NodeSecure/scanner/issues?q=author%3Atony-go" title="Bug reports">🐛</a></td>
84
- <td align="center"><a href="https://mickaelcroquet.fr"><img src="https://avatars.githubusercontent.com/u/23740372?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Haze</b></sub></a><br /><a href="https://github.com/NodeSecure/scanner/commits?author=CroquetMickael" title="Code">💻</a></td>
85
- </tr>
86
- </table>
87
-
88
- <!-- markdownlint-restore -->
89
- <!-- prettier-ignore-end -->
90
-
91
- <!-- ALL-CONTRIBUTORS-LIST:END -->
92
-
93
- ## License
94
- MIT
1
+ # NodeSecure Scanner
2
+ ![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/NodeSecure/scanner/master/package.json&query=$.version&label=Version)
3
+ [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/NodeSecure/scanner/commit-activity)
4
+ [![Security Responsible Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/nodejs/security-wg/blob/master/processes/responsible_disclosure_template.md
5
+ )
6
+ [![mit](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/NodeSecure/scanner/blob/master/LICENSE)
7
+ ![build](https://img.shields.io/github/workflow/status/NodeSecure/scanner/Node.js%20CI)
8
+
9
+ ⚡️ Run a static analysis of your module's dependencies.
10
+
11
+ ## Requirements
12
+
13
+ - [Node.js](https://nodejs.org/en/) version 16 or higher
14
+
15
+ ## Getting Started
16
+
17
+ 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).
18
+
19
+ ```bash
20
+ $ npm i @nodesecure/scanner
21
+ # or
22
+ $ yarn add @nodesecure/scanner
23
+ ```
24
+
25
+ ## Usage example
26
+
27
+ ```js
28
+ import * as scanner from "@nodesecure/scanner";
29
+ import fs from "fs/promises";
30
+
31
+ // CONSTANTS
32
+ const kPackagesToAnalyze = ["mocha", "cacache", "is-wsl"];
33
+
34
+ const payloads = await Promise.all(
35
+ kPackagesToAnalyze.map((name) => scanner.from(name))
36
+ );
37
+
38
+ const promises = [];
39
+ for (let i = 0; i < kPackagesToAnalyze.length; i++) {
40
+ const data = JSON.stringify(payloads[i], null, 2);
41
+
42
+ promises.push(fs.writeFile(`${kPackagesToAnalyze[i]}.json`, data));
43
+ }
44
+ await Promise.allSettled(promises);
45
+ ```
46
+
47
+ ## API
48
+
49
+ See `types/api.d.ts` for a complete TypeScript definition.
50
+
51
+ ```ts
52
+ function cwd(path: string, options?: Scanner.Options): Promise<Scanner.Payload>;
53
+ function from(packageName: string, options?: Scanner.Options): Promise<Scanner.Payload>;
54
+ function verify(packageName: string): Promise<Scanner.VerifyPayload>;
55
+ ```
56
+
57
+ `Options` is described with the following TypeScript interface:
58
+
59
+ ```ts
60
+ interface Options {
61
+ readonly maxDepth?: number;
62
+ readonly usePackageLock?: boolean;
63
+ readonly vulnerabilityStrategy: Strategy.Kind;
64
+ readonly forceRootAnalysis?: boolean;
65
+ readonly fullLockMode?: boolean;
66
+ }
67
+ ```
68
+
69
+ ## Contributors ✨
70
+
71
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
72
+ [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
73
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
74
+
75
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
76
+
77
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
78
+ <!-- prettier-ignore-start -->
79
+ <!-- markdownlint-disable -->
80
+ <table>
81
+ <tr>
82
+ <td align="center"><a href="https://www.linkedin.com/in/thomas-gentilhomme/"><img src="https://avatars.githubusercontent.com/u/4438263?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gentilhomme</b></sub></a><br /><a href="https://github.com/NodeSecure/scanner/commits?author=fraxken" title="Code">💻</a> <a href="https://github.com/NodeSecure/scanner/commits?author=fraxken" title="Documentation">📖</a> <a href="https://github.com/NodeSecure/scanner/pulls?q=is%3Apr+reviewed-by%3Afraxken" title="Reviewed Pull Requests">👀</a> <a href="#security-fraxken" title="Security">🛡️</a> <a href="https://github.com/NodeSecure/scanner/issues?q=author%3Afraxken" title="Bug reports">🐛</a></td>
83
+ <td align="center"><a href="http://tonygo.dev"><img src="https://avatars.githubusercontent.com/u/22824417?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tony Gorez</b></sub></a><br /><a href="https://github.com/NodeSecure/scanner/commits?author=tony-go" title="Code">💻</a> <a href="https://github.com/NodeSecure/scanner/commits?author=tony-go" title="Documentation">📖</a> <a href="https://github.com/NodeSecure/scanner/pulls?q=is%3Apr+reviewed-by%3Atony-go" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/NodeSecure/scanner/issues?q=author%3Atony-go" title="Bug reports">🐛</a></td>
84
+ <td align="center"><a href="https://mickaelcroquet.fr"><img src="https://avatars.githubusercontent.com/u/23740372?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Haze</b></sub></a><br /><a href="https://github.com/NodeSecure/scanner/commits?author=CroquetMickael" title="Code">💻</a></td>
85
+ <td align="center"><a href="https://github.com/mbalabash"><img src="https://avatars.githubusercontent.com/u/16868922?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maksim Balabash</b></sub></a><br /><a href="https://github.com/NodeSecure/scanner/commits?author=mbalabash" title="Code">💻</a></td>
86
+ </tr>
87
+ </table>
88
+
89
+ <!-- markdownlint-restore -->
90
+ <!-- prettier-ignore-end -->
91
+
92
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
93
+
94
+ ## License
95
+ MIT
package/index.js CHANGED
@@ -10,8 +10,8 @@ import { getLocalRegistryURL } from "@nodesecure/npm-registry-sdk";
10
10
 
11
11
  // Import Internal Dependencies
12
12
  import { depWalker } from "./src/depWalker.js";
13
- import { constants } from "./src/utils/index.js";
14
- import Logger from "./src/logger.class.js";
13
+ import { NPM_TOKEN } from "./src/utils/index.js";
14
+ import Logger from "./src/class/logger.class.js";
15
15
  import * as tarball from "./src/tarball.js";
16
16
 
17
17
  // CONSTANTS
@@ -31,7 +31,7 @@ export async function cwd(cwd = process.cwd(), options = {}, logger = new Logger
31
31
  export async function from(packageName, options, logger = new Logger()) {
32
32
  logger.start("fetchManifest");
33
33
  const manifest = await pacote.manifest(packageName, {
34
- ...constants.NPM_TOKEN, registry: getLocalRegistryURL(), cache: `${os.homedir()}/.npm`
34
+ ...NPM_TOKEN, registry: getLocalRegistryURL(), cache: `${os.homedir()}/.npm`
35
35
  });
36
36
  logger.end("fetchManifest");
37
37
 
@@ -48,7 +48,7 @@ export async function verify(packageName = null) {
48
48
 
49
49
  try {
50
50
  await pacote.extract(packageName, dest, {
51
- ...constants.NPM_TOKEN, registry: getLocalRegistryURL(), cache: `${os.homedir()}/.npm`
51
+ ...NPM_TOKEN, registry: getLocalRegistryURL(), cache: `${os.homedir()}/.npm`
52
52
  });
53
53
 
54
54
  return await tarball.scanPackage(dest, packageName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodesecure/scanner",
3
- "version": "2.2.0",
3
+ "version": "3.0.0",
4
4
  "description": "A package API to run a static analysis of your module's dependencies.",
5
5
  "exports": "./index.js",
6
6
  "engines": {
@@ -10,7 +10,8 @@
10
10
  "lint": "eslint src test",
11
11
  "prepublishOnly": "pkg-ok",
12
12
  "test": "npm run lint && npm run test-only",
13
- "test-only": "cross-env NODE_OPTIONS=--experimental-vm-modules jest"
13
+ "test-only": "cross-env esm-tape-runner 'test/**/*.spec.js' | tap-monkey",
14
+ "coverage": "c8 -r html npm run test-only"
14
15
  },
15
16
  "files": [
16
17
  "src",
@@ -46,54 +47,36 @@
46
47
  "url": "https://github.com/NodeSecure/scanner/issues"
47
48
  },
48
49
  "homepage": "https://github.com/NodeSecure/scanner#readme",
49
- "jest": {
50
- "setupFilesAfterEnv": [
51
- "./jest.setup.js"
52
- ],
53
- "collectCoverage": true,
54
- "collectCoverageFrom": [
55
- "**/src/**/*.js"
56
- ],
57
- "testEnvironment": "node",
58
- "testMatch": [
59
- "**/test/**/*.js"
60
- ],
61
- "testPathIgnorePatterns": [
62
- "/test/fixtures/"
63
- ],
64
- "moduleNameMapper": {
65
- "^@nodesecure/npm-registry-sdk$": "@nodesecure/npm-registry-sdk/dist/index.js",
66
- "^@nodesecure/sec-literal$": "@nodesecure/sec-literal/src/index.js",
67
- "^estree-walker$": "estree-walker/src/index.js"
68
- }
69
- },
70
50
  "devDependencies": {
71
51
  "@nodesecure/eslint-config": "^1.3.0",
72
52
  "@slimio/is": "^1.5.1",
73
- "@types/jest": "^27.0.2",
74
- "@types/node": "^16.11.7",
53
+ "@small-tech/esm-tape-runner": "^1.0.3",
54
+ "@small-tech/tap-monkey": "^1.3.0",
55
+ "@types/node": "^16.11.10",
56
+ "c8": "^7.10.0",
75
57
  "cross-env": "^7.0.3",
76
58
  "dotenv": "^10.0.0",
77
- "eslint": "^8.2.0",
59
+ "eslint": "^8.3.0",
78
60
  "get-folder-size": "^3.1.0",
79
- "jest": "^27.3.1",
80
- "pkg-ok": "^2.3.1"
61
+ "pkg-ok": "^2.3.1",
62
+ "sinon": "^12.0.1",
63
+ "snap-shot-core": "^10.2.4",
64
+ "tape": "^5.3.2"
81
65
  },
82
66
  "dependencies": {
83
67
  "@nodesecure/flags": "^2.2.0",
84
68
  "@nodesecure/fs-walk": "^1.0.0",
85
- "@nodesecure/i18n": "^1.2.0",
86
- "@nodesecure/js-x-ray": "^4.0.1",
69
+ "@nodesecure/i18n": "^1.2.1",
70
+ "@nodesecure/js-x-ray": "^4.2.0",
87
71
  "@nodesecure/npm-registry-sdk": "^1.3.0",
88
- "@nodesecure/ntlp": "^2.0.0",
72
+ "@nodesecure/ntlp": "^2.1.0",
89
73
  "@nodesecure/utils": "^1.0.0",
90
- "@nodesecure/vuln": "^1.4.0",
74
+ "@nodesecure/vuln": "^1.4.1",
91
75
  "@npm/types": "^1.0.1",
92
- "@npmcli/arborist": "^4.0.4",
76
+ "@npmcli/arborist": "^4.1.0",
93
77
  "@slimio/lock": "^1.0.0",
94
78
  "builtins": "^4.0.0",
95
79
  "combine-async-iterators": "^2.0.1",
96
- "is-minified-code": "^2.0.0",
97
80
  "itertools": "^1.7.1",
98
81
  "lodash.difference": "^4.5.0",
99
82
  "pacote": "^12.0.2",
@@ -56,28 +56,29 @@ export default class Dependency {
56
56
  }
57
57
 
58
58
  return {
59
- [this.version]: {
60
- id: typeof customId === "number" ? customId : Dependency.currentId++,
61
- usedBy: this.parent,
62
- flags: this.flags,
63
- description: "",
64
- size: 0,
65
- author: {},
66
- warnings: this.warnings,
67
- composition: {
68
- extensions: [],
69
- files: [],
70
- minified: [],
71
- unused: [],
72
- missing: [],
73
- required_files: [],
74
- required_nodejs: [],
75
- required_thirdparty: []
76
- },
77
- license: "unkown license",
78
- gitUrl: this.gitUrl
59
+ versions: {
60
+ [this.version]: {
61
+ id: typeof customId === "number" ? customId : Dependency.currentId++,
62
+ usedBy: this.parent,
63
+ flags: this.flags,
64
+ description: "",
65
+ size: 0,
66
+ author: {},
67
+ warnings: this.warnings,
68
+ composition: {
69
+ extensions: [],
70
+ files: [],
71
+ minified: [],
72
+ unused: [],
73
+ missing: [],
74
+ required_files: [],
75
+ required_nodejs: [],
76
+ required_thirdparty: []
77
+ },
78
+ license: "unkown license",
79
+ gitUrl: this.gitUrl
80
+ }
79
81
  },
80
- versions: [this.version],
81
82
  vulnerabilities: [],
82
83
  metadata: {
83
84
  dependencyCount: this.dependencyCount,
File without changes