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