// Package denylist is the Mac runners spec §4.2 deny list: what no step // on a Mac may read or write. It is a leaf (standard library only) so // both the Mac worker (package mac, for its checks and Engineering // profiles) and the native permission port (provider/claude, whose // tests build darwin policies from it) share the one list, although mac // itself imports provider/claude. package denylist import ( "path/filepath" "slices" ) // Paths are the places the §4.2 deny list protects on this machine. type Paths struct { // Home is the runner user's home (/Users/equipo-paul). Home string // StateDir holds the enrolment key, the steps and the relayed // objects; AccountsRoot and SessionRoot the model sign-ins. StateDir, AccountsRoot, SessionRoot string // InstallDir is where the runner's binaries live (denied writes). InstallDir string // OtherHomes are every home under /Users but the runner user's. OtherHomes []string // UserTemp is the runner user's DARWIN_USER_TEMP_DIR, resolved and // checked by UserTemp; "" when it was refused, and UserTempWhy says // why. No checks profile is made without it: Xcode writes there // whatever $TMPDIR says. UserTemp, UserTempWhy string // HomesUnknown: /Users could not be listed. Every profile then denies // all of /Users, the runner's own home too, so no checks profile can // be made (checks cannot run) rather than one that misses a home. HomesUnknown bool } // DenyList is §4.2: what no step may read or write. func DenyList(p Paths) []string { out := []string{p.StateDir, p.AccountsRoot, p.SessionRoot} for _, rel := range []string{".ssh", ".aws", ".gnupg", ".config/op", "Library/Keychains"} { out = append(out, filepath.Join(p.Home, rel)) } out = append(out, p.OtherHomes...) if p.HomesUnknown { out = append(out, "/Users") } out = append(out, "/Volumes") result := []string{} for _, path := range out { if path != "" && !slices.Contains(result, path) { result = append(result, path) } } return result }