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
use clap::Subcommand;
#[derive(Debug, Subcommand)]
pub enum SearchAction {
/// Run an ES|QL query
Esql {
/// The ES|QL query text
query: String,
/// Resolve a Kibana data view to an index pattern
#[arg(long, conflicts_with = "index")]
data_view: Option<String>,
/// Explicit index or alias, overrides the query's own source
#[arg(long, conflicts_with = "data_view")]
index: Option<String>,
/// Cap the number of result rows
#[arg(long)]
limit: Option<usize>,
},
/// Run a Query DSL search body
Dsl {
/// JSON body or @path
body: String,
/// Resolve a Kibana data view to an index pattern
#[arg(long, conflicts_with = "index")]
data_view: Option<String>,
/// Explicit index or alias
#[arg(long, conflicts_with = "data_view")]
index: Option<String>,
/// Cap the number of result rows
#[arg(long)]
limit: Option<usize>,
/// Add `_id`, `_index`, and `_score` to each rendered row
#[arg(long)]
with_meta: bool,
},
}
#[derive(Debug, Subcommand)]
pub enum AlertsAction {
/// List detection alerts
List {
/// Filter by workflow status
#[arg(long, value_parser = ["open", "acknowledged", "closed"])]
status: Option<String>,
/// Filter by severity
#[arg(long)]
severity: Option<String>,
/// Filter by rule name or rule_id
#[arg(long)]
rule: Option<String>,
/// Filter by workflow tag
#[arg(long)]
tag: Option<String>,
/// Filter by assignee username, or uid:<profile_uid>
#[arg(long)]
assignee: Option<String>,
/// Only alerts newer than a duration (90m, 24h, 7d) or an ISO timestamp
#[arg(long)]
since: Option<String>,
/// Substring match on the rule name and reason text
#[arg(long)]
search: Option<String>,
/// Cap the rows returned (peek default: 100; --out is uncapped)
#[arg(long)]
limit: Option<usize>,
/// Merge _id into each alert document
#[arg(long)]
with_meta: bool,
},
/// Show one alert by document id
Get {
/// The alert document _id
alert_id: String,
},
/// Acknowledge alerts, by id or by query
Ack {
/// Alert document ids
#[arg(conflicts_with = "query", required_unless_present = "query")]
alert_ids: Vec<String>,
/// Query DSL selecting the alerts: inline JSON or @file
#[arg(long)]
query: Option<String>,
},
/// Reopen alerts, by id or by query
Open {
/// Alert document ids
#[arg(conflicts_with = "query", required_unless_present = "query")]
alert_ids: Vec<String>,
/// Query DSL selecting the alerts: inline JSON or @file
#[arg(long)]
query: Option<String>,
},
/// Close alerts, by id or by query
Close {
/// Alert document ids
#[arg(conflicts_with = "query", required_unless_present = "query")]
alert_ids: Vec<String>,
/// Query DSL selecting the alerts: inline JSON or @file
#[arg(long)]
query: Option<String>,
/// Close reason recorded on each alert
#[arg(long)]
reason: Option<String>,
/// On a version conflict: abort (default) or proceed
#[arg(long, value_parser = ["abort", "proceed"])]
conflicts: Option<String>,
},
/// Add or remove workflow tags on alerts
Tag {
/// Alert document ids
#[arg(required = true)]
alert_ids: Vec<String>,
/// Tag to add (repeatable)
#[arg(long)]
add: Vec<String>,
/// Tag to remove (repeatable)
#[arg(long)]
remove: Vec<String>,
},
/// Assign or unassign users on alerts
Assign {
/// Alert document ids
#[arg(required = true)]
alert_ids: Vec<String>,
/// Username or uid:<profile_uid> to assign (repeatable)
#[arg(long)]
add: Vec<String>,
/// Username or uid:<profile_uid> to unassign (repeatable)
#[arg(long)]
remove: Vec<String>,
},
}
#[derive(Debug, Subcommand)]
pub enum CasesAction {
/// List cases
List {
/// Filter by status
#[arg(long, value_parser = ["open", "in-progress", "closed"])]
status: Option<String>,
/// Filter by severity
#[arg(long)]
severity: Option<String>,
/// Filter by tag
#[arg(long)]
tag: Option<String>,
/// Substring match on title and description
#[arg(long)]
search: Option<String>,
/// Cap the rows returned (peek default: 100; --out is uncapped)
#[arg(long)]
limit: Option<usize>,
},
/// Show one case in full
Get {
/// The case id
case_id: String,
},
/// Create a case
Create {
/// The case title
#[arg(long)]
title: String,
/// The case description (defaults to the title)
#[arg(long)]
description: Option<String>,
/// Tag to set (repeatable)
#[arg(long)]
tag: Vec<String>,
/// Case severity
#[arg(long)]
severity: Option<String>,
/// Username or uid:<profile_uid> to assign (repeatable)
#[arg(long)]
assignee: Vec<String>,
},
/// Close cases
Close {
/// Case ids
#[arg(required = true)]
case_ids: Vec<String>,
},
/// Reopen cases
Open {
/// Case ids
#[arg(required = true)]
case_ids: Vec<String>,
},
/// Delete cases permanently
Delete {
/// Case ids
#[arg(required = true)]
case_ids: Vec<String>,
},
/// Attach alerts to a case
Attach {
/// The case id
case_id: String,
/// Alert document id to attach (repeatable)
#[arg(long, required = true)]
alert: Vec<String>,
},
/// Add a comment to a case
Comment {
/// The case id
case_id: String,
/// The comment text
#[arg(long)]
message: String,
},
}