| 1 | package sandbox |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "runtime" |
| 6 | ) |
| 7 | |
| 8 | // ValidateShellPolicy rejects the unsupported MSYS execution lane before any |
| 9 | // process or private-temp lease is created. Full-access explicit Bash remains |
| 10 | // supported; auto selection on Windows never selects Bash. |
| 11 | func ValidateShellPolicy(spec Spec, sh Shell) error { |
| 12 | return validateShellPolicy(runtime.GOOS, spec, sh) |
| 13 | } |
| 14 | |
| 15 | func validateShellPolicy(goos string, spec Spec, sh Shell) error { |
| 16 | if goos == "windows" && spec.Enforce() && sh.Kind != ShellPowerShell { |
| 17 | return fmt.Errorf("Bash/POSIX shell execution is disabled in the Windows restricted sandbox because MSYS/Cygwin runtime initialization is incompatible. Select auto, pwsh or powershell in Shell settings and use PowerShell syntax. The requested command was not run; sandbox permissions were not changed") |
| 18 | } |
| 19 | return nil |
| 20 | } |
| 21 |