@agenticcli/shipguard 0.2.0 → 0.3.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/LICENSE +91 -0
- package/README.md +4 -0
- package/dist/checksum-manifest.json +7 -0
- package/dist/{chunk-7HMLDAMC.js → chunk-ALFVS2BH.js} +44 -14
- package/dist/chunk-ANTCYKRO.js +2024 -0
- package/dist/chunk-ZGFTTSVM.js +3143 -0
- package/dist/cli.js +177 -49
- package/dist/{config-generator-YSWNA53I.js → config-generator-RMWNQQHW.js} +2 -1
- package/dist/dist-PCVBV5S6.js +74 -0
- package/dist/pro-scanner-K7QKKY4E.js +15 -0
- package/package.json +20 -6
- package/dist/chunk-YE2GPROS.js +0 -1507
- package/dist/pro-scanner-IJJLUSAC.js +0 -10
package/dist/cli.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
applySuppressions,
|
|
4
|
+
assertTrustedApiUrl,
|
|
3
5
|
authCheck,
|
|
4
6
|
clearCredentials,
|
|
5
7
|
databaseCheck,
|
|
6
8
|
deploymentCheck,
|
|
7
9
|
getAuthToken,
|
|
8
10
|
isTokenExpired,
|
|
11
|
+
loadChecksumManifest,
|
|
9
12
|
loadCredentials,
|
|
10
13
|
payments,
|
|
11
14
|
runProRulesWithDispatch,
|
|
12
15
|
saveCredentials,
|
|
13
16
|
secretsCheck
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ZGFTTSVM.js";
|
|
15
18
|
import {
|
|
16
19
|
DEFAULT_MAX_FILES,
|
|
17
20
|
DEFAULT_MAX_FILE_SIZE_BYTES,
|
|
18
21
|
DEFAULT_MAX_TOTAL_BYTES,
|
|
19
22
|
readFiles
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ALFVS2BH.js";
|
|
24
|
+
import {
|
|
25
|
+
decodeUtf8Strict,
|
|
26
|
+
detectBinary,
|
|
27
|
+
normalizeNewlines,
|
|
28
|
+
stripBom
|
|
29
|
+
} from "./chunk-ANTCYKRO.js";
|
|
21
30
|
|
|
22
31
|
// src/cli.ts
|
|
23
32
|
import { Command as Command7, CommanderError } from "commander";
|
|
@@ -138,9 +147,9 @@ async function createShipguardDir(dir) {
|
|
|
138
147
|
// src/utils/logger.ts
|
|
139
148
|
import chalk from "chalk";
|
|
140
149
|
var logger = {
|
|
141
|
-
info: (msg) => console.
|
|
142
|
-
success: (msg) => console.
|
|
143
|
-
warn: (msg) => console.
|
|
150
|
+
info: (msg) => console.error(chalk.blue("\u2139"), msg),
|
|
151
|
+
success: (msg) => console.error(chalk.green("\u2713"), msg),
|
|
152
|
+
warn: (msg) => console.error(chalk.yellow("\u26A0"), msg),
|
|
144
153
|
error: (msg) => console.error(chalk.red("\u2717"), msg),
|
|
145
154
|
finding: (severity, msg) => {
|
|
146
155
|
const colors = {
|
|
@@ -152,17 +161,17 @@ var logger = {
|
|
|
152
161
|
};
|
|
153
162
|
const colorFn = colors[severity] || chalk.white;
|
|
154
163
|
const label = severity.toUpperCase().padEnd(8);
|
|
155
|
-
console.
|
|
164
|
+
console.error(` ${colorFn(label)} ${msg}`);
|
|
156
165
|
},
|
|
157
166
|
score: (score, recommendation) => {
|
|
158
167
|
const color = score <= 20 ? chalk.green : score <= 50 ? chalk.yellow : chalk.red;
|
|
159
168
|
const icon = score <= 20 ? "\u2713" : score <= 50 ? "\u26A0" : "\u2717";
|
|
160
|
-
console.
|
|
161
|
-
console.
|
|
162
|
-
console.
|
|
163
|
-
console.
|
|
169
|
+
console.error("");
|
|
170
|
+
console.error(chalk.bold("ShipGuard Scan Result"));
|
|
171
|
+
console.error(`Risk Score: ${color(`${score}/100`)}`);
|
|
172
|
+
console.error(`Status: ${color(`${icon} ${recommendation.replace(/_/g, " ")}`)}`);
|
|
164
173
|
},
|
|
165
|
-
divider: () => console.
|
|
174
|
+
divider: () => console.error(chalk.gray("\u2500".repeat(50)))
|
|
166
175
|
};
|
|
167
176
|
|
|
168
177
|
// src/commands/init.ts
|
|
@@ -193,7 +202,7 @@ import { existsSync as existsSync3 } from "fs";
|
|
|
193
202
|
import { join as join5, resolve as resolve3 } from "path";
|
|
194
203
|
|
|
195
204
|
// src/core/scanner.ts
|
|
196
|
-
import { readFile as readFile2, stat } from "fs/promises";
|
|
205
|
+
import { readFile as readFile2, stat, realpath } from "fs/promises";
|
|
197
206
|
import { join as join2 } from "path";
|
|
198
207
|
|
|
199
208
|
// src/core/risk-score.ts
|
|
@@ -309,8 +318,11 @@ async function scan(options, proRules, onProgress) {
|
|
|
309
318
|
};
|
|
310
319
|
let files;
|
|
311
320
|
let skippedTooLarge = 0;
|
|
321
|
+
const skippedTooLargeFiles = [];
|
|
312
322
|
let skippedBinary = 0;
|
|
313
323
|
let truncated = false;
|
|
324
|
+
const changedInvalidUtf8 = [];
|
|
325
|
+
const changedUnreadable = [];
|
|
314
326
|
if (options.changedOnly && isGitRepo(cwd)) {
|
|
315
327
|
const changedRelPaths = getChangedFiles(cwd);
|
|
316
328
|
const filteredPaths = changedRelPaths.filter(
|
|
@@ -330,30 +342,54 @@ async function scan(options, proRules, onProgress) {
|
|
|
330
342
|
}
|
|
331
343
|
const fullPath = join2(cwd, relPath);
|
|
332
344
|
try {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
345
|
+
let resolvedPath;
|
|
346
|
+
try {
|
|
347
|
+
resolvedPath = await realpath(fullPath);
|
|
348
|
+
} catch (realpathErr) {
|
|
349
|
+
const detail = realpathErr instanceof Error ? realpathErr.message : String(realpathErr);
|
|
350
|
+
logger.warn(`[shipguard] Could not resolve path for changed file ${relPath}: ${detail}`);
|
|
351
|
+
changedUnreadable.push(relPath);
|
|
336
352
|
onProgress?.(++changedProcessed, changedTotal, relPath);
|
|
337
353
|
continue;
|
|
338
354
|
}
|
|
339
|
-
const
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
355
|
+
const canonicalCwd = await realpath(cwd).catch(() => cwd);
|
|
356
|
+
const cwdWithSep = canonicalCwd.endsWith("/") ? canonicalCwd : canonicalCwd + "/";
|
|
357
|
+
if (!resolvedPath.startsWith(cwdWithSep) && resolvedPath !== canonicalCwd) {
|
|
358
|
+
logger.warn(
|
|
359
|
+
`[shipguard] Refusing out-of-root path for changed file ${relPath}: resolved to ${resolvedPath} which is outside ${canonicalCwd}`
|
|
360
|
+
);
|
|
361
|
+
changedUnreadable.push(relPath);
|
|
362
|
+
onProgress?.(++changedProcessed, changedTotal, relPath);
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const fileStat = await stat(resolvedPath);
|
|
366
|
+
if (fileStat.size > limits.maxFileSizeBytes) {
|
|
367
|
+
skippedTooLarge++;
|
|
368
|
+
if (skippedTooLargeFiles.length < 50) {
|
|
369
|
+
skippedTooLargeFiles.push(relPath);
|
|
346
370
|
}
|
|
371
|
+
onProgress?.(++changedProcessed, changedTotal, relPath);
|
|
372
|
+
continue;
|
|
347
373
|
}
|
|
348
|
-
|
|
374
|
+
const buffer = await readFile2(resolvedPath);
|
|
375
|
+
if (detectBinary(new Uint8Array(buffer))) {
|
|
349
376
|
skippedBinary++;
|
|
350
377
|
onProgress?.(++changedProcessed, changedTotal, relPath);
|
|
351
378
|
continue;
|
|
352
379
|
}
|
|
353
|
-
const
|
|
380
|
+
const decoded = decodeUtf8Strict(new Uint8Array(buffer));
|
|
381
|
+
if (!decoded.ok) {
|
|
382
|
+
changedInvalidUtf8.push({ relativePath: relPath, reason: decoded.reason });
|
|
383
|
+
onProgress?.(++changedProcessed, changedTotal, relPath);
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
const content = normalizeNewlines(stripBom(decoded.text));
|
|
354
387
|
totalBytes += buffer.length;
|
|
355
388
|
files.push({ path: fullPath, content, relativePath: relPath });
|
|
356
|
-
} catch {
|
|
389
|
+
} catch (err) {
|
|
390
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
391
|
+
logger.warn(`[shipguard] Could not read changed file ${relPath}: ${detail}`);
|
|
392
|
+
changedUnreadable.push(relPath);
|
|
357
393
|
}
|
|
358
394
|
onProgress?.(++changedProcessed, changedTotal, relPath);
|
|
359
395
|
}
|
|
@@ -369,13 +405,29 @@ async function scan(options, proRules, onProgress) {
|
|
|
369
405
|
});
|
|
370
406
|
files = readResult.files;
|
|
371
407
|
skippedTooLarge = readResult.skippedTooLarge;
|
|
408
|
+
skippedTooLargeFiles.push(...readResult.skippedTooLargeFiles);
|
|
372
409
|
skippedBinary = readResult.skippedBinary;
|
|
373
410
|
truncated = readResult.truncated;
|
|
411
|
+
changedInvalidUtf8.push(...readResult.invalidUtf8Files);
|
|
412
|
+
changedUnreadable.push(...readResult.unreadableFiles);
|
|
374
413
|
}
|
|
375
|
-
let allFindings =
|
|
414
|
+
let allFindings = applySuppressions(
|
|
415
|
+
CHECK_MODULES.flatMap((mod) => mod.run(files, policy)),
|
|
416
|
+
files
|
|
417
|
+
);
|
|
376
418
|
let coderefDegraded = false;
|
|
377
419
|
if (proRules?.length) {
|
|
378
|
-
const
|
|
420
|
+
const checksumManifest = loadChecksumManifest();
|
|
421
|
+
const { findings: proFindings, degraded, warnings } = runProRulesWithDispatch(
|
|
422
|
+
proRules,
|
|
423
|
+
files,
|
|
424
|
+
policy,
|
|
425
|
+
void 0,
|
|
426
|
+
// cliVersion — use default (reads from package.json)
|
|
427
|
+
void 0,
|
|
428
|
+
// table — use default dispatch table
|
|
429
|
+
checksumManifest
|
|
430
|
+
);
|
|
379
431
|
allFindings = [...allFindings, ...proFindings];
|
|
380
432
|
coderefDegraded = degraded;
|
|
381
433
|
for (const w of warnings) {
|
|
@@ -383,17 +435,63 @@ async function scan(options, proRules, onProgress) {
|
|
|
383
435
|
}
|
|
384
436
|
}
|
|
385
437
|
const riskScore = computeRiskScore(allFindings);
|
|
438
|
+
const degradedReasons = [];
|
|
439
|
+
if (skippedTooLarge > 0) {
|
|
440
|
+
const named = skippedTooLargeFiles.slice(0, 10).join(", ");
|
|
441
|
+
const extra = skippedTooLarge > skippedTooLargeFiles.length || skippedTooLargeFiles.length > 10 ? ` (and others)` : "";
|
|
442
|
+
degradedReasons.push({
|
|
443
|
+
code: "FILE_TOO_LARGE",
|
|
444
|
+
detail: `${skippedTooLarge} file(s) exceeded the per-file size cap and were not scanned: ${named}${extra}`
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
if (truncated) {
|
|
448
|
+
degradedReasons.push({
|
|
449
|
+
code: "OUTPUT_TRUNCATED",
|
|
450
|
+
detail: "File count or total size ceiling was reached; collection stopped early \u2014 results are incomplete."
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
if (coderefDegraded) {
|
|
454
|
+
degradedReasons.push({
|
|
455
|
+
code: "CODEREF_SKIPPED",
|
|
456
|
+
detail: "One or more pro coderef rules were skipped because they require a newer CLI version."
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
if (changedInvalidUtf8.length > 0) {
|
|
460
|
+
const named = changedInvalidUtf8.slice(0, 10).map((f) => f.relativePath).join(", ");
|
|
461
|
+
const extra = changedInvalidUtf8.length > 10 ? ` (and ${changedInvalidUtf8.length - 10} more)` : "";
|
|
462
|
+
degradedReasons.push({
|
|
463
|
+
code: "INVALID_UTF8",
|
|
464
|
+
detail: `${changedInvalidUtf8.length} file(s) contained invalid UTF-8 and were not scanned: ${named}${extra}`
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
if (changedUnreadable.length > 0) {
|
|
468
|
+
const named = changedUnreadable.slice(0, 10).join(", ");
|
|
469
|
+
const extra = changedUnreadable.length > 10 ? ` (and ${changedUnreadable.length - 10} more)` : "";
|
|
470
|
+
degradedReasons.push({
|
|
471
|
+
code: "UNREADABLE_FILE",
|
|
472
|
+
detail: `${changedUnreadable.length} file(s) could not be read and were not scanned: ${named}${extra}`
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
const isDegraded = degradedReasons.length > 0 || void 0;
|
|
386
476
|
const result = {
|
|
387
477
|
findings: allFindings,
|
|
388
478
|
riskScore,
|
|
389
479
|
filesScanned: files.length,
|
|
390
480
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
391
481
|
policyUsed: policy.project.name,
|
|
392
|
-
//
|
|
393
|
-
//
|
|
394
|
-
|
|
482
|
+
// Degraded when ANY of: coderef version-skip, collection truncation, OR a
|
|
483
|
+
// file was skipped for being too large. The oversized-skip case (incident
|
|
484
|
+
// f8fdaa6c/18e93b67) means a file was NOT scanned — the scan is incomplete,
|
|
485
|
+
// so it must NOT be reported SAFE. Binary skips (skippedBinary) are NORMAL
|
|
486
|
+
// and intentionally EXCLUDED — a binary file legitimately has no source to
|
|
487
|
+
// scan. scan.ts OR-merges this with its own pro-fetch-failure flag.
|
|
488
|
+
degraded: isDegraded,
|
|
489
|
+
// Machine-readable WHY for each degrade source — safe to key on in agent logic.
|
|
490
|
+
// scan.ts OR-merges its own PRO_RULES_UNAVAILABLE entry after pro-fetch failure.
|
|
491
|
+
degradedReasons: degradedReasons.length > 0 ? degradedReasons : void 0,
|
|
395
492
|
// Internal metadata for the human-output path — NOT included in --json output
|
|
396
493
|
_skippedTooLarge: skippedTooLarge,
|
|
494
|
+
_skippedTooLargeFiles: skippedTooLargeFiles,
|
|
397
495
|
_skippedBinary: skippedBinary,
|
|
398
496
|
_truncated: truncated
|
|
399
497
|
};
|
|
@@ -620,7 +718,7 @@ import { homedir } from "os";
|
|
|
620
718
|
var DOCS_URL = "https://agenticcli.dev/docs";
|
|
621
719
|
var SITE_URL = "https://agenticcli.dev";
|
|
622
720
|
var PRICING_URL = "https://agenticcli.dev/pricing";
|
|
623
|
-
var ISSUES_URL = "https://github.com/
|
|
721
|
+
var ISSUES_URL = "https://github.com/agenticcli/shipguard/issues";
|
|
624
722
|
var SEVERITY_ORDER = ["critical", "high", "medium", "low", "info"];
|
|
625
723
|
var BOX_WIDTH = 78;
|
|
626
724
|
var H = "\u2500";
|
|
@@ -1077,7 +1175,8 @@ function sendTelemetry(payload) {
|
|
|
1077
1175
|
}
|
|
1078
1176
|
|
|
1079
1177
|
// src/commands/scan.ts
|
|
1080
|
-
var LEARN_MORE = "Docs https://agenticcli.dev/docs \xB7 Site https://agenticcli.dev \xB7 Pricing https://agenticcli.dev/pricing \xB7 Issues https://github.com/
|
|
1178
|
+
var LEARN_MORE = "Docs https://agenticcli.dev/docs \xB7 Site https://agenticcli.dev \xB7 Pricing https://agenticcli.dev/pricing \xB7 Issues https://github.com/agenticcli/shipguard/issues";
|
|
1179
|
+
var CLI_VERSION = true ? "0.3.0" : process.env.npm_package_version ?? "0.0.0-dev";
|
|
1081
1180
|
function resolveExitCode(opts) {
|
|
1082
1181
|
if (opts.strict && opts.blockingCount > 0) {
|
|
1083
1182
|
return EXIT_CODES.BLOCKED;
|
|
@@ -1177,14 +1276,15 @@ async function runScan(ctx) {
|
|
|
1177
1276
|
let creditsRemaining;
|
|
1178
1277
|
let rulesVersion;
|
|
1179
1278
|
let degraded = false;
|
|
1279
|
+
let proFetchDegradeReason;
|
|
1180
1280
|
if (opts.pro) {
|
|
1181
1281
|
if (!machineOutput && !quiet) {
|
|
1182
1282
|
logger.info("Detecting stack...");
|
|
1183
1283
|
}
|
|
1184
1284
|
try {
|
|
1185
1285
|
const { detectFrameworks } = await import("./framework-PA6RVE7G.js");
|
|
1186
|
-
const { fetchProRules } = await import("./pro-scanner-
|
|
1187
|
-
const { hasConfig, generateConfig } = await import("./config-generator-
|
|
1286
|
+
const { fetchProRules } = await import("./pro-scanner-K7QKKY4E.js");
|
|
1287
|
+
const { hasConfig, generateConfig } = await import("./config-generator-RMWNQQHW.js");
|
|
1188
1288
|
const detectedResult = detectFrameworks(cwd);
|
|
1189
1289
|
const { frameworks } = detectedResult;
|
|
1190
1290
|
if (!hasConfig(cwd)) {
|
|
@@ -1218,9 +1318,14 @@ async function runScan(ctx) {
|
|
|
1218
1318
|
logger.info(" + Encrypted | Signed | Memory-only");
|
|
1219
1319
|
}
|
|
1220
1320
|
} catch (err) {
|
|
1221
|
-
|
|
1321
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1322
|
+
logger.warn(`Pro rules unavailable: ${errMsg}`);
|
|
1222
1323
|
logger.warn("Degrading to free scan \u2014 pro rules will not be applied");
|
|
1223
1324
|
degraded = true;
|
|
1325
|
+
proFetchDegradeReason = {
|
|
1326
|
+
code: "PRO_RULES_UNAVAILABLE",
|
|
1327
|
+
detail: `Pro rules could not be fetched: ${errMsg}`
|
|
1328
|
+
};
|
|
1224
1329
|
}
|
|
1225
1330
|
}
|
|
1226
1331
|
const showProgress = shouldShowProgress({
|
|
@@ -1257,11 +1362,17 @@ async function runScan(ctx) {
|
|
|
1257
1362
|
process.stderr.write("\r\x1B[K");
|
|
1258
1363
|
}
|
|
1259
1364
|
const skippedTooLarge = result._skippedTooLarge ?? 0;
|
|
1365
|
+
const skippedTooLargeFiles = result._skippedTooLargeFiles ?? [];
|
|
1260
1366
|
const skippedBinary = result._skippedBinary ?? 0;
|
|
1261
1367
|
const truncatedByBounds = result._truncated ?? false;
|
|
1262
1368
|
result.recommendation = result.riskScore.recommendation;
|
|
1263
1369
|
result.schemaVersion = "2";
|
|
1264
1370
|
result.degraded = degraded || Boolean(result.degraded);
|
|
1371
|
+
if (result.degraded) {
|
|
1372
|
+
const existingReasons = result.degradedReasons ?? [];
|
|
1373
|
+
const commandReasons = proFetchDegradeReason ? [proFetchDegradeReason] : [];
|
|
1374
|
+
result.degradedReasons = [...existingReasons, ...commandReasons];
|
|
1375
|
+
}
|
|
1265
1376
|
result.creditsWarning = creditsRemaining !== void 0 && creditsRemaining < 10;
|
|
1266
1377
|
result.rulesVersion = rulesVersion;
|
|
1267
1378
|
if (proRules?.length) {
|
|
@@ -1275,6 +1386,7 @@ async function runScan(ctx) {
|
|
|
1275
1386
|
}
|
|
1276
1387
|
const publicResult = { ...result };
|
|
1277
1388
|
delete publicResult._skippedTooLarge;
|
|
1389
|
+
delete publicResult._skippedTooLargeFiles;
|
|
1278
1390
|
delete publicResult._skippedBinary;
|
|
1279
1391
|
delete publicResult._truncated;
|
|
1280
1392
|
if (opts.sarif) {
|
|
@@ -1295,11 +1407,19 @@ async function runScan(ctx) {
|
|
|
1295
1407
|
console.log(findingsByCategoryTable(result.findings));
|
|
1296
1408
|
console.log("");
|
|
1297
1409
|
}
|
|
1298
|
-
if (skippedTooLarge > 0
|
|
1299
|
-
|
|
1300
|
-
|
|
1410
|
+
if (skippedTooLarge > 0) {
|
|
1411
|
+
const named = skippedTooLargeFiles.slice(0, 10).join(", ");
|
|
1412
|
+
const more = skippedTooLarge > skippedTooLargeFiles.length || skippedTooLargeFiles.length > 10 ? ` (and others)` : "";
|
|
1413
|
+
logger.warn(
|
|
1414
|
+
`Scan INCOMPLETE: ${skippedTooLarge} file(s) skipped for exceeding the size limit \u2014 NOT scanned: ${named}${more}`
|
|
1415
|
+
);
|
|
1416
|
+
logger.warn(
|
|
1417
|
+
`These files were not checked. Split/minify-exclude them, or raise \`limits.maxFileSizeBytes\` in shipguard.policy.yml. Verdict is degraded (exit 2).`
|
|
1301
1418
|
);
|
|
1302
1419
|
}
|
|
1420
|
+
if (skippedBinary > 0) {
|
|
1421
|
+
logger.info(`Files skipped (binary, normal): ${skippedBinary}`);
|
|
1422
|
+
}
|
|
1303
1423
|
if (creditsRemaining !== void 0) {
|
|
1304
1424
|
logger.info(`Credits remaining: ${creditsRemaining}`);
|
|
1305
1425
|
}
|
|
@@ -1372,7 +1492,7 @@ async function runScan(ctx) {
|
|
|
1372
1492
|
[EXIT_CODES.RUNTIME_ERROR]: "error"
|
|
1373
1493
|
};
|
|
1374
1494
|
sendTelemetry({
|
|
1375
|
-
cliVersion:
|
|
1495
|
+
cliVersion: CLI_VERSION,
|
|
1376
1496
|
verdict: verdictMap[exitCode2] ?? "error",
|
|
1377
1497
|
durationMs: elapsedMs,
|
|
1378
1498
|
ci: Boolean(process.env.CI),
|
|
@@ -1400,6 +1520,7 @@ var DEFAULT_API_URL = "https://agenticcli.dev";
|
|
|
1400
1520
|
function loginCommand() {
|
|
1401
1521
|
return new Command3("login").description("Authenticate with ShipGuard for pro features").option("--api-url <url>", "API server URL", DEFAULT_API_URL).action(async (opts) => {
|
|
1402
1522
|
const apiUrl = opts.apiUrl;
|
|
1523
|
+
assertTrustedApiUrl(apiUrl);
|
|
1403
1524
|
const res = await fetch(`${apiUrl}/api/auth/device`, { method: "POST" });
|
|
1404
1525
|
if (!res.ok) {
|
|
1405
1526
|
logger.error("Failed to start auth");
|
|
@@ -1471,6 +1592,7 @@ function statusCommand() {
|
|
|
1471
1592
|
logger.info(`Token: ${expired ? "expired" : "valid"} (expires ${new Date(creds.expiresAt).toISOString()})`);
|
|
1472
1593
|
if (!expired) {
|
|
1473
1594
|
try {
|
|
1595
|
+
assertTrustedApiUrl(creds.apiUrl);
|
|
1474
1596
|
const res = await fetch(`${creds.apiUrl}/api/user/me`, {
|
|
1475
1597
|
headers: { "Authorization": `Bearer ${creds.accessToken}` }
|
|
1476
1598
|
});
|
|
@@ -1506,6 +1628,7 @@ function feedbackCommand() {
|
|
|
1506
1628
|
return;
|
|
1507
1629
|
}
|
|
1508
1630
|
try {
|
|
1631
|
+
assertTrustedApiUrl(creds.apiUrl);
|
|
1509
1632
|
const res = await fetch(`${creds.apiUrl}/api/feedback`, {
|
|
1510
1633
|
method: "POST",
|
|
1511
1634
|
headers: {
|
|
@@ -1547,6 +1670,7 @@ function rateCommand() {
|
|
|
1547
1670
|
return;
|
|
1548
1671
|
}
|
|
1549
1672
|
try {
|
|
1673
|
+
assertTrustedApiUrl(creds.apiUrl);
|
|
1550
1674
|
const res = await fetch(`${creds.apiUrl}/api/feedback`, {
|
|
1551
1675
|
method: "POST",
|
|
1552
1676
|
headers: {
|
|
@@ -1570,7 +1694,7 @@ function rateCommand() {
|
|
|
1570
1694
|
}
|
|
1571
1695
|
|
|
1572
1696
|
// src/handlers.ts
|
|
1573
|
-
var ISSUES_URL2 = "https://github.com/
|
|
1697
|
+
var ISSUES_URL2 = "https://github.com/agenticcli/shipguard/issues";
|
|
1574
1698
|
var DOCS_URL2 = "https://agenticcli.dev/docs";
|
|
1575
1699
|
var REPORT_LINE = `Report this: ${ISSUES_URL2} \xB7 Docs: ${DOCS_URL2}`;
|
|
1576
1700
|
function handleUncaughtException(error) {
|
|
@@ -1601,14 +1725,14 @@ process.on("uncaughtException", handleUncaughtException);
|
|
|
1601
1725
|
process.on("unhandledRejection", handleUnhandledRejection);
|
|
1602
1726
|
process.on("SIGINT", handleSignal);
|
|
1603
1727
|
process.on("SIGTERM", handleSignal);
|
|
1604
|
-
var ISSUES_URL3 = "https://github.com/
|
|
1728
|
+
var ISSUES_URL3 = "https://github.com/agenticcli/shipguard/issues";
|
|
1605
1729
|
var program = new Command7();
|
|
1606
1730
|
var rawArgs = process.argv.slice(2);
|
|
1607
1731
|
if (rawArgs[0] === "?") {
|
|
1608
1732
|
process.argv = [process.argv[0], process.argv[1], "help"];
|
|
1609
1733
|
}
|
|
1610
1734
|
program.name("shipguard").description("CLI-first release gate for AI-built apps").version(
|
|
1611
|
-
true ? "0.
|
|
1735
|
+
true ? "0.3.0" : process.env.npm_package_version ?? "0.0.0-dev"
|
|
1612
1736
|
).helpCommand(false).addHelpText("after", `
|
|
1613
1737
|
Learn more:
|
|
1614
1738
|
Docs https://agenticcli.dev/docs
|
|
@@ -1616,13 +1740,17 @@ Learn more:
|
|
|
1616
1740
|
Pricing https://agenticcli.dev/pricing
|
|
1617
1741
|
Issues ${ISSUES_URL3}`);
|
|
1618
1742
|
program.exitOverride();
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
program.addCommand(
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1743
|
+
function addSubcommand(cmd) {
|
|
1744
|
+
cmd.exitOverride();
|
|
1745
|
+
program.addCommand(cmd);
|
|
1746
|
+
}
|
|
1747
|
+
addSubcommand(initCommand());
|
|
1748
|
+
addSubcommand(scanCommand());
|
|
1749
|
+
addSubcommand(loginCommand());
|
|
1750
|
+
addSubcommand(logoutCommand());
|
|
1751
|
+
addSubcommand(statusCommand());
|
|
1752
|
+
addSubcommand(feedbackCommand());
|
|
1753
|
+
addSubcommand(rateCommand());
|
|
1626
1754
|
program.addCommand(
|
|
1627
1755
|
new Command7("help").description("Show the quickstart guide").action(() => {
|
|
1628
1756
|
const isTTY = Boolean(process.stdout.isTTY);
|
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
DEFAULT_MAX_FILES,
|
|
3
3
|
DEFAULT_MAX_FILE_SIZE_BYTES,
|
|
4
4
|
DEFAULT_MAX_TOTAL_BYTES
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ALFVS2BH.js";
|
|
6
|
+
import "./chunk-ANTCYKRO.js";
|
|
6
7
|
|
|
7
8
|
// src/core/config-generator.ts
|
|
8
9
|
import { writeFileSync, existsSync } from "fs";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CapTracker,
|
|
3
|
+
DEFAULT_CAPS,
|
|
4
|
+
DegradedReason,
|
|
5
|
+
EXEC_RULE_EXTENSION_FIELDS,
|
|
6
|
+
EXEC_RULE_FIELDS,
|
|
7
|
+
NATIVE_V1_ADAPTER_IMPL_HASH,
|
|
8
|
+
NATIVE_V1_RUNTIME_ID,
|
|
9
|
+
RE2JS_V1_ADAPTER_IMPL_HASH,
|
|
10
|
+
RE2JS_V1_RUNTIME_ID,
|
|
11
|
+
RE2JS_VERSION,
|
|
12
|
+
SUPPORTED_NODE_VERSIONS,
|
|
13
|
+
UNICODE_NORMALIZATION_POLICY,
|
|
14
|
+
allConformanceVectors,
|
|
15
|
+
canonicalJson,
|
|
16
|
+
canonicalizeFinding,
|
|
17
|
+
computeExecutableHash,
|
|
18
|
+
computeMatcherRuntimeId,
|
|
19
|
+
decodeUtf8Strict,
|
|
20
|
+
detectBinary,
|
|
21
|
+
executorDependentVectors,
|
|
22
|
+
executorIndependentVectors,
|
|
23
|
+
hugeSingleLineCap,
|
|
24
|
+
makeNativeEngineMeta,
|
|
25
|
+
makeRe2jsEngineMeta,
|
|
26
|
+
nativeV1Executor,
|
|
27
|
+
normalizeNewlines,
|
|
28
|
+
parseFlags,
|
|
29
|
+
parseStrictNoDup,
|
|
30
|
+
re2jsTestPattern,
|
|
31
|
+
re2jsV1Executor,
|
|
32
|
+
resolveExitCode,
|
|
33
|
+
runConformance,
|
|
34
|
+
selectExpected,
|
|
35
|
+
stripBom,
|
|
36
|
+
verifyExactSet
|
|
37
|
+
} from "./chunk-ANTCYKRO.js";
|
|
38
|
+
export {
|
|
39
|
+
CapTracker,
|
|
40
|
+
DEFAULT_CAPS,
|
|
41
|
+
DegradedReason,
|
|
42
|
+
EXEC_RULE_EXTENSION_FIELDS,
|
|
43
|
+
EXEC_RULE_FIELDS,
|
|
44
|
+
NATIVE_V1_ADAPTER_IMPL_HASH,
|
|
45
|
+
NATIVE_V1_RUNTIME_ID,
|
|
46
|
+
RE2JS_V1_ADAPTER_IMPL_HASH,
|
|
47
|
+
RE2JS_V1_RUNTIME_ID,
|
|
48
|
+
RE2JS_VERSION,
|
|
49
|
+
SUPPORTED_NODE_VERSIONS,
|
|
50
|
+
UNICODE_NORMALIZATION_POLICY,
|
|
51
|
+
allConformanceVectors,
|
|
52
|
+
canonicalJson,
|
|
53
|
+
canonicalizeFinding,
|
|
54
|
+
computeExecutableHash,
|
|
55
|
+
computeMatcherRuntimeId,
|
|
56
|
+
decodeUtf8Strict,
|
|
57
|
+
detectBinary,
|
|
58
|
+
executorDependentVectors,
|
|
59
|
+
executorIndependentVectors,
|
|
60
|
+
hugeSingleLineCap,
|
|
61
|
+
makeNativeEngineMeta,
|
|
62
|
+
makeRe2jsEngineMeta,
|
|
63
|
+
nativeV1Executor,
|
|
64
|
+
normalizeNewlines,
|
|
65
|
+
parseFlags,
|
|
66
|
+
parseStrictNoDup,
|
|
67
|
+
re2jsTestPattern,
|
|
68
|
+
re2jsV1Executor,
|
|
69
|
+
resolveExitCode,
|
|
70
|
+
runConformance,
|
|
71
|
+
selectExpected,
|
|
72
|
+
stripBom,
|
|
73
|
+
verifyExactSet
|
|
74
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RunProRulesFatalError,
|
|
3
|
+
fetchProRules,
|
|
4
|
+
runProRules,
|
|
5
|
+
runProRulesWithDispatch,
|
|
6
|
+
validateBundleCompile
|
|
7
|
+
} from "./chunk-ZGFTTSVM.js";
|
|
8
|
+
import "./chunk-ANTCYKRO.js";
|
|
9
|
+
export {
|
|
10
|
+
RunProRulesFatalError,
|
|
11
|
+
fetchProRules,
|
|
12
|
+
runProRules,
|
|
13
|
+
runProRulesWithDispatch,
|
|
14
|
+
validateBundleCompile
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenticcli/shipguard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "CLI-first release gate for AI-built apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cli.js",
|
|
@@ -20,13 +20,18 @@
|
|
|
20
20
|
"fast-glob": "^3.3.0",
|
|
21
21
|
"jose": "^6.2.3",
|
|
22
22
|
"minimatch": "^10.2.5",
|
|
23
|
+
"re2js": "2.8.3",
|
|
23
24
|
"yaml": "^2.7.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@types/node": "^22.0.0",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^7",
|
|
29
|
+
"@typescript-eslint/parser": "^7",
|
|
30
|
+
"eslint": "^8",
|
|
27
31
|
"tsup": "^8.5.1",
|
|
28
32
|
"typescript": "^5.8.0",
|
|
29
33
|
"vitest": "^3.2.0",
|
|
34
|
+
"@agenticcli/matcher-contract": "0.5.0",
|
|
30
35
|
"@agenticcli/shared": "0.1.0"
|
|
31
36
|
},
|
|
32
37
|
"keywords": [
|
|
@@ -35,17 +40,25 @@
|
|
|
35
40
|
"release-gate",
|
|
36
41
|
"ai-code",
|
|
37
42
|
"security",
|
|
38
|
-
"cli"
|
|
43
|
+
"cli",
|
|
44
|
+
"ai-agents",
|
|
45
|
+
"claude-code",
|
|
46
|
+
"cursor",
|
|
47
|
+
"codex",
|
|
48
|
+
"agentic",
|
|
49
|
+
"pre-deploy-check",
|
|
50
|
+
"secrets-scanner",
|
|
51
|
+
"llm-generated-code"
|
|
39
52
|
],
|
|
40
|
-
"license": "
|
|
41
|
-
"author": "
|
|
53
|
+
"license": "Elastic-2.0",
|
|
54
|
+
"author": "agenticcli",
|
|
42
55
|
"repository": {
|
|
43
56
|
"type": "git",
|
|
44
|
-
"url": "https://github.com/
|
|
57
|
+
"url": "git+https://github.com/agenticcli/shipguard.git"
|
|
45
58
|
},
|
|
46
59
|
"homepage": "https://agenticcli.dev/shipguard",
|
|
47
60
|
"bugs": {
|
|
48
|
-
"url": "https://github.com/
|
|
61
|
+
"url": "https://github.com/agenticcli/shipguard/issues"
|
|
49
62
|
},
|
|
50
63
|
"engines": {
|
|
51
64
|
"node": ">=20"
|
|
@@ -56,6 +69,7 @@
|
|
|
56
69
|
"scripts": {
|
|
57
70
|
"build": "tsup",
|
|
58
71
|
"dev": "tsup --watch",
|
|
72
|
+
"lint": "eslint src --ext .ts",
|
|
59
73
|
"test": "vitest run",
|
|
60
74
|
"test:watch": "vitest",
|
|
61
75
|
"clean": "rm -rf dist"
|