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
//! 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,
},
/// 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)]
html: bool,
/// Output path for the HTML report.
#[arg(long, default_value = "killer-report.html")]
out: PathBuf,
},
/// 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,
},
/// 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,
},
}