You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d8e57e3
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/scanners.md
+97-14Lines changed: 97 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ clawscan scanners
17
17
clawscan scanners skillspector
18
18
```
19
19
20
-
## User-defined scanners
20
+
## Profile scanner configuration
21
21
22
22
A trusted config can mix built-in scanner IDs with user-defined command
23
23
scanners. The config schema uses the existing `profiles.<name>.scanners` list:
@@ -28,7 +28,24 @@ version: 1
28
28
profiles:
29
29
review:
30
30
scanners:
31
-
- clawscan-static
31
+
- id: skillspector
32
+
gate:
33
+
rules:
34
+
- id: do-not-install
35
+
path: risk_assessment.recommendation
36
+
equals: DO_NOT_INSTALL
37
+
action: block
38
+
- id: critical-finding
39
+
path: filtered_findings[].severity
40
+
equals: CRITICAL
41
+
action: block
42
+
- id: clawscan-static
43
+
gate:
44
+
rules:
45
+
- id: any-finding
46
+
path: findings[]
47
+
exists: true
48
+
action: warn
32
49
- id: my-scanner
33
50
command: my-scanner --json {{target}}
34
51
env:
@@ -39,11 +56,21 @@ profiles:
39
56
- skill
40
57
- plugin
41
58
gate:
59
+
rules:
60
+
- id: high-risk
61
+
path: result.risk
62
+
equals: high
63
+
action: warn
42
64
blockOnExitCode: nonzero
43
65
```
44
66
45
-
String entries select built-in scanners. Object entries define a scanner for
46
-
that config-backed run and accept these fields:
67
+
String entries select built-in scanners without gate policy. An object with a
68
+
registered built-in `id` and no `command` selects that built-in and can attach
69
+
gate rules. The rules inspect its existing JSON output; the scanner does not
70
+
need to implement ClawScan-specific policy or change its exit codes.
71
+
72
+
An object with a `command` defines a user-provided scanner for that
73
+
config-backed run. The same JSON rules work for built-in and command scanners:
47
74
48
75
| Field | Required | Meaning |
49
76
| --- | --- | --- |
@@ -52,7 +79,58 @@ that config-backed run and accept these fields:
52
79
| `env` | no | Required non-secret environment variable names passed to the scanner. Their values are not automatically redacted from scanner error text. |
53
80
| `secretEnv` | no | Required secret environment variable names passed to the scanner. Their values are redacted from scanner error text regardless of how the names are spelled. |
54
81
| `targets` | no | Supported target kinds: `skill`, `plugin`, and/or `url`. Defaults to `skill` and `url`. |
55
-
| `gate` | no | Exit-code policy with optional `blockOnExitCode` and `warnOnExitCode` rules. |
82
+
| `gate` | no | JSON and/or exit-code policy applied after the scanner completes. |
83
+
84
+
### JSON gate rules
85
+
86
+
`gate.rules`evaluates the scanner's raw JSON without rewriting it. Every rule
87
+
has:
88
+
89
+
| Field | Required | Meaning |
90
+
| --- | --- | --- |
91
+
| `id` | yes | Stable name reported in `gateRules`; IDs must be unique within one scanner gate. |
92
+
| `path` | yes | One path or an ordered list of aliases. Paths use dotted object fields, with `[]` after a field to traverse every array item. Separate alternative field names with the pipe character. Array indexes and other expression syntax are not supported. |
93
+
| `action` | yes | `warn` or `block`. |
94
+
| `equals` | one condition | Matches a string, number, or boolean exactly. String comparison is case-sensitive. |
95
+
| `exists` | one condition | Must be `true`; matches when the path resolves to at least one value. |
96
+
| `normalize` | no | `identifier` makes string `equals` matching case-insensitive and treats spaces and hyphens like underscores. It cannot be used with numbers, booleans, or `exists`. |
97
+
| `fallback` | no | `root` makes the first path whose root field exists authoritative, even when a nested field is missing. Use this when a preferred filtered collection must override legacy raw collections. |
98
+
99
+
Specify exactly one of `equals` or `exists: true`. A rule fires at most once,
100
+
even when several paths or array items match. The fired artifact records the
101
+
path that matched. A path list is an ordered fallback: ClawScan evaluates the
102
+
first path with a non-empty value and ignores later aliases, whether or not its
103
+
value matches. Empty strings and `null` fall through to the next alias. An
104
+
explicitly empty traversed array remains authoritative, letting a preferred
105
+
filtered result override legacy raw-result fields. Missing paths, empty arrays,
106
+
and type mismatches do not fire. Within one path segment, `|` alternatives are
107
+
resolved separately for each object, using the first present field; if that
108
+
field is empty, the rule can still fall through to the next path. For
109
+
`fallback: root`, a present root field prevents later path aliases from being
110
+
consulted. For example, `findings[].severity|risk_severity` checks `severity`
111
+
and then `risk_severity` on each finding. An immutable third-party scanner can
112
+
be gated without a wrapper:
113
+
114
+
```yaml
115
+
scanners:
116
+
- id: third-party
117
+
command: third-party scan --json {{target}}
118
+
gate:
119
+
rules:
120
+
- id: critical-risk
121
+
path:
122
+
- result.risk
123
+
- result.risk_level
124
+
equals: critical
125
+
normalize: identifier
126
+
action: block
127
+
- id: any-policy-violation
128
+
path: result.violations[]
129
+
exists: true
130
+
action: warn
131
+
```
132
+
133
+
### Exit-code rules
56
134
57
135
Each exit-code rule accepts one integer from 0 through 124, a list such as
58
136
`[1, 2, 3]`, or the string `nonzero`. The block and warning rules may not
@@ -66,22 +144,27 @@ gate:
66
144
warnOnExitCode: 1
67
145
```
68
146
147
+
JSON and exit-code rules can be combined on the same scanner. A gate-eligible
148
+
process exit code is preserved alongside raw JSON, and all fired rules
149
+
participate in the same strongest-action decision.
150
+
69
151
After every selected scanner finishes, ClawScan records the strongest fired
70
152
action as the top-level artifact `gate`: `block`wins over `warn`, and an
71
153
artifact with no fired rules records `"gate": "pass"`. Each fired rule is also
72
-
listed in `gateRules` with its scanner ID, rule name, exit code, and action.
73
-
Gate actions are record-only: `block`does not stop later scanners or the
74
-
judge, and it does not change ClawScan's process exit status. For enforcement,
75
-
inspect `gate` and `gateRules` on a single run, `runs[].gate` and
154
+
listed in `gateRules` with its scanner ID, rule ID, and action. Exit-code rules
155
+
include `exitCode`; JSON rules include `path` and, for `equals`, the matched
156
+
`value`. Gate actions are record-only: `block`does not stop later scanners or
157
+
the judge, and it does not change ClawScan's process exit status. For
158
+
enforcement, inspect `gate` and `gateRules` on a single run, `runs[].gate` and
76
159
`runs[].gateRules`in a batch, or `cases[].run.gate` and
77
160
`cases[].run.gateRules`in a benchmark. The human scan summary aggregates the
78
161
strongest batch action; the benchmark summary does not aggregate gate actions.
79
162
80
-
Skipped scanners do not fire gate rules. A scanner result with status `failed`
81
-
also does not fire an exit-code rule; a nonzero command that still returned
82
-
valid JSON has status `completed` and can fire one. Valid JSON from a timeout,
83
-
signal, or reserved infrastructure exit is still preserved, but its omitted
84
-
`exitCode`means it cannot fire a gate rule.
163
+
Skipped or failed scanners do not fire gate rules. A nonzero command that still
164
+
returned valid JSON has status `completed` and can fire both JSON and exit-code
165
+
rules. Valid JSON from a timeout, signal, or reserved infrastructure exit is
166
+
still preserved, but the failed scanner does not fire gate rules and its
167
+
`exitCode`is omitted.
85
168
86
169
The command must write JSON to stdout. ClawScan preserves valid stdout as the
87
170
scanner's raw evidence; empty or non-JSON stdout produces a failed scanner
0 commit comments