@mnci/cli 4.40.8 → 4.40.9
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/dist/cli.js +18 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -299,27 +299,35 @@ function planIsEmpty(stdout) {
|
|
|
299
299
|
return false;
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
|
-
function auditNpm(result, dryRun, log) {
|
|
302
|
+
function auditNpm(result, production, dryRun, log) {
|
|
303
303
|
let report;
|
|
304
|
+
let shipped;
|
|
304
305
|
try {
|
|
305
306
|
report = JSON.parse(result.stdout);
|
|
307
|
+
shipped = JSON.parse(production.stdout);
|
|
306
308
|
} catch {
|
|
307
309
|
log(`npm audit produced no JSON (exit ${result.status}) - not blocking on a broken audit.`);
|
|
308
310
|
return 0;
|
|
309
311
|
}
|
|
310
|
-
const {
|
|
312
|
+
const { notes } = classifyNpmAudit(report);
|
|
313
|
+
const { blocking, total } = classifyNpmAudit(shipped);
|
|
314
|
+
const productionNames = new Set(Object.keys(shipped.vulnerabilities ?? {}));
|
|
315
|
+
const developmentOnly = classifyNpmAudit(report).blocking.filter((advisory) => !productionNames.has(advisory.name));
|
|
311
316
|
for (const note of notes) {
|
|
312
317
|
log(note);
|
|
313
318
|
}
|
|
319
|
+
for (const advisory of developmentOnly) {
|
|
320
|
+
log(` note [${advisory.severity}] ${advisory.name} - reaches only dev dependencies, which no consumer receives, so it does not block`);
|
|
321
|
+
}
|
|
314
322
|
if (blocking.length === 0) {
|
|
315
|
-
log(`npm audit - ${
|
|
323
|
+
log(`npm audit - ${Object.keys(report.vulnerabilities ?? {}).length} advisory(ies), none actionable at moderate or above in production dependencies.`);
|
|
316
324
|
return 0;
|
|
317
325
|
}
|
|
318
326
|
if (planIsEmpty(dryRun().stdout)) {
|
|
319
327
|
for (const advisory of blocking) {
|
|
320
328
|
log(` note [${advisory.severity}] ${advisory.name} - npm reports a fix, but npm audit fix has nothing to apply`);
|
|
321
329
|
}
|
|
322
|
-
log(`npm audit - ${total} advisory(ies); ${blocking.length} reported as fixable, but no patched release is reachable, so there is nothing to do here.`);
|
|
330
|
+
log(`npm audit - ${total} production advisory(ies); ${blocking.length} reported as fixable, but no patched release is reachable, so there is nothing to do here.`);
|
|
323
331
|
return 0;
|
|
324
332
|
}
|
|
325
333
|
for (const advisory of blocking) {
|
|
@@ -348,7 +356,12 @@ function runAudit(workspaceRoot, dependencies = {}) {
|
|
|
348
356
|
}
|
|
349
357
|
};
|
|
350
358
|
log(groupStart(host, "npm audit"));
|
|
351
|
-
const npm = auditNpm(
|
|
359
|
+
const npm = auditNpm(
|
|
360
|
+
processes.capture("npm", ["audit", "--json"]),
|
|
361
|
+
processes.capture("npm", ["audit", "--omit=dev", "--json"]),
|
|
362
|
+
() => processes.capture("npm", ["audit", "fix", "--omit=dev", "--dry-run", "--json"]),
|
|
363
|
+
log
|
|
364
|
+
);
|
|
352
365
|
closeGroup();
|
|
353
366
|
if (npm !== 0) {
|
|
354
367
|
return npm;
|