shield-llm 0.5.1 → 0.5.3
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-IB7T5OJ2.js → chunk-CWJWN44I.js} +53 -43
- package/dist/cli.js +230 -58
- package/dist/index.js +1 -2
- package/package.json +1 -13
- package/dist/chunk-AH5UVQFM.js +0 -544
- package/dist/chunk-I7M3BZK7.js +0 -20
- package/dist/token-4MGV4LR3.js +0 -70
- package/dist/token-util-U5SGZSEU.js +0 -6
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
analyzeJudgeHealth,
|
|
9
9
|
buildAuthFromFlags,
|
|
10
10
|
buildTargetConfig,
|
|
11
|
+
c,
|
|
11
12
|
calculateComplianceScore,
|
|
12
13
|
computeCatalogHash,
|
|
13
14
|
computeScanKey,
|
|
@@ -26,15 +27,19 @@ import {
|
|
|
26
27
|
parseSnapshot,
|
|
27
28
|
resolveOfflinePosition,
|
|
28
29
|
summarizeAttackErrors
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
|
|
30
|
+
} from "./chunk-CWJWN44I.js";
|
|
31
|
+
|
|
32
|
+
// src/load-env.ts
|
|
33
|
+
try {
|
|
34
|
+
process.loadEnvFile();
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
31
37
|
|
|
32
38
|
// src/cli.ts
|
|
33
|
-
import "dotenv/config";
|
|
34
39
|
import { Command, CommanderError } from "commander";
|
|
35
40
|
|
|
36
41
|
// package.json
|
|
37
|
-
var version = "0.5.
|
|
42
|
+
var version = "0.5.3";
|
|
38
43
|
|
|
39
44
|
// src/credentials.ts
|
|
40
45
|
import {
|
|
@@ -230,7 +235,77 @@ Attack catalogue \u2014 ${total} attack(s)${wanted ? ` (severity: ${wanted})` :
|
|
|
230
235
|
|
|
231
236
|
// src/commands/benchmark.ts
|
|
232
237
|
import { writeFileSync as writeFileSync2 } from "fs";
|
|
233
|
-
|
|
238
|
+
|
|
239
|
+
// src/lib/prompts.ts
|
|
240
|
+
import * as readline from "readline/promises";
|
|
241
|
+
import { stdin, stdout } from "process";
|
|
242
|
+
async function withReadline(fn) {
|
|
243
|
+
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
244
|
+
rl.on("SIGINT", () => {
|
|
245
|
+
rl.close();
|
|
246
|
+
process.exit(130);
|
|
247
|
+
});
|
|
248
|
+
try {
|
|
249
|
+
return await fn(rl);
|
|
250
|
+
} finally {
|
|
251
|
+
rl.close();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async function input(opts) {
|
|
255
|
+
return withReadline(async (rl) => {
|
|
256
|
+
const suffix = opts.default !== void 0 ? ` (${opts.default})` : "";
|
|
257
|
+
for (; ; ) {
|
|
258
|
+
const answer = (await rl.question(`${opts.message}${suffix} `)).trim();
|
|
259
|
+
const value = answer === "" && opts.default !== void 0 ? opts.default : answer;
|
|
260
|
+
if (opts.validate) {
|
|
261
|
+
const result = await opts.validate(value);
|
|
262
|
+
if (result !== true) {
|
|
263
|
+
process.stderr.write(
|
|
264
|
+
`${typeof result === "string" ? result : "Invalid input"}
|
|
265
|
+
`
|
|
266
|
+
);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return value;
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
async function confirm(opts) {
|
|
275
|
+
const def = opts.default ?? false;
|
|
276
|
+
const hint = def ? "(Y/n)" : "(y/N)";
|
|
277
|
+
return withReadline(async (rl) => {
|
|
278
|
+
for (; ; ) {
|
|
279
|
+
const answer = (await rl.question(`${opts.message} ${hint} `)).trim().toLowerCase();
|
|
280
|
+
if (answer === "") return def;
|
|
281
|
+
if (answer === "y" || answer === "yes") return true;
|
|
282
|
+
if (answer === "n" || answer === "no") return false;
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
async function select(opts) {
|
|
287
|
+
const { choices } = opts;
|
|
288
|
+
const defaultIndex = opts.default !== void 0 ? choices.findIndex((ch) => ch.value === opts.default) : -1;
|
|
289
|
+
return withReadline(async (rl) => {
|
|
290
|
+
stdout.write(`${opts.message}
|
|
291
|
+
`);
|
|
292
|
+
choices.forEach((ch, i) => {
|
|
293
|
+
const marker = i === defaultIndex ? " (default)" : "";
|
|
294
|
+
stdout.write(` ${i + 1}) ${ch.name}${marker}
|
|
295
|
+
`);
|
|
296
|
+
});
|
|
297
|
+
const prompt = `Enter a number (1-${choices.length})${defaultIndex >= 0 ? ` [${defaultIndex + 1}]` : ""}: `;
|
|
298
|
+
for (; ; ) {
|
|
299
|
+
const answer = (await rl.question(prompt)).trim();
|
|
300
|
+
if (answer === "" && defaultIndex >= 0)
|
|
301
|
+
return choices[defaultIndex].value;
|
|
302
|
+
const n = Number(answer);
|
|
303
|
+
if (Number.isInteger(n) && n >= 1 && n <= choices.length) {
|
|
304
|
+
return choices[n - 1].value;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
234
309
|
|
|
235
310
|
// src/benchmark/api.ts
|
|
236
311
|
var BenchmarkApiError = class extends Error {
|
|
@@ -488,9 +563,9 @@ async function cohortsCommand(opts) {
|
|
|
488
563
|
);
|
|
489
564
|
return;
|
|
490
565
|
}
|
|
491
|
-
for (const
|
|
566
|
+
for (const c2 of cohorts) {
|
|
492
567
|
console.log(
|
|
493
|
-
`${
|
|
568
|
+
`${c2.id} ${c2.displayName} pack v${c2.activePackVersion} k_min=${c2.kMin} targets=${c2.targetCount} submissions=${c2.submissionCount}`
|
|
494
569
|
);
|
|
495
570
|
}
|
|
496
571
|
} catch (err) {
|
|
@@ -670,9 +745,9 @@ async function interactiveSubmitFlow(creds, scanId, log) {
|
|
|
670
745
|
}
|
|
671
746
|
const cohortId = cohorts.length === 1 ? cohorts[0].id : await select({
|
|
672
747
|
message: "Cohort to contribute to:",
|
|
673
|
-
choices: cohorts.map((
|
|
674
|
-
name: `${
|
|
675
|
-
value:
|
|
748
|
+
choices: cohorts.map((c2) => ({
|
|
749
|
+
name: `${c2.displayName} (pack v${c2.activePackVersion})`,
|
|
750
|
+
value: c2.id
|
|
676
751
|
}))
|
|
677
752
|
});
|
|
678
753
|
const detail = await getCohort(creds, cohortId);
|
|
@@ -700,7 +775,6 @@ async function interactiveSubmitFlow(creds, scanId, log) {
|
|
|
700
775
|
// src/commands/init.ts
|
|
701
776
|
import { existsSync as existsSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
702
777
|
import { resolve } from "path";
|
|
703
|
-
import { select as select2, input, confirm as confirm2 } from "@inquirer/prompts";
|
|
704
778
|
var CONFIG_FILENAME = "shield.config.json";
|
|
705
779
|
async function initCommand() {
|
|
706
780
|
console.log("\nShield LLM \u2014 Configuration wizard\n");
|
|
@@ -713,7 +787,7 @@ async function initCommand() {
|
|
|
713
787
|
}
|
|
714
788
|
const configPath = resolve(CONFIG_FILENAME);
|
|
715
789
|
if (existsSync2(configPath)) {
|
|
716
|
-
const overwrite = await
|
|
790
|
+
const overwrite = await confirm({
|
|
717
791
|
message: `${CONFIG_FILENAME} already exists. Overwrite?`,
|
|
718
792
|
default: false
|
|
719
793
|
});
|
|
@@ -733,7 +807,7 @@ async function initCommand() {
|
|
|
733
807
|
}
|
|
734
808
|
}
|
|
735
809
|
});
|
|
736
|
-
const method = await
|
|
810
|
+
const method = await select({
|
|
737
811
|
message: "HTTP method:",
|
|
738
812
|
choices: [
|
|
739
813
|
{ value: "POST", name: "POST (most chatbots)" },
|
|
@@ -745,7 +819,7 @@ async function initCommand() {
|
|
|
745
819
|
const auth = await collectAuth();
|
|
746
820
|
const { body, responseField } = await collectBodyShape();
|
|
747
821
|
const customHeaders = await collectCustomHeaders();
|
|
748
|
-
const preset = await
|
|
822
|
+
const preset = await select({
|
|
749
823
|
message: "Default scan preset:",
|
|
750
824
|
choices: [
|
|
751
825
|
{ value: "owasp", name: "owasp \u2014 OWASP LLM Top 10 (10 tests)" },
|
|
@@ -798,7 +872,7 @@ ${issues}`);
|
|
|
798
872
|
console.log("");
|
|
799
873
|
}
|
|
800
874
|
async function collectAuth() {
|
|
801
|
-
const authType = await
|
|
875
|
+
const authType = await select({
|
|
802
876
|
message: "How does your endpoint authenticate?",
|
|
803
877
|
choices: [
|
|
804
878
|
{ value: "none", name: "No authentication" },
|
|
@@ -849,7 +923,7 @@ async function collectAuth() {
|
|
|
849
923
|
return { type: "oauth2", clientId, clientSecret, tokenUrl };
|
|
850
924
|
}
|
|
851
925
|
async function collectBodyShape() {
|
|
852
|
-
const shape = await
|
|
926
|
+
const shape = await select({
|
|
853
927
|
message: "Request body shape:",
|
|
854
928
|
choices: [
|
|
855
929
|
{
|
|
@@ -875,7 +949,7 @@ async function collectBodyShape() {
|
|
|
875
949
|
default: "message"
|
|
876
950
|
});
|
|
877
951
|
const body = { [promptField]: "{{prompt}}" };
|
|
878
|
-
const addExtra = await
|
|
952
|
+
const addExtra = await confirm({
|
|
879
953
|
message: "Add extra fixed fields to the request body (assistant_id, thread_id, ...) ?",
|
|
880
954
|
default: false
|
|
881
955
|
});
|
|
@@ -890,7 +964,7 @@ async function collectBodyShape() {
|
|
|
890
964
|
message: `Value for "${key}":`
|
|
891
965
|
});
|
|
892
966
|
body[key] = value;
|
|
893
|
-
more = await
|
|
967
|
+
more = await confirm({ message: "Another field?", default: false });
|
|
894
968
|
}
|
|
895
969
|
}
|
|
896
970
|
const responseField = await input({
|
|
@@ -900,7 +974,7 @@ async function collectBodyShape() {
|
|
|
900
974
|
return { body, responseField };
|
|
901
975
|
}
|
|
902
976
|
async function collectCustomHeaders() {
|
|
903
|
-
const add = await
|
|
977
|
+
const add = await confirm({
|
|
904
978
|
message: "Add custom request headers?",
|
|
905
979
|
default: false
|
|
906
980
|
});
|
|
@@ -917,7 +991,7 @@ async function collectCustomHeaders() {
|
|
|
917
991
|
});
|
|
918
992
|
warnIfHardcodedSecret(value);
|
|
919
993
|
headers[name] = value;
|
|
920
|
-
more = await
|
|
994
|
+
more = await confirm({ message: "Another header?", default: false });
|
|
921
995
|
}
|
|
922
996
|
return headers;
|
|
923
997
|
}
|
|
@@ -1234,21 +1308,119 @@ var BackendEvaluator = class {
|
|
|
1234
1308
|
}
|
|
1235
1309
|
};
|
|
1236
1310
|
|
|
1311
|
+
// src/display/spinner.ts
|
|
1312
|
+
var FRAMES_UNICODE = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1313
|
+
var FRAMES_ASCII = ["-", "\\", "|", "/"];
|
|
1314
|
+
function unicodeSupported() {
|
|
1315
|
+
if (process.platform !== "win32") {
|
|
1316
|
+
return /UTF-?8/i.test(
|
|
1317
|
+
process.env.LC_ALL || process.env.LC_CTYPE || process.env.LANG || ""
|
|
1318
|
+
);
|
|
1319
|
+
}
|
|
1320
|
+
return Boolean(
|
|
1321
|
+
process.env.WT_SESSION || process.env.TERM_PROGRAM === "vscode"
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
var AnsiSpinner = class {
|
|
1325
|
+
constructor() {
|
|
1326
|
+
this._text = "";
|
|
1327
|
+
this.timer = null;
|
|
1328
|
+
this.frame = 0;
|
|
1329
|
+
this.cursorHidden = false;
|
|
1330
|
+
this.isTTY = process.stderr.isTTY === true;
|
|
1331
|
+
this.frames = unicodeSupported() ? FRAMES_UNICODE : FRAMES_ASCII;
|
|
1332
|
+
this.sym = unicodeSupported() ? { ok: "\u2714", fail: "\u2716", warn: "\u26A0", info: "\u2139" } : { ok: "\u221A", fail: "\xD7", warn: "\u203C", info: "i" };
|
|
1333
|
+
}
|
|
1334
|
+
get text() {
|
|
1335
|
+
return this._text;
|
|
1336
|
+
}
|
|
1337
|
+
set text(value) {
|
|
1338
|
+
this._text = value;
|
|
1339
|
+
if (this.isTTY && this.timer) this.render();
|
|
1340
|
+
}
|
|
1341
|
+
render() {
|
|
1342
|
+
process.stderr.write(
|
|
1343
|
+
`\r\x1B[K${c.cyan(this.frames[this.frame])} ${this._text}`
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
start(text) {
|
|
1347
|
+
if (text !== void 0) this._text = text;
|
|
1348
|
+
if (!this.isTTY) {
|
|
1349
|
+
if (text) process.stderr.write(`${text}
|
|
1350
|
+
`);
|
|
1351
|
+
return this;
|
|
1352
|
+
}
|
|
1353
|
+
if (!this.cursorHidden) {
|
|
1354
|
+
process.stderr.write("\x1B[?25l");
|
|
1355
|
+
this.cursorHidden = true;
|
|
1356
|
+
}
|
|
1357
|
+
if (this.timer) clearInterval(this.timer);
|
|
1358
|
+
this.render();
|
|
1359
|
+
this.timer = setInterval(() => {
|
|
1360
|
+
this.frame = (this.frame + 1) % this.frames.length;
|
|
1361
|
+
this.render();
|
|
1362
|
+
}, 80);
|
|
1363
|
+
this.timer.unref?.();
|
|
1364
|
+
return this;
|
|
1365
|
+
}
|
|
1366
|
+
stop() {
|
|
1367
|
+
if (this.timer) {
|
|
1368
|
+
clearInterval(this.timer);
|
|
1369
|
+
this.timer = null;
|
|
1370
|
+
}
|
|
1371
|
+
if (this.isTTY) process.stderr.write("\r\x1B[K");
|
|
1372
|
+
if (this.cursorHidden) {
|
|
1373
|
+
process.stderr.write("\x1B[?25h");
|
|
1374
|
+
this.cursorHidden = false;
|
|
1375
|
+
}
|
|
1376
|
+
return this;
|
|
1377
|
+
}
|
|
1378
|
+
persist(symbol, text) {
|
|
1379
|
+
if (this.timer) {
|
|
1380
|
+
clearInterval(this.timer);
|
|
1381
|
+
this.timer = null;
|
|
1382
|
+
}
|
|
1383
|
+
if (this.isTTY) process.stderr.write("\r\x1B[K");
|
|
1384
|
+
process.stderr.write(`${symbol} ${text ?? this._text}
|
|
1385
|
+
`);
|
|
1386
|
+
return this;
|
|
1387
|
+
}
|
|
1388
|
+
succeed(text) {
|
|
1389
|
+
return this.persist(c.green(this.sym.ok), text);
|
|
1390
|
+
}
|
|
1391
|
+
fail(text) {
|
|
1392
|
+
return this.persist(c.red(this.sym.fail), text);
|
|
1393
|
+
}
|
|
1394
|
+
warn(text) {
|
|
1395
|
+
return this.persist(c.yellow(this.sym.warn), text);
|
|
1396
|
+
}
|
|
1397
|
+
info(text) {
|
|
1398
|
+
return this.persist(c.cyan(this.sym.info), text);
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
function createSpinner() {
|
|
1402
|
+
const spinner2 = new AnsiSpinner();
|
|
1403
|
+
if (process.stderr.isTTY) {
|
|
1404
|
+
process.once("exit", () => spinner2.stop());
|
|
1405
|
+
process.once("SIGINT", () => {
|
|
1406
|
+
spinner2.stop();
|
|
1407
|
+
process.exit(130);
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
return spinner2;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1237
1413
|
// src/display/progress.ts
|
|
1238
|
-
|
|
1239
|
-
import ora from "ora";
|
|
1240
|
-
var spinner = ora();
|
|
1414
|
+
var spinner = createSpinner();
|
|
1241
1415
|
var currentAttackName = "";
|
|
1242
1416
|
function handleEvent(event) {
|
|
1243
1417
|
switch (event.type) {
|
|
1244
1418
|
case "scan:start":
|
|
1245
|
-
spinner.start(
|
|
1246
|
-
chalk.cyan(`Starting scan (${event.totalAttacks} attacks)...`)
|
|
1247
|
-
);
|
|
1419
|
+
spinner.start(c.cyan(`Starting scan (${event.totalAttacks} attacks)...`));
|
|
1248
1420
|
break;
|
|
1249
1421
|
case "scan:resume":
|
|
1250
1422
|
spinner.info(
|
|
1251
|
-
|
|
1423
|
+
c.cyan(
|
|
1252
1424
|
`Resuming \u2014 ${event.completed}/${event.total} attacks already done, running the rest`
|
|
1253
1425
|
)
|
|
1254
1426
|
);
|
|
@@ -1256,7 +1428,7 @@ function handleEvent(event) {
|
|
|
1256
1428
|
break;
|
|
1257
1429
|
case "attack:start":
|
|
1258
1430
|
currentAttackName = event.attack.name;
|
|
1259
|
-
spinner.text =
|
|
1431
|
+
spinner.text = c.cyan(
|
|
1260
1432
|
`[${event.index + 1}/${event.total}] ${event.attack.name} (${severityColor(event.attack.severity)})`
|
|
1261
1433
|
);
|
|
1262
1434
|
break;
|
|
@@ -1265,14 +1437,14 @@ function handleEvent(event) {
|
|
|
1265
1437
|
const prefix = `[${event.index + 1}/${event.total}]`;
|
|
1266
1438
|
if (result.error) {
|
|
1267
1439
|
spinner.warn(
|
|
1268
|
-
`${prefix} ${result.name} \u2014 ${
|
|
1440
|
+
`${prefix} ${result.name} \u2014 ${c.yellow("error")}: ${result.error}`
|
|
1269
1441
|
);
|
|
1270
1442
|
} else if (result.vulnerable) {
|
|
1271
1443
|
spinner.fail(
|
|
1272
|
-
`${prefix} ${result.name} \u2014 ${
|
|
1444
|
+
`${prefix} ${result.name} \u2014 ${c.red("VULNERABLE")} (${severityColor(result.severity)})`
|
|
1273
1445
|
);
|
|
1274
1446
|
} else {
|
|
1275
|
-
spinner.succeed(`${prefix} ${result.name} \u2014 ${
|
|
1447
|
+
spinner.succeed(`${prefix} ${result.name} \u2014 ${c.green("secure")}`);
|
|
1276
1448
|
}
|
|
1277
1449
|
if (event.index < event.total - 1) {
|
|
1278
1450
|
spinner.start();
|
|
@@ -1280,18 +1452,18 @@ function handleEvent(event) {
|
|
|
1280
1452
|
break;
|
|
1281
1453
|
}
|
|
1282
1454
|
case "crescendo:turn":
|
|
1283
|
-
spinner.text =
|
|
1455
|
+
spinner.text = c.cyan(
|
|
1284
1456
|
`${currentAttackName} \u2014 turn ${event.turn}/${event.totalTurns}`
|
|
1285
1457
|
);
|
|
1286
1458
|
break;
|
|
1287
1459
|
case "attack:retry":
|
|
1288
|
-
spinner.text =
|
|
1460
|
+
spinner.text = c.yellow(
|
|
1289
1461
|
`${currentAttackName} \u2014 ${event.reason === "rate_limited" ? "rate limited" : "server error"}, backing off ${(event.waitMs / 1e3).toFixed(1)}s (retry ${event.attempt}/${event.maxRetries})`
|
|
1290
1462
|
);
|
|
1291
1463
|
break;
|
|
1292
1464
|
case "scan:rate_limited":
|
|
1293
1465
|
spinner.fail(
|
|
1294
|
-
|
|
1466
|
+
c.red(
|
|
1295
1467
|
`Rate limited by target \u2014 skipping remaining attacks${event.retryAfterSec ? ` (retry after ${event.retryAfterSec}s)` : ""}`
|
|
1296
1468
|
)
|
|
1297
1469
|
);
|
|
@@ -1304,9 +1476,9 @@ function handleEvent(event) {
|
|
|
1304
1476
|
}
|
|
1305
1477
|
function printSummary(report, thresholds) {
|
|
1306
1478
|
console.log("");
|
|
1307
|
-
console.log(
|
|
1479
|
+
console.log(c.bold("\u2550\u2550\u2550 Shield LLM Scan Results \u2550\u2550\u2550"));
|
|
1308
1480
|
console.log("");
|
|
1309
|
-
console.log(` Target: ${
|
|
1481
|
+
console.log(` Target: ${c.white(report.target)}`);
|
|
1310
1482
|
console.log(` Score: ${scoreColor(report.score)}`);
|
|
1311
1483
|
console.log(` Grade: ${gradeColor(report.grade)}`);
|
|
1312
1484
|
console.log(` Duration: ${(report.durationMs / 1e3).toFixed(1)}s`);
|
|
@@ -1315,15 +1487,15 @@ function printSummary(report, thresholds) {
|
|
|
1315
1487
|
const secure = report.attacks.filter((a) => !a.vulnerable && !a.error);
|
|
1316
1488
|
const errors = report.attacks.filter((a) => a.error);
|
|
1317
1489
|
console.log(
|
|
1318
|
-
` ${
|
|
1490
|
+
` ${c.red(`${vulnerable.length} vulnerable`)} \xB7 ${c.green(`${secure.length} secure`)} \xB7 ${c.yellow(`${errors.length} errors`)}`
|
|
1319
1491
|
);
|
|
1320
1492
|
if (vulnerable.length > 0) {
|
|
1321
1493
|
console.log("");
|
|
1322
|
-
console.log(
|
|
1494
|
+
console.log(c.redBold(" Vulnerabilities:"));
|
|
1323
1495
|
for (const a of vulnerable) {
|
|
1324
1496
|
const conf = a.llmEvaluation ? ` (${(a.llmEvaluation.confidence * 100).toFixed(0)}% confidence)` : "";
|
|
1325
1497
|
console.log(
|
|
1326
|
-
` ${
|
|
1498
|
+
` ${c.red("\u2717")} ${a.name} \u2014 ${severityColor(a.severity)}${conf}`
|
|
1327
1499
|
);
|
|
1328
1500
|
}
|
|
1329
1501
|
}
|
|
@@ -1331,21 +1503,21 @@ function printSummary(report, thresholds) {
|
|
|
1331
1503
|
if (judge.degraded) {
|
|
1332
1504
|
console.log("");
|
|
1333
1505
|
console.log(
|
|
1334
|
-
|
|
1506
|
+
c.bgYellowBlackBold(" JUDGE DEGRADED ") + c.yellow(
|
|
1335
1507
|
` ${judge.degradedCount}/${judge.totalEvaluated} verdicts fell back to regex (${judge.errorSummary}).`
|
|
1336
1508
|
)
|
|
1337
1509
|
);
|
|
1338
1510
|
console.log(
|
|
1339
|
-
|
|
1511
|
+
c.yellow(
|
|
1340
1512
|
" Regex-only verdicts are less reliable than LLM-assisted ones. False positives likely. Fix the LLM provider config and re-run."
|
|
1341
1513
|
)
|
|
1342
1514
|
);
|
|
1343
1515
|
}
|
|
1344
1516
|
console.log("");
|
|
1345
1517
|
if (thresholds.passed) {
|
|
1346
|
-
console.log(
|
|
1518
|
+
console.log(c.greenBold(" \u2713 PASSED \u2014 all thresholds met"));
|
|
1347
1519
|
} else {
|
|
1348
|
-
console.log(
|
|
1520
|
+
console.log(c.redBold(" \u2717 FAILED \u2014 threshold violations:"));
|
|
1349
1521
|
for (const reason of thresholds.reasons) {
|
|
1350
1522
|
console.log(` - ${reason}`);
|
|
1351
1523
|
}
|
|
@@ -1355,36 +1527,36 @@ function printSummary(report, thresholds) {
|
|
|
1355
1527
|
function severityColor(severity) {
|
|
1356
1528
|
switch (severity) {
|
|
1357
1529
|
case "CRITICAL":
|
|
1358
|
-
return
|
|
1530
|
+
return c.redBold(severity);
|
|
1359
1531
|
case "HIGH":
|
|
1360
1532
|
case "CRESCENDO":
|
|
1361
1533
|
case "COMBO":
|
|
1362
|
-
return
|
|
1534
|
+
return c.yellow(severity);
|
|
1363
1535
|
case "MEDIUM":
|
|
1364
|
-
return
|
|
1536
|
+
return c.blue(severity);
|
|
1365
1537
|
default:
|
|
1366
|
-
return
|
|
1538
|
+
return c.gray(severity);
|
|
1367
1539
|
}
|
|
1368
1540
|
}
|
|
1369
1541
|
function scoreColor(score) {
|
|
1370
|
-
if (score >= 90) return
|
|
1371
|
-
if (score >= 75) return
|
|
1372
|
-
if (score >= 60) return
|
|
1373
|
-
if (score >= 40) return
|
|
1374
|
-
return
|
|
1542
|
+
if (score >= 90) return c.greenBold(`${score}/100`);
|
|
1543
|
+
if (score >= 75) return c.green(`${score}/100`);
|
|
1544
|
+
if (score >= 60) return c.yellow(`${score}/100`);
|
|
1545
|
+
if (score >= 40) return c.red(`${score}/100`);
|
|
1546
|
+
return c.redBold(`${score}/100`);
|
|
1375
1547
|
}
|
|
1376
1548
|
function gradeColor(grade) {
|
|
1377
1549
|
switch (grade) {
|
|
1378
1550
|
case "A":
|
|
1379
|
-
return
|
|
1551
|
+
return c.greenBold(grade);
|
|
1380
1552
|
case "B":
|
|
1381
|
-
return
|
|
1553
|
+
return c.green(grade);
|
|
1382
1554
|
case "C":
|
|
1383
|
-
return
|
|
1555
|
+
return c.yellow(grade);
|
|
1384
1556
|
case "D":
|
|
1385
|
-
return
|
|
1557
|
+
return c.red(grade);
|
|
1386
1558
|
default:
|
|
1387
|
-
return
|
|
1559
|
+
return c.redBold(grade);
|
|
1388
1560
|
}
|
|
1389
1561
|
}
|
|
1390
1562
|
|
|
@@ -1639,7 +1811,7 @@ async function retestCommand(scanId, opts) {
|
|
|
1639
1811
|
attacks: plan.singles.map((s) => s.attack),
|
|
1640
1812
|
multiTurnAttacks: plan.multiTurn.map((m) => m.attack),
|
|
1641
1813
|
includeCrescendo: plan.multiTurn.length > 0,
|
|
1642
|
-
customTests: plan.customs.map((
|
|
1814
|
+
customTests: plan.customs.map((c2) => c2.test),
|
|
1643
1815
|
concurrency: config.concurrency,
|
|
1644
1816
|
delayMs: config.delayMs,
|
|
1645
1817
|
attackTimeoutMs: config.attackTimeoutMs,
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shield-llm",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "AI chatbot security scanner — automated red teaming for LLMs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -50,21 +50,9 @@
|
|
|
50
50
|
"prepublishOnly": "pnpm build"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@inquirer/prompts": "^8.2.1",
|
|
54
|
-
"chalk": "^5.3.0",
|
|
55
53
|
"commander": "^12.0.0",
|
|
56
|
-
"dotenv": "^17.2.3",
|
|
57
|
-
"ora": "^8.0.0",
|
|
58
54
|
"zod": "^3.23.0"
|
|
59
55
|
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"puppeteer": ">=24"
|
|
62
|
-
},
|
|
63
|
-
"peerDependenciesMeta": {
|
|
64
|
-
"puppeteer": {
|
|
65
|
-
"optional": true
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
56
|
"devDependencies": {
|
|
69
57
|
"@shield-llm/scanner-core": "workspace:*",
|
|
70
58
|
"@shield-llm/shared": "workspace:*",
|