1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
//! Command-line interface definition (clap).
use std::path::PathBuf;
use clap::{Parser, Subcommand};
/// Killer — a Rust security platform: scan code, run `.klr` attacks, and gate CI.
#[derive(Debug, Parser)]
#[command(
name = "killer",
version,
about = "A Rust security platform — scan code, run .klr attacks, review diffs, and gate CI.",
long_about = "Killer analyzes a project for vulnerabilities, runs adversarial .klr tests \
against a live service, tracks a security score over time, reviews git diffs, and \
provides a single CI gate.",
after_help = "EXAMPLES:\n \
killer scan . Static analysis with a 0-100 score\n \
killer test --suite web --url URL Run a built-in attack suite\n \
killer review --base origin/main Review the lines a change touched\n \
killer ci Full gate for CI (scan + rules + review)\n\n\
Docs: https://github.com/martin-k-m/killer/tree/main/docs",
propagate_version = true
)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
/// Scan a project directory and print an analysis report.
Scan {
/// Path to the project to scan (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Suppress the report body and print only the summary line.
#[arg(long)]
quiet: bool,
/// Exit with a non-zero status if any critical/high issues are found.
#[arg(long)]
fail_on_issues: bool,
/// Do not record a snapshot in the project intelligence history.
#[arg(long)]
no_record: bool,
},
/// Run `.klr` attack scripts against a target and report vulnerabilities.
Test {
/// A `.klr` file or a directory of them. Defaults to the `[klr]
/// directory` from config, or the current directory.
path: Option<PathBuf>,
/// Run a built-in suite instead of files (e.g. `--suite web`).
#[arg(long)]
suite: Option<String>,
/// Base URL that relative attack targets resolve against.
#[arg(long)]
url: Option<String>,
/// Also run any static `.klr` rules against this project directory.
#[arg(long, default_value = ".")]
project: PathBuf,
/// Number of worker threads for parallel execution (0/absent = auto).
#[arg(long, num_args = 0..=1, default_missing_value = "0")]
parallel: Option<usize>,
/// Output format: `terminal` (default) or `json`.
#[arg(long, default_value = "terminal")]
format: String,
/// Do not write results to `.killer/results/`.
#[arg(long)]
no_save: bool,
/// Exit non-zero if any vulnerability is found.
#[arg(long)]
fail_on_issues: bool,
},
/// Generate adversarial inputs and (optionally) fire them at a target.
///
/// Surfaces the same fuzz generators the `.klr` `mutate` construct uses.
/// Without `--url` it just prints the inputs it would send.
Fuzz {
/// List the available generators and exit.
#[arg(long)]
list: bool,
/// The request field to mutate (fuzz values are sent as this key).
#[arg(long, default_value = "input")]
field: String,
/// Comma-separated generator names (default: all of them).
#[arg(long)]
generators: Option<String>,
/// Absolute or relative target URL. Relative targets resolve against
/// the configured `base_url`. Without this, inputs are only printed.
#[arg(long)]
url: Option<String>,
/// HTTP method to use when a target is set.
#[arg(long, default_value = "POST")]
method: String,
/// Project directory used to resolve config/`base_url` (default: `.`).
#[arg(long, default_value = ".")]
project: PathBuf,
/// Exit non-zero if any input triggers a fault or an unreachable target.
#[arg(long)]
fail_on_issues: bool,
},
/// Render a report from the latest saved test results.
Report {
/// Project directory (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Write a self-contained HTML report instead of terminal output.
#[arg(long, group = "format")]
html: bool,
/// Output path for the HTML report.
#[arg(long, default_value = "killer-report.html")]
out: PathBuf,
/// High-level summary: score, risk, headline findings, recommendations.
#[arg(long, group = "format")]
executive: bool,
/// Detailed report: evidence, severity, and remediation per finding.
#[arg(long, group = "format")]
technical: bool,
/// Emit the raw results as JSON.
#[arg(long, group = "format")]
json: bool,
/// Emit a Markdown report (for PR comments, wikis, …).
#[arg(long, group = "format")]
markdown: bool,
},
/// Analyze the project's declared dependencies across ecosystems.
Dependencies {
/// Project directory (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// List every dependency, not just the summary and warnings.
#[arg(long)]
details: bool,
/// Emit the analysis as JSON.
#[arg(long)]
json: bool,
},
/// Map detected findings to OWASP Top 10 and CWE references.
///
/// This is a local mapping of what Killer detects — not a certification audit.
Compliance {
/// Project directory (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Emit the compliance report as JSON.
#[arg(long)]
json: bool,
},
/// Build a structural graph of the project (files, imports, dependencies).
Graph {
/// Project directory to graph (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Emit the graph as JSON instead of a terminal summary.
#[arg(long)]
json: bool,
},
/// Benchmark scan performance over a project.
Benchmark {
/// Project directory to benchmark (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Number of scan iterations to time.
#[arg(long, default_value = "5")]
runs: usize,
},
/// Watch source files and re-scan whenever they change.
Watch {
/// Project directory to watch (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Seconds between checks for changes.
#[arg(long, default_value = "2")]
interval: u64,
},
/// Explain a security issue id, e.g. `killer explain KLR-SQLI`.
Explain {
/// The issue id to explain.
issue_id: String,
},
/// Show the recorded security-score history and trend for a project.
History {
/// Project directory (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
},
/// Review the lines changed in the working tree (or a diff range).
Review {
/// Project directory (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Review only staged changes.
#[arg(long)]
staged: bool,
/// Diff against this base ref (e.g. `origin/main`).
#[arg(long)]
base: Option<String>,
/// Exit non-zero if any blocking (critical/high) issue is found.
#[arg(long)]
fail_on_issues: bool,
},
/// Run the full CI gate: scan + `.klr` tests + review of the diff.
Ci {
/// Project directory (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Diff base ref for the review step (e.g. `origin/main`).
#[arg(long)]
base: Option<String>,
},
/// Manage GitHub integration (generate a CI workflow).
Github {
#[command(subcommand)]
action: GithubAction,
},
/// Create a default `.killer.toml` configuration file.
Init {
/// Directory to write the config into (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Overwrite an existing config file.
#[arg(long)]
force: bool,
/// Also scaffold a `security-tests/` directory with a starter `.klr`
/// file so you can run `killer test` right away.
#[arg(long)]
scaffold: bool,
},
/// Diagnose a project's Killer setup and environment.
Doctor {
/// Project directory (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Repair what can be fixed automatically (e.g. create a config).
#[arg(long)]
fix: bool,
},
/// Print version and build information.
Version,
}
/// Actions for `killer github`.
#[derive(Debug, Subcommand)]
pub enum GithubAction {
/// Write a GitHub Actions workflow that runs the Killer gate.
Enable {
/// Repository root (defaults to the current directory).
#[arg(default_value = ".")]
path: PathBuf,
/// Overwrite an existing workflow file.
#[arg(long)]
force: bool,
},
}