Skip to content

Commit a9b8307

Browse files
committed
test(permissions): align Gentleman-Programming#4327 fixtures with the deny-by-default policy
Rebase onto main brought in Gentleman-Programming#4327's fixtures, which pin ask-by-default and non-interception of absolute-path invocations. This PR ships the opposite policy for Gentleman-Programming#4324: deny by default (explicit personal config still wins and is not silently rewritten), and deny of absolute-path, backslash-escape, and shell resolution wrapper invocations of the remote shell utilities. Update both fixtures to pin the intended behavior instead of the upstream intermediate state.
1 parent 6563fb3 commit a9b8307

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

internal/components/permissions/inject_test.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,19 @@ func remoteAction(t *testing.T, raw []byte, command string) string {
6363
}
6464

6565
func TestRemoteMatcherBoundaryFixtures(t *testing.T) {
66-
// These are matcher inputs, not shell programs. bash.ts extracts command
66+
// #4324 deny policy: absolute-path, backslash-escape, and shell resolution
67+
// wrapper invocations of the remote shell utilities are denied by the
68+
// overlay itself. Pattern-only rules are bypassable through these forms
69+
// (the command token is not the bare utility name), so the deny entries
70+
// enumerate them explicitly instead of relying on guidance alone.
71+
for _, input := range []string{"/usr/bin/ssh example.invalid", "/bin/scp file example.invalid:file", "\\ssh example.invalid", "command ssh example.invalid", "exec rsync -a src dst"} {
72+
if got := remoteAction(t, openCodeOverlayJSON, input); got != "deny" {
73+
t.Errorf("bypass invocation %q not denied: %s", input, got)
74+
}
75+
}
76+
// These remain matcher inputs, not shell programs. bash.ts extracts command
6777
// nodes separately; no claim is made about parsing arbitrary shell syntax.
68-
for _, input := range []string{"/usr/bin/ssh example.invalid", "env ssh example.invalid", "true && ssh example.invalid", `python -c 'import subprocess'`} {
78+
for _, input := range []string{"env ssh example.invalid", "true && ssh example.invalid", `python -c 'import subprocess'`} {
6979
if got := remoteAction(t, openCodeOverlayJSON, input); got != "allow" {
7080
t.Errorf("unsupported matcher input %q unexpectedly intercepted: %s", input, got)
7181
}
@@ -93,9 +103,12 @@ func TestRemoteCommandApprovalDefaults(t *testing.T) {
93103
t.Fatal(err)
94104
}
95105
for _, command := range []string{"ssh", "ssh example.invalid", "scp", "scp file example.invalid:file", "sftp", "sftp example.invalid", "rsync", "rsync source destination"} {
96-
want := "ask"
97-
if seed == `{"permission":"deny"}` || seed == `{"permission":{"bash":"deny"}}` || strings.Contains(seed, `"*":"deny"`) || (strings.Contains(seed, `"deny"`) && strings.HasPrefix(command, "ssh")) {
98-
want = "deny"
106+
// #4324 deny policy: the overlay denies the remote shell
107+
// utilities by default instead of asking per command; a human
108+
// who wants them re-enables them explicitly in their own config.
109+
want := "deny"
110+
if seed == `{"permission":{"bash":"ask"}}` {
111+
want = "ask" // Explicit personal scalar ask is not silently rewritten.
99112
}
100113
if strings.Contains(seed, `"ssh*":"allow"`) && strings.HasPrefix(command, "ssh") {
101114
want = "allow" // Explicit personal allow is not silently rewritten.

0 commit comments

Comments
 (0)