qualiow-exploratory-testing 2.2.1 → 2.3.1

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.
Files changed (44) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.env.example +6 -0
  4. package/CHANGELOG.md +183 -0
  5. package/README.md +110 -27
  6. package/agents/qa-bug-judge.md +115 -0
  7. package/agents/qa-diff-indexer-agent.md +1 -1
  8. package/agents/qa-gather-agent.md +1 -1
  9. package/agents/qa-reporting-agent.md +15 -4
  10. package/bin/mobile-cli.mjs +74 -26
  11. package/bin/qualiow +7 -2
  12. package/bin/wk-ios +60 -6
  13. package/bin/wkeval.mjs +7 -2
  14. package/data/security/SECURITY-POLICY.md +17 -1
  15. package/data/templates/bug-report.md +11 -0
  16. package/data/templates/session-report.md +12 -4
  17. package/dist/cli/index.js +1660 -85
  18. package/dist/index.d.ts +623 -2
  19. package/dist/index.js +1626 -47
  20. package/docs/GETTING-STARTED.md +44 -12
  21. package/docs/MOBILE-SETUP.md +31 -0
  22. package/hooks/hooks.json +12 -2
  23. package/hooks/scripts/bash-guard.mjs +242 -0
  24. package/hooks/scripts/secret-patterns.d.mts +4 -1
  25. package/hooks/scripts/secret-patterns.mjs +126 -34
  26. package/hooks/scripts/write-guard.mjs +70 -15
  27. package/package.json +2 -2
  28. package/skills/qa-explore/SKILL.md +9 -5
  29. package/skills/qa-explore/phases/00-setup.md +9 -1
  30. package/skills/qa-explore/phases/07-reporting.md +186 -11
  31. package/skills/qa-explore/references/delegation-rules.md +21 -2
  32. package/skills/qa-explore/references/evidence-triage.md +213 -0
  33. package/skills/qa-explore/references/output-contract.md +41 -8
  34. package/skills/qa-explore/references/security-rules.md +31 -2
  35. package/skills/qa-explore-cleanup/SKILL.md +1 -1
  36. package/skills/qa-explore-mobile/SKILL.md +13 -3
  37. package/skills/qa-explore-mobile/references/mobile-edges.md +3 -1
  38. package/skills/qa-explore-quick/SKILL.md +1 -1
  39. package/skills/qa-explore-report/SKILL.md +4 -2
  40. package/skills/qa-gather/SKILL.md +1 -1
  41. package/skills/qa-knowledge-add/SKILL.md +1 -1
  42. package/skills/qa-knowledge-list/SKILL.md +1 -1
  43. package/skills/qa-verify-backend/SKILL.md +1 -1
  44. package/skills/qa-verify-backend/phases/05-reporting.md +2 -1
@@ -30,7 +30,7 @@ That writes:
30
30
  | What | Where |
31
31
  |------|-------|
32
32
  | the 11 skills | `.claude/skills/qa-*/` |
33
- | the four sub-agents | `.claude/agents/` |
33
+ | the five sub-agents | `.claude/agents/` |
34
34
  | knowledge base, domain profiles, templates, security policy | `data/knowledge/`, `data/domains/`, `data/templates/`, `data/security/` |
35
35
  | the `_default` target (add `--include-examples` for the `_example-*` templates and `testers-ai.yml`) | `data/targets/` |
36
36
  | the mobile driver plus `setup-mobile.sh` and `doctor-mobile.sh`, executable | `qa/bin/` |
@@ -52,18 +52,22 @@ npx playwright-cli install --skills # optional: the official Playwright skill
52
52
  qualiow init --hooks
53
53
  ```
54
54
 
55
- Optional, and only for npm projects — a plugin install already ships the same two hooks and
55
+ Optional, and only for npm projects — a plugin install already ships the same three hooks and
56
56
  has them on by default, so do not enable both in one project. `--hooks` copies the guard
57
- scripts to `qa/hooks/` and merges into `.claude/settings.json` two `PreToolUse` entries and
58
- three `permissions.allow` rules. The merge is by exact string: running it again changes
59
- nothing, and hooks you already had are kept.
57
+ scripts to `qa/hooks/` and merges into `.claude/settings.json` three `PreToolUse` entries and
58
+ three `permissions.allow` rules. Running it again changes nothing, and hooks you already had
59
+ are kept; an older qualiow-only write-guard entry gets the new matcher. If `settings.json`
60
+ does not parse (a comment, a trailing comma), init stops without writing anything and prints
61
+ the entries to merge by hand.
60
62
 
61
63
  What the guards do: `read-guard.mjs` denies a whole-file `Read` of a qualiow file over
62
64
  `QUALIOW_READ_MAX_LINES` lines (default 300) — the knowledge manifest, a knowledge release
63
65
  file, a session phase file or a raw snapshot — and names the cheaper route in the refusal; a
64
66
  `Read` with `offset` or `limit` passes. `write-guard.mjs` refuses a `Write` or `Edit` under
65
- `output/` whose content matches the redaction list, so a secret never reaches disk. Neither
66
- one looks at anything else in your project. `QUALIOW_HOOKS=off` disables both.
67
+ `output/` whose content matches the redaction list, so a secret never reaches disk.
68
+ `bash-guard.mjs` sees every `Bash` command but only acts on a few: it asks before
69
+ `playwright-cli run-code` and before `git` options that can run a shell, and denies `npx -c`
70
+ or `npx -y` of an unknown package. `QUALIOW_HOOKS=off` disables all three.
67
71
 
68
72
  To write it by hand instead, this is the whole of it:
69
73
 
@@ -78,10 +82,16 @@ To write it by hand instead, this is the whole of it:
78
82
  ]
79
83
  },
80
84
  {
81
- "matcher": "Write|Edit|MultiEdit",
85
+ "matcher": "Write|Edit|MultiEdit|NotebookEdit",
82
86
  "hooks": [
83
87
  { "type": "command", "command": "node \"$CLAUDE_PROJECT_DIR/qa/hooks/write-guard.mjs\"" }
84
88
  ]
89
+ },
90
+ {
91
+ "matcher": "Bash",
92
+ "hooks": [
93
+ { "type": "command", "command": "node \"$CLAUDE_PROJECT_DIR/qa/hooks/bash-guard.mjs\"" }
94
+ ]
85
95
  }
86
96
  ]
87
97
  },
@@ -138,7 +148,8 @@ Claude will:
138
148
  4. Load the heuristics that apply to this domain with `qualiow kb digest --for explore
139
149
  --domain <domain>`, rather than reading the manifest and the entry files whole
140
150
  5. Explore across eight phases, saving findings to disk between each
141
- 6. File one bug report per finding in `bugs/`
151
+ 6. Draft one bug report per finding, then have the `qa-bug-judge` sub-agent try to refute each
152
+ one from a fresh context; survivors go to `bugs/`, refuted candidates to `bugs/refuted/`
142
153
  7. Write `phase-7-notes.md` — the executive summary, coverage map, recommendations and
143
154
  reflection — then hand the assembly of `session-report.md` and the
144
155
  `qualiow session finalize <session-dir>` call to the `qa-reporting-agent` sub-agent
@@ -154,7 +165,7 @@ The eight phases and their share of the 45-minute cap:
154
165
  | 4 | Journeys | 10 | End-to-end user journeys with data-integrity checks |
155
166
  | 5 | Features | 10 | Deep testing of the highest-risk features |
156
167
  | 6 | Edge cases | 6 | Boundaries, negative input, security, "what is missing?" |
157
- | 7 | Reporting | 4 | Reflection, coverage map, session report, cleanup |
168
+ | 7 | Reporting | 4 (+ up to 15) | Reflection, bug verification, coverage map, session report, cleanup |
158
169
 
159
170
  Three points in that run are not done by the session itself. At setup the knowledge base
160
171
  arrives as a `qualiow kb digest` call rather than as the manifest and the entry files. In
@@ -166,6 +177,25 @@ into `phase-7-notes.md` and the `qa-reporting-agent` sub-agent assembles `sessio
166
177
  around them and runs `finalize`; the bug reports, `stats.json` and every word of the summary
167
178
  and reflection are still the session's own.
168
179
 
180
+ Before that, each candidate bug faces the `qa-bug-judge` sub-agent, which sees only a claim
181
+ card (claim, steps, evidence, safety block) and tries to refute it, re-running the steps in its
182
+ own browser session when the card allows. It pins `model: opus` and adds up to 15 minutes to
183
+ phase 7; a bug it cannot reach (model unavailable, timeout, budget spent) still ships, marked
184
+ `Unverified`. To skip it for one run:
185
+
186
+ ```bash
187
+ /qa-explore https://testers.ai/testing/ --no-judge
188
+ ```
189
+
190
+ or set it off for a target in its YAML:
191
+
192
+ ```yaml
193
+ verification:
194
+ mode: off # judge (the default) | off
195
+ ```
196
+
197
+ With the judge off, phase 7 writes `bugs/` directly and no `verification/` directory appears.
198
+
169
199
  ### Option B: quick check on one page
170
200
 
171
201
  ```bash
@@ -210,6 +240,8 @@ output/sessions/2026-09-08-1813-explore-parabank/
210
240
  bugs/
211
241
  BUG-001.md # one bug = one report
212
242
  BUG-002.md
243
+ refuted/ # candidates the bug judge refuted (judge on)
244
+ verification/ # claim cards and verdicts (judge on)
213
245
  screenshots/
214
246
  BUG-001.png
215
247
  snapshots/ # raw page snapshots — working files, never part of the report
@@ -384,11 +416,11 @@ decide which entries a skill always gets without touching the skill itself.
384
416
 
385
417
  ```bash
386
418
  qualiow init --dry-run # preview what init would write
387
- qualiow init --hooks # add the read/write guards to .claude/settings.json
419
+ qualiow init --hooks # add the read/write/bash guards to .claude/settings.json
388
420
  qualiow validate --all # targets + qa/target.yml + domains + knowledge base
389
421
  qualiow list sessions # also: knowledge | targets | domains
390
422
  qualiow list knowledge --stats # also: --domain --tag --type --entry <id> --changelog
391
- qualiow report -s latest -f html -o report.html
423
+ qualiow report -s latest -f html -o report.html # writes output/report.html
392
424
  qualiow kb check
393
425
  qualiow kb digest --for explore # the knowledge a session loads
394
426
  qualiow session finalize latest # validate a finished session and index it
@@ -181,6 +181,37 @@ Requires `ios-webkit-debug-proxy`, `python3`, Node ≥ 22.4 (`wkeval.mjs` uses t
181
181
  `WebSocket`), and a booted Simulator with Safari on a page. `WK_IOS_PORT` (default 9221) sets
182
182
  the iwdp device-list port; pages are served on `WK_IOS_PORT + 1`.
183
183
 
184
+ > **⚠️ The proxy listens on every network interface, without authentication.**
185
+ > `ios-webkit-debug-proxy` (1.9.x) has no bind-address option, so ports `WK_IOS_PORT` to
186
+ > `WK_IOS_PORT + 101` are reachable from your LAN while it runs, and anyone who can reach them
187
+ > can evaluate JavaScript in the Simulator's pages — including their logged-in sessions. The
188
+ > proxy stays up between calls so each eval is fast; `wk-ios` prints a warning when it starts
189
+ > it. **Run `bin/wk-ios --stop` as soon as the session ends**, keep the macOS firewall on
190
+ > (System Settings → Network → Firewall), and avoid using the bridge on untrusted networks.
191
+
192
+ Safari keeps old tabs inspectable, so the newest page is not always the one under test. Set
193
+ `WK_PAGE_FILTER` to pin it. The filter is matched against the parsed page URL — never as a raw
194
+ substring, so a page cannot win by carrying the filter in its query string or fragment — and the
195
+ newest matching page is used:
196
+
197
+ | `WK_PAGE_FILTER` | Matches |
198
+ |---|---|
199
+ | `/account` | any page whose path starts with `/account` (any host) |
200
+ | `staging.example.com` | that host or any subdomain of it; `host:port` matches that exact host and port |
201
+ | `staging.example.com/account` | exactly that host, path starting with `/account` |
202
+ | `https://staging.example.com/account` | same scheme and host[:port], path starting with `/account` |
203
+
204
+ When no page matches, `wk-ios` stops with an error rather than evaluating in another tab. Prefer
205
+ a host-qualified form: a bare `/path` does not pin the host.
206
+
207
+ ```bash
208
+ WK_PAGE_FILTER=staging.example.com/account bin/wk-ios 'document.title'
209
+ ```
210
+
211
+ The proxy's pid and log files live in a private per-user directory,
212
+ `${TMPDIR:-/tmp}/wk-ios-<uid>/` (mode 700). Page values printed by `wk-ios`, and app labels
213
+ printed by `mcli snapshot` and `mcli logs`, have terminal control characters stripped.
214
+
184
215
  ## Why a Google **Play** (or `google_apis`) Android image
185
216
 
186
217
  A stock **AOSP** system image ships **no `com.android.chrome`** — only a basic AOSP
package/hooks/hooks.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "qualiow routing guards: whole-file reads of qualiow data over the line threshold, and secrets in session output",
2
+ "description": "qualiow routing guards: whole-file reads of qualiow data over the line threshold, secrets in session output, and code-execution routes in Bash (playwright-cli run-code, arbitrary npx)",
3
3
  "hooks": {
4
4
  "PreToolUse": [
5
5
  {
@@ -13,7 +13,7 @@
13
13
  ]
14
14
  },
15
15
  {
16
- "matcher": "Write|Edit|MultiEdit",
16
+ "matcher": "Write|Edit|MultiEdit|NotebookEdit",
17
17
  "hooks": [
18
18
  {
19
19
  "type": "command",
@@ -21,6 +21,16 @@
21
21
  "timeout": 10
22
22
  }
23
23
  ]
24
+ },
25
+ {
26
+ "matcher": "Bash",
27
+ "hooks": [
28
+ {
29
+ "type": "command",
30
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/bash-guard.mjs\"",
31
+ "timeout": 10
32
+ }
33
+ ]
24
34
  }
25
35
  ]
26
36
  }
@@ -0,0 +1,242 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * PreToolUse hook (matcher: Bash).
4
+ *
5
+ * Code-execution routes that a pre-approved `Bash(playwright-cli:*)`,
6
+ * `Bash(git -C:*)` or a permissive `npx` rule would otherwise let through
7
+ * without a prompt:
8
+ *
9
+ * - `playwright-cli run-code` (direct or via `npx playwright-cli`) runs its
10
+ * JavaScript in the Playwright node process, not in the browser sandbox —
11
+ * the `vm` context holding `page` is escapable to the host `process`. It is
12
+ * used legitimately, so the decision is `ask`: the user confirms every call.
13
+ * - `npx -c/--call <shell>`, and `npx -y`/`-p` of a package outside a short
14
+ * allowlist, install or run arbitrary code. The decision is `deny`.
15
+ * - `git -c <key>=<value>`, `--config-env`, `--upload-pack`, `--receive-pack`,
16
+ * `--exec`, `--ext-diff` and `--output` run a program or write an arbitrary
17
+ * file from an otherwise read-only git call — the skills pre-approve
18
+ * `git -C <repo> …` for the repository under test. The decision is `ask`.
19
+ *
20
+ * Compound commands are split on `&&`, `||`, `;`, `|`, `&` and newlines;
21
+ * leading `VAR=value` assignments and `env`/`command`/`exec`/`time`/`nohup`
22
+ * wrappers are skipped; `bash|sh|zsh -c '<cmd>'`, `eval`, `$(…)` and backticks
23
+ * are inspected as nested commands. A `deny` anywhere wins over an `ask`.
24
+ *
25
+ * Node built-ins only — a git-sourced plugin install has neither `dist/` nor
26
+ * `node_modules`. Never throws and never blocks on its own failure: any error
27
+ * here lets the command through (exit 0, no stdout) to the normal permission
28
+ * check rather than breaking the caller because of a hook bug.
29
+ */
30
+ import { readFileSync } from 'node:fs';
31
+
32
+ const NPX_ALLOWED_PACKAGES = new Set(['playwright-cli', '@playwright/cli', 'qualiow-exploratory-testing']);
33
+ const PLAYWRIGHT_CLI_NAMES = new Set(['playwright-cli', '@playwright/cli']);
34
+ const WRAPPERS = new Set(['env', 'command', 'exec', 'time', 'nohup']);
35
+ const SHELLS = new Set(['bash', 'sh', 'zsh', 'dash']);
36
+ const MAX_DEPTH = 4;
37
+
38
+ function decide(permissionDecision, reason) {
39
+ process.stdout.write(
40
+ JSON.stringify({
41
+ hookSpecificOutput: {
42
+ hookEventName: 'PreToolUse',
43
+ permissionDecision,
44
+ permissionDecisionReason: reason,
45
+ },
46
+ }),
47
+ );
48
+ }
49
+
50
+ /**
51
+ * Splits a command line into segments of words. Honours single and double
52
+ * quotes and backslash escapes; splits on unquoted && || ; | & and newlines.
53
+ */
54
+ function segments(command) {
55
+ const out = [];
56
+ let words = [];
57
+ let word = '';
58
+ let inWord = false;
59
+ let quote = null;
60
+ const endWord = () => {
61
+ if (inWord) words.push(word);
62
+ word = '';
63
+ inWord = false;
64
+ };
65
+ const endSegment = () => {
66
+ endWord();
67
+ if (words.length) out.push(words);
68
+ words = [];
69
+ };
70
+ for (let i = 0; i < command.length; i++) {
71
+ const c = command[i];
72
+ if (quote) {
73
+ if (c === quote) quote = null;
74
+ else if (c === '\\' && quote === '"' && i + 1 < command.length) word += command[++i];
75
+ else word += c;
76
+ continue;
77
+ }
78
+ if (c === '"' || c === "'") {
79
+ quote = c;
80
+ inWord = true;
81
+ } else if (c === '\\' && i + 1 < command.length) {
82
+ word += command[++i];
83
+ inWord = true;
84
+ } else if (c === ';' || c === '|' || c === '&' || c === '\n') {
85
+ endSegment();
86
+ } else if (c === ' ' || c === '\t' || c === '(' || c === ')' || c === '{' || c === '}') {
87
+ endWord();
88
+ } else {
89
+ word += c;
90
+ inWord = true;
91
+ }
92
+ }
93
+ endSegment();
94
+ return out;
95
+ }
96
+
97
+ /** `$(…)` and backtick bodies, inspected as nested commands. */
98
+ function substitutions(command) {
99
+ const found = [];
100
+ for (const m of command.matchAll(/\$\(([^()]*)\)/g)) found.push(m[1]);
101
+ for (const m of command.matchAll(/`([^`]*)`/g)) found.push(m[1]);
102
+ return found;
103
+ }
104
+
105
+ function basename(word) {
106
+ const parts = word.split('/');
107
+ return parts[parts.length - 1];
108
+ }
109
+
110
+ /** `@scope/name@1.2.3` → `@scope/name`, `name@latest` → `name`. */
111
+ function packageName(spec) {
112
+ const at = spec.lastIndexOf('@');
113
+ return at > 0 ? spec.slice(0, at) : spec;
114
+ }
115
+
116
+ function runCodeIn(words) {
117
+ return words.includes('run-code');
118
+ }
119
+
120
+ const ASK_RUN_CODE =
121
+ 'ask:playwright-cli run-code executes JavaScript in the Playwright node process (outside the browser sandbox); ' +
122
+ 'confirm the code is yours and contains no text taken from page content. Set QUALIOW_HOOKS=off to disable.';
123
+
124
+ const GIT_EXEC_OPTION = /^(--upload-pack|--receive-pack|--exec|--ext-diff|--output|--config-env)(=|$)/;
125
+
126
+ /** A git option that runs a program or writes a file outside the read-only calls the skills make. */
127
+ function gitExecOption(words) {
128
+ let k = 0;
129
+ // Global options before the subcommand: `-c` is a config override there (and a
130
+ // harmless diff flag after it, as in `git log -c`).
131
+ while (k < words.length && words[k].startsWith('-')) {
132
+ if (words[k] === '-c') return '-c';
133
+ k += /^(-C|--git-dir|--work-tree|--namespace)$/.test(words[k]) ? 2 : 1;
134
+ }
135
+ const hit = words.slice(k).find((w) => GIT_EXEC_OPTION.test(w)) || words.slice(0, k).find((w) => GIT_EXEC_OPTION.test(w));
136
+ return hit ? hit.split('=')[0] : null;
137
+ }
138
+
139
+ /** Returns 'deny:<reason>', 'ask:<reason>' or null for one segment's words. */
140
+ function checkWords(words, depth) {
141
+ let i = 0;
142
+ while (i < words.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(words[i])) i++;
143
+ while (i < words.length && WRAPPERS.has(basename(words[i]))) {
144
+ i++;
145
+ while (i < words.length && (/^[A-Za-z_][A-Za-z0-9_]*=/.test(words[i]) || words[i].startsWith('-'))) i++;
146
+ }
147
+ if (i >= words.length) return null;
148
+ const program = basename(words[i]);
149
+ const rest = words.slice(i + 1);
150
+
151
+ if (SHELLS.has(program)) {
152
+ const c = rest.findIndex((w) => /^-[a-z]*c$/.test(w));
153
+ if (c >= 0 && rest[c + 1] != null) return checkCommand(rest[c + 1], depth + 1);
154
+ return null;
155
+ }
156
+ if (program === 'eval') return checkCommand(rest.join(' '), depth + 1);
157
+
158
+ if (program === 'playwright-cli') return runCodeIn(rest) ? ASK_RUN_CODE : null;
159
+
160
+ if (program === 'git') {
161
+ const option = gitExecOption(rest);
162
+ return option
163
+ ? `ask:git ${option} can run a program or write an arbitrary file; confirm it is intended. Set QUALIOW_HOOKS=off to disable.`
164
+ : null;
165
+ }
166
+
167
+ if (program !== 'npx') return null;
168
+
169
+ let yes = false;
170
+ const packages = [];
171
+ let j = 0;
172
+ for (; j < rest.length; j++) {
173
+ const w = rest[j];
174
+ if (w === '--') {
175
+ j++;
176
+ break;
177
+ }
178
+ if (!w.startsWith('-')) break;
179
+ if (w === '-c' || w === '--call' || w.startsWith('--call=')) {
180
+ return 'deny:npx -c/--call runs an arbitrary shell string; call the tool directly instead. Set QUALIOW_HOOKS=off to disable.';
181
+ }
182
+ if (w === '-y' || w === '--yes' || w.startsWith('--yes=')) yes = true;
183
+ else if (w === '-p' || w === '--package') {
184
+ if (rest[j + 1] != null) packages.push(rest[++j]);
185
+ } else if (w.startsWith('--package=')) packages.push(w.slice('--package='.length));
186
+ }
187
+ const command = rest.slice(j);
188
+ const candidates = packages.length ? packages : command.length ? [command[0]] : [];
189
+ if (packages.length || yes) {
190
+ const unknown = candidates.map(packageName).filter((p) => !NPX_ALLOWED_PACKAGES.has(p));
191
+ if (unknown.length) {
192
+ return (
193
+ `deny:npx would install and run ${unknown.join(', ')}, which is not on the qualiow allowlist ` +
194
+ `(${[...NPX_ALLOWED_PACKAGES].join(', ')}). Install it deliberately instead. Set QUALIOW_HOOKS=off to disable.`
195
+ );
196
+ }
197
+ }
198
+ if (command.length) {
199
+ const bin = PLAYWRIGHT_CLI_NAMES.has(packageName(command[0])) ? 'playwright-cli' : basename(command[0]);
200
+ if (bin === 'playwright-cli' && runCodeIn(command.slice(1))) return ASK_RUN_CODE;
201
+ }
202
+ return null;
203
+ }
204
+
205
+ /** Worst decision across every segment and nested command. */
206
+ function checkCommand(command, depth = 0) {
207
+ if (typeof command !== 'string' || depth > MAX_DEPTH) return null;
208
+ let ask = null;
209
+ const nested = substitutions(command).map((s) => checkCommand(s, depth + 1));
210
+ const direct = segments(command).map((w) => checkWords(w, depth));
211
+ for (const r of [...nested, ...direct]) {
212
+ if (!r) continue;
213
+ if (r.startsWith('deny:')) return r;
214
+ ask = ask || r;
215
+ }
216
+ return ask;
217
+ }
218
+
219
+ try {
220
+ if (process.env.QUALIOW_HOOKS === 'off') process.exit(0);
221
+
222
+ let raw = '';
223
+ try {
224
+ raw = readFileSync(0, 'utf-8');
225
+ } catch {
226
+ process.exit(0);
227
+ }
228
+ if (!raw || !raw.trim()) process.exit(0);
229
+
230
+ const input = JSON.parse(raw);
231
+ if (input.tool_name !== 'Bash') process.exit(0);
232
+
233
+ const command = (input.tool_input || {}).command;
234
+ if (!command || typeof command !== 'string') process.exit(0);
235
+
236
+ const result = checkCommand(command);
237
+ if (result && result.startsWith('deny:')) decide('deny', result.slice('deny:'.length));
238
+ else if (result && result.startsWith('ask:')) decide('ask', result.slice('ask:'.length));
239
+ process.exit(0);
240
+ } catch {
241
+ process.exit(0);
242
+ }
@@ -1,8 +1,11 @@
1
1
  export interface SecretPattern {
2
2
  category: string;
3
3
  re: RegExp;
4
- filter?: (match: string) => boolean;
4
+ /** Receives the match and its capture groups, as `String.prototype.replace` would. */
5
+ filter?: (match: string, ...groups: string[]) => boolean;
5
6
  }
6
7
  export const SECRET_PATTERNS: SecretPattern[];
7
8
  /** Category names of every secret-shaped pattern found in `text`; never the matched text. */
8
9
  export function findSecretCategories(text: string): string[];
10
+ /** Number of secret-shaped matches per category in `text`; never the matched text. */
11
+ export function countSecrets(text: string): Map<string, number>;