Skip to content

Commit dacf8ad

Browse files
authored
chore(cli/scanner): implement new workers options (#714)
* chore(cli/scanner): implement new workers options * fix(cli/verify): properly handle SourceArrayLocation
2 parents 4dfc79c + b25135f commit dacf8ad

6 files changed

Lines changed: 37 additions & 15 deletions

File tree

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"build:front": "node ./esbuild.config.ts",
2222
"build:workspaces": "npm run build --ws --if-present",
2323
"test": "npm run test:cli && npm run lint && npm run lint:css",
24-
"test:cli": "node --no-warnings --test test/**/*.test.js",
24+
"test:cli": "node --no-warnings --test \"test/**/*.test.js\"",
2525
"test:all": "npm run test --ws --if-present",
2626
"coverage": "c8 --reporter=lcov npm run test",
2727
"ci:publish": "changeset publish",
@@ -92,6 +92,7 @@
9292
"stylelint": "17.5.0",
9393
"stylelint-config-standard": "40.0.0",
9494
"typescript": "^5.8.3",
95+
"undici": "7.24.6",
9596
"vite": "8.0.2"
9697
},
9798
"dependencies": {
@@ -107,7 +108,7 @@
107108
"@nodesecure/ossf-scorecard-sdk": "4.0.1",
108109
"@nodesecure/rc": "5.5.0",
109110
"@nodesecure/report": "4.2.2",
110-
"@nodesecure/scanner": "10.7.0",
111+
"@nodesecure/scanner": "10.8.0",
111112
"@nodesecure/server": "1.0.0",
112113
"@nodesecure/utils": "^2.2.0",
113114
"@nodesecure/vulnera": "3.1.0",

src/commands/scanner.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import * as scanner from "@nodesecure/scanner";
1313
// Import Internal Dependencies
1414
import kleur from "../utils/styleText.js";
1515
import * as http from "./http.js";
16-
import { logScannerStat, logScannerError, formatMs } from "./loggers/logger.js";
16+
import {
17+
logScannerStat,
18+
logScannerError,
19+
formatMs
20+
} from "./loggers/logger.js";
1721
import { parseContacts } from "./parsers/contacts.js";
1822

1923
export async function auto(spec, options) {
@@ -73,8 +77,15 @@ export async function cwd(options) {
7377
const payload = await scanner.workingDir(
7478
process.cwd(),
7579
{
76-
maxDepth, usePackageLock: !nolock, fullLockMode: full, vulnerabilityStrategy, highlight:
77-
{ contacts: parseContacts(contacts) }, isVerbose: verbose
80+
maxDepth,
81+
usePackageLock: !nolock,
82+
fullLockMode: full,
83+
vulnerabilityStrategy,
84+
highlight: {
85+
contacts: parseContacts(contacts)
86+
},
87+
isVerbose: verbose,
88+
workers: true
7889
},
7990
initLogger(void 0, !silent)
8091
);
@@ -83,7 +94,14 @@ export async function cwd(options) {
8394
}
8495

8596
export async function from(spec, options) {
86-
const { depth: maxDepth = Infinity, output, silent, contacts, vulnerabilityStrategy, verbose } = options;
97+
const {
98+
depth: maxDepth = Infinity,
99+
output,
100+
silent,
101+
contacts,
102+
vulnerabilityStrategy,
103+
verbose
104+
} = options;
87105

88106
const payload = await scanner.from(
89107
spec,
@@ -93,7 +111,8 @@ export async function from(spec, options) {
93111
highlight: {
94112
contacts: parseContacts(contacts)
95113
},
96-
isVerbose: verbose
114+
isVerbose: verbose,
115+
workers: true
97116
},
98117
initLogger(spec, !silent)
99118
);
@@ -258,7 +277,9 @@ async function logAndWrite(
258277
fs.writeFileSync(filePath, ret);
259278

260279
console.log("");
261-
console.log(kleur.white().bold(i18n.getTokenSync("cli.successfully_written_json", kleur.green().bold(filePath))));
280+
console.log(
281+
kleur.white().bold(i18n.getTokenSync("cli.successfully_written_json", kleur.green().bold(filePath)))
282+
);
262283
console.log("");
263284

264285
return filePath;

src/commands/verify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ export async function main(
7575
{ text: white().bold("source location"), width: 30, align: "right" }
7676
);
7777
for (const [depName, infos] of Object.entries(deps)) {
78-
const { start, end } = infos.location;
79-
const position = `[${start.line}:${start.column}] - [${end.line}:${end.column}]`;
78+
const [start, end] = infos.location;
79+
const position = `[${start[0]}:${start[1]}] - [${end[0]}:${end[1]}]`;
8080

8181
ui.div(
8282
{ text: depName, width: 30 },

workspaces/cache/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build": "tsc",
1313
"prepublishOnly": "npm run build",
1414
"lint": "eslint src test",
15-
"test": "node --test test/**.test.ts",
15+
"test": "node --test \"test/**.test.ts\"",
1616
"test:c8": "c8 npm run test"
1717
},
1818
"publishConfig": {
@@ -28,7 +28,7 @@
2828
"author": "GENTILHOMME Thomas <gentilhomme.thomas@gmail.com>",
2929
"license": "MIT",
3030
"dependencies": {
31-
"@nodesecure/scanner": "10.7.0",
31+
"@nodesecure/scanner": "10.8.0",
3232
"cacache": "20.0.4"
3333
},
3434
"devDependencies": {

workspaces/server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build": "tsc",
1313
"prepublishOnly": "npm run build",
1414
"lint": "eslint src test",
15-
"test": "node --test ./test/**/*.test.ts",
15+
"test": "node --test \"./test/**/*.test.ts\"",
1616
"test:c8": "c8 npm run test"
1717
},
1818
"publishConfig": {
@@ -37,7 +37,7 @@
3737
"@nodesecure/i18n": "4.1.0",
3838
"@nodesecure/npm-registry-sdk": "4.5.2",
3939
"@nodesecure/ossf-scorecard-sdk": "4.0.1",
40-
"@nodesecure/scanner": "10.7.0",
40+
"@nodesecure/scanner": "10.8.0",
4141
"cacache": "20.0.4",
4242
"chokidar": "5.0.0",
4343
"find-my-way": "9.5.0",

workspaces/vis-network/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"prepublishOnly": "npm run build",
1313
"lint": "eslint src test",
1414
"lint:fix": "eslint --fix src test",
15-
"test-only": "node --test test/*.test.ts",
15+
"test-only": "node --test \"test/*.test.ts\"",
1616
"test": "c8 npm run test",
1717
"example": "vite"
1818
},

0 commit comments

Comments
 (0)