@agenttrail/guardrails 0.2.2 → 0.2.3
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 +22 -9
- package/dist/{chunk-GNN4TGRY.js → chunk-IQHM6BLL.js} +78 -4
- package/dist/chunk-IQHM6BLL.js.map +1 -0
- package/dist/chunk-LO4OCVQN.js +72 -0
- package/dist/chunk-LO4OCVQN.js.map +1 -0
- package/dist/{chunk-FTTMZCDH.js → chunk-UORFMSG4.js} +62 -1
- package/dist/chunk-UORFMSG4.js.map +1 -0
- package/dist/guardrails.cjs +146 -3
- package/dist/guardrails.cjs.map +1 -1
- package/dist/guardrails.d.cts +6 -6
- package/dist/guardrails.d.ts +6 -6
- package/dist/guardrails.js +17 -1
- package/dist/index.cjs +202 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -2
- package/dist/schema-BRdYtWjP.d.cts +951 -0
- package/dist/schema-BRdYtWjP.d.ts +951 -0
- package/dist/schema.cjs +88 -0
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +2 -892
- package/dist/schema.d.ts +2 -892
- package/dist/schema.js +4 -1
- package/package.json +1 -1
- package/dist/chunk-FTTMZCDH.js.map +0 -1
- package/dist/chunk-GNN4TGRY.js.map +0 -1
package/dist/schema.d.ts
CHANGED
|
@@ -1,892 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The guardrails rule format — self-contained, and deliberately so.
|
|
5
|
-
*
|
|
6
|
-
* This file defines the rule format and imports nothing but zod, so the package
|
|
7
|
-
* builds on its own. The condition and match shapes mirror the evaluator's rather
|
|
8
|
-
* than importing them; a change to either has to be made in both places.
|
|
9
|
-
*
|
|
10
|
-
* A rule carries `defaultAction` (what the guard does when it matches) and no
|
|
11
|
-
* `version`; the package version is the corpus version.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The five severities, in order, most→least severe.
|
|
16
|
-
*
|
|
17
|
-
* `info` earns its place: seven of the eleven packs default to `ask`/`warn`, and a
|
|
18
|
-
* warn-only rule labelled `low` overstates itself.
|
|
19
|
-
*
|
|
20
|
-
* Severity says how serious a match is. This package maps it to nothing else,
|
|
21
|
-
* including cost: the guard prints no currency.
|
|
22
|
-
*/
|
|
23
|
-
declare const SEVERITIES: readonly ["critical", "high", "medium", "low", "info"];
|
|
24
|
-
/** How dangerous the thing a rule catches is. An authoring signal, not a price. */
|
|
25
|
-
declare const SeveritySchema: z.ZodEnum<["critical", "high", "medium", "low", "info"]>;
|
|
26
|
-
/**
|
|
27
|
-
* What the guard does when a rule matches.
|
|
28
|
-
*
|
|
29
|
-
* The guard maps these onto Claude Code's `PreToolUse` verdicts:
|
|
30
|
-
* `block` → deny, `require_approval` → ask, `warn` → allow-but-recorded.
|
|
31
|
-
*/
|
|
32
|
-
declare const ACTIONS: readonly ["block", "require_approval", "warn"];
|
|
33
|
-
/** The action a rule takes by default, before any user override. */
|
|
34
|
-
declare const ActionSchema: z.ZodEnum<["block", "require_approval", "warn"]>;
|
|
35
|
-
/**
|
|
36
|
-
* Longest accepted `detail_matches` pattern. Long enough for any real rule; raised
|
|
37
|
-
* from 200 to fit the compound-command quoted-mention exemption, whose longest arm
|
|
38
|
-
* (a carrier wrapped in a bounded chain of read-only surrounding segments) is ~300.
|
|
39
|
-
* Kept in lockstep with the engine's own copy of this limit.
|
|
40
|
-
*/
|
|
41
|
-
declare const DETAIL_MATCHES_MAX_PATTERN_LENGTH = 320;
|
|
42
|
-
/** Most `detail_matches` patterns allowed on one condition (they are ORed). */
|
|
43
|
-
declare const DETAIL_MATCHES_MAX_PATTERNS = 10;
|
|
44
|
-
/**
|
|
45
|
-
* Reject a regex that can backtrack catastrophically, at PARSE time.
|
|
46
|
-
*
|
|
47
|
-
* Node has no regex timeout, so the only real bounds are a non-backtracking
|
|
48
|
-
* engine (RE2 — a runtime dependency deliberately not taken) or a syntactic
|
|
49
|
-
* restriction. This is the syntactic one: it rejects **star height >= 2**, an
|
|
50
|
-
* unbounded quantifier applied to a group that itself contains an unbounded
|
|
51
|
-
* quantifier — `(a+)+`, `(a*)*`, `(\s+x?)+` — the shape behind essentially every
|
|
52
|
-
* practical ReDoS.
|
|
53
|
-
*
|
|
54
|
-
* The guard's hook has a 10s Claude Code timeout, no internal watchdog, and it
|
|
55
|
-
* **fails open**: a pattern that backtracks does not merely make enforcement slow,
|
|
56
|
-
* it lets the action through. A slow rule in the guard is a disabled rule.
|
|
57
|
-
*
|
|
58
|
-
* HONEST LIMIT: this is a bound, not a proof. Star height 1 can still be
|
|
59
|
-
* quadratic (`(a|a)*`), which is slow but not exponential, and is acceptable
|
|
60
|
-
* against the length cap above. A hard guarantee needs RE2.
|
|
61
|
-
*
|
|
62
|
-
* @param source - The regex body (no delimiters, no flags).
|
|
63
|
-
* @returns `true` when the pattern nests unbounded quantifiers.
|
|
64
|
-
*/
|
|
65
|
-
declare function hasNestedUnboundedQuantifier(source: string): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* One condition matched against a tool call.
|
|
68
|
-
*
|
|
69
|
-
* - `kind`: required. The span kind, e.g. `execute_tool`. Case-insensitive.
|
|
70
|
-
* - `label`: optional. The tool name — a case-insensitive GLOB, so
|
|
71
|
-
* `mcp__chrome__*` and `{Bash,PowerShell}` are one condition rather than a
|
|
72
|
-
* list that rots. A plain label has no glob character and matches exactly.
|
|
73
|
-
* - `detail_contains`: optional. Substrings that must ALL appear (AND).
|
|
74
|
-
* **CASE-SENSITIVE**, and deliberately: `AKIA`, `ghp_`, `sk_live_` and the
|
|
75
|
-
* upper-case `TRUNCATE` arm are rules where case IS the signal. Author
|
|
76
|
-
* case-insensitive text matches with `detail_matches` instead.
|
|
77
|
-
* - `detail_matches`: optional. Regex patterns against the same text; at least
|
|
78
|
-
* one must match (OR, unlike `detail_contains`). Case-insensitive.
|
|
79
|
-
* - `file_glob`: optional. Case-insensitive glob against the file path.
|
|
80
|
-
*
|
|
81
|
-
* ── Two engine fields are deliberately absent ────────────────────────────────
|
|
82
|
-
*
|
|
83
|
-
* `numeric` is BANNED. At guard decision time `tokens`,
|
|
84
|
-
* `cachedTokens` and `durationMs` are all 0, because the action has not run yet.
|
|
85
|
-
* `gt` is therefore always false — the rule can never fire — and, worse, **`lt`
|
|
86
|
-
* is always true, so the rule fires on every single command.** Omitting the key
|
|
87
|
-
* from a `.strict()` object makes that a parse error rather than a lint finding.
|
|
88
|
-
*
|
|
89
|
-
* `scope` is BANNED for the same class of reason and is absent from the rule
|
|
90
|
-
* envelope below: `agent_in` compares literally against an agent id that is
|
|
91
|
-
* always a UUID, never the string `"claude-code"`, so a scoped rule matches
|
|
92
|
-
* nothing, forever, silently.
|
|
93
|
-
*
|
|
94
|
-
* ── The third ban needs an actual check ──────────────────────────────────────
|
|
95
|
-
*
|
|
96
|
-
* A command matcher (`detail_contains` / `detail_matches`) and a file matcher
|
|
97
|
-
* (`file_glob`) in ONE condition can never both be satisfied: the guard's mapper
|
|
98
|
-
* is an if/else chain, so no real tool call ever carries both a command and a
|
|
99
|
-
* file path. This schema refuses the combination.
|
|
100
|
-
*/
|
|
101
|
-
declare const MatchConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
102
|
-
kind: z.ZodString;
|
|
103
|
-
label: z.ZodOptional<z.ZodString>;
|
|
104
|
-
detail_contains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
105
|
-
detail_matches: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
106
|
-
file_glob: z.ZodOptional<z.ZodString>;
|
|
107
|
-
}, "strict", z.ZodTypeAny, {
|
|
108
|
-
kind: string;
|
|
109
|
-
label?: string | undefined;
|
|
110
|
-
detail_contains?: string[] | undefined;
|
|
111
|
-
detail_matches?: string[] | undefined;
|
|
112
|
-
file_glob?: string | undefined;
|
|
113
|
-
}, {
|
|
114
|
-
kind: string;
|
|
115
|
-
label?: string | undefined;
|
|
116
|
-
detail_contains?: string[] | undefined;
|
|
117
|
-
detail_matches?: string[] | undefined;
|
|
118
|
-
file_glob?: string | undefined;
|
|
119
|
-
}>, {
|
|
120
|
-
kind: string;
|
|
121
|
-
label?: string | undefined;
|
|
122
|
-
detail_contains?: string[] | undefined;
|
|
123
|
-
detail_matches?: string[] | undefined;
|
|
124
|
-
file_glob?: string | undefined;
|
|
125
|
-
}, {
|
|
126
|
-
kind: string;
|
|
127
|
-
label?: string | undefined;
|
|
128
|
-
detail_contains?: string[] | undefined;
|
|
129
|
-
detail_matches?: string[] | undefined;
|
|
130
|
-
file_glob?: string | undefined;
|
|
131
|
-
}>;
|
|
132
|
-
/**
|
|
133
|
-
* Match composition — conditions combined with `any_of` (OR), `all_of` (AND)
|
|
134
|
-
* and/or `none_of` (negation).
|
|
135
|
-
*
|
|
136
|
-
* At least one of `any_of` or `all_of` must be present. `none_of` is an optional
|
|
137
|
-
* refinement that CANNOT stand alone: a match must positively select calls
|
|
138
|
-
* before excluding some. A pure-negation match is satisfied by every
|
|
139
|
-
* non-matching call and, at `block`, would deny everything the agent does.
|
|
140
|
-
*/
|
|
141
|
-
declare const MatchSchema: z.ZodEffects<z.ZodObject<{
|
|
142
|
-
any_of: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
143
|
-
kind: z.ZodString;
|
|
144
|
-
label: z.ZodOptional<z.ZodString>;
|
|
145
|
-
detail_contains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
146
|
-
detail_matches: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
147
|
-
file_glob: z.ZodOptional<z.ZodString>;
|
|
148
|
-
}, "strict", z.ZodTypeAny, {
|
|
149
|
-
kind: string;
|
|
150
|
-
label?: string | undefined;
|
|
151
|
-
detail_contains?: string[] | undefined;
|
|
152
|
-
detail_matches?: string[] | undefined;
|
|
153
|
-
file_glob?: string | undefined;
|
|
154
|
-
}, {
|
|
155
|
-
kind: string;
|
|
156
|
-
label?: string | undefined;
|
|
157
|
-
detail_contains?: string[] | undefined;
|
|
158
|
-
detail_matches?: string[] | undefined;
|
|
159
|
-
file_glob?: string | undefined;
|
|
160
|
-
}>, {
|
|
161
|
-
kind: string;
|
|
162
|
-
label?: string | undefined;
|
|
163
|
-
detail_contains?: string[] | undefined;
|
|
164
|
-
detail_matches?: string[] | undefined;
|
|
165
|
-
file_glob?: string | undefined;
|
|
166
|
-
}, {
|
|
167
|
-
kind: string;
|
|
168
|
-
label?: string | undefined;
|
|
169
|
-
detail_contains?: string[] | undefined;
|
|
170
|
-
detail_matches?: string[] | undefined;
|
|
171
|
-
file_glob?: string | undefined;
|
|
172
|
-
}>, "many">>;
|
|
173
|
-
all_of: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
174
|
-
kind: z.ZodString;
|
|
175
|
-
label: z.ZodOptional<z.ZodString>;
|
|
176
|
-
detail_contains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
177
|
-
detail_matches: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
178
|
-
file_glob: z.ZodOptional<z.ZodString>;
|
|
179
|
-
}, "strict", z.ZodTypeAny, {
|
|
180
|
-
kind: string;
|
|
181
|
-
label?: string | undefined;
|
|
182
|
-
detail_contains?: string[] | undefined;
|
|
183
|
-
detail_matches?: string[] | undefined;
|
|
184
|
-
file_glob?: string | undefined;
|
|
185
|
-
}, {
|
|
186
|
-
kind: string;
|
|
187
|
-
label?: string | undefined;
|
|
188
|
-
detail_contains?: string[] | undefined;
|
|
189
|
-
detail_matches?: string[] | undefined;
|
|
190
|
-
file_glob?: string | undefined;
|
|
191
|
-
}>, {
|
|
192
|
-
kind: string;
|
|
193
|
-
label?: string | undefined;
|
|
194
|
-
detail_contains?: string[] | undefined;
|
|
195
|
-
detail_matches?: string[] | undefined;
|
|
196
|
-
file_glob?: string | undefined;
|
|
197
|
-
}, {
|
|
198
|
-
kind: string;
|
|
199
|
-
label?: string | undefined;
|
|
200
|
-
detail_contains?: string[] | undefined;
|
|
201
|
-
detail_matches?: string[] | undefined;
|
|
202
|
-
file_glob?: string | undefined;
|
|
203
|
-
}>, "many">>;
|
|
204
|
-
none_of: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
205
|
-
kind: z.ZodString;
|
|
206
|
-
label: z.ZodOptional<z.ZodString>;
|
|
207
|
-
detail_contains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
208
|
-
detail_matches: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
209
|
-
file_glob: z.ZodOptional<z.ZodString>;
|
|
210
|
-
}, "strict", z.ZodTypeAny, {
|
|
211
|
-
kind: string;
|
|
212
|
-
label?: string | undefined;
|
|
213
|
-
detail_contains?: string[] | undefined;
|
|
214
|
-
detail_matches?: string[] | undefined;
|
|
215
|
-
file_glob?: string | undefined;
|
|
216
|
-
}, {
|
|
217
|
-
kind: string;
|
|
218
|
-
label?: string | undefined;
|
|
219
|
-
detail_contains?: string[] | undefined;
|
|
220
|
-
detail_matches?: string[] | undefined;
|
|
221
|
-
file_glob?: string | undefined;
|
|
222
|
-
}>, {
|
|
223
|
-
kind: string;
|
|
224
|
-
label?: string | undefined;
|
|
225
|
-
detail_contains?: string[] | undefined;
|
|
226
|
-
detail_matches?: string[] | undefined;
|
|
227
|
-
file_glob?: string | undefined;
|
|
228
|
-
}, {
|
|
229
|
-
kind: string;
|
|
230
|
-
label?: string | undefined;
|
|
231
|
-
detail_contains?: string[] | undefined;
|
|
232
|
-
detail_matches?: string[] | undefined;
|
|
233
|
-
file_glob?: string | undefined;
|
|
234
|
-
}>, "many">>;
|
|
235
|
-
}, "strict", z.ZodTypeAny, {
|
|
236
|
-
any_of?: {
|
|
237
|
-
kind: string;
|
|
238
|
-
label?: string | undefined;
|
|
239
|
-
detail_contains?: string[] | undefined;
|
|
240
|
-
detail_matches?: string[] | undefined;
|
|
241
|
-
file_glob?: string | undefined;
|
|
242
|
-
}[] | undefined;
|
|
243
|
-
all_of?: {
|
|
244
|
-
kind: string;
|
|
245
|
-
label?: string | undefined;
|
|
246
|
-
detail_contains?: string[] | undefined;
|
|
247
|
-
detail_matches?: string[] | undefined;
|
|
248
|
-
file_glob?: string | undefined;
|
|
249
|
-
}[] | undefined;
|
|
250
|
-
none_of?: {
|
|
251
|
-
kind: string;
|
|
252
|
-
label?: string | undefined;
|
|
253
|
-
detail_contains?: string[] | undefined;
|
|
254
|
-
detail_matches?: string[] | undefined;
|
|
255
|
-
file_glob?: string | undefined;
|
|
256
|
-
}[] | undefined;
|
|
257
|
-
}, {
|
|
258
|
-
any_of?: {
|
|
259
|
-
kind: string;
|
|
260
|
-
label?: string | undefined;
|
|
261
|
-
detail_contains?: string[] | undefined;
|
|
262
|
-
detail_matches?: string[] | undefined;
|
|
263
|
-
file_glob?: string | undefined;
|
|
264
|
-
}[] | undefined;
|
|
265
|
-
all_of?: {
|
|
266
|
-
kind: string;
|
|
267
|
-
label?: string | undefined;
|
|
268
|
-
detail_contains?: string[] | undefined;
|
|
269
|
-
detail_matches?: string[] | undefined;
|
|
270
|
-
file_glob?: string | undefined;
|
|
271
|
-
}[] | undefined;
|
|
272
|
-
none_of?: {
|
|
273
|
-
kind: string;
|
|
274
|
-
label?: string | undefined;
|
|
275
|
-
detail_contains?: string[] | undefined;
|
|
276
|
-
detail_matches?: string[] | undefined;
|
|
277
|
-
file_glob?: string | undefined;
|
|
278
|
-
}[] | undefined;
|
|
279
|
-
}>, {
|
|
280
|
-
any_of?: {
|
|
281
|
-
kind: string;
|
|
282
|
-
label?: string | undefined;
|
|
283
|
-
detail_contains?: string[] | undefined;
|
|
284
|
-
detail_matches?: string[] | undefined;
|
|
285
|
-
file_glob?: string | undefined;
|
|
286
|
-
}[] | undefined;
|
|
287
|
-
all_of?: {
|
|
288
|
-
kind: string;
|
|
289
|
-
label?: string | undefined;
|
|
290
|
-
detail_contains?: string[] | undefined;
|
|
291
|
-
detail_matches?: string[] | undefined;
|
|
292
|
-
file_glob?: string | undefined;
|
|
293
|
-
}[] | undefined;
|
|
294
|
-
none_of?: {
|
|
295
|
-
kind: string;
|
|
296
|
-
label?: string | undefined;
|
|
297
|
-
detail_contains?: string[] | undefined;
|
|
298
|
-
detail_matches?: string[] | undefined;
|
|
299
|
-
file_glob?: string | undefined;
|
|
300
|
-
}[] | undefined;
|
|
301
|
-
}, {
|
|
302
|
-
any_of?: {
|
|
303
|
-
kind: string;
|
|
304
|
-
label?: string | undefined;
|
|
305
|
-
detail_contains?: string[] | undefined;
|
|
306
|
-
detail_matches?: string[] | undefined;
|
|
307
|
-
file_glob?: string | undefined;
|
|
308
|
-
}[] | undefined;
|
|
309
|
-
all_of?: {
|
|
310
|
-
kind: string;
|
|
311
|
-
label?: string | undefined;
|
|
312
|
-
detail_contains?: string[] | undefined;
|
|
313
|
-
detail_matches?: string[] | undefined;
|
|
314
|
-
file_glob?: string | undefined;
|
|
315
|
-
}[] | undefined;
|
|
316
|
-
none_of?: {
|
|
317
|
-
kind: string;
|
|
318
|
-
label?: string | undefined;
|
|
319
|
-
detail_contains?: string[] | undefined;
|
|
320
|
-
detail_matches?: string[] | undefined;
|
|
321
|
-
file_glob?: string | undefined;
|
|
322
|
-
}[] | undefined;
|
|
323
|
-
}>;
|
|
324
|
-
/**
|
|
325
|
-
* One fixture: a tool call this rule must match, or must not.
|
|
326
|
-
*
|
|
327
|
-
* A bare string is shorthand for `{ tool: "Bash", command: "<string>" }`, which
|
|
328
|
-
* covers most rules and keeps them terse. Anything else is an object with a
|
|
329
|
-
* `tool` plus **exactly one** of `command` or `file_path` — the two channels.
|
|
330
|
-
* `.strict()` on each variant is what makes "exactly one" true: a
|
|
331
|
-
* `command` object carrying a `file_path` matches neither variant.
|
|
332
|
-
*
|
|
333
|
-
* The parse output is always normalized to the object form, so the harness has
|
|
334
|
-
* exactly one shape to feed the evaluator.
|
|
335
|
-
*
|
|
336
|
-
* ── There is no `url` channel ─────────────────────────────────────────────────
|
|
337
|
-
*
|
|
338
|
-
* **The evaluator cannot see a URL**: the only two attribute keys any matcher
|
|
339
|
-
* reads are `detail` and `file_path`, and there is no `url` field in the condition
|
|
340
|
-
* schema. A value written to `url` would be read by nothing, so a `WebFetch` rule
|
|
341
|
-
* would match nothing, silently — the same failure `scope` is banned for. There
|
|
342
|
-
* are no website rules and `WebFetch` is not intercepted; `WebSearch` is, because
|
|
343
|
-
* its query is text on the command channel.
|
|
344
|
-
*
|
|
345
|
-
* A `url` key therefore fails to parse rather than becoming a fixture that tests
|
|
346
|
-
* nothing. `__tests__/schema.test.ts` pins that.
|
|
347
|
-
*/
|
|
348
|
-
declare const FixtureSchema: z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
349
|
-
tool: "Bash";
|
|
350
|
-
command: string;
|
|
351
|
-
}, string>, z.ZodObject<{
|
|
352
|
-
tool: z.ZodString;
|
|
353
|
-
command: z.ZodString;
|
|
354
|
-
}, "strict", z.ZodTypeAny, {
|
|
355
|
-
tool: string;
|
|
356
|
-
command: string;
|
|
357
|
-
}, {
|
|
358
|
-
tool: string;
|
|
359
|
-
command: string;
|
|
360
|
-
}>, z.ZodObject<{
|
|
361
|
-
tool: z.ZodString;
|
|
362
|
-
file_path: z.ZodString;
|
|
363
|
-
}, "strict", z.ZodTypeAny, {
|
|
364
|
-
tool: string;
|
|
365
|
-
file_path: string;
|
|
366
|
-
}, {
|
|
367
|
-
tool: string;
|
|
368
|
-
file_path: string;
|
|
369
|
-
}>]>;
|
|
370
|
-
/**
|
|
371
|
-
* The two directions every rule must prove, through the real evaluator.
|
|
372
|
-
*
|
|
373
|
-
* **`block` means "this rule MUST match"; `allow` means "this rule MUST NOT
|
|
374
|
-
* match".** They are not verdicts. Seven of the eleven packs default to `ask` or
|
|
375
|
-
* `warn`, and `warn` folds into an allow verdict, so reading `block` as "the
|
|
376
|
-
* guard denies" would fail every `warn` rule and make the negative fixture
|
|
377
|
-
* vacuous for them.
|
|
378
|
-
*
|
|
379
|
-
* Both are `.min(1)`: CI only has to fail on a rule missing a
|
|
380
|
-
* negative fixture, but requiring it here moves that failure to authoring time,
|
|
381
|
-
* where it costs a keystroke instead of a pull-request round trip.
|
|
382
|
-
*/
|
|
383
|
-
declare const FixturesSchema: z.ZodObject<{
|
|
384
|
-
block: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
385
|
-
tool: "Bash";
|
|
386
|
-
command: string;
|
|
387
|
-
}, string>, z.ZodObject<{
|
|
388
|
-
tool: z.ZodString;
|
|
389
|
-
command: z.ZodString;
|
|
390
|
-
}, "strict", z.ZodTypeAny, {
|
|
391
|
-
tool: string;
|
|
392
|
-
command: string;
|
|
393
|
-
}, {
|
|
394
|
-
tool: string;
|
|
395
|
-
command: string;
|
|
396
|
-
}>, z.ZodObject<{
|
|
397
|
-
tool: z.ZodString;
|
|
398
|
-
file_path: z.ZodString;
|
|
399
|
-
}, "strict", z.ZodTypeAny, {
|
|
400
|
-
tool: string;
|
|
401
|
-
file_path: string;
|
|
402
|
-
}, {
|
|
403
|
-
tool: string;
|
|
404
|
-
file_path: string;
|
|
405
|
-
}>]>, "many">;
|
|
406
|
-
allow: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
407
|
-
tool: "Bash";
|
|
408
|
-
command: string;
|
|
409
|
-
}, string>, z.ZodObject<{
|
|
410
|
-
tool: z.ZodString;
|
|
411
|
-
command: z.ZodString;
|
|
412
|
-
}, "strict", z.ZodTypeAny, {
|
|
413
|
-
tool: string;
|
|
414
|
-
command: string;
|
|
415
|
-
}, {
|
|
416
|
-
tool: string;
|
|
417
|
-
command: string;
|
|
418
|
-
}>, z.ZodObject<{
|
|
419
|
-
tool: z.ZodString;
|
|
420
|
-
file_path: z.ZodString;
|
|
421
|
-
}, "strict", z.ZodTypeAny, {
|
|
422
|
-
tool: string;
|
|
423
|
-
file_path: string;
|
|
424
|
-
}, {
|
|
425
|
-
tool: string;
|
|
426
|
-
file_path: string;
|
|
427
|
-
}>]>, "many">;
|
|
428
|
-
}, "strict", z.ZodTypeAny, {
|
|
429
|
-
block: ({
|
|
430
|
-
tool: string;
|
|
431
|
-
command: string;
|
|
432
|
-
} | {
|
|
433
|
-
tool: string;
|
|
434
|
-
file_path: string;
|
|
435
|
-
} | {
|
|
436
|
-
tool: "Bash";
|
|
437
|
-
command: string;
|
|
438
|
-
})[];
|
|
439
|
-
allow: ({
|
|
440
|
-
tool: string;
|
|
441
|
-
command: string;
|
|
442
|
-
} | {
|
|
443
|
-
tool: string;
|
|
444
|
-
file_path: string;
|
|
445
|
-
} | {
|
|
446
|
-
tool: "Bash";
|
|
447
|
-
command: string;
|
|
448
|
-
})[];
|
|
449
|
-
}, {
|
|
450
|
-
block: (string | {
|
|
451
|
-
tool: string;
|
|
452
|
-
command: string;
|
|
453
|
-
} | {
|
|
454
|
-
tool: string;
|
|
455
|
-
file_path: string;
|
|
456
|
-
})[];
|
|
457
|
-
allow: (string | {
|
|
458
|
-
tool: string;
|
|
459
|
-
command: string;
|
|
460
|
-
} | {
|
|
461
|
-
tool: string;
|
|
462
|
-
file_path: string;
|
|
463
|
-
})[];
|
|
464
|
-
}>;
|
|
465
|
-
/**
|
|
466
|
-
* One published rule.
|
|
467
|
-
*
|
|
468
|
-
* `.strict()` rejects any key not declared here, so an unknown field fails to parse
|
|
469
|
-
* rather than riding along into the published package.
|
|
470
|
-
*
|
|
471
|
-
* `description` carries the rule's COVERAGE LIMITS, verbatim — e.g. that an
|
|
472
|
-
* `rm -rf` rule misses `rm -fr`. It is a convention rather than a schema
|
|
473
|
-
* constraint, because no validator can tell a real limit from a sentence shaped
|
|
474
|
-
* like one.
|
|
475
|
-
*/
|
|
476
|
-
declare const RuleSchema: z.ZodObject<{
|
|
477
|
-
/** Stable: a rule id is never renamed. */
|
|
478
|
-
id: z.ZodString;
|
|
479
|
-
/** The pack this rule belongs to. Validated against `PACKS` by the registry. */
|
|
480
|
-
category: z.ZodString;
|
|
481
|
-
severity: z.ZodEnum<["critical", "high", "medium", "low", "info"]>;
|
|
482
|
-
defaultAction: z.ZodEnum<["block", "require_approval", "warn"]>;
|
|
483
|
-
title: z.ZodString;
|
|
484
|
-
description: z.ZodString;
|
|
485
|
-
match: z.ZodEffects<z.ZodObject<{
|
|
486
|
-
any_of: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
487
|
-
kind: z.ZodString;
|
|
488
|
-
label: z.ZodOptional<z.ZodString>;
|
|
489
|
-
detail_contains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
490
|
-
detail_matches: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
491
|
-
file_glob: z.ZodOptional<z.ZodString>;
|
|
492
|
-
}, "strict", z.ZodTypeAny, {
|
|
493
|
-
kind: string;
|
|
494
|
-
label?: string | undefined;
|
|
495
|
-
detail_contains?: string[] | undefined;
|
|
496
|
-
detail_matches?: string[] | undefined;
|
|
497
|
-
file_glob?: string | undefined;
|
|
498
|
-
}, {
|
|
499
|
-
kind: string;
|
|
500
|
-
label?: string | undefined;
|
|
501
|
-
detail_contains?: string[] | undefined;
|
|
502
|
-
detail_matches?: string[] | undefined;
|
|
503
|
-
file_glob?: string | undefined;
|
|
504
|
-
}>, {
|
|
505
|
-
kind: string;
|
|
506
|
-
label?: string | undefined;
|
|
507
|
-
detail_contains?: string[] | undefined;
|
|
508
|
-
detail_matches?: string[] | undefined;
|
|
509
|
-
file_glob?: string | undefined;
|
|
510
|
-
}, {
|
|
511
|
-
kind: string;
|
|
512
|
-
label?: string | undefined;
|
|
513
|
-
detail_contains?: string[] | undefined;
|
|
514
|
-
detail_matches?: string[] | undefined;
|
|
515
|
-
file_glob?: string | undefined;
|
|
516
|
-
}>, "many">>;
|
|
517
|
-
all_of: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
518
|
-
kind: z.ZodString;
|
|
519
|
-
label: z.ZodOptional<z.ZodString>;
|
|
520
|
-
detail_contains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
521
|
-
detail_matches: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
522
|
-
file_glob: z.ZodOptional<z.ZodString>;
|
|
523
|
-
}, "strict", z.ZodTypeAny, {
|
|
524
|
-
kind: string;
|
|
525
|
-
label?: string | undefined;
|
|
526
|
-
detail_contains?: string[] | undefined;
|
|
527
|
-
detail_matches?: string[] | undefined;
|
|
528
|
-
file_glob?: string | undefined;
|
|
529
|
-
}, {
|
|
530
|
-
kind: string;
|
|
531
|
-
label?: string | undefined;
|
|
532
|
-
detail_contains?: string[] | undefined;
|
|
533
|
-
detail_matches?: string[] | undefined;
|
|
534
|
-
file_glob?: string | undefined;
|
|
535
|
-
}>, {
|
|
536
|
-
kind: string;
|
|
537
|
-
label?: string | undefined;
|
|
538
|
-
detail_contains?: string[] | undefined;
|
|
539
|
-
detail_matches?: string[] | undefined;
|
|
540
|
-
file_glob?: string | undefined;
|
|
541
|
-
}, {
|
|
542
|
-
kind: string;
|
|
543
|
-
label?: string | undefined;
|
|
544
|
-
detail_contains?: string[] | undefined;
|
|
545
|
-
detail_matches?: string[] | undefined;
|
|
546
|
-
file_glob?: string | undefined;
|
|
547
|
-
}>, "many">>;
|
|
548
|
-
none_of: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
549
|
-
kind: z.ZodString;
|
|
550
|
-
label: z.ZodOptional<z.ZodString>;
|
|
551
|
-
detail_contains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
552
|
-
detail_matches: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
553
|
-
file_glob: z.ZodOptional<z.ZodString>;
|
|
554
|
-
}, "strict", z.ZodTypeAny, {
|
|
555
|
-
kind: string;
|
|
556
|
-
label?: string | undefined;
|
|
557
|
-
detail_contains?: string[] | undefined;
|
|
558
|
-
detail_matches?: string[] | undefined;
|
|
559
|
-
file_glob?: string | undefined;
|
|
560
|
-
}, {
|
|
561
|
-
kind: string;
|
|
562
|
-
label?: string | undefined;
|
|
563
|
-
detail_contains?: string[] | undefined;
|
|
564
|
-
detail_matches?: string[] | undefined;
|
|
565
|
-
file_glob?: string | undefined;
|
|
566
|
-
}>, {
|
|
567
|
-
kind: string;
|
|
568
|
-
label?: string | undefined;
|
|
569
|
-
detail_contains?: string[] | undefined;
|
|
570
|
-
detail_matches?: string[] | undefined;
|
|
571
|
-
file_glob?: string | undefined;
|
|
572
|
-
}, {
|
|
573
|
-
kind: string;
|
|
574
|
-
label?: string | undefined;
|
|
575
|
-
detail_contains?: string[] | undefined;
|
|
576
|
-
detail_matches?: string[] | undefined;
|
|
577
|
-
file_glob?: string | undefined;
|
|
578
|
-
}>, "many">>;
|
|
579
|
-
}, "strict", z.ZodTypeAny, {
|
|
580
|
-
any_of?: {
|
|
581
|
-
kind: string;
|
|
582
|
-
label?: string | undefined;
|
|
583
|
-
detail_contains?: string[] | undefined;
|
|
584
|
-
detail_matches?: string[] | undefined;
|
|
585
|
-
file_glob?: string | undefined;
|
|
586
|
-
}[] | undefined;
|
|
587
|
-
all_of?: {
|
|
588
|
-
kind: string;
|
|
589
|
-
label?: string | undefined;
|
|
590
|
-
detail_contains?: string[] | undefined;
|
|
591
|
-
detail_matches?: string[] | undefined;
|
|
592
|
-
file_glob?: string | undefined;
|
|
593
|
-
}[] | undefined;
|
|
594
|
-
none_of?: {
|
|
595
|
-
kind: string;
|
|
596
|
-
label?: string | undefined;
|
|
597
|
-
detail_contains?: string[] | undefined;
|
|
598
|
-
detail_matches?: string[] | undefined;
|
|
599
|
-
file_glob?: string | undefined;
|
|
600
|
-
}[] | undefined;
|
|
601
|
-
}, {
|
|
602
|
-
any_of?: {
|
|
603
|
-
kind: string;
|
|
604
|
-
label?: string | undefined;
|
|
605
|
-
detail_contains?: string[] | undefined;
|
|
606
|
-
detail_matches?: string[] | undefined;
|
|
607
|
-
file_glob?: string | undefined;
|
|
608
|
-
}[] | undefined;
|
|
609
|
-
all_of?: {
|
|
610
|
-
kind: string;
|
|
611
|
-
label?: string | undefined;
|
|
612
|
-
detail_contains?: string[] | undefined;
|
|
613
|
-
detail_matches?: string[] | undefined;
|
|
614
|
-
file_glob?: string | undefined;
|
|
615
|
-
}[] | undefined;
|
|
616
|
-
none_of?: {
|
|
617
|
-
kind: string;
|
|
618
|
-
label?: string | undefined;
|
|
619
|
-
detail_contains?: string[] | undefined;
|
|
620
|
-
detail_matches?: string[] | undefined;
|
|
621
|
-
file_glob?: string | undefined;
|
|
622
|
-
}[] | undefined;
|
|
623
|
-
}>, {
|
|
624
|
-
any_of?: {
|
|
625
|
-
kind: string;
|
|
626
|
-
label?: string | undefined;
|
|
627
|
-
detail_contains?: string[] | undefined;
|
|
628
|
-
detail_matches?: string[] | undefined;
|
|
629
|
-
file_glob?: string | undefined;
|
|
630
|
-
}[] | undefined;
|
|
631
|
-
all_of?: {
|
|
632
|
-
kind: string;
|
|
633
|
-
label?: string | undefined;
|
|
634
|
-
detail_contains?: string[] | undefined;
|
|
635
|
-
detail_matches?: string[] | undefined;
|
|
636
|
-
file_glob?: string | undefined;
|
|
637
|
-
}[] | undefined;
|
|
638
|
-
none_of?: {
|
|
639
|
-
kind: string;
|
|
640
|
-
label?: string | undefined;
|
|
641
|
-
detail_contains?: string[] | undefined;
|
|
642
|
-
detail_matches?: string[] | undefined;
|
|
643
|
-
file_glob?: string | undefined;
|
|
644
|
-
}[] | undefined;
|
|
645
|
-
}, {
|
|
646
|
-
any_of?: {
|
|
647
|
-
kind: string;
|
|
648
|
-
label?: string | undefined;
|
|
649
|
-
detail_contains?: string[] | undefined;
|
|
650
|
-
detail_matches?: string[] | undefined;
|
|
651
|
-
file_glob?: string | undefined;
|
|
652
|
-
}[] | undefined;
|
|
653
|
-
all_of?: {
|
|
654
|
-
kind: string;
|
|
655
|
-
label?: string | undefined;
|
|
656
|
-
detail_contains?: string[] | undefined;
|
|
657
|
-
detail_matches?: string[] | undefined;
|
|
658
|
-
file_glob?: string | undefined;
|
|
659
|
-
}[] | undefined;
|
|
660
|
-
none_of?: {
|
|
661
|
-
kind: string;
|
|
662
|
-
label?: string | undefined;
|
|
663
|
-
detail_contains?: string[] | undefined;
|
|
664
|
-
detail_matches?: string[] | undefined;
|
|
665
|
-
file_glob?: string | undefined;
|
|
666
|
-
}[] | undefined;
|
|
667
|
-
}>;
|
|
668
|
-
fixtures: z.ZodObject<{
|
|
669
|
-
block: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
670
|
-
tool: "Bash";
|
|
671
|
-
command: string;
|
|
672
|
-
}, string>, z.ZodObject<{
|
|
673
|
-
tool: z.ZodString;
|
|
674
|
-
command: z.ZodString;
|
|
675
|
-
}, "strict", z.ZodTypeAny, {
|
|
676
|
-
tool: string;
|
|
677
|
-
command: string;
|
|
678
|
-
}, {
|
|
679
|
-
tool: string;
|
|
680
|
-
command: string;
|
|
681
|
-
}>, z.ZodObject<{
|
|
682
|
-
tool: z.ZodString;
|
|
683
|
-
file_path: z.ZodString;
|
|
684
|
-
}, "strict", z.ZodTypeAny, {
|
|
685
|
-
tool: string;
|
|
686
|
-
file_path: string;
|
|
687
|
-
}, {
|
|
688
|
-
tool: string;
|
|
689
|
-
file_path: string;
|
|
690
|
-
}>]>, "many">;
|
|
691
|
-
allow: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
692
|
-
tool: "Bash";
|
|
693
|
-
command: string;
|
|
694
|
-
}, string>, z.ZodObject<{
|
|
695
|
-
tool: z.ZodString;
|
|
696
|
-
command: z.ZodString;
|
|
697
|
-
}, "strict", z.ZodTypeAny, {
|
|
698
|
-
tool: string;
|
|
699
|
-
command: string;
|
|
700
|
-
}, {
|
|
701
|
-
tool: string;
|
|
702
|
-
command: string;
|
|
703
|
-
}>, z.ZodObject<{
|
|
704
|
-
tool: z.ZodString;
|
|
705
|
-
file_path: z.ZodString;
|
|
706
|
-
}, "strict", z.ZodTypeAny, {
|
|
707
|
-
tool: string;
|
|
708
|
-
file_path: string;
|
|
709
|
-
}, {
|
|
710
|
-
tool: string;
|
|
711
|
-
file_path: string;
|
|
712
|
-
}>]>, "many">;
|
|
713
|
-
}, "strict", z.ZodTypeAny, {
|
|
714
|
-
block: ({
|
|
715
|
-
tool: string;
|
|
716
|
-
command: string;
|
|
717
|
-
} | {
|
|
718
|
-
tool: string;
|
|
719
|
-
file_path: string;
|
|
720
|
-
} | {
|
|
721
|
-
tool: "Bash";
|
|
722
|
-
command: string;
|
|
723
|
-
})[];
|
|
724
|
-
allow: ({
|
|
725
|
-
tool: string;
|
|
726
|
-
command: string;
|
|
727
|
-
} | {
|
|
728
|
-
tool: string;
|
|
729
|
-
file_path: string;
|
|
730
|
-
} | {
|
|
731
|
-
tool: "Bash";
|
|
732
|
-
command: string;
|
|
733
|
-
})[];
|
|
734
|
-
}, {
|
|
735
|
-
block: (string | {
|
|
736
|
-
tool: string;
|
|
737
|
-
command: string;
|
|
738
|
-
} | {
|
|
739
|
-
tool: string;
|
|
740
|
-
file_path: string;
|
|
741
|
-
})[];
|
|
742
|
-
allow: (string | {
|
|
743
|
-
tool: string;
|
|
744
|
-
command: string;
|
|
745
|
-
} | {
|
|
746
|
-
tool: string;
|
|
747
|
-
file_path: string;
|
|
748
|
-
})[];
|
|
749
|
-
}>;
|
|
750
|
-
}, "strict", z.ZodTypeAny, {
|
|
751
|
-
id: string;
|
|
752
|
-
category: string;
|
|
753
|
-
severity: "critical" | "high" | "medium" | "low" | "info";
|
|
754
|
-
defaultAction: "block" | "require_approval" | "warn";
|
|
755
|
-
title: string;
|
|
756
|
-
description: string;
|
|
757
|
-
match: {
|
|
758
|
-
any_of?: {
|
|
759
|
-
kind: string;
|
|
760
|
-
label?: string | undefined;
|
|
761
|
-
detail_contains?: string[] | undefined;
|
|
762
|
-
detail_matches?: string[] | undefined;
|
|
763
|
-
file_glob?: string | undefined;
|
|
764
|
-
}[] | undefined;
|
|
765
|
-
all_of?: {
|
|
766
|
-
kind: string;
|
|
767
|
-
label?: string | undefined;
|
|
768
|
-
detail_contains?: string[] | undefined;
|
|
769
|
-
detail_matches?: string[] | undefined;
|
|
770
|
-
file_glob?: string | undefined;
|
|
771
|
-
}[] | undefined;
|
|
772
|
-
none_of?: {
|
|
773
|
-
kind: string;
|
|
774
|
-
label?: string | undefined;
|
|
775
|
-
detail_contains?: string[] | undefined;
|
|
776
|
-
detail_matches?: string[] | undefined;
|
|
777
|
-
file_glob?: string | undefined;
|
|
778
|
-
}[] | undefined;
|
|
779
|
-
};
|
|
780
|
-
fixtures: {
|
|
781
|
-
block: ({
|
|
782
|
-
tool: string;
|
|
783
|
-
command: string;
|
|
784
|
-
} | {
|
|
785
|
-
tool: string;
|
|
786
|
-
file_path: string;
|
|
787
|
-
} | {
|
|
788
|
-
tool: "Bash";
|
|
789
|
-
command: string;
|
|
790
|
-
})[];
|
|
791
|
-
allow: ({
|
|
792
|
-
tool: string;
|
|
793
|
-
command: string;
|
|
794
|
-
} | {
|
|
795
|
-
tool: string;
|
|
796
|
-
file_path: string;
|
|
797
|
-
} | {
|
|
798
|
-
tool: "Bash";
|
|
799
|
-
command: string;
|
|
800
|
-
})[];
|
|
801
|
-
};
|
|
802
|
-
}, {
|
|
803
|
-
id: string;
|
|
804
|
-
category: string;
|
|
805
|
-
severity: "critical" | "high" | "medium" | "low" | "info";
|
|
806
|
-
defaultAction: "block" | "require_approval" | "warn";
|
|
807
|
-
title: string;
|
|
808
|
-
description: string;
|
|
809
|
-
match: {
|
|
810
|
-
any_of?: {
|
|
811
|
-
kind: string;
|
|
812
|
-
label?: string | undefined;
|
|
813
|
-
detail_contains?: string[] | undefined;
|
|
814
|
-
detail_matches?: string[] | undefined;
|
|
815
|
-
file_glob?: string | undefined;
|
|
816
|
-
}[] | undefined;
|
|
817
|
-
all_of?: {
|
|
818
|
-
kind: string;
|
|
819
|
-
label?: string | undefined;
|
|
820
|
-
detail_contains?: string[] | undefined;
|
|
821
|
-
detail_matches?: string[] | undefined;
|
|
822
|
-
file_glob?: string | undefined;
|
|
823
|
-
}[] | undefined;
|
|
824
|
-
none_of?: {
|
|
825
|
-
kind: string;
|
|
826
|
-
label?: string | undefined;
|
|
827
|
-
detail_contains?: string[] | undefined;
|
|
828
|
-
detail_matches?: string[] | undefined;
|
|
829
|
-
file_glob?: string | undefined;
|
|
830
|
-
}[] | undefined;
|
|
831
|
-
};
|
|
832
|
-
fixtures: {
|
|
833
|
-
block: (string | {
|
|
834
|
-
tool: string;
|
|
835
|
-
command: string;
|
|
836
|
-
} | {
|
|
837
|
-
tool: string;
|
|
838
|
-
file_path: string;
|
|
839
|
-
})[];
|
|
840
|
-
allow: (string | {
|
|
841
|
-
tool: string;
|
|
842
|
-
command: string;
|
|
843
|
-
} | {
|
|
844
|
-
tool: string;
|
|
845
|
-
file_path: string;
|
|
846
|
-
})[];
|
|
847
|
-
};
|
|
848
|
-
}>;
|
|
849
|
-
/** How dangerous the caught action is. Never a price. */
|
|
850
|
-
type Severity = (typeof SEVERITIES)[number];
|
|
851
|
-
/** What the guard does on a match. */
|
|
852
|
-
type Action = (typeof ACTIONS)[number];
|
|
853
|
-
/** One condition matched against a tool call. */
|
|
854
|
-
type MatchCondition = z.infer<typeof MatchConditionSchema>;
|
|
855
|
-
/** A composed match — `any_of` / `all_of` / `none_of`. */
|
|
856
|
-
type Match = z.infer<typeof MatchSchema>;
|
|
857
|
-
/** A fixture as authored: a bare command string, or a tagged single-channel object. */
|
|
858
|
-
type FixtureInput = z.input<typeof FixtureSchema>;
|
|
859
|
-
/** A fixture after parsing — always the tagged object form. */
|
|
860
|
-
type Fixture = z.output<typeof FixtureSchema>;
|
|
861
|
-
/** The must-match / must-not-match pair every rule ships. */
|
|
862
|
-
type Fixtures = z.infer<typeof FixturesSchema>;
|
|
863
|
-
/** One published rule, as authored. */
|
|
864
|
-
type RuleInput = z.input<typeof RuleSchema>;
|
|
865
|
-
/** One published rule, parsed and normalized. */
|
|
866
|
-
type Rule = z.output<typeof RuleSchema>;
|
|
867
|
-
/**
|
|
868
|
-
* Validate a rule from unknown input.
|
|
869
|
-
*
|
|
870
|
-
* It answers "is this a well-formed rule?" — it does NOT answer "does this rule
|
|
871
|
-
* actually fire on the command you think it does." That needs the evaluator, which
|
|
872
|
-
* is not part of this package.
|
|
873
|
-
*
|
|
874
|
-
* @param input - Unknown input, e.g. parsed JSON or a rule module's default export.
|
|
875
|
-
* @returns A Zod SafeParseReturnType — check `.success` before reading `.data`.
|
|
876
|
-
*/
|
|
877
|
-
declare function parseRule(input: unknown): z.SafeParseReturnType<unknown, Rule>;
|
|
878
|
-
/**
|
|
879
|
-
* Parse a rule, or throw with the reason.
|
|
880
|
-
*
|
|
881
|
-
* Used by rule modules themselves via {@link defineRule}, so an authoring
|
|
882
|
-
* mistake fails at import — which is to say, at test time — rather than
|
|
883
|
-
* surviving into a corpus that only validates what it remembers to check.
|
|
884
|
-
*/
|
|
885
|
-
declare function parseRuleOrThrow(input: unknown): Rule;
|
|
886
|
-
/**
|
|
887
|
-
* Declare a rule. Validates at module load, so a malformed rule cannot reach the
|
|
888
|
-
* registry — the corpus is only as trustworthy as its weakest unvalidated entry.
|
|
889
|
-
*/
|
|
890
|
-
declare function defineRule(rule: RuleInput): Rule;
|
|
891
|
-
|
|
892
|
-
export { ACTIONS, type Action, ActionSchema, DETAIL_MATCHES_MAX_PATTERNS, DETAIL_MATCHES_MAX_PATTERN_LENGTH, type Fixture, type FixtureInput, FixtureSchema, type Fixtures, FixturesSchema, type Match, type MatchCondition, MatchConditionSchema, MatchSchema, type Rule, type RuleInput, RuleSchema, SEVERITIES, type Severity, SeveritySchema, defineRule, hasNestedUnboundedQuantifier, parseRule, parseRuleOrThrow };
|
|
1
|
+
import 'zod';
|
|
2
|
+
export { l as ACTIONS, A as Action, m as ActionSchema, D as DETAIL_MATCHES_MAX_PATTERNS, n as DETAIL_MATCHES_MAX_PATTERN_LENGTH, F as Fixture, a as FixtureInput, p as FixtureSchema, b as Fixtures, q as FixturesSchema, c as Match, M as MatchCondition, r as MatchConditionSchema, s as MatchSchema, t as OwaspIdsSchema, R as Rule, i as RuleInput, u as RuleSchema, v as SEVERITIES, S as Severity, w as SeveritySchema, x as defineRule, y as hasNestedUnboundedQuantifier, z as parseRule, B as parseRuleOrThrow } from './schema-BRdYtWjP.js';
|