prompt-injection-bench 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 prompt-injection-bench contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # prompt-injection-bench
2
+
3
+ [![npm version](https://img.shields.io/npm/v/prompt-injection-bench.svg)](https://www.npmjs.com/package/prompt-injection-bench)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/reaatech/prompt-injection-bench/blob/main/LICENSE)
5
+ [![CI](https://img.shields.io/github/actions/workflow/status/reaatech/prompt-injection-bench/ci.yml?branch=main&label=CI)](https://github.com/reaatech/prompt-injection-bench/actions/workflows/ci.yml)
6
+
7
+ > **Status:** Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.
8
+
9
+ Umbrella package and CLI for the prompt-injection-bench suite. Re-exports the full public API from all `@reaatech/pi-bench-*` packages and provides the `prompt-injection-bench` CLI for running benchmarks from the command line.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install prompt-injection-bench
15
+ # or
16
+ pnpm add prompt-injection-bench
17
+ ```
18
+
19
+ ```bash
20
+ # Global install for CLI usage
21
+ npm install -g prompt-injection-bench
22
+ ```
23
+
24
+ ## Feature Overview
25
+
26
+ - **Full API re-export** — Single import for all `@reaatech/pi-bench-*` packages
27
+ - **CLI tool** — `prompt-injection-bench` command with 6 subcommands
28
+ - **9 adapters** — All defense adapters available via `--defense` flag
29
+ - **Dual ESM/CJS output** — works with `import` and `require`
30
+
31
+ ## CLI Quick Start
32
+
33
+ ```bash
34
+ # Run a benchmark with the mock adapter
35
+ prompt-injection-bench benchmark --defense mock
36
+
37
+ # Compare two defense results
38
+ prompt-injection-bench compare --results rebuff.json lakera.json
39
+
40
+ # View leaderboard
41
+ prompt-injection-bench leaderboard view
42
+
43
+ # Generate an HTML report
44
+ prompt-injection-bench report --results latest.json --format html --output report.html
45
+ ```
46
+
47
+ ## CLI Commands
48
+
49
+ ### `benchmark`
50
+
51
+ Run a full benchmark against a defense adapter:
52
+
53
+ ```bash
54
+ prompt-injection-bench benchmark \
55
+ --defense rebuff \
56
+ --corpus default \
57
+ --categories direct-injection,role-playing \
58
+ --parallel 10 \
59
+ --timeout 30000 \
60
+ --output results/benchmark.json
61
+ ```
62
+
63
+ | Flag | Description |
64
+ |------|-------------|
65
+ | `--defense` | Defense adapter name (mock, rebuff, lakera, llm-guard, garak, moderation-openai, etc.) |
66
+ | `--corpus` | Corpus source: `default` or path to corpus directory |
67
+ | `--categories` | Comma-separated attack categories (default: all) |
68
+ | `--parallel` | Max parallel attack executions (default: 10) |
69
+ | `--timeout` | Per-attack timeout in ms (default: 30000) |
70
+ | `--output` | JSON output file path |
71
+
72
+ ### `attack`
73
+
74
+ Run attacks from a single category:
75
+
76
+ ```bash
77
+ prompt-injection-bench attack \
78
+ --category direct-injection \
79
+ --defense mock \
80
+ --count 100
81
+ ```
82
+
83
+ ### `compare`
84
+
85
+ Compare two defense result files:
86
+
87
+ ```bash
88
+ prompt-injection-bench compare \
89
+ --results results/rebuff.json results/lakera.json \
90
+ --significance 0.05
91
+ ```
92
+
93
+ ### `corpus`
94
+
95
+ Manage attack corpora:
96
+
97
+ ```bash
98
+ # List available categories
99
+ prompt-injection-bench corpus list
100
+
101
+ # Generate a new corpus
102
+ prompt-injection-bench corpus generate --output corpus/v2026.05
103
+
104
+ # Validate an existing corpus
105
+ prompt-injection-bench corpus validate --input corpus/v2026.04
106
+
107
+ # Export corpus to JSON
108
+ prompt-injection-bench corpus export --input corpus/v2026.04 --format json
109
+ ```
110
+
111
+ ### `leaderboard`
112
+
113
+ View and manage the leaderboard:
114
+
115
+ ```bash
116
+ prompt-injection-bench leaderboard view
117
+ prompt-injection-bench leaderboard submit \
118
+ --results results/latest.json \
119
+ --defense my-defense \
120
+ --version 1.0.0
121
+ ```
122
+
123
+ ### `report`
124
+
125
+ Generate reports from benchmark results:
126
+
127
+ ```bash
128
+ prompt-injection-bench report \
129
+ --results results/latest.json \
130
+ --format html \
131
+ --output reports/benchmark.html
132
+ ```
133
+
134
+ Supported formats: `json`, `html`, `markdown`.
135
+
136
+ ## Library Quick Start
137
+
138
+ ```typescript
139
+ import { createBenchmarkEngine, createMockAdapter, generateDefaultCorpus } from "prompt-injection-bench";
140
+
141
+ const adapter = createMockAdapter(0.95, 0.03);
142
+ const corpus = generateDefaultCorpus();
143
+ const engine = createBenchmarkEngine({ defense: adapter });
144
+
145
+ const result = await engine.runBenchmark(corpus);
146
+ console.log(`Detection rate: ${(result.attackResults.filter(r => r.detected).length / result.attackResults.length * 100).toFixed(1)}%`);
147
+ ```
148
+
149
+ ## Re-exported Packages
150
+
151
+ | Package | Description |
152
+ |---------|-------------|
153
+ | `@reaatech/pi-bench-core` | Core types, taxonomy, Zod schemas |
154
+ | `@reaatech/pi-bench-observability` | Logging, tracing, and metrics |
155
+ | `@reaatech/pi-bench-corpus` | Corpus builder, validator, template engine |
156
+ | `@reaatech/pi-bench-adapters` | Defense adapter implementations |
157
+ | `@reaatech/pi-bench-scoring` | Scoring engine and statistical analysis |
158
+ | `@reaatech/pi-bench-runner` | Benchmark execution engine |
159
+ | `@reaatech/pi-bench-leaderboard` | Leaderboard management |
160
+ | `@reaatech/pi-bench-mcp-server` | MCP server and reproducibility tools |
161
+
162
+ ## Related Packages
163
+
164
+ Each package can also be installed individually:
165
+
166
+ ```bash
167
+ pnpm add @reaatech/pi-bench-core
168
+ pnpm add @reaatech/pi-bench-adapters
169
+ pnpm add @reaatech/pi-bench-scoring
170
+ ```
171
+
172
+ ## License
173
+
174
+ [MIT](https://github.com/reaatech/prompt-injection-bench/blob/main/LICENSE)