Skip to content

Commit d8d26f6

Browse files
committed
fix CI: TestSecurity_WriteFile_CustomAllowlist false-fails on 'permission denied' OS error, now checks security-layer denial only
1 parent 1478dba commit d8d26f6

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

cmd/kode/security_e2e_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ func TestSecurity_WriteFile_DestructivePath(t *testing.T) {
111111
func TestSecurity_WriteFile_CustomAllowlist(t *testing.T) {
112112
// /etc is system_write → deny by default in deny-non-interactive mode.
113113
// But non_interactive=allow should override the security denial.
114-
// Note: the actual os.WriteFile may still fail due to filesystem
115-
// permissions (we're not root in CI). That's OK — we're testing
116-
// that the security layer allows the operation, not that the
117-
// filesystem write succeeds.
114+
// The actual os.WriteFile will fail with a filesystem permission error
115+
// (CI runners aren't root). We test that the error is a filesystem
116+
// error, NOT a security-layer denial.
118117
allow := "allow"
119118
dc := danger.DangerousConfig{
120119
NonInteractive: &allow,
@@ -125,8 +124,12 @@ func TestSecurity_WriteFile_CustomAllowlist(t *testing.T) {
125124
mustUnmarshal(t, result, &r)
126125
// With non_interactive=allow, the security layer should NOT issue
127126
// a denial. A filesystem-level permission error is acceptable.
128-
if strings.Contains(r.Error, "denied") {
129-
t.Errorf("expected security layer to allow, got denial: %s", r.Error)
127+
if r.Error != "" && (strings.Contains(r.Error, "security") || strings.Contains(r.Error, "config")) {
128+
t.Errorf("expected security layer to allow, got security denial: %s", r.Error)
129+
}
130+
// Verify it's a filesystem-level error
131+
if r.Error != "" && !strings.Contains(r.Error, "permission") {
132+
t.Logf("expected FS error (not denial): %s", r.Error)
130133
}
131134
}
132135

0 commit comments

Comments
 (0)