nexarch 0.6.5 → 0.6.6
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.
|
@@ -62,17 +62,24 @@ function parseFindingToken(token) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
function parseFindings(args) {
|
|
65
|
-
const
|
|
65
|
+
const findingsFile = parseOptionValue(args, "--findings-file");
|
|
66
|
+
let findingsJson = parseOptionValue(args, "--findings-json");
|
|
67
|
+
if (findingsFile) {
|
|
68
|
+
if (!existsSync(findingsFile)) {
|
|
69
|
+
throw new Error(`--findings-file not found: ${findingsFile}`);
|
|
70
|
+
}
|
|
71
|
+
findingsJson = readFileSync(findingsFile, "utf8");
|
|
72
|
+
}
|
|
66
73
|
if (findingsJson) {
|
|
67
74
|
let parsed;
|
|
68
75
|
try {
|
|
69
76
|
parsed = JSON.parse(findingsJson);
|
|
70
77
|
}
|
|
71
78
|
catch {
|
|
72
|
-
throw new Error("--findings-json must be valid JSON array");
|
|
79
|
+
throw new Error(findingsFile ? "--findings-file must contain valid JSON array" : "--findings-json must be valid JSON array");
|
|
73
80
|
}
|
|
74
81
|
if (!Array.isArray(parsed) || parsed.length === 0) {
|
|
75
|
-
throw new Error("--findings-json must be a non-empty JSON array");
|
|
82
|
+
throw new Error(findingsFile ? "--findings-file must contain a non-empty JSON array" : "--findings-json must be a non-empty JSON array");
|
|
76
83
|
}
|
|
77
84
|
return parsed.map((item) => {
|
|
78
85
|
const value = item;
|
|
@@ -94,7 +101,7 @@ function parseFindings(args) {
|
|
|
94
101
|
}
|
|
95
102
|
const tokens = parseMultiOptionValues(args, "--finding");
|
|
96
103
|
if (tokens.length === 0) {
|
|
97
|
-
throw new Error("Provide findings via --finding (repeatable)
|
|
104
|
+
throw new Error("Provide findings via --finding (repeatable), --findings-json '<json-array>', or --findings-file <path.json>");
|
|
98
105
|
}
|
|
99
106
|
return tokens.map(parseFindingToken);
|
|
100
107
|
}
|
package/dist/index.js
CHANGED
|
@@ -149,6 +149,7 @@ Usage:
|
|
|
149
149
|
--agent-key <key> (optional; defaults from identity)
|
|
150
150
|
--finding <controlId|ruleId|result|rationale|missing1;missing2> (repeatable)
|
|
151
151
|
--findings-json <json-array>
|
|
152
|
+
--findings-file <path.json>
|
|
152
153
|
--json
|
|
153
154
|
`);
|
|
154
155
|
process.exit(command ? 1 : 0);
|