Repository navigation
Commit 30557a6
fix(hooks): honor permission rules for already-rtk-prefixed commands
Fixes rtk-ai#3152. Claude Code sometimes issues the already-rewritten
form of a command directly (e.g. `rtk grep foo` instead of `grep foo`) once
it has seen it once in an earlier turn. Permission rules like
`Bash(grep *)` are written against the underlying tool, but neither RTK's
own matcher nor the host's native one recognized `rtk grep foo` as a match
for that pattern — RTK's hook fell back to Defer (nothing to rewrite), and
the host's native check independently failed the same way, so both allow
and deny rules silently stopped applying once a command arrived pre-rewritten.
- permissions.rs: strip a leading `rtk ` from each compound-command segment
before matching against deny/ask/allow patterns, so rules match regardless
of which form the command arrives in.
- hook_cmd.rs (decide_from_verdict): an Allow verdict with nothing left to
rewrite is no longer silently discarded as Defer — it's asserted directly,
since the corrected matching above means it's a real Allow.
- hook_cmd.rs (process_claude_payload): a Deny verdict on an already-rtk
segment is now asserted explicitly instead of silently deferring to the
host's native check — deferring only works when the host evaluates text
that still matches the user's original pattern, which isn't true once the
segment carries the `rtk ` prefix. This closes a real bypass: a deny rule
could previously be sidestepped just by the command arriving pre-rewritten.
The original (non-rtk) command path is untouched — same defer-to-native
behavior as before.
Verified live against the reporter's exact settings.local.json + rtk-prefixed
grep/ls repro, the already-rtk deny case, and a compound already-rtk `||`
chain. Added regression tests in both files; full suite (2498), clippy, and
fmt all clean.1 parent e3f9581 commit 30557a6
2 files changed
Lines changed: 178 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
| |||
283 | 284 | | |
284 | 285 | | |
285 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
286 | 295 | | |
287 | 296 | | |
288 | 297 | | |
| |||
617 | 626 | | |
618 | 627 | | |
619 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
620 | 639 | | |
621 | 640 | | |
622 | 641 | | |
| |||
636 | 655 | | |
637 | 656 | | |
638 | 657 | | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
639 | 673 | | |
640 | 674 | | |
641 | 675 | | |
| |||
644 | 678 | | |
645 | 679 | | |
646 | 680 | | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
647 | 694 | | |
648 | 695 | | |
649 | 696 | | |
650 | | - | |
| 697 | + | |
651 | 698 | | |
652 | 699 | | |
653 | 700 | | |
| |||
721 | 768 | | |
722 | 769 | | |
723 | 770 | | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
724 | 775 | | |
725 | 776 | | |
726 | 777 | | |
| |||
733 | 784 | | |
734 | 785 | | |
735 | 786 | | |
| 787 | + | |
736 | 788 | | |
737 | 789 | | |
738 | 790 | | |
| |||
1565 | 1617 | | |
1566 | 1618 | | |
1567 | 1619 | | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
1568 | 1640 | | |
1569 | 1641 | | |
1570 | 1642 | | |
| |||
1977 | 2049 | | |
1978 | 2050 | | |
1979 | 2051 | | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
1980 | 2086 | | |
1981 | 2087 | | |
1982 | 2088 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
378 | 392 | | |
379 | 393 | | |
380 | 394 | | |
| |||
1166 | 1180 | | |
1167 | 1181 | | |
1168 | 1182 | | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
1169 | 1238 | | |
1170 | 1239 | | |
1171 | 1240 | | |
| |||
0 commit comments