shield-llm 0.2.0 → 0.2.2
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/cli.js +66 -23
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -172,22 +172,44 @@ async function attacksCommand(opts) {
|
|
|
172
172
|
(a) => !wanted || a.severity.toLowerCase() === wanted
|
|
173
173
|
);
|
|
174
174
|
const total = singleTurn.length + multiTurn.length;
|
|
175
|
+
const SEVERITY_ORDER = [
|
|
176
|
+
"CRITICAL",
|
|
177
|
+
"HIGH",
|
|
178
|
+
"MEDIUM",
|
|
179
|
+
"LOW",
|
|
180
|
+
"CRESCENDO",
|
|
181
|
+
"COMBO"
|
|
182
|
+
];
|
|
183
|
+
const countBySeverity = (arr) => {
|
|
184
|
+
const counts = {};
|
|
185
|
+
for (const a of arr) counts[a.severity] = (counts[a.severity] ?? 0) + 1;
|
|
186
|
+
const keys = Object.keys(counts).sort(
|
|
187
|
+
(a, b) => (SEVERITY_ORDER.indexOf(a) + 1 || 99) - (SEVERITY_ORDER.indexOf(b) + 1 || 99)
|
|
188
|
+
);
|
|
189
|
+
return keys.map((s) => `${s} ${counts[s]}`).join(", ") || "\u2014";
|
|
190
|
+
};
|
|
191
|
+
const special = singleTurn.filter(
|
|
192
|
+
(a) => a.requiresMcpHarness || a.requiresVisionTarget || a.requiresMultiAgent
|
|
193
|
+
).length;
|
|
175
194
|
console.log(
|
|
176
195
|
`
|
|
177
|
-
|
|
196
|
+
Attack catalogue \u2014 ${total} attack(s)${wanted ? ` (severity: ${wanted})` : ""}, catalog ${fetched.catalogVersion}:
|
|
178
197
|
`
|
|
179
198
|
);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
199
|
+
console.log(
|
|
200
|
+
` Single-turn (${singleTurn.length}) ${countBySeverity(singleTurn)}`
|
|
201
|
+
);
|
|
202
|
+
console.log(
|
|
203
|
+
` Multi-turn (${multiTurn.length}) ${countBySeverity(multiTurn)}`
|
|
204
|
+
);
|
|
205
|
+
if (special) {
|
|
186
206
|
console.log(
|
|
187
|
-
` ${
|
|
207
|
+
` ${special} need a special harness (MCP / vision / multi-agent)`
|
|
188
208
|
);
|
|
189
209
|
}
|
|
190
|
-
console.log(
|
|
210
|
+
console.log(
|
|
211
|
+
"\n Per-attack payloads stay server-side \u2014 run `shield-llm scan` to exercise them.\n"
|
|
212
|
+
);
|
|
191
213
|
}
|
|
192
214
|
|
|
193
215
|
// src/commands/init.ts
|
|
@@ -1087,23 +1109,41 @@ async function scanCommand(opts) {
|
|
|
1087
1109
|
}
|
|
1088
1110
|
const systemPrompt = loadSystemPrompt(config);
|
|
1089
1111
|
const presetForScan = config.preset ?? "standard";
|
|
1090
|
-
const
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1112
|
+
const customOnly = Boolean(opts.customOnly);
|
|
1113
|
+
const includeCrescendo = customOnly ? false : config.includeCrescendo ?? config.preset === "full";
|
|
1114
|
+
let attacks = [];
|
|
1115
|
+
let multiTurnAttacks = [];
|
|
1116
|
+
if (customOnly) {
|
|
1117
|
+
if (!config.customTests || config.customTests.length === 0) {
|
|
1118
|
+
console.error(
|
|
1119
|
+
"--custom-only needs at least one custom test (config.customTests or --load-custom-tests)."
|
|
1120
|
+
);
|
|
1121
|
+
setExitCode(2);
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
info(
|
|
1125
|
+
`Custom-only mode: ${config.customTests.length} custom test(s), no preset attacks sent.`
|
|
1126
|
+
);
|
|
1127
|
+
} else {
|
|
1128
|
+
const fetched = await fetchAttacks({
|
|
1129
|
+
apiUrl: credentials.apiUrl,
|
|
1130
|
+
apiKey: credentials.apiKey,
|
|
1131
|
+
preset: presetForScan,
|
|
1132
|
+
includeMultiTurn: includeCrescendo
|
|
1133
|
+
});
|
|
1134
|
+
attacks = fetched.attacks;
|
|
1135
|
+
multiTurnAttacks = fetched.multiTurnAttacks;
|
|
1136
|
+
const multiTurnNote = fetched.multiTurnAttacks.length > 0 ? ` + ${fetched.multiTurnAttacks.length} multi-turn` : "";
|
|
1137
|
+
info(
|
|
1138
|
+
`Loaded ${fetched.attacks.length} attacks${multiTurnNote} from ${fetched.source} (catalog ${fetched.catalogVersion})`
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1101
1141
|
const scanOptions = {
|
|
1102
1142
|
target: buildTargetConfig(config),
|
|
1103
1143
|
systemPrompt,
|
|
1104
1144
|
preset: presetForScan,
|
|
1105
|
-
attacks
|
|
1106
|
-
multiTurnAttacks
|
|
1145
|
+
attacks,
|
|
1146
|
+
multiTurnAttacks,
|
|
1107
1147
|
includeCrescendo,
|
|
1108
1148
|
customTests: config.customTests,
|
|
1109
1149
|
concurrency: config.concurrency,
|
|
@@ -1389,7 +1429,7 @@ process.on("uncaughtException", (err) => {
|
|
|
1389
1429
|
});
|
|
1390
1430
|
var program = new Command();
|
|
1391
1431
|
program.exitOverride();
|
|
1392
|
-
program.name("shield-llm").description("AI chatbot security scanner \u2014 automated red teaming for LLMs").version("0.2.
|
|
1432
|
+
program.name("shield-llm").description("AI chatbot security scanner \u2014 automated red teaming for LLMs").version("0.2.2");
|
|
1393
1433
|
program.command("scan").description("Run a security scan against a target chatbot").option("-c, --config <path>", "Path to shield.config.json").option("-p, --provider <name>", "Target provider (openai, mistral)").option("-m, --model <name>", "Target model name").option("-e, --endpoint <url>", "Target chatbot HTTP endpoint URL").option("--auth <type>", "Auth type: bearer, api-key, oauth2").option("--token <value>", "Bearer token or API key value").option("--auth-header <name>", "Custom auth header name (for api-key auth)").option(
|
|
1394
1434
|
"--response-field <path>",
|
|
1395
1435
|
"Dot-notation path to response text in JSON (default: response)"
|
|
@@ -1408,6 +1448,9 @@ program.command("scan").description("Run a security scan against a target chatbo
|
|
|
1408
1448
|
).option(
|
|
1409
1449
|
"--load-custom-tests",
|
|
1410
1450
|
"Fetch custom tests from your Shield LLM dashboard"
|
|
1451
|
+
).option(
|
|
1452
|
+
"--custom-only",
|
|
1453
|
+
"Run ONLY custom tests \u2014 send no preset attack payloads to the target"
|
|
1411
1454
|
).option("--eu-ai-act", "Show EU AI Act compliance assessment after scan").option(
|
|
1412
1455
|
"--compliance-threshold <n>",
|
|
1413
1456
|
"Minimum compliance score (0-100)",
|