@agenticcli/shipguard 0.2.0 → 0.2.1
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/{chunk-YE2GPROS.js → chunk-2N3P2DUE.js} +83 -16
- package/dist/{chunk-7HMLDAMC.js → chunk-BZWSFLBO.js} +15 -2
- package/dist/cli.js +95 -30
- package/dist/{config-generator-YSWNA53I.js → config-generator-Q2YTMBZ5.js} +1 -1
- package/dist/{pro-scanner-IJJLUSAC.js → pro-scanner-ER2RYPI5.js} +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
// src/core/auth.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
readFileSync,
|
|
4
|
+
writeFileSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
rmSync,
|
|
7
|
+
existsSync,
|
|
8
|
+
statSync,
|
|
9
|
+
chmodSync
|
|
10
|
+
} from "fs";
|
|
3
11
|
import { join, dirname } from "path";
|
|
4
12
|
import { homedir } from "os";
|
|
13
|
+
var DIR_MODE = 448;
|
|
14
|
+
var FILE_MODE = 384;
|
|
15
|
+
var UNSAFE_PERM_MASK = 63;
|
|
16
|
+
var isPosix = process.platform !== "win32";
|
|
5
17
|
function getCredentialsPath() {
|
|
6
18
|
return join(homedir(), ".config", "shipguard", "credentials.json");
|
|
7
19
|
}
|
|
20
|
+
function hasUnsafePermissions(path) {
|
|
21
|
+
if (!isPosix) return false;
|
|
22
|
+
const mode = statSync(path).mode & 511;
|
|
23
|
+
return (mode & UNSAFE_PERM_MASK) !== 0;
|
|
24
|
+
}
|
|
8
25
|
function loadCredentials() {
|
|
9
26
|
const p = getCredentialsPath();
|
|
10
27
|
if (!existsSync(p)) return null;
|
|
28
|
+
if (hasUnsafePermissions(p)) {
|
|
29
|
+
console.warn(
|
|
30
|
+
"[shipguard] credentials file has unsafe permissions (group/other-readable or writable) \u2014 refusing to use it. Run `shipguard login` again to re-create it with 0600 perms."
|
|
31
|
+
);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
11
34
|
try {
|
|
12
35
|
return JSON.parse(readFileSync(p, "utf-8"));
|
|
13
36
|
} catch {
|
|
@@ -17,12 +40,21 @@ function loadCredentials() {
|
|
|
17
40
|
}
|
|
18
41
|
async function saveCredentials(creds) {
|
|
19
42
|
const p = getCredentialsPath();
|
|
20
|
-
|
|
21
|
-
|
|
43
|
+
const dir = dirname(p);
|
|
44
|
+
mkdirSync(dir, { recursive: true, mode: DIR_MODE });
|
|
45
|
+
if (isPosix) chmodSync(dir, DIR_MODE);
|
|
46
|
+
writeFileSync(p, JSON.stringify(creds, null, 2), { mode: FILE_MODE });
|
|
47
|
+
if (isPosix) chmodSync(p, FILE_MODE);
|
|
22
48
|
}
|
|
23
49
|
function clearCredentials() {
|
|
24
50
|
const p = getCredentialsPath();
|
|
25
|
-
if (existsSync(p))
|
|
51
|
+
if (!existsSync(p)) return;
|
|
52
|
+
try {
|
|
53
|
+
const size = statSync(p).size;
|
|
54
|
+
if (size > 0) writeFileSync(p, Buffer.alloc(size, 0), { mode: FILE_MODE });
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
rmSync(p, { force: true });
|
|
26
58
|
}
|
|
27
59
|
function isTokenExpired(creds) {
|
|
28
60
|
return creds.expiresAt < Date.now();
|
|
@@ -61,6 +93,9 @@ import { sha256 } from "@noble/hashes/sha2.js";
|
|
|
61
93
|
var PINNED_KEYS = {
|
|
62
94
|
"k1-2026": `-----BEGIN PUBLIC KEY-----
|
|
63
95
|
MCowBQYDK2VwAyEAkpeX0A3zIOttGn8t+jagJHLRTv5Q809vqIZU37lE6xQ=
|
|
96
|
+
-----END PUBLIC KEY-----`,
|
|
97
|
+
"k2-2026": `-----BEGIN PUBLIC KEY-----
|
|
98
|
+
MCowBQYDK2VwAyEA1DXW6sA9dllAbfXMa/G+50Sw00svQF2X5bcU+YcP6M8=
|
|
64
99
|
-----END PUBLIC KEY-----`
|
|
65
100
|
};
|
|
66
101
|
var DEFAULT_KID = "k1-2026";
|
|
@@ -1356,6 +1391,49 @@ try {
|
|
|
1356
1391
|
CLI_VERSION = "0.0.0";
|
|
1357
1392
|
}
|
|
1358
1393
|
|
|
1394
|
+
// src/core/suppression.ts
|
|
1395
|
+
var SUPPRESS_RE = /\/\/\s*shipguard-ignore:\s*([\w.-]+)\s*--\s*(.+)/;
|
|
1396
|
+
function isLineSuppressed(lines, lineIndex, ruleId) {
|
|
1397
|
+
const sameLine = lines[lineIndex];
|
|
1398
|
+
if (sameLine !== void 0) {
|
|
1399
|
+
const sameMatch = SUPPRESS_RE.exec(sameLine);
|
|
1400
|
+
if (sameMatch && sameMatch[1] === ruleId) return true;
|
|
1401
|
+
}
|
|
1402
|
+
if (lineIndex > 0) {
|
|
1403
|
+
const aboveLine = lines[lineIndex - 1];
|
|
1404
|
+
if (aboveLine !== void 0) {
|
|
1405
|
+
const aboveMatch = SUPPRESS_RE.exec(aboveLine);
|
|
1406
|
+
if (aboveMatch && aboveMatch[1] === ruleId) return true;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
return false;
|
|
1410
|
+
}
|
|
1411
|
+
function applySuppressions(findings, files) {
|
|
1412
|
+
if (findings.length === 0) return findings;
|
|
1413
|
+
const linesByPath = /* @__PURE__ */ new Map();
|
|
1414
|
+
const linesFor = (relativePath) => {
|
|
1415
|
+
if (linesByPath.has(relativePath)) return linesByPath.get(relativePath);
|
|
1416
|
+
const file = files.find((f) => f.relativePath === relativePath);
|
|
1417
|
+
if (!file) {
|
|
1418
|
+
linesByPath.set(relativePath, []);
|
|
1419
|
+
return void 0;
|
|
1420
|
+
}
|
|
1421
|
+
const split = file.content.split("\n");
|
|
1422
|
+
linesByPath.set(relativePath, split);
|
|
1423
|
+
return split;
|
|
1424
|
+
};
|
|
1425
|
+
for (const finding of findings) {
|
|
1426
|
+
if (finding.line === void 0) continue;
|
|
1427
|
+
const lines = linesFor(finding.file);
|
|
1428
|
+
if (!lines || lines.length === 0) continue;
|
|
1429
|
+
if (isLineSuppressed(lines, finding.line - 1, finding.id)) {
|
|
1430
|
+
finding.suppressed = true;
|
|
1431
|
+
finding.blocking = false;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
return findings;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1359
1437
|
// src/core/pro-scanner.ts
|
|
1360
1438
|
async function fetchProRules(frameworks, categories, apiUrl) {
|
|
1361
1439
|
const token = await getAuthToken();
|
|
@@ -1411,18 +1489,6 @@ function compileRules(rules) {
|
|
|
1411
1489
|
}
|
|
1412
1490
|
return compiled;
|
|
1413
1491
|
}
|
|
1414
|
-
var SUPPRESS_RE = /\/\/\s*shipguard-ignore:\s*([\w.-]+)\s*--\s*(.+)/;
|
|
1415
|
-
function isLineSuppressed(lines, lineIndex, ruleId) {
|
|
1416
|
-
const sameLine = lines[lineIndex];
|
|
1417
|
-
const sameMatch = SUPPRESS_RE.exec(sameLine);
|
|
1418
|
-
if (sameMatch && sameMatch[1] === ruleId) return true;
|
|
1419
|
-
if (lineIndex > 0) {
|
|
1420
|
-
const aboveLine = lines[lineIndex - 1];
|
|
1421
|
-
const aboveMatch = SUPPRESS_RE.exec(aboveLine);
|
|
1422
|
-
if (aboveMatch && aboveMatch[1] === ruleId) return true;
|
|
1423
|
-
}
|
|
1424
|
-
return false;
|
|
1425
|
-
}
|
|
1426
1492
|
function deriveBlocking(rule) {
|
|
1427
1493
|
if (rule.action === "block") return true;
|
|
1428
1494
|
if (rule.action === "warn" || rule.action === "monitor") return false;
|
|
@@ -1501,6 +1567,7 @@ export {
|
|
|
1501
1567
|
clearCredentials,
|
|
1502
1568
|
isTokenExpired,
|
|
1503
1569
|
getAuthToken,
|
|
1570
|
+
applySuppressions,
|
|
1504
1571
|
fetchProRules,
|
|
1505
1572
|
runProRules,
|
|
1506
1573
|
runProRulesWithDispatch
|
|
@@ -46,6 +46,7 @@ var DEFAULT_IGNORE = [
|
|
|
46
46
|
// ShipGuard's own report output — never scan the tool's own artifacts
|
|
47
47
|
".shipguard/**"
|
|
48
48
|
];
|
|
49
|
+
var MAX_SKIPPED_NAMES = 50;
|
|
49
50
|
async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], options = {}) {
|
|
50
51
|
const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
|
|
51
52
|
const maxTotalBytes = options.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;
|
|
@@ -57,11 +58,20 @@ async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], opti
|
|
|
57
58
|
ignore: allIgnore,
|
|
58
59
|
dot: true,
|
|
59
60
|
absolute: false,
|
|
60
|
-
onlyFiles: true
|
|
61
|
+
onlyFiles: true,
|
|
62
|
+
// Privacy moat (incident 3063d8a9): NEVER follow symlinks. A symlink inside
|
|
63
|
+
// the project pointing out of the root (e.g. `ln -s /home escape`) would
|
|
64
|
+
// otherwise cause the scan to descend out-of-tree, reading and reporting
|
|
65
|
+
// files the user never intended to scan (and risking a hang on huge external
|
|
66
|
+
// trees). The user's code must never leave their machine; out-of-tree files
|
|
67
|
+
// must never enter the scan. fast-glob defaults this to true, so it is
|
|
68
|
+
// load-bearing that we set it false explicitly.
|
|
69
|
+
followSymbolicLinks: false
|
|
61
70
|
});
|
|
62
71
|
const total = filePaths.length;
|
|
63
72
|
const files = [];
|
|
64
73
|
let skippedTooLarge = 0;
|
|
74
|
+
const skippedTooLargeFiles = [];
|
|
65
75
|
let skippedBinary = 0;
|
|
66
76
|
let truncated = false;
|
|
67
77
|
let totalBytes = 0;
|
|
@@ -76,6 +86,9 @@ async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], opti
|
|
|
76
86
|
const fileStat = await stat(fullPath);
|
|
77
87
|
if (fileStat.size > maxFileSizeBytes) {
|
|
78
88
|
skippedTooLarge++;
|
|
89
|
+
if (skippedTooLargeFiles.length < MAX_SKIPPED_NAMES) {
|
|
90
|
+
skippedTooLargeFiles.push(fp);
|
|
91
|
+
}
|
|
79
92
|
onProgress?.(++processed, total, fp);
|
|
80
93
|
continue;
|
|
81
94
|
}
|
|
@@ -104,7 +117,7 @@ async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], opti
|
|
|
104
117
|
}
|
|
105
118
|
onProgress?.(++processed, total, fp);
|
|
106
119
|
}
|
|
107
|
-
return { files, skippedTooLarge, skippedBinary, truncated };
|
|
120
|
+
return { files, skippedTooLarge, skippedTooLargeFiles, skippedBinary, truncated };
|
|
108
121
|
}
|
|
109
122
|
|
|
110
123
|
export {
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
applySuppressions,
|
|
3
4
|
authCheck,
|
|
4
5
|
clearCredentials,
|
|
5
6
|
databaseCheck,
|
|
@@ -11,13 +12,13 @@ import {
|
|
|
11
12
|
runProRulesWithDispatch,
|
|
12
13
|
saveCredentials,
|
|
13
14
|
secretsCheck
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-2N3P2DUE.js";
|
|
15
16
|
import {
|
|
16
17
|
DEFAULT_MAX_FILES,
|
|
17
18
|
DEFAULT_MAX_FILE_SIZE_BYTES,
|
|
18
19
|
DEFAULT_MAX_TOTAL_BYTES,
|
|
19
20
|
readFiles
|
|
20
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-BZWSFLBO.js";
|
|
21
22
|
|
|
22
23
|
// src/cli.ts
|
|
23
24
|
import { Command as Command7, CommanderError } from "commander";
|
|
@@ -138,9 +139,9 @@ async function createShipguardDir(dir) {
|
|
|
138
139
|
// src/utils/logger.ts
|
|
139
140
|
import chalk from "chalk";
|
|
140
141
|
var logger = {
|
|
141
|
-
info: (msg) => console.
|
|
142
|
-
success: (msg) => console.
|
|
143
|
-
warn: (msg) => console.
|
|
142
|
+
info: (msg) => console.error(chalk.blue("\u2139"), msg),
|
|
143
|
+
success: (msg) => console.error(chalk.green("\u2713"), msg),
|
|
144
|
+
warn: (msg) => console.error(chalk.yellow("\u26A0"), msg),
|
|
144
145
|
error: (msg) => console.error(chalk.red("\u2717"), msg),
|
|
145
146
|
finding: (severity, msg) => {
|
|
146
147
|
const colors = {
|
|
@@ -152,17 +153,17 @@ var logger = {
|
|
|
152
153
|
};
|
|
153
154
|
const colorFn = colors[severity] || chalk.white;
|
|
154
155
|
const label = severity.toUpperCase().padEnd(8);
|
|
155
|
-
console.
|
|
156
|
+
console.error(` ${colorFn(label)} ${msg}`);
|
|
156
157
|
},
|
|
157
158
|
score: (score, recommendation) => {
|
|
158
159
|
const color = score <= 20 ? chalk.green : score <= 50 ? chalk.yellow : chalk.red;
|
|
159
160
|
const icon = score <= 20 ? "\u2713" : score <= 50 ? "\u26A0" : "\u2717";
|
|
160
|
-
console.
|
|
161
|
-
console.
|
|
162
|
-
console.
|
|
163
|
-
console.
|
|
161
|
+
console.error("");
|
|
162
|
+
console.error(chalk.bold("ShipGuard Scan Result"));
|
|
163
|
+
console.error(`Risk Score: ${color(`${score}/100`)}`);
|
|
164
|
+
console.error(`Status: ${color(`${icon} ${recommendation.replace(/_/g, " ")}`)}`);
|
|
164
165
|
},
|
|
165
|
-
divider: () => console.
|
|
166
|
+
divider: () => console.error(chalk.gray("\u2500".repeat(50)))
|
|
166
167
|
};
|
|
167
168
|
|
|
168
169
|
// src/commands/init.ts
|
|
@@ -309,6 +310,7 @@ async function scan(options, proRules, onProgress) {
|
|
|
309
310
|
};
|
|
310
311
|
let files;
|
|
311
312
|
let skippedTooLarge = 0;
|
|
313
|
+
const skippedTooLargeFiles = [];
|
|
312
314
|
let skippedBinary = 0;
|
|
313
315
|
let truncated = false;
|
|
314
316
|
if (options.changedOnly && isGitRepo(cwd)) {
|
|
@@ -333,6 +335,9 @@ async function scan(options, proRules, onProgress) {
|
|
|
333
335
|
const fileStat = await stat(fullPath);
|
|
334
336
|
if (fileStat.size > limits.maxFileSizeBytes) {
|
|
335
337
|
skippedTooLarge++;
|
|
338
|
+
if (skippedTooLargeFiles.length < 50) {
|
|
339
|
+
skippedTooLargeFiles.push(relPath);
|
|
340
|
+
}
|
|
336
341
|
onProgress?.(++changedProcessed, changedTotal, relPath);
|
|
337
342
|
continue;
|
|
338
343
|
}
|
|
@@ -369,10 +374,14 @@ async function scan(options, proRules, onProgress) {
|
|
|
369
374
|
});
|
|
370
375
|
files = readResult.files;
|
|
371
376
|
skippedTooLarge = readResult.skippedTooLarge;
|
|
377
|
+
skippedTooLargeFiles.push(...readResult.skippedTooLargeFiles);
|
|
372
378
|
skippedBinary = readResult.skippedBinary;
|
|
373
379
|
truncated = readResult.truncated;
|
|
374
380
|
}
|
|
375
|
-
let allFindings =
|
|
381
|
+
let allFindings = applySuppressions(
|
|
382
|
+
CHECK_MODULES.flatMap((mod) => mod.run(files, policy)),
|
|
383
|
+
files
|
|
384
|
+
);
|
|
376
385
|
let coderefDegraded = false;
|
|
377
386
|
if (proRules?.length) {
|
|
378
387
|
const { findings: proFindings, degraded, warnings } = runProRulesWithDispatch(proRules, files, policy);
|
|
@@ -383,17 +392,47 @@ async function scan(options, proRules, onProgress) {
|
|
|
383
392
|
}
|
|
384
393
|
}
|
|
385
394
|
const riskScore = computeRiskScore(allFindings);
|
|
395
|
+
const degradedReasons = [];
|
|
396
|
+
if (skippedTooLarge > 0) {
|
|
397
|
+
const named = skippedTooLargeFiles.slice(0, 10).join(", ");
|
|
398
|
+
const extra = skippedTooLarge > skippedTooLargeFiles.length || skippedTooLargeFiles.length > 10 ? ` (and others)` : "";
|
|
399
|
+
degradedReasons.push({
|
|
400
|
+
code: "FILE_TOO_LARGE",
|
|
401
|
+
detail: `${skippedTooLarge} file(s) exceeded the per-file size cap and were not scanned: ${named}${extra}`
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
if (truncated) {
|
|
405
|
+
degradedReasons.push({
|
|
406
|
+
code: "OUTPUT_TRUNCATED",
|
|
407
|
+
detail: "File count or total size ceiling was reached; collection stopped early \u2014 results are incomplete."
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
if (coderefDegraded) {
|
|
411
|
+
degradedReasons.push({
|
|
412
|
+
code: "CODEREF_SKIPPED",
|
|
413
|
+
detail: "One or more pro coderef rules were skipped because they require a newer CLI version."
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
const isDegraded = degradedReasons.length > 0 || void 0;
|
|
386
417
|
const result = {
|
|
387
418
|
findings: allFindings,
|
|
388
419
|
riskScore,
|
|
389
420
|
filesScanned: files.length,
|
|
390
421
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
391
422
|
policyUsed: policy.project.name,
|
|
392
|
-
//
|
|
393
|
-
//
|
|
394
|
-
|
|
423
|
+
// Degraded when ANY of: coderef version-skip, collection truncation, OR a
|
|
424
|
+
// file was skipped for being too large. The oversized-skip case (incident
|
|
425
|
+
// f8fdaa6c/18e93b67) means a file was NOT scanned — the scan is incomplete,
|
|
426
|
+
// so it must NOT be reported SAFE. Binary skips (skippedBinary) are NORMAL
|
|
427
|
+
// and intentionally EXCLUDED — a binary file legitimately has no source to
|
|
428
|
+
// scan. scan.ts OR-merges this with its own pro-fetch-failure flag.
|
|
429
|
+
degraded: isDegraded,
|
|
430
|
+
// Machine-readable WHY for each degrade source — safe to key on in agent logic.
|
|
431
|
+
// scan.ts OR-merges its own PRO_RULES_UNAVAILABLE entry after pro-fetch failure.
|
|
432
|
+
degradedReasons: degradedReasons.length > 0 ? degradedReasons : void 0,
|
|
395
433
|
// Internal metadata for the human-output path — NOT included in --json output
|
|
396
434
|
_skippedTooLarge: skippedTooLarge,
|
|
435
|
+
_skippedTooLargeFiles: skippedTooLargeFiles,
|
|
397
436
|
_skippedBinary: skippedBinary,
|
|
398
437
|
_truncated: truncated
|
|
399
438
|
};
|
|
@@ -1078,6 +1117,7 @@ function sendTelemetry(payload) {
|
|
|
1078
1117
|
|
|
1079
1118
|
// src/commands/scan.ts
|
|
1080
1119
|
var LEARN_MORE = "Docs https://agenticcli.dev/docs \xB7 Site https://agenticcli.dev \xB7 Pricing https://agenticcli.dev/pricing \xB7 Issues https://github.com/ramxH3421/agentic-cli/issues";
|
|
1120
|
+
var CLI_VERSION = true ? "0.2.1" : process.env.npm_package_version ?? "0.0.0-dev";
|
|
1081
1121
|
function resolveExitCode(opts) {
|
|
1082
1122
|
if (opts.strict && opts.blockingCount > 0) {
|
|
1083
1123
|
return EXIT_CODES.BLOCKED;
|
|
@@ -1177,14 +1217,15 @@ async function runScan(ctx) {
|
|
|
1177
1217
|
let creditsRemaining;
|
|
1178
1218
|
let rulesVersion;
|
|
1179
1219
|
let degraded = false;
|
|
1220
|
+
let proFetchDegradeReason;
|
|
1180
1221
|
if (opts.pro) {
|
|
1181
1222
|
if (!machineOutput && !quiet) {
|
|
1182
1223
|
logger.info("Detecting stack...");
|
|
1183
1224
|
}
|
|
1184
1225
|
try {
|
|
1185
1226
|
const { detectFrameworks } = await import("./framework-PA6RVE7G.js");
|
|
1186
|
-
const { fetchProRules } = await import("./pro-scanner-
|
|
1187
|
-
const { hasConfig, generateConfig } = await import("./config-generator-
|
|
1227
|
+
const { fetchProRules } = await import("./pro-scanner-ER2RYPI5.js");
|
|
1228
|
+
const { hasConfig, generateConfig } = await import("./config-generator-Q2YTMBZ5.js");
|
|
1188
1229
|
const detectedResult = detectFrameworks(cwd);
|
|
1189
1230
|
const { frameworks } = detectedResult;
|
|
1190
1231
|
if (!hasConfig(cwd)) {
|
|
@@ -1218,9 +1259,14 @@ async function runScan(ctx) {
|
|
|
1218
1259
|
logger.info(" + Encrypted | Signed | Memory-only");
|
|
1219
1260
|
}
|
|
1220
1261
|
} catch (err) {
|
|
1221
|
-
|
|
1262
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1263
|
+
logger.warn(`Pro rules unavailable: ${errMsg}`);
|
|
1222
1264
|
logger.warn("Degrading to free scan \u2014 pro rules will not be applied");
|
|
1223
1265
|
degraded = true;
|
|
1266
|
+
proFetchDegradeReason = {
|
|
1267
|
+
code: "PRO_RULES_UNAVAILABLE",
|
|
1268
|
+
detail: `Pro rules could not be fetched: ${errMsg}`
|
|
1269
|
+
};
|
|
1224
1270
|
}
|
|
1225
1271
|
}
|
|
1226
1272
|
const showProgress = shouldShowProgress({
|
|
@@ -1257,11 +1303,17 @@ async function runScan(ctx) {
|
|
|
1257
1303
|
process.stderr.write("\r\x1B[K");
|
|
1258
1304
|
}
|
|
1259
1305
|
const skippedTooLarge = result._skippedTooLarge ?? 0;
|
|
1306
|
+
const skippedTooLargeFiles = result._skippedTooLargeFiles ?? [];
|
|
1260
1307
|
const skippedBinary = result._skippedBinary ?? 0;
|
|
1261
1308
|
const truncatedByBounds = result._truncated ?? false;
|
|
1262
1309
|
result.recommendation = result.riskScore.recommendation;
|
|
1263
1310
|
result.schemaVersion = "2";
|
|
1264
1311
|
result.degraded = degraded || Boolean(result.degraded);
|
|
1312
|
+
if (result.degraded) {
|
|
1313
|
+
const existingReasons = result.degradedReasons ?? [];
|
|
1314
|
+
const commandReasons = proFetchDegradeReason ? [proFetchDegradeReason] : [];
|
|
1315
|
+
result.degradedReasons = [...existingReasons, ...commandReasons];
|
|
1316
|
+
}
|
|
1265
1317
|
result.creditsWarning = creditsRemaining !== void 0 && creditsRemaining < 10;
|
|
1266
1318
|
result.rulesVersion = rulesVersion;
|
|
1267
1319
|
if (proRules?.length) {
|
|
@@ -1275,6 +1327,7 @@ async function runScan(ctx) {
|
|
|
1275
1327
|
}
|
|
1276
1328
|
const publicResult = { ...result };
|
|
1277
1329
|
delete publicResult._skippedTooLarge;
|
|
1330
|
+
delete publicResult._skippedTooLargeFiles;
|
|
1278
1331
|
delete publicResult._skippedBinary;
|
|
1279
1332
|
delete publicResult._truncated;
|
|
1280
1333
|
if (opts.sarif) {
|
|
@@ -1295,10 +1348,18 @@ async function runScan(ctx) {
|
|
|
1295
1348
|
console.log(findingsByCategoryTable(result.findings));
|
|
1296
1349
|
console.log("");
|
|
1297
1350
|
}
|
|
1298
|
-
if (skippedTooLarge > 0
|
|
1299
|
-
|
|
1300
|
-
|
|
1351
|
+
if (skippedTooLarge > 0) {
|
|
1352
|
+
const named = skippedTooLargeFiles.slice(0, 10).join(", ");
|
|
1353
|
+
const more = skippedTooLarge > skippedTooLargeFiles.length || skippedTooLargeFiles.length > 10 ? ` (and others)` : "";
|
|
1354
|
+
logger.warn(
|
|
1355
|
+
`Scan INCOMPLETE: ${skippedTooLarge} file(s) skipped for exceeding the size limit \u2014 NOT scanned: ${named}${more}`
|
|
1301
1356
|
);
|
|
1357
|
+
logger.warn(
|
|
1358
|
+
`These files were not checked. Split/minify-exclude them, or raise \`limits.maxFileSizeBytes\` in shipguard.policy.yml. Verdict is degraded (exit 2).`
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
if (skippedBinary > 0) {
|
|
1362
|
+
logger.info(`Files skipped (binary, normal): ${skippedBinary}`);
|
|
1302
1363
|
}
|
|
1303
1364
|
if (creditsRemaining !== void 0) {
|
|
1304
1365
|
logger.info(`Credits remaining: ${creditsRemaining}`);
|
|
@@ -1372,7 +1433,7 @@ async function runScan(ctx) {
|
|
|
1372
1433
|
[EXIT_CODES.RUNTIME_ERROR]: "error"
|
|
1373
1434
|
};
|
|
1374
1435
|
sendTelemetry({
|
|
1375
|
-
cliVersion:
|
|
1436
|
+
cliVersion: CLI_VERSION,
|
|
1376
1437
|
verdict: verdictMap[exitCode2] ?? "error",
|
|
1377
1438
|
durationMs: elapsedMs,
|
|
1378
1439
|
ci: Boolean(process.env.CI),
|
|
@@ -1608,7 +1669,7 @@ if (rawArgs[0] === "?") {
|
|
|
1608
1669
|
process.argv = [process.argv[0], process.argv[1], "help"];
|
|
1609
1670
|
}
|
|
1610
1671
|
program.name("shipguard").description("CLI-first release gate for AI-built apps").version(
|
|
1611
|
-
true ? "0.2.
|
|
1672
|
+
true ? "0.2.1" : process.env.npm_package_version ?? "0.0.0-dev"
|
|
1612
1673
|
).helpCommand(false).addHelpText("after", `
|
|
1613
1674
|
Learn more:
|
|
1614
1675
|
Docs https://agenticcli.dev/docs
|
|
@@ -1616,13 +1677,17 @@ Learn more:
|
|
|
1616
1677
|
Pricing https://agenticcli.dev/pricing
|
|
1617
1678
|
Issues ${ISSUES_URL3}`);
|
|
1618
1679
|
program.exitOverride();
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
program.addCommand(
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1680
|
+
function addSubcommand(cmd) {
|
|
1681
|
+
cmd.exitOverride();
|
|
1682
|
+
program.addCommand(cmd);
|
|
1683
|
+
}
|
|
1684
|
+
addSubcommand(initCommand());
|
|
1685
|
+
addSubcommand(scanCommand());
|
|
1686
|
+
addSubcommand(loginCommand());
|
|
1687
|
+
addSubcommand(logoutCommand());
|
|
1688
|
+
addSubcommand(statusCommand());
|
|
1689
|
+
addSubcommand(feedbackCommand());
|
|
1690
|
+
addSubcommand(rateCommand());
|
|
1626
1691
|
program.addCommand(
|
|
1627
1692
|
new Command7("help").description("Show the quickstart guide").action(() => {
|
|
1628
1693
|
const isTTY = Boolean(process.stdout.isTTY);
|