Skip to content

Commit 2dc8dcb

Browse files
committed
fix(sandbox): support symlinked SSH dirs and canonicalize test candidates
Compare os.Stat instead of os.Lstat during SSH root directory walk so symlinked directory roots match root.Stat without failing closed as unexpected replacements. Canonicalize both entry and target in denyCovered to correctly handle macOS /private/var and Windows 8.3 short-path aliases. Refs #815
1 parent ac80d1f commit 2dc8dcb

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎internal/sandbox/ssh_gpg_deny_test.go‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ import (
1212

1313
func denyCovered(denied []string, target string) bool {
1414
norm := normalizeProfilePath(target)
15+
if norm == "" {
16+
norm = filepath.Clean(target)
17+
}
1518
for _, entry := range denied {
16-
if entry == norm || pathWithinRoot(entry, norm) {
19+
normEntry := normalizeProfilePath(entry)
20+
if normEntry == "" {
21+
normEntry = filepath.Clean(entry)
22+
}
23+
if normEntry == norm || pathWithinRoot(normEntry, norm) {
1724
return true
1825
}
1926
}

‎internal/sandbox/ssh_key_deny.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (s *sshDiscovery) walkPrivateKeyFiles(sshDir string) []string {
127127
testSSHWalkChildHook(dir)
128128
}
129129
// Verify directory identity has not changed since opening root.
130-
dirStat, statErr := os.Lstat(dir)
130+
dirStat, statErr := os.Stat(dir)
131131
if statErr != nil || !os.SameFile(dirStat, rootStat) {
132132
s.fail(dir, "directory identity changed during inspection")
133133
return

0 commit comments

Comments
 (0)