@knime/utils 1.12.1 → 2.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/CHANGELOG.md +10 -0
- package/README.md +0 -9
- package/dist/index.js +947 -745
- package/dist/index.js.map +1 -1
- package/dist/test-utils/index.js +41 -38
- package/dist/test-utils/index.js.map +1 -1
- package/package.json +7 -15
- package/audit/README.md +0 -118
- package/audit/bulkAudit.js +0 -671
- package/audit/cli.js +0 -117
package/audit/cli.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable no-console, n/no-process-exit */
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* CLI wrapper for the bulk advisory audit.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* pnpm-bulk-audit [--lockfile path] [--registry url] [--severity level] [--json]
|
|
9
|
-
*
|
|
10
|
-
* Defaults:
|
|
11
|
-
* --lockfile pnpm-lock.yaml (in cwd)
|
|
12
|
-
* --registry https://registry.npmjs.org
|
|
13
|
-
* --severity low
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { existsSync } from "node:fs";
|
|
17
|
-
import { dirname, resolve } from "node:path";
|
|
18
|
-
|
|
19
|
-
import { audit, formatAuditReport, readAuditConfig } from "./bulkAudit.js";
|
|
20
|
-
|
|
21
|
-
function parseArgs(args) {
|
|
22
|
-
let lockfilePath = resolve("pnpm-lock.yaml");
|
|
23
|
-
let registry = "https://registry.npmjs.org";
|
|
24
|
-
let minSeverity = "low";
|
|
25
|
-
let json = false;
|
|
26
|
-
let noIgnore = false;
|
|
27
|
-
let prod = false;
|
|
28
|
-
|
|
29
|
-
for (let i = 0; i < args.length; i++) {
|
|
30
|
-
const arg = args[i];
|
|
31
|
-
if (arg === "--lockfile" && args[i + 1]) {
|
|
32
|
-
lockfilePath = resolve(args[++i]);
|
|
33
|
-
} else if (arg === "--registry" && args[i + 1]) {
|
|
34
|
-
registry = args[++i];
|
|
35
|
-
} else if (arg === "--severity" && args[i + 1]) {
|
|
36
|
-
minSeverity = args[++i];
|
|
37
|
-
const validSeverities = ["low", "moderate", "high", "critical"];
|
|
38
|
-
if (!validSeverities.includes(minSeverity)) {
|
|
39
|
-
console.error(
|
|
40
|
-
`Error: unknown severity "${minSeverity}". Must be one of: ${validSeverities.join(", ")}`,
|
|
41
|
-
);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
} else if (arg === "--json") {
|
|
45
|
-
json = true;
|
|
46
|
-
} else if (arg === "--no-ignore") {
|
|
47
|
-
noIgnore = true;
|
|
48
|
-
} else if (arg === "--prod" || arg === "-P") {
|
|
49
|
-
prod = true;
|
|
50
|
-
} else if (arg === "--help" || arg === "-h") {
|
|
51
|
-
console.log(`Usage: pnpm-bulk-audit [options]
|
|
52
|
-
|
|
53
|
-
Options:
|
|
54
|
-
--lockfile <path> Path to pnpm-lock.yaml (default: ./pnpm-lock.yaml)
|
|
55
|
-
--registry <url> npm registry URL (default: https://registry.npmjs.org)
|
|
56
|
-
--severity <level> Minimum severity: low, moderate, high, critical (default: low)
|
|
57
|
-
--prod, -P Only report vulnerabilities in production dependencies
|
|
58
|
-
--json Output raw JSON
|
|
59
|
-
--no-ignore Skip reading ignoreCves/ignoreGhsas from config
|
|
60
|
-
--help, -h Show this help`);
|
|
61
|
-
process.exit(0);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return { lockfilePath, registry, minSeverity, json, noIgnore, prod };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function main() {
|
|
69
|
-
const opts = parseArgs(process.argv.slice(2));
|
|
70
|
-
|
|
71
|
-
if (!existsSync(opts.lockfilePath)) {
|
|
72
|
-
console.error(`Error: lockfile not found at ${opts.lockfilePath}`);
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
const workspaceDir = dirname(opts.lockfilePath);
|
|
78
|
-
const auditConfig = opts.noIgnore
|
|
79
|
-
? undefined
|
|
80
|
-
: readAuditConfig(workspaceDir);
|
|
81
|
-
|
|
82
|
-
if (auditConfig && !opts.json) {
|
|
83
|
-
const ignoredCount =
|
|
84
|
-
(auditConfig.ignoreCves?.length ?? 0) +
|
|
85
|
-
(auditConfig.ignoreGhsas?.length ?? 0);
|
|
86
|
-
if (ignoredCount > 0) {
|
|
87
|
-
console.log(
|
|
88
|
-
`Ignoring ${ignoredCount} CVE/GHSA entr${ignoredCount === 1 ? "y" : "ies"} from config.\n`,
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const result = await audit({
|
|
94
|
-
lockfilePath: opts.lockfilePath,
|
|
95
|
-
registry: opts.registry,
|
|
96
|
-
minSeverity: opts.minSeverity,
|
|
97
|
-
auditConfig,
|
|
98
|
-
prod: opts.prod,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
if (opts.json) {
|
|
102
|
-
console.log(JSON.stringify(result, null, 2));
|
|
103
|
-
} else {
|
|
104
|
-
console.log(formatAuditReport(result));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
process.exit(result.totalVulnerabilities > 0 ? 1 : 0);
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error(
|
|
110
|
-
`Audit failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
111
|
-
);
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// eslint-disable-next-line no-void
|
|
117
|
-
void main();
|