shield-llm 0.1.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 ADDED
@@ -0,0 +1,127 @@
1
+ # shield-llm
2
+
3
+ **Automated red teaming for AI chatbots — from your terminal.**
4
+
5
+ `shield-llm` scans a chatbot (any HTTP endpoint, or an LLM provider directly)
6
+ against a catalogue of prompt-injection, jailbreak, data-extraction, excessive-
7
+ agency, RAG, supply-chain and multi-turn attacks mapped to the **OWASP LLM Top
8
+ 10 (2025)**. It produces a security score, a letter grade, and reports in JSON,
9
+ Markdown, SARIF, or PDF — ready for CI/CD.
10
+
11
+ ## How it works (thin client)
12
+
13
+ The CLI is a thin client. It authenticates against a Shield LLM backend, pulls
14
+ the plan-filtered attack catalogue, sends each attack prompt to **your** target
15
+ chatbot, and posts the responses back to the backend, which runs an LLM judge
16
+ and scores them. The CLI itself contains no attack payloads and no scoring
17
+ logic — so adding new attacks server-side reaches every install instantly, with
18
+ no upgrade.
19
+
20
+ > A backend connection is required. Two modes, same binary:
21
+ > - **SaaS** — `https://shield-llm.com` (default)
22
+ > - **License / self-hosted** — your own instance via `--api-url`
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ npm install -g shield-llm
28
+ # or run once without installing:
29
+ npx shield-llm --help
30
+ ```
31
+
32
+ Requires Node.js >= 22. PDF reports need Puppeteer (installed automatically as
33
+ an optional dependency; set `PUPPETEER_EXECUTABLE_PATH` to use a system Chrome).
34
+
35
+ ## Quick start
36
+
37
+ ```bash
38
+ # 1. Authenticate with your API key (create one in your dashboard → Settings)
39
+ shield-llm login --key sk_shield_xxxxxxxx
40
+ # self-hosted:
41
+ shield-llm login --key <license-key> --api-url https://shield.your-corp.com
42
+
43
+ # 2. Generate a config for your chatbot endpoint (interactive)
44
+ shield-llm init
45
+
46
+ # 3. Scan
47
+ shield-llm scan --preset owasp
48
+ ```
49
+
50
+ ## Configuration
51
+
52
+ `shield-llm init` writes a `shield.config.json` describing your endpoint:
53
+
54
+ ```json
55
+ {
56
+ "endpoint": {
57
+ "url": "https://api.example.com/chat",
58
+ "request": { "method": "POST", "body": { "message": "{{prompt}}" } },
59
+ "response": { "field": "data.reply" }
60
+ },
61
+ "preset": "standard"
62
+ }
63
+ ```
64
+
65
+ - `{{prompt}}` is replaced with each attack. `{{history}}` is available for
66
+ multi-turn.
67
+ - `response.field` is a dot-path into the JSON response (e.g.
68
+ `choices[0].message.content`). SSE streams are auto-detected.
69
+ - Auth: `bearer`, `api-key`, or `oauth2` (use `$ENV_VAR` to read secrets from
70
+ the environment instead of hard-coding them).
71
+ - CLI flags override config values.
72
+
73
+ ## Commands
74
+
75
+ | Command | Description |
76
+ |---------|-------------|
77
+ | `scan` | Run a security scan against a target chatbot |
78
+ | `init` | Interactive wizard → generates `shield.config.json` |
79
+ | `login` / `logout` | Manage your API key credentials |
80
+ | `attacks` | List the live attack catalogue (from your backend) |
81
+ | `presets` | List available scan presets |
82
+ | `tests` | List custom tests (local config and/or `--remote`) |
83
+ | `validate` | Validate a `shield.config.json` without scanning |
84
+ | `report <scanId>` | Fetch a past scan from your dashboard |
85
+
86
+ ## Presets
87
+
88
+ | Preset | Scope |
89
+ |--------|-------|
90
+ | `dev` | 3 tests — smoke test |
91
+ | `quick` | 7 tests — fast triage |
92
+ | `owasp` | 1 test per OWASP LLM Top 10 category |
93
+ | `standard` | broad coverage |
94
+ | `full` | full catalogue + multi-turn (crescendo / memory) attacks |
95
+
96
+ Available presets depend on your plan; the backend filters them.
97
+
98
+ ## Key scan flags
99
+
100
+ ```
101
+ --preset <name> dev | quick | owasp | standard | full
102
+ --endpoint <url> target URL (overrides config)
103
+ --system-prompt <text> give the target's system prompt for context
104
+ --crescendo include multi-turn attacks
105
+ --load-custom-tests also run your dashboard's custom tests
106
+ --eu-ai-act print an EU AI Act compliance summary
107
+ -o, --output <format> json | markdown | sarif | pdf
108
+ --output-file <path> write the report to a file
109
+ --min-score <n> fail if score < n
110
+ --fail-on-critical fail if any CRITICAL finding
111
+ --ci JSON to stdout, no spinner (logs to stderr)
112
+ ```
113
+
114
+ ## CI/CD
115
+
116
+ ```bash
117
+ shield-llm scan --ci --min-score 80 --fail-on-critical \
118
+ --output sarif --output-file shield.sarif
119
+ ```
120
+
121
+ Exit codes: `0` passed · `1` threshold violation · `2` config/auth error ·
122
+ `3` runtime/network error. Upload the SARIF to GitHub's Security tab, or use
123
+ `--write-json` to emit a parseable copy alongside any other format.
124
+
125
+ ## License
126
+
127
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/cli.js";