shield-llm 0.2.1 → 0.3.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 +7 -4
- package/dist/{chunk-LH6W4P2C.js → chunk-LR2LXQEB.js} +5 -15
- package/dist/cli.js +37 -31
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,8 +76,9 @@ shield-llm scan --preset owasp
|
|
|
76
76
|
|---------|-------------|
|
|
77
77
|
| `scan` | Run a security scan against a target chatbot |
|
|
78
78
|
| `init` | Interactive wizard → generates `shield.config.json` |
|
|
79
|
+
| `test-connection` | Send one benign message to check your config works (no attacks) |
|
|
79
80
|
| `login` / `logout` | Manage your API key credentials |
|
|
80
|
-
| `attacks` |
|
|
81
|
+
| `attacks` | Show the attack catalogue summary for your plan (counts, from your backend) |
|
|
81
82
|
| `presets` | List available scan presets |
|
|
82
83
|
| `tests` | List custom tests (local config and/or `--remote`) |
|
|
83
84
|
| `validate` | Validate a `shield.config.json` without scanning |
|
|
@@ -87,9 +88,9 @@ shield-llm scan --preset owasp
|
|
|
87
88
|
|
|
88
89
|
| Preset | Scope |
|
|
89
90
|
|--------|-------|
|
|
90
|
-
| `dev` |
|
|
91
|
-
| `quick` |
|
|
92
|
-
| `owasp` |
|
|
91
|
+
| `dev` | quick smoke test |
|
|
92
|
+
| `quick` | fast triage |
|
|
93
|
+
| `owasp` | one test per OWASP LLM Top 10 category |
|
|
93
94
|
| `standard` | broad coverage |
|
|
94
95
|
| `full` | full catalogue + multi-turn (crescendo / memory) attacks |
|
|
95
96
|
|
|
@@ -103,12 +104,14 @@ Available presets depend on your plan; the backend filters them.
|
|
|
103
104
|
--system-prompt <text> give the target's system prompt for context
|
|
104
105
|
--crescendo include multi-turn attacks
|
|
105
106
|
--load-custom-tests also run your dashboard's custom tests
|
|
107
|
+
--custom-only run ONLY your custom tests (no preset attacks)
|
|
106
108
|
--eu-ai-act print an EU AI Act compliance summary
|
|
107
109
|
-o, --output <format> json | markdown | sarif | pdf
|
|
108
110
|
--output-file <path> write the report to a file
|
|
109
111
|
--min-score <n> fail if score < n
|
|
110
112
|
--fail-on-critical fail if any CRITICAL finding
|
|
111
113
|
--ci JSON to stdout, no spinner (logs to stderr)
|
|
114
|
+
--include-full-payloads keep full chatbot responses in the JSON (default: truncated)
|
|
112
115
|
```
|
|
113
116
|
|
|
114
117
|
## CI/CD
|
|
@@ -23414,11 +23414,9 @@ var OutputSchema = z29.object({
|
|
|
23414
23414
|
|
|
23415
23415
|
// src/config/schema.ts
|
|
23416
23416
|
var ConfigSchema = z30.object({
|
|
23417
|
-
/**
|
|
23418
|
-
|
|
23419
|
-
/**
|
|
23420
|
-
endpoint: EndpointConfigSchema.optional(),
|
|
23421
|
-
/** Judge LLM provider (always LLM-based) */
|
|
23417
|
+
/** HTTP endpoint mode (URL + auth + template) — the only target mode */
|
|
23418
|
+
endpoint: EndpointConfigSchema,
|
|
23419
|
+
/** Judge LLM provider (judging is server-side; kept for display/compat) */
|
|
23422
23420
|
judge: ProviderConfigSchema.optional(),
|
|
23423
23421
|
systemPrompt: z30.string().optional(),
|
|
23424
23422
|
preset: z30.enum(["dev", "quick", "owasp", "standard", "full"]).optional(),
|
|
@@ -23430,8 +23428,6 @@ var ConfigSchema = z30.object({
|
|
|
23430
23428
|
maxConsecutiveFailures: z30.number().int().min(1).optional(),
|
|
23431
23429
|
thresholds: ThresholdSchema.optional(),
|
|
23432
23430
|
output: OutputSchema.optional()
|
|
23433
|
-
}).refine((data) => data.target || data.endpoint, {
|
|
23434
|
-
message: "Either 'target' (LLM provider) or 'endpoint' (HTTP URL) must be specified"
|
|
23435
23431
|
});
|
|
23436
23432
|
|
|
23437
23433
|
// src/config/loader.ts
|
|
@@ -23466,15 +23462,9 @@ ${issues}`);
|
|
|
23466
23462
|
return result.data;
|
|
23467
23463
|
}
|
|
23468
23464
|
function buildTargetConfig(config) {
|
|
23469
|
-
if (config.endpoint) {
|
|
23470
|
-
return {
|
|
23471
|
-
mode: "endpoint",
|
|
23472
|
-
...config.endpoint
|
|
23473
|
-
};
|
|
23474
|
-
}
|
|
23475
23465
|
return {
|
|
23476
|
-
mode: "
|
|
23477
|
-
...config.
|
|
23466
|
+
mode: "endpoint",
|
|
23467
|
+
...config.endpoint
|
|
23478
23468
|
};
|
|
23479
23469
|
}
|
|
23480
23470
|
function loadSystemPrompt(config) {
|
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
generatePdf,
|
|
18
18
|
loadConfig,
|
|
19
19
|
loadSystemPrompt
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-LR2LXQEB.js";
|
|
21
21
|
import "./chunk-7D5WVZW5.js";
|
|
22
22
|
|
|
23
23
|
// src/cli.ts
|
|
@@ -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
|
|
@@ -1036,11 +1058,6 @@ async function scanCommand(opts) {
|
|
|
1036
1058
|
field: opts.responseField ?? "response"
|
|
1037
1059
|
}
|
|
1038
1060
|
};
|
|
1039
|
-
} else if (opts.provider || opts.model) {
|
|
1040
|
-
cliOverrides.target = {
|
|
1041
|
-
provider: opts.provider,
|
|
1042
|
-
model: opts.model
|
|
1043
|
-
};
|
|
1044
1061
|
}
|
|
1045
1062
|
if (opts.preset) cliOverrides.preset = opts.preset;
|
|
1046
1063
|
if (opts.systemPrompt) cliOverrides.systemPrompt = opts.systemPrompt;
|
|
@@ -1355,20 +1372,9 @@ function validateCommand(opts) {
|
|
|
1355
1372
|
try {
|
|
1356
1373
|
const config = loadConfig({ configPath: opts.config });
|
|
1357
1374
|
console.log("Configuration is valid.");
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
console.log(` Auth: ${config.endpoint.auth?.type ?? "none"}`);
|
|
1362
|
-
console.log(` Response field: ${config.endpoint.response.field}`);
|
|
1363
|
-
} else {
|
|
1364
|
-
console.log(` Mode: LLM Provider`);
|
|
1365
|
-
console.log(
|
|
1366
|
-
` Target: ${config.target.provider}/${config.target.model ?? "default"}`
|
|
1367
|
-
);
|
|
1368
|
-
}
|
|
1369
|
-
console.log(
|
|
1370
|
-
` Judge: ${config.judge?.provider ?? "mistral"}/${config.judge?.model ?? "mistral-small-latest"}`
|
|
1371
|
-
);
|
|
1375
|
+
console.log(` Target: ${config.endpoint.url}`);
|
|
1376
|
+
console.log(` Auth: ${config.endpoint.auth?.type ?? "none"}`);
|
|
1377
|
+
console.log(` Response field: ${config.endpoint.response.field}`);
|
|
1372
1378
|
console.log(` Preset: ${config.preset ?? "standard"}`);
|
|
1373
1379
|
if (config.customTests?.length) {
|
|
1374
1380
|
console.log(` Custom tests: ${config.customTests.length}`);
|
|
@@ -1407,8 +1413,8 @@ process.on("uncaughtException", (err) => {
|
|
|
1407
1413
|
});
|
|
1408
1414
|
var program = new Command();
|
|
1409
1415
|
program.exitOverride();
|
|
1410
|
-
program.name("shield-llm").description("AI chatbot security scanner \u2014 automated red teaming for LLMs").version("0.
|
|
1411
|
-
program.command("scan").description("Run a security scan against a target chatbot").option("-c, --config <path>", "Path to shield.config.json").option("-
|
|
1416
|
+
program.name("shield-llm").description("AI chatbot security scanner \u2014 automated red teaming for LLMs").version("0.3.0");
|
|
1417
|
+
program.command("scan").description("Run a security scan against a target chatbot").option("-c, --config <path>", "Path to shield.config.json").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(
|
|
1412
1418
|
"--response-field <path>",
|
|
1413
1419
|
"Dot-notation path to response text in JSON (default: response)"
|
|
1414
1420
|
).option(
|
package/dist/index.js
CHANGED