shield-llm 0.6.2 → 0.6.4
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-3ZVL7ZFC.js → chunk-K3CXSNC7.js} +804 -256
- package/dist/cli.js +61 -41
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
resolveOfflinePosition,
|
|
30
30
|
summarizeAttackErrors,
|
|
31
31
|
version
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-K3CXSNC7.js";
|
|
33
33
|
|
|
34
34
|
// src/load-env.ts
|
|
35
35
|
try {
|
|
@@ -1768,15 +1768,18 @@ async function retestCommand(scanId, opts) {
|
|
|
1768
1768
|
method: "POST",
|
|
1769
1769
|
body: opts.requestBody ? JSON.parse(opts.requestBody) : { message: "{{prompt}}" }
|
|
1770
1770
|
},
|
|
1771
|
-
response: { field: opts.responseField ?? "response" }
|
|
1771
|
+
response: { field: opts.responseField ?? "response" },
|
|
1772
|
+
// Local testing against localhost / private IPs (opt-in).
|
|
1773
|
+
...opts.allowPrivateUrls ? { allowPrivateUrls: true } : {}
|
|
1772
1774
|
};
|
|
1773
1775
|
}
|
|
1774
1776
|
const config = loadConfig({ configPath: opts.config, cliOverrides });
|
|
1775
1777
|
const systemPrompt = loadSystemPrompt(config);
|
|
1776
1778
|
const endpointHost = safeHostname(config.endpoint?.url);
|
|
1777
|
-
|
|
1779
|
+
const targetMismatch = scan.targetDomain && endpointHost && endpointHost !== scan.targetDomain ? { retestedHost: endpointHost, scannedDomain: scan.targetDomain } : null;
|
|
1780
|
+
if (targetMismatch) {
|
|
1778
1781
|
console.error(
|
|
1779
|
-
`Warning: retesting against "${
|
|
1782
|
+
`Warning: retesting against "${targetMismatch.retestedHost}" but scan ${scanId} targeted "${targetMismatch.scannedDomain}". Verification badges will reflect this endpoint.`
|
|
1780
1783
|
);
|
|
1781
1784
|
}
|
|
1782
1785
|
const needsCustom = findings.some(
|
|
@@ -1877,6 +1880,7 @@ async function retestCommand(scanId, opts) {
|
|
|
1877
1880
|
{
|
|
1878
1881
|
scanId,
|
|
1879
1882
|
targetUrl: config.endpoint?.url,
|
|
1883
|
+
...targetMismatch ? { targetMismatch } : {},
|
|
1880
1884
|
retested: outcome.verifications.length,
|
|
1881
1885
|
fixed: fixed.length,
|
|
1882
1886
|
stillVulnerable: stillVulnerable.length,
|
|
@@ -2103,6 +2107,48 @@ async function reportScanFailure(credentials, scanId, reason) {
|
|
|
2103
2107
|
} catch {
|
|
2104
2108
|
}
|
|
2105
2109
|
}
|
|
2110
|
+
function buildCliOverrides(opts) {
|
|
2111
|
+
const cliOverrides = {};
|
|
2112
|
+
if (opts.endpoint) {
|
|
2113
|
+
cliOverrides.endpoint = {
|
|
2114
|
+
url: opts.endpoint,
|
|
2115
|
+
auth: buildAuthFromFlags(opts),
|
|
2116
|
+
request: {
|
|
2117
|
+
method: "POST",
|
|
2118
|
+
body: opts.requestBody ? JSON.parse(opts.requestBody) : { message: "{{prompt}}" }
|
|
2119
|
+
},
|
|
2120
|
+
response: {
|
|
2121
|
+
field: opts.responseField ?? "response"
|
|
2122
|
+
},
|
|
2123
|
+
// Local testing against localhost / private IPs (opt-in).
|
|
2124
|
+
...opts.allowPrivateUrls ? { allowPrivateUrls: true } : {}
|
|
2125
|
+
};
|
|
2126
|
+
}
|
|
2127
|
+
if (opts.preset) cliOverrides.preset = opts.preset;
|
|
2128
|
+
if (opts.systemPrompt) cliOverrides.systemPrompt = opts.systemPrompt;
|
|
2129
|
+
if (opts.crescendo) cliOverrides.includeCrescendo = true;
|
|
2130
|
+
if (opts.minScore !== void 0 || opts.failOnCritical) {
|
|
2131
|
+
cliOverrides.thresholds = {
|
|
2132
|
+
...opts.minScore !== void 0 ? { minScore: opts.minScore } : {},
|
|
2133
|
+
...opts.failOnCritical ? { failOnCritical: true } : {}
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
if (opts.output || opts.outputFile) {
|
|
2137
|
+
cliOverrides.output = {
|
|
2138
|
+
...opts.output ? { format: opts.output } : {},
|
|
2139
|
+
...opts.outputFile ? { file: opts.outputFile } : {}
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
if (opts.concurrency !== void 0)
|
|
2143
|
+
cliOverrides.concurrency = opts.concurrency;
|
|
2144
|
+
if (opts.delay !== void 0) cliOverrides.delayMs = opts.delay;
|
|
2145
|
+
if (opts.maxDelay !== void 0) cliOverrides.maxDelayMs = opts.maxDelay;
|
|
2146
|
+
if (opts.retries !== void 0)
|
|
2147
|
+
cliOverrides.maxRateLimitRetries = opts.retries;
|
|
2148
|
+
if (opts.maxFloorThrottles !== void 0)
|
|
2149
|
+
cliOverrides.maxFloorThrottles = opts.maxFloorThrottles;
|
|
2150
|
+
return cliOverrides;
|
|
2151
|
+
}
|
|
2106
2152
|
async function scanCommand(opts) {
|
|
2107
2153
|
let reservedScanId = null;
|
|
2108
2154
|
let scanFinalized = false;
|
|
@@ -2162,43 +2208,7 @@ async function scanCommand(opts) {
|
|
|
2162
2208
|
credentials.apiUrl,
|
|
2163
2209
|
credentials.apiKey
|
|
2164
2210
|
);
|
|
2165
|
-
const cliOverrides =
|
|
2166
|
-
if (opts.endpoint) {
|
|
2167
|
-
cliOverrides.endpoint = {
|
|
2168
|
-
url: opts.endpoint,
|
|
2169
|
-
auth: buildAuthFromFlags(opts),
|
|
2170
|
-
request: {
|
|
2171
|
-
method: "POST",
|
|
2172
|
-
body: opts.requestBody ? JSON.parse(opts.requestBody) : { message: "{{prompt}}" }
|
|
2173
|
-
},
|
|
2174
|
-
response: {
|
|
2175
|
-
field: opts.responseField ?? "response"
|
|
2176
|
-
}
|
|
2177
|
-
};
|
|
2178
|
-
}
|
|
2179
|
-
if (opts.preset) cliOverrides.preset = opts.preset;
|
|
2180
|
-
if (opts.systemPrompt) cliOverrides.systemPrompt = opts.systemPrompt;
|
|
2181
|
-
if (opts.crescendo) cliOverrides.includeCrescendo = true;
|
|
2182
|
-
if (opts.minScore !== void 0 || opts.failOnCritical) {
|
|
2183
|
-
cliOverrides.thresholds = {
|
|
2184
|
-
...opts.minScore !== void 0 ? { minScore: opts.minScore } : {},
|
|
2185
|
-
...opts.failOnCritical ? { failOnCritical: true } : {}
|
|
2186
|
-
};
|
|
2187
|
-
}
|
|
2188
|
-
if (opts.output || opts.outputFile) {
|
|
2189
|
-
cliOverrides.output = {
|
|
2190
|
-
...opts.output ? { format: opts.output } : {},
|
|
2191
|
-
...opts.outputFile ? { file: opts.outputFile } : {}
|
|
2192
|
-
};
|
|
2193
|
-
}
|
|
2194
|
-
if (opts.concurrency !== void 0)
|
|
2195
|
-
cliOverrides.concurrency = opts.concurrency;
|
|
2196
|
-
if (opts.delay !== void 0) cliOverrides.delayMs = opts.delay;
|
|
2197
|
-
if (opts.maxDelay !== void 0) cliOverrides.maxDelayMs = opts.maxDelay;
|
|
2198
|
-
if (opts.retries !== void 0)
|
|
2199
|
-
cliOverrides.maxRateLimitRetries = opts.retries;
|
|
2200
|
-
if (opts.maxFloorThrottles !== void 0)
|
|
2201
|
-
cliOverrides.maxFloorThrottles = opts.maxFloorThrottles;
|
|
2211
|
+
const cliOverrides = buildCliOverrides(opts);
|
|
2202
2212
|
const config = loadConfig({
|
|
2203
2213
|
configPath: opts.config,
|
|
2204
2214
|
cliOverrides
|
|
@@ -2349,6 +2359,7 @@ async function scanCommand(opts) {
|
|
|
2349
2359
|
attackPackVersion
|
|
2350
2360
|
);
|
|
2351
2361
|
uploadedScanId = reservedScanId;
|
|
2362
|
+
report.id = reservedScanId;
|
|
2352
2363
|
scanFinalized = true;
|
|
2353
2364
|
await checkpointStore.finalize();
|
|
2354
2365
|
report.score = authoritative.score;
|
|
@@ -2381,6 +2392,7 @@ async function scanCommand(opts) {
|
|
|
2381
2392
|
}
|
|
2382
2393
|
}
|
|
2383
2394
|
let thresholdResult = evaluateThresholds(report, config.thresholds);
|
|
2395
|
+
const thresholdsConfigured = config.thresholds !== void 0 || opts.complianceThreshold !== void 0;
|
|
2384
2396
|
if (!opts.ci) {
|
|
2385
2397
|
printSummary(report, thresholdResult);
|
|
2386
2398
|
}
|
|
@@ -2437,6 +2449,7 @@ async function scanCommand(opts) {
|
|
|
2437
2449
|
content = formatJson({
|
|
2438
2450
|
report,
|
|
2439
2451
|
thresholds: thresholdResult,
|
|
2452
|
+
thresholdsConfigured,
|
|
2440
2453
|
compliance: complianceResult
|
|
2441
2454
|
});
|
|
2442
2455
|
break;
|
|
@@ -2455,6 +2468,7 @@ async function scanCommand(opts) {
|
|
|
2455
2468
|
const jsonContent = formatJson({
|
|
2456
2469
|
report: reportForDisk,
|
|
2457
2470
|
thresholds: thresholdResult,
|
|
2471
|
+
thresholdsConfigured,
|
|
2458
2472
|
compliance: complianceResult
|
|
2459
2473
|
});
|
|
2460
2474
|
writeFileSync5(jsonPath, jsonContent, "utf-8");
|
|
@@ -2663,6 +2677,9 @@ program.command("scan").description("Run a security scan against a target chatbo
|
|
|
2663
2677
|
).option(
|
|
2664
2678
|
"--request-body <json>",
|
|
2665
2679
|
"JSON request body template (use {{prompt}} placeholder)"
|
|
2680
|
+
).option(
|
|
2681
|
+
"--allow-private-urls",
|
|
2682
|
+
"Allow a localhost / private-IP target (local testing only; quick mode -e)"
|
|
2666
2683
|
).option(
|
|
2667
2684
|
"--preset <name>",
|
|
2668
2685
|
"Scan preset (dev, quick, owasp, frontier, standard, full)"
|
|
@@ -2771,6 +2788,9 @@ program.command("retest <scanId>").description(
|
|
|
2771
2788
|
).option(
|
|
2772
2789
|
"--request-body <json>",
|
|
2773
2790
|
"JSON request body template (use {{prompt}} placeholder)"
|
|
2791
|
+
).option(
|
|
2792
|
+
"--allow-private-urls",
|
|
2793
|
+
"Allow a localhost / private-IP target (local testing only; quick mode -e)"
|
|
2774
2794
|
).option(
|
|
2775
2795
|
"--finding <attackId>",
|
|
2776
2796
|
"Retest only this finding (attack id or name). Repeatable.",
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shield-llm",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "AI chatbot security scanner — automated red teaming for LLMs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"url": "https://github.com/sami-essouri/shield-ai/issues"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
"
|
|
44
|
+
"lint": "eslint src --ext .ts",
|
|
45
|
+
"build": "tsc --noEmit && tsup && cp src/reporters/assets/logo.png dist/",
|
|
45
46
|
"dev": "tsx src/cli.ts",
|
|
46
|
-
"test": "vitest run
|
|
47
|
-
"test:integration": "vitest run src/integration.test.ts",
|
|
47
|
+
"test": "vitest run",
|
|
48
48
|
"mock-server": "tsx test-server/server.ts",
|
|
49
49
|
"typecheck": "tsc --noEmit",
|
|
50
50
|
"prepublishOnly": "pnpm build"
|