@agenticcli/shipguard 0.4.0 → 0.5.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/README.md +16 -6
- package/dist/checksum-manifest.json +5 -5
- package/dist/{chunk-ANTCYKRO.js → chunk-5T42QTNT.js} +1 -0
- package/dist/{chunk-XOWMKGOE.js → chunk-LD3EQSPU.js} +198 -26
- package/dist/{chunk-ALFVS2BH.js → chunk-QUBEIHTH.js} +1 -1
- package/dist/cli-facts.json +15 -5
- package/dist/cli.js +1182 -229
- package/dist/{config-generator-RMWNQQHW.js → config-generator-TUQCF2SD.js} +2 -2
- package/dist/{dist-PCVBV5S6.js → dist-PI34PRNW.js} +1 -1
- package/dist/{pro-scanner-ENFCTA4R.js → pro-scanner-7NX6BST3.js} +6 -2
- package/docs/llms.txt +2 -0
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -23,8 +23,8 @@ shipguard scan
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
shipguard scan # Scan current project (rich output)
|
|
27
|
-
shipguard scan --strict # CI
|
|
26
|
+
shipguard scan # Scan current project (rich output; verdict in JSON `recommendation`)
|
|
27
|
+
shipguard scan --strict # CI hard gate: exit 1 on blocking findings (opt-in)
|
|
28
28
|
shipguard scan --json # Machine-readable output for agents/CI
|
|
29
29
|
shipguard scan --quiet # One-line verdict only
|
|
30
30
|
shipguard scan --pro # Pro rules — requires login
|
|
@@ -34,12 +34,22 @@ shipguard init # Generate .shipguard.yml policy file
|
|
|
34
34
|
|
|
35
35
|
## Exit codes
|
|
36
36
|
|
|
37
|
+
ShipGuard is triggered by an agent; output is read machine-readably (`--json`).
|
|
38
|
+
**ShipGuard informs — the caller chooses soft vs hard gating.** The exit code
|
|
39
|
+
is verdict-neutral by default: it does NOT tell you whether findings are
|
|
40
|
+
blocking, or whether the scan was degraded — read the JSON `recommendation`
|
|
41
|
+
and `degraded`/`degradedReasons` fields for that.
|
|
42
|
+
|
|
37
43
|
| Code | Meaning |
|
|
38
44
|
|------|---------|
|
|
39
|
-
| `0` |
|
|
40
|
-
| `1` | Blocked — `--strict`
|
|
41
|
-
| `2` | Config error
|
|
42
|
-
| `3` | Runtime error |
|
|
45
|
+
| `0` | Scan completed — verdict is in the JSON `recommendation` field. Returned even if findings are blocking, and even if the scan is degraded/partial. |
|
|
46
|
+
| `1` | Blocked — **only** with `--strict` + at least one blocking finding. |
|
|
47
|
+
| `2` | Config error, strictly (bad policy file, bad flags, non-project directory). Never doubles as "degraded scan." |
|
|
48
|
+
| `3` | Runtime error — the scan could not meaningfully run at all. |
|
|
49
|
+
|
|
50
|
+
A degraded/partial scan (e.g. pro rules unavailable, an oversized file skipped)
|
|
51
|
+
is exit `0` with `degraded: true` and a `degradedReasons[]` array in `--json`
|
|
52
|
+
output — it never hijacks exit `2`, which is reserved for genuine config errors.
|
|
43
53
|
|
|
44
54
|
## Telemetry
|
|
45
55
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"secrets": "
|
|
3
|
-
"auth": "
|
|
4
|
-
"database": "
|
|
5
|
-
"deployment": "
|
|
6
|
-
"payments": "
|
|
2
|
+
"secrets": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c",
|
|
3
|
+
"auth": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c",
|
|
4
|
+
"database": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c",
|
|
5
|
+
"deployment": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c",
|
|
6
|
+
"payments": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c"
|
|
7
7
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
re2jsV1Executor,
|
|
9
9
|
selectExpected,
|
|
10
10
|
verifyExactSet
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-5T42QTNT.js";
|
|
12
12
|
|
|
13
13
|
// src/core/pro-scanner.ts
|
|
14
14
|
import * as path2 from "path";
|
|
@@ -101,8 +101,69 @@ function clearCredentials() {
|
|
|
101
101
|
function isTokenExpired(creds) {
|
|
102
102
|
return creds.expiresAt < Date.now();
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
var DEFAULT_API_URL = "https://agenticcli.dev";
|
|
105
|
+
var cachedExchangedToken = null;
|
|
106
|
+
async function exchangeApiKeyForToken(apiKey, apiUrl) {
|
|
107
|
+
assertTrustedApiUrl(apiUrl);
|
|
108
|
+
let res;
|
|
109
|
+
try {
|
|
110
|
+
res = await fetch(`${apiUrl}/api/agent/exchange`, {
|
|
111
|
+
method: "POST",
|
|
112
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
113
|
+
});
|
|
114
|
+
} catch (err) {
|
|
115
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
116
|
+
console.error(`[shipguard] SHIPGUARD_API_KEY exchange request to ${apiUrl} failed: ${msg}`);
|
|
117
|
+
throw new Error(
|
|
118
|
+
`Could not reach ${apiUrl}/api/agent/exchange to exchange SHIPGUARD_API_KEY: ${msg}`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
if (res.status === 401) {
|
|
122
|
+
console.error("[shipguard] SHIPGUARD_API_KEY exchange rejected \u2014 invalid or revoked key");
|
|
123
|
+
throw new Error(
|
|
124
|
+
"SHIPGUARD_API_KEY is invalid or has been revoked. Check the key value or generate a new one at https://agenticcli.dev/dashboard."
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
if (res.status === 402) {
|
|
128
|
+
console.error("[shipguard] SHIPGUARD_API_KEY exchange rejected \u2014 monthly budget exhausted");
|
|
129
|
+
throw new Error(
|
|
130
|
+
"SHIPGUARD_API_KEY has exhausted its monthly credit budget. Buy more at https://agenticcli.dev/dashboard/billing"
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (!res.ok) {
|
|
134
|
+
let detail = res.statusText;
|
|
135
|
+
try {
|
|
136
|
+
const body2 = await res.json();
|
|
137
|
+
detail = body2?.error_description ?? body2?.error ?? detail;
|
|
138
|
+
} catch {
|
|
139
|
+
}
|
|
140
|
+
console.error(`[shipguard] SHIPGUARD_API_KEY exchange failed (${res.status}): ${detail}`);
|
|
141
|
+
throw new Error(`SHIPGUARD_API_KEY exchange failed (${res.status}): ${detail}`);
|
|
142
|
+
}
|
|
143
|
+
const body = await res.json();
|
|
144
|
+
if (!body.access_token) {
|
|
145
|
+
console.error("[shipguard] SHIPGUARD_API_KEY exchange returned 200 with no access_token");
|
|
146
|
+
throw new Error("SHIPGUARD_API_KEY exchange succeeded but the server returned no access_token.");
|
|
147
|
+
}
|
|
148
|
+
cachedExchangedToken = {
|
|
149
|
+
apiKey,
|
|
150
|
+
apiUrl,
|
|
151
|
+
accessToken: body.access_token,
|
|
152
|
+
// Refresh 30s ahead of actual expiry so a long-running scan never races a
|
|
153
|
+
// mid-request expiry against the server's 15-minute access-token TTL.
|
|
154
|
+
expiresAt: Date.now() + (body.expires_in ?? 900) * 1e3 - 3e4
|
|
155
|
+
};
|
|
156
|
+
return body.access_token;
|
|
157
|
+
}
|
|
158
|
+
async function getAuthToken(apiUrl) {
|
|
159
|
+
const apiKey = process.env.SHIPGUARD_API_KEY;
|
|
160
|
+
if (apiKey) {
|
|
161
|
+
const targetApiUrl = apiUrl ?? loadCredentials()?.apiUrl ?? DEFAULT_API_URL;
|
|
162
|
+
if (cachedExchangedToken && cachedExchangedToken.apiKey === apiKey && cachedExchangedToken.apiUrl === targetApiUrl && Date.now() < cachedExchangedToken.expiresAt) {
|
|
163
|
+
return cachedExchangedToken.accessToken;
|
|
164
|
+
}
|
|
165
|
+
return exchangeApiKeyForToken(apiKey, targetApiUrl);
|
|
166
|
+
}
|
|
106
167
|
const creds = loadCredentials();
|
|
107
168
|
if (!creds) return null;
|
|
108
169
|
if (!isTokenExpired(creds)) return creds.accessToken;
|
|
@@ -660,7 +721,8 @@ async function verifyBundleResponse(response, request, floorPath) {
|
|
|
660
721
|
const VALID_MATCHER_TYPES = /* @__PURE__ */ new Set(["pattern", "file-presence", "file-relationship"]);
|
|
661
722
|
const VALID_BOUNDARY = /* @__PURE__ */ new Set(["none", "word", "token"]);
|
|
662
723
|
const EXEC_RULE_ALLOWED = /* @__PURE__ */ new Set([...EXEC_RULE_FIELDS]);
|
|
663
|
-
const EXEC_RULE_REQUIRED = ["enabled", "flags", "framework", "id", "matcherType", "severity", "tier", "title"];
|
|
724
|
+
const EXEC_RULE_REQUIRED = ["confidence", "enabled", "flags", "framework", "id", "matcherType", "severity", "tier", "title"];
|
|
725
|
+
const VALID_CONFIDENCE = /* @__PURE__ */ new Set(["HIGH", "MEDIUM", "LOW"]);
|
|
664
726
|
for (let i = 0; i < deliveredRulesRaw.length; i++) {
|
|
665
727
|
const r = deliveredRulesRaw[i];
|
|
666
728
|
if (r === null || typeof r !== "object" || Array.isArray(r)) {
|
|
@@ -669,6 +731,13 @@ async function verifyBundleResponse(response, request, floorPath) {
|
|
|
669
731
|
const rObj = r;
|
|
670
732
|
for (const field of EXEC_RULE_REQUIRED) {
|
|
671
733
|
if (!(field in rObj) || rObj[field] === void 0) {
|
|
734
|
+
if (field === "confidence") {
|
|
735
|
+
return {
|
|
736
|
+
ok: false,
|
|
737
|
+
reason: `selectedRules[${i}]: missing required field "confidence" \u2014 this is a pre-0.5.1 release without per-rule confidence. The CLI refuses to guess (no HIGH default); the server must serve a re-published release that includes confidence.`,
|
|
738
|
+
nonSafe: true
|
|
739
|
+
};
|
|
740
|
+
}
|
|
672
741
|
return { ok: false, reason: `selectedRules[${i}]: missing required field "${field}"`, nonSafe: true };
|
|
673
742
|
}
|
|
674
743
|
}
|
|
@@ -677,6 +746,9 @@ async function verifyBundleResponse(response, request, floorPath) {
|
|
|
677
746
|
return { ok: false, reason: `selectedRules[${i}]: unexpected field "${key}"`, nonSafe: true };
|
|
678
747
|
}
|
|
679
748
|
}
|
|
749
|
+
if (typeof rObj["confidence"] !== "string" || !VALID_CONFIDENCE.has(rObj["confidence"])) {
|
|
750
|
+
return { ok: false, reason: `selectedRules[${i}].confidence must be "HIGH"|"MEDIUM"|"LOW", got "${String(rObj["confidence"])}"`, nonSafe: true };
|
|
751
|
+
}
|
|
680
752
|
if (typeof rObj["enabled"] !== "boolean") {
|
|
681
753
|
return { ok: false, reason: `selectedRules[${i}].enabled must be a boolean`, nonSafe: true };
|
|
682
754
|
}
|
|
@@ -1397,6 +1469,36 @@ var secretsCheck = {
|
|
|
1397
1469
|
run: checkSecrets
|
|
1398
1470
|
};
|
|
1399
1471
|
|
|
1472
|
+
// src/utils/logger.ts
|
|
1473
|
+
import chalk from "chalk";
|
|
1474
|
+
var logger = {
|
|
1475
|
+
info: (msg) => console.error(chalk.blue("\u2139"), msg),
|
|
1476
|
+
success: (msg) => console.error(chalk.green("\u2713"), msg),
|
|
1477
|
+
warn: (msg) => console.error(chalk.yellow("\u26A0"), msg),
|
|
1478
|
+
error: (msg) => console.error(chalk.red("\u2717"), msg),
|
|
1479
|
+
finding: (severity, msg) => {
|
|
1480
|
+
const colors = {
|
|
1481
|
+
critical: chalk.bgRed.white,
|
|
1482
|
+
high: chalk.red,
|
|
1483
|
+
medium: chalk.yellow,
|
|
1484
|
+
low: chalk.blue,
|
|
1485
|
+
info: chalk.gray
|
|
1486
|
+
};
|
|
1487
|
+
const colorFn = colors[severity] || chalk.white;
|
|
1488
|
+
const label = severity.toUpperCase().padEnd(8);
|
|
1489
|
+
console.error(` ${colorFn(label)} ${msg}`);
|
|
1490
|
+
},
|
|
1491
|
+
score: (score, recommendation) => {
|
|
1492
|
+
const color = score <= 20 ? chalk.green : score <= 50 ? chalk.yellow : chalk.red;
|
|
1493
|
+
const icon = score <= 20 ? "\u2713" : score <= 50 ? "\u26A0" : "\u2717";
|
|
1494
|
+
console.error("");
|
|
1495
|
+
console.error(chalk.bold("ShipGuard Scan Result"));
|
|
1496
|
+
console.error(`Risk Score: ${color(`${score}/100`)}`);
|
|
1497
|
+
console.error(`Status: ${color(`${icon} ${recommendation.replace(/_/g, " ")}`)}`);
|
|
1498
|
+
},
|
|
1499
|
+
divider: () => console.error(chalk.gray("\u2500".repeat(50)))
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1400
1502
|
// src/checks/auth.ts
|
|
1401
1503
|
var SENSITIVE_NEXTJS_PAGE_PATTERN = /^(?:src\/)?app\/(admin|dashboard|billing|account|settings|management)(\/|$)/;
|
|
1402
1504
|
var SENSITIVE_API_ROUTE_PATTERN = /^(?:src\/)?app\/api\/(admin|users|billing|account|management)(\/|$)/;
|
|
@@ -1436,7 +1538,9 @@ function isNextjsProject(files) {
|
|
|
1436
1538
|
const pkg = JSON.parse(f.content);
|
|
1437
1539
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
1438
1540
|
if ("next" in deps) return true;
|
|
1439
|
-
} catch {
|
|
1541
|
+
} catch (err) {
|
|
1542
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
1543
|
+
logger.warn(`[auth] Could not parse ${f.relativePath} as JSON \u2014 Next.js dependency signal skipped for this file (app-router path / next.config.* signals still apply): ${detail}`);
|
|
1440
1544
|
}
|
|
1441
1545
|
}
|
|
1442
1546
|
}
|
|
@@ -1990,7 +2094,21 @@ function checkPackageJson(file, findings) {
|
|
|
1990
2094
|
let parsed;
|
|
1991
2095
|
try {
|
|
1992
2096
|
parsed = JSON.parse(file.content);
|
|
1993
|
-
} catch {
|
|
2097
|
+
} catch (err) {
|
|
2098
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
2099
|
+
logger.warn(`[database] Could not parse ${file.relativePath} as JSON \u2014 db-push-in-scripts check skipped for this file: ${detail}`);
|
|
2100
|
+
findings.push({
|
|
2101
|
+
id: "pkg-json-unparseable-database",
|
|
2102
|
+
title: `Could not parse ${file.relativePath} \u2014 database checks skipped for this file`,
|
|
2103
|
+
severity: "info",
|
|
2104
|
+
category: "database",
|
|
2105
|
+
file: file.relativePath,
|
|
2106
|
+
evidence: detail.slice(0, 200),
|
|
2107
|
+
confidence: "HIGH",
|
|
2108
|
+
explanation: 'package.json is not valid JSON, so the db-push-in-scripts check (dangerous "prisma db push" / "drizzle-kit push" in scripts) could not run against this file.',
|
|
2109
|
+
recommendation: "Fix the JSON syntax error in package.json so ShipGuard can scan its scripts.",
|
|
2110
|
+
blocking: false
|
|
2111
|
+
});
|
|
1994
2112
|
return;
|
|
1995
2113
|
}
|
|
1996
2114
|
const scripts = parsed["scripts"];
|
|
@@ -2365,7 +2483,21 @@ function checkPackageJson2(file) {
|
|
|
2365
2483
|
let parsed;
|
|
2366
2484
|
try {
|
|
2367
2485
|
parsed = JSON.parse(content);
|
|
2368
|
-
} catch {
|
|
2486
|
+
} catch (err) {
|
|
2487
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
2488
|
+
logger.warn(`[deployment] Could not parse ${relativePath} as JSON \u2014 NODE_ENV/DEBUG script checks skipped for this file: ${detail}`);
|
|
2489
|
+
findings.push({
|
|
2490
|
+
id: "pkg-json-unparseable-deployment",
|
|
2491
|
+
title: `Could not parse ${relativePath} \u2014 deployment checks skipped for this file`,
|
|
2492
|
+
severity: "info",
|
|
2493
|
+
category: "deployment",
|
|
2494
|
+
file: relativePath,
|
|
2495
|
+
evidence: detail.slice(0, 200),
|
|
2496
|
+
confidence: "HIGH",
|
|
2497
|
+
explanation: "package.json is not valid JSON, so the NODE_ENV=development / DEBUG=true script checks could not run against this file.",
|
|
2498
|
+
recommendation: "Fix the JSON syntax error in package.json so ShipGuard can scan its scripts.",
|
|
2499
|
+
blocking: false
|
|
2500
|
+
});
|
|
2369
2501
|
return findings;
|
|
2370
2502
|
}
|
|
2371
2503
|
const scripts = parsed["scripts"];
|
|
@@ -2816,20 +2948,48 @@ var NoRulesAppliedError = class extends Error {
|
|
|
2816
2948
|
this.name = "NoRulesAppliedError";
|
|
2817
2949
|
}
|
|
2818
2950
|
};
|
|
2951
|
+
var ProFetchError = class extends Error {
|
|
2952
|
+
code;
|
|
2953
|
+
/** Only populated for RATE_LIMITED, when the server sends a `Retry-After` header. */
|
|
2954
|
+
retryAfterSeconds;
|
|
2955
|
+
constructor(code, message, opts) {
|
|
2956
|
+
super(message);
|
|
2957
|
+
this.name = "ProFetchError";
|
|
2958
|
+
this.code = code;
|
|
2959
|
+
this.retryAfterSeconds = opts?.retryAfterSeconds;
|
|
2960
|
+
}
|
|
2961
|
+
};
|
|
2819
2962
|
async function fetchProRules(frameworks, categories, apiUrl, scanId, floorPath) {
|
|
2820
2963
|
assertTrustedApiUrl(apiUrl);
|
|
2821
|
-
const token = await getAuthToken();
|
|
2822
|
-
if (!token) throw new
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
"
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2964
|
+
const token = await getAuthToken(apiUrl);
|
|
2965
|
+
if (!token) throw new ProFetchError("AUTH_FAILED", "Not authenticated. Run `shipguard login` first.");
|
|
2966
|
+
let res;
|
|
2967
|
+
try {
|
|
2968
|
+
res = await fetch(`${apiUrl}/api/rules/fetch`, {
|
|
2969
|
+
method: "POST",
|
|
2970
|
+
headers: {
|
|
2971
|
+
"Authorization": `Bearer ${token}`,
|
|
2972
|
+
"Content-Type": "application/json",
|
|
2973
|
+
...scanId ? { "Idempotency-Key": scanId } : {}
|
|
2974
|
+
},
|
|
2975
|
+
body: JSON.stringify({ frameworks, categories, ...scanId ? { scanId } : {} })
|
|
2976
|
+
});
|
|
2977
|
+
} catch (networkErr) {
|
|
2978
|
+
const msg = networkErr instanceof Error ? networkErr.message : String(networkErr);
|
|
2979
|
+
throw new ProFetchError("SERVER_ERROR", `Network error contacting pro rules API: ${msg}`);
|
|
2980
|
+
}
|
|
2981
|
+
if (res.status === 401) throw new ProFetchError("AUTH_FAILED", "Auth expired. Run `shipguard login` again.");
|
|
2982
|
+
if (res.status === 402) throw new ProFetchError("INSUFFICIENT_CREDITS", "No credits. Buy at https://agenticcli.dev/dashboard/billing");
|
|
2983
|
+
if (res.status === 429) {
|
|
2984
|
+
const retryAfterHeader = res.headers.get("Retry-After");
|
|
2985
|
+
const retryAfterSeconds = retryAfterHeader ? parseInt(retryAfterHeader, 10) : void 0;
|
|
2986
|
+
throw new ProFetchError(
|
|
2987
|
+
"RATE_LIMITED",
|
|
2988
|
+
`Rate limited (429): too many pro rule fetches.`,
|
|
2989
|
+
{ retryAfterSeconds: Number.isFinite(retryAfterSeconds) ? retryAfterSeconds : void 0 }
|
|
2990
|
+
);
|
|
2991
|
+
}
|
|
2992
|
+
if (res.status === 409) throw new ProFetchError("SERVER_ERROR", `Rule fetch conflict (409): ${res.statusText}`);
|
|
2833
2993
|
if (res.status === 422) {
|
|
2834
2994
|
let detail = res.statusText;
|
|
2835
2995
|
try {
|
|
@@ -2843,19 +3003,21 @@ async function fetchProRules(frameworks, categories, apiUrl, scanId, floorPath)
|
|
|
2843
3003
|
} catch (err) {
|
|
2844
3004
|
if (err instanceof NoRulesAppliedError) throw err;
|
|
2845
3005
|
}
|
|
2846
|
-
throw new
|
|
3006
|
+
throw new ProFetchError("BUNDLE_INVALID", `Rule fetch failed (422): ${detail}`);
|
|
2847
3007
|
}
|
|
2848
|
-
if (
|
|
3008
|
+
if (res.status >= 500) throw new ProFetchError("SERVER_ERROR", `Rule fetch failed (${res.status}): ${res.statusText}`);
|
|
3009
|
+
if (!res.ok) throw new ProFetchError("SERVER_ERROR", `Rule fetch failed: ${res.statusText}`);
|
|
2849
3010
|
const credits = parseInt(res.headers.get("X-Credits-Remaining") ?? "0", 10);
|
|
2850
3011
|
const rulesVersion = res.headers.get("X-Rules-Version") ?? void 0;
|
|
2851
3012
|
const rawText = await res.text();
|
|
2852
3013
|
let responseJson;
|
|
2853
3014
|
try {
|
|
2854
|
-
const { parseStrictNoDup: parseStrict } = await import("./dist-
|
|
3015
|
+
const { parseStrictNoDup: parseStrict } = await import("./dist-PI34PRNW.js");
|
|
2855
3016
|
responseJson = parseStrict(rawText);
|
|
2856
3017
|
} catch (parseErr) {
|
|
2857
3018
|
const msg = parseErr instanceof Error ? parseErr.message : String(parseErr);
|
|
2858
|
-
throw new
|
|
3019
|
+
throw new ProFetchError(
|
|
3020
|
+
"BUNDLE_INVALID",
|
|
2859
3021
|
`Rule fetch response rejected \u2014 duplicate-key or malformed JSON detected: ${msg}`
|
|
2860
3022
|
);
|
|
2861
3023
|
}
|
|
@@ -2874,7 +3036,8 @@ async function fetchProRules(frameworks, categories, apiUrl, scanId, floorPath)
|
|
|
2874
3036
|
effectiveFloorPath
|
|
2875
3037
|
);
|
|
2876
3038
|
if (!verifyResult.ok) {
|
|
2877
|
-
throw new
|
|
3039
|
+
throw new ProFetchError(
|
|
3040
|
+
"BUNDLE_INVALID",
|
|
2878
3041
|
`Attested bundle verification failed: ${verifyResult.reason}` + (verifyResult.nonSafe ? " [non-safe exit]" : "")
|
|
2879
3042
|
);
|
|
2880
3043
|
}
|
|
@@ -2889,7 +3052,12 @@ async function fetchProRules(frameworks, categories, apiUrl, scanId, floorPath)
|
|
|
2889
3052
|
explanation: r.title,
|
|
2890
3053
|
recommendation: "",
|
|
2891
3054
|
action,
|
|
2892
|
-
confidence:
|
|
3055
|
+
// Task #16 (hardcoded-confidence fix): carry the rule's REAL signed confidence.
|
|
3056
|
+
// verifyBundleResponse has already fail-closed if any rule lacks confidence, so
|
|
3057
|
+
// r.confidence is guaranteed present here — never a silent HIGH default. Corpus
|
|
3058
|
+
// governance (rule-corpus/rule-logic.md §4) calibrates action to this value, and
|
|
3059
|
+
// deriveBlocking() + CLI output/JSON depend on it being the author's signed intent.
|
|
3060
|
+
confidence: r.confidence,
|
|
2893
3061
|
matcher: {
|
|
2894
3062
|
type: r.matcherType === "pattern" ? "pattern" : r.matcherType,
|
|
2895
3063
|
// fileGlob: all 20 fields are hashed in 0.5.0 and delivered on the wire.
|
|
@@ -2923,7 +3091,8 @@ async function fetchProRules(frameworks, categories, apiUrl, scanId, floorPath)
|
|
|
2923
3091
|
});
|
|
2924
3092
|
return { rules, creditsRemaining: credits, rulesVersion };
|
|
2925
3093
|
}
|
|
2926
|
-
throw new
|
|
3094
|
+
throw new ProFetchError(
|
|
3095
|
+
"BUNDLE_INVALID",
|
|
2927
3096
|
"legacy-bundle-rejected: attestation required \u2014 server response lacks fullManifest. The server must deliver a BundleResponse with fullManifest + corpusAttestation (attested-release protocol, GC.14). Exit non-safe."
|
|
2928
3097
|
);
|
|
2929
3098
|
}
|
|
@@ -3144,6 +3313,7 @@ function runProRulesWithDispatch(rules, files, policy, cliVersion, table, manife
|
|
|
3144
3313
|
}
|
|
3145
3314
|
|
|
3146
3315
|
export {
|
|
3316
|
+
logger,
|
|
3147
3317
|
secretsCheck,
|
|
3148
3318
|
authCheck,
|
|
3149
3319
|
databaseCheck,
|
|
@@ -3158,8 +3328,10 @@ export {
|
|
|
3158
3328
|
loadChecksumManifest,
|
|
3159
3329
|
applySuppressions,
|
|
3160
3330
|
NoRulesAppliedError,
|
|
3331
|
+
ProFetchError,
|
|
3161
3332
|
fetchProRules,
|
|
3162
3333
|
validateBundleCompile,
|
|
3334
|
+
deriveBlocking,
|
|
3163
3335
|
RunProRulesFatalError,
|
|
3164
3336
|
runProRules,
|
|
3165
3337
|
runProRulesWithDispatch
|
package/dist/cli-facts.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.5.0",
|
|
3
3
|
"packageName": "@agenticcli/shipguard",
|
|
4
|
+
"license": "Elastic-2.0",
|
|
5
|
+
"licenseDisplay": "ELv2",
|
|
4
6
|
"nodeEngine": ">=20",
|
|
5
7
|
"exitCodes": {
|
|
6
8
|
"SAFE": 0,
|
|
@@ -27,6 +29,7 @@
|
|
|
27
29
|
"db-truncate",
|
|
28
30
|
"db-delete-without-where",
|
|
29
31
|
"db-alter-drop",
|
|
32
|
+
"pkg-json-unparseable-database",
|
|
30
33
|
"db-push-in-scripts",
|
|
31
34
|
"db-schema-without-migration",
|
|
32
35
|
"database",
|
|
@@ -34,6 +37,7 @@
|
|
|
34
37
|
"payment_webhook_without_signature_check",
|
|
35
38
|
"missing_idempotency",
|
|
36
39
|
"missing_error_handling",
|
|
40
|
+
"pkg-json-unparseable-deployment",
|
|
37
41
|
"deployment",
|
|
38
42
|
"deployment_cors_wildcard",
|
|
39
43
|
"deployment_source_maps_exposed",
|
|
@@ -50,7 +54,7 @@
|
|
|
50
54
|
"deployment_config_cors_wildcard_origin",
|
|
51
55
|
"deployment_config_debug_mode"
|
|
52
56
|
],
|
|
53
|
-
"freeRuleCount":
|
|
57
|
+
"freeRuleCount": 35,
|
|
54
58
|
"jsonSchemaFields": [
|
|
55
59
|
"findings",
|
|
56
60
|
"riskScore",
|
|
@@ -65,9 +69,15 @@
|
|
|
65
69
|
"degradedReasons",
|
|
66
70
|
"creditsWarning",
|
|
67
71
|
"rulesVersion",
|
|
68
|
-
"aiCodeIssues"
|
|
72
|
+
"aiCodeIssues",
|
|
73
|
+
"stateStatus",
|
|
74
|
+
"regressionCheckSkipped",
|
|
75
|
+
"regressionCheckSkippedReason",
|
|
76
|
+
"regressions",
|
|
77
|
+
"coverageChanged",
|
|
78
|
+
"scanIdReused"
|
|
69
79
|
],
|
|
70
|
-
"schemaVersion": "0.
|
|
80
|
+
"schemaVersion": "0.5",
|
|
71
81
|
"degradeCodes": [
|
|
72
82
|
"FILE_TOO_LARGE",
|
|
73
83
|
"OUTPUT_TRUNCATED",
|
|
@@ -97,5 +107,5 @@
|
|
|
97
107
|
],
|
|
98
108
|
"installSnippet": "npx @agenticcli/shipguard scan --changed --strict --json",
|
|
99
109
|
"re2Engine": true,
|
|
100
|
-
"generatedAt": "2026-
|
|
110
|
+
"generatedAt": "2026-07-18T20:19:53.031Z"
|
|
101
111
|
}
|