shield-llm 0.6.0 → 0.6.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-6AYERWP2.js → chunk-LGX52ZEL.js} +21 -2
- package/dist/cli.js +40 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __cjs_createRequire } from "module"; import { fileURLToPath as __cjs_fileURLToPath } from "url"; import { dirname as __cjs_dirname } from "path"; const __filename = __cjs_fileURLToPath(import.meta.url); const __dirname = __cjs_dirname(__filename); const require = __cjs_createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// package.json
|
|
4
|
-
var version = "0.6.
|
|
4
|
+
var version = "0.6.1";
|
|
5
5
|
|
|
6
6
|
// src/config/schema.ts
|
|
7
7
|
import { z as z2 } from "zod";
|
|
@@ -5823,6 +5823,11 @@ var Scanner = class {
|
|
|
5823
5823
|
// from a hard quota/ban. Both reset at the start of run().
|
|
5824
5824
|
this.currentDelayMs = 0;
|
|
5825
5825
|
this.throttleFloorStreak = 0;
|
|
5826
|
+
// Pool-global not-before floor (ms epoch). Every send path waits until this
|
|
5827
|
+
// before issuing a turn, so a single observed Retry-After / throttle backoff
|
|
5828
|
+
// quiets the WHOLE worker pool — not just the worker that hit it. 0 = no pause
|
|
5829
|
+
// (the default and the no-throttle hot path, so it's a no-op when idle).
|
|
5830
|
+
this.pauseUntil = 0;
|
|
5826
5831
|
this.targetClient = createTargetClient(
|
|
5827
5832
|
options.target,
|
|
5828
5833
|
options.systemPrompt
|
|
@@ -5900,6 +5905,7 @@ var Scanner = class {
|
|
|
5900
5905
|
let rateLimited = false;
|
|
5901
5906
|
this.currentDelayMs = this.options.delayMs;
|
|
5902
5907
|
this.throttleFloorStreak = 0;
|
|
5908
|
+
this.pauseUntil = 0;
|
|
5903
5909
|
const singleResults = new Array(
|
|
5904
5910
|
attacks.length
|
|
5905
5911
|
);
|
|
@@ -6406,6 +6412,10 @@ var Scanner = class {
|
|
|
6406
6412
|
async sendTurnWithRetry(session, prompt, attackId) {
|
|
6407
6413
|
let attempt = 0;
|
|
6408
6414
|
for (; ; ) {
|
|
6415
|
+
const pause = this.pauseUntil - Date.now();
|
|
6416
|
+
if (pause > 0) {
|
|
6417
|
+
await sleep(pause + Math.floor(Math.random() * PAUSE_JITTER_MS));
|
|
6418
|
+
}
|
|
6409
6419
|
try {
|
|
6410
6420
|
return await session.sendTurn(prompt, {
|
|
6411
6421
|
abortSignal: AbortSignal.timeout(this.options.attackTimeoutMs),
|
|
@@ -6425,7 +6435,10 @@ var Scanner = class {
|
|
|
6425
6435
|
waitMs,
|
|
6426
6436
|
reason: error instanceof RateLimitError ? "rate_limited" : "server_error"
|
|
6427
6437
|
});
|
|
6428
|
-
if (error instanceof RateLimitError)
|
|
6438
|
+
if (error instanceof RateLimitError) {
|
|
6439
|
+
this.aimdDecrease();
|
|
6440
|
+
this.pauseUntil = Math.max(this.pauseUntil, Date.now() + waitMs);
|
|
6441
|
+
}
|
|
6429
6442
|
await sleep(waitMs);
|
|
6430
6443
|
}
|
|
6431
6444
|
}
|
|
@@ -6578,6 +6591,7 @@ var Scanner = class {
|
|
|
6578
6591
|
this.onEvent?.(event);
|
|
6579
6592
|
}
|
|
6580
6593
|
};
|
|
6594
|
+
var PAUSE_JITTER_MS = 250;
|
|
6581
6595
|
function isRetryable(error) {
|
|
6582
6596
|
if (error instanceof RateLimitError) return true;
|
|
6583
6597
|
if (error instanceof HttpTargetError) {
|
|
@@ -6705,6 +6719,11 @@ var ConfigSchema = z2.object({
|
|
|
6705
6719
|
maxRateLimitRetries: z2.number().int().min(0).max(10).optional(),
|
|
6706
6720
|
rateLimitBackoffMs: z2.number().int().min(0).optional(),
|
|
6707
6721
|
rateLimitMaxBackoffMs: z2.number().int().min(0).optional(),
|
|
6722
|
+
// Adaptive-pacing knobs. These existed in ScanOptions but were unreachable —
|
|
6723
|
+
// absent from this schema (stripped by Zod) AND from the scan.ts passthrough —
|
|
6724
|
+
// so they always fell back to the scanner defaults (5000 / 3). Now settable.
|
|
6725
|
+
maxDelayMs: z2.number().int().min(0).optional(),
|
|
6726
|
+
maxFloorThrottles: z2.number().int().min(1).optional(),
|
|
6708
6727
|
thresholds: ThresholdSchema.optional(),
|
|
6709
6728
|
output: OutputSchema.optional()
|
|
6710
6729
|
});
|
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-LGX52ZEL.js";
|
|
33
33
|
|
|
34
34
|
// src/load-env.ts
|
|
35
35
|
try {
|
|
@@ -38,7 +38,7 @@ try {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// src/cli.ts
|
|
41
|
-
import { Command, CommanderError } from "commander";
|
|
41
|
+
import { Command, CommanderError, InvalidArgumentError } from "commander";
|
|
42
42
|
|
|
43
43
|
// src/credentials.ts
|
|
44
44
|
import {
|
|
@@ -2191,6 +2191,14 @@ async function scanCommand(opts) {
|
|
|
2191
2191
|
...opts.outputFile ? { file: opts.outputFile } : {}
|
|
2192
2192
|
};
|
|
2193
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;
|
|
2194
2202
|
const config = loadConfig({
|
|
2195
2203
|
configPath: opts.config,
|
|
2196
2204
|
cliOverrides
|
|
@@ -2303,6 +2311,8 @@ async function scanCommand(opts) {
|
|
|
2303
2311
|
maxRateLimitRetries: config.maxRateLimitRetries,
|
|
2304
2312
|
rateLimitBackoffMs: config.rateLimitBackoffMs,
|
|
2305
2313
|
rateLimitMaxBackoffMs: config.rateLimitMaxBackoffMs,
|
|
2314
|
+
maxDelayMs: config.maxDelayMs,
|
|
2315
|
+
maxFloorThrottles: config.maxFloorThrottles,
|
|
2306
2316
|
checkpoint: checkpointStore,
|
|
2307
2317
|
evaluator
|
|
2308
2318
|
};
|
|
@@ -2612,6 +2622,13 @@ function validateCommand(opts) {
|
|
|
2612
2622
|
}
|
|
2613
2623
|
|
|
2614
2624
|
// src/cli.ts
|
|
2625
|
+
function parseIntArg(value) {
|
|
2626
|
+
const n = Number.parseInt(value, 10);
|
|
2627
|
+
if (Number.isNaN(n)) {
|
|
2628
|
+
throw new InvalidArgumentError("Expected an integer.");
|
|
2629
|
+
}
|
|
2630
|
+
return n;
|
|
2631
|
+
}
|
|
2615
2632
|
function reportFatal(label, err) {
|
|
2616
2633
|
console.error(`
|
|
2617
2634
|
${label}:`);
|
|
@@ -2649,7 +2666,27 @@ program.command("scan").description("Run a security scan against a target chatbo
|
|
|
2649
2666
|
).option(
|
|
2650
2667
|
"--preset <name>",
|
|
2651
2668
|
"Scan preset (dev, quick, owasp, frontier, standard, full)"
|
|
2652
|
-
).option("--system-prompt <text>", "System prompt for target chatbot").option("--system-prompt-file <path>", "Path to system prompt file").option("--crescendo", "Include crescendo (multi-turn) attacks").option(
|
|
2669
|
+
).option("--system-prompt <text>", "System prompt for target chatbot").option("--system-prompt-file <path>", "Path to system prompt file").option("--crescendo", "Include crescendo (multi-turn) attacks").option(
|
|
2670
|
+
"--concurrency <n>",
|
|
2671
|
+
"Max parallel single-turn attacks (AIMD backs off on throttling; default 4, set 1 for sequential)",
|
|
2672
|
+
parseIntArg
|
|
2673
|
+
).option(
|
|
2674
|
+
"--delay <ms>",
|
|
2675
|
+
"Base inter-request delay in ms (the adaptive pacing floor)",
|
|
2676
|
+
parseIntArg
|
|
2677
|
+
).option(
|
|
2678
|
+
"--max-delay <ms>",
|
|
2679
|
+
"Ceiling for the adaptive inter-request delay in ms (default 5000)",
|
|
2680
|
+
parseIntArg
|
|
2681
|
+
).option(
|
|
2682
|
+
"--retries <n>",
|
|
2683
|
+
"Max retries on a 429 / gateway 5xx before giving up an attack (default 3)",
|
|
2684
|
+
parseIntArg
|
|
2685
|
+
).option(
|
|
2686
|
+
"--max-floor-throttles <n>",
|
|
2687
|
+
"Consecutive throttles at the pacing floor before hard-stopping (default 3)",
|
|
2688
|
+
parseIntArg
|
|
2689
|
+
).option("--min-score <n>", "Minimum score threshold", parseFloat).option("--fail-on-critical", "Fail if any CRITICAL vulnerability found").option("-o, --output <format>", "Output format (json, markdown, sarif, pdf)").option("--output-file <path>", "Write report to file").option(
|
|
2653
2690
|
"--write-json <path>",
|
|
2654
2691
|
"Always write a parseable JSON copy here, regardless of --output (useful for CI to extract score/grade alongside SARIF)"
|
|
2655
2692
|
).option(
|
package/dist/index.js
CHANGED