Skip to content

Commit a3f5436

Browse files
committed
fix(gatekeeper): fix dead .claude/settings soft_deny pattern
Split combined pattern into two rules because \b word boundary doesn't match before `.` (non-word character), making the .claude/settings branch unreachable.
1 parent cf0bdf3 commit a3f5436

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

plugins/gatekeeper/dist/pre-tool-use.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// src/pre-tool-use.ts
1+
// plugins/gatekeeper/src/pre-tool-use.ts
22
import process from "node:process";
33

4-
// src/chain-parser.ts
4+
// plugins/gatekeeper/src/chain-parser.ts
55
function isDigit(ch) {
66
return ch !== undefined && ch >= "0" && ch <= "9";
77
}
@@ -124,7 +124,7 @@ function parseChainedCommand(cmd) {
124124
return { kind: "chain", parts: trimmed };
125125
}
126126

127-
// src/pre-tool-use.ts
127+
// plugins/gatekeeper/src/pre-tool-use.ts
128128
var HARD_DENY_RULES = [
129129
{ pattern: /^rm\s+-rf\s+\/(?:\s|$)/i, reason: "Filesystem root deletion blocked" },
130130
{ pattern: /^rm\s+-rf\s+\/\*(?:\s|$)/i, reason: "Destructive wildcard deletion from root blocked" },
@@ -162,7 +162,8 @@ var SOFT_DENY_RULES = [
162162
{ pattern: /^(terraform|pulumi)\s+apply\b/i, reason: "Infrastructure apply needs user intent verification" },
163163
{ pattern: /^(terraform|pulumi)\s+destroy\b/i, reason: "Infrastructure destroy needs user intent verification" },
164164
{ pattern: /^kubectl\s+(apply|delete)\b/i, reason: "Kubernetes mutation needs user intent verification" },
165-
{ pattern: /\b(\.claude\/settings|CLAUDE\.md)\b/i, reason: "Agent self-modification needs user intent verification" },
165+
{ pattern: /(?:^|\s)\.claude\/settings/i, reason: "Agent self-modification needs user intent verification" },
166+
{ pattern: /\bCLAUDE\.md\b/i, reason: "Agent self-modification needs user intent verification" },
166167
{ pattern: /^git\s+commit\s+.*--no-verify\b/i, reason: "Skipping commit verification needs user intent verification" },
167168
{ pattern: /\bchmod\s+777\b/i, reason: "Broad permission change needs user intent verification" },
168169
{ pattern: /\b(nc|ncat|socat)\s+-l/i, reason: "Exposing local service needs user intent verification" },

plugins/gatekeeper/src/pre-tool-use.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ export const SOFT_DENY_RULES: Rule[] = [
6565
{ pattern: /^(terraform|pulumi)\s+destroy\b/i, reason: 'Infrastructure destroy needs user intent verification' },
6666
{ pattern: /^kubectl\s+(apply|delete)\b/i, reason: 'Kubernetes mutation needs user intent verification' },
6767

68-
// Self-modification
69-
{ pattern: /\b(\.claude\/settings|CLAUDE\.md)\b/i, reason: 'Agent self-modification needs user intent verification' },
68+
// Self-modification — split into two patterns because \b doesn't match before `.` (non-word char)
69+
{ pattern: /(?:^|\s)\.claude\/settings/i, reason: 'Agent self-modification needs user intent verification' },
70+
{ pattern: /\bCLAUDE\.md\b/i, reason: 'Agent self-modification needs user intent verification' },
7071

7172
// Security weakening — only match --no-verify on commit (not push, which just skips pre-push hook)
7273
{ pattern: /^git\s+commit\s+.*--no-verify\b/i, reason: 'Skipping commit verification needs user intent verification' },

0 commit comments

Comments
 (0)