fix(auth): close cancellation and workspace races
This commit is contained in:
@@ -6,28 +6,29 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWindowsTerminationUsesBoundedExactPIDTreeKillWithoutAShell(t *testing.T) {
|
||||
func TestWindowsTerminationOwnsTheProcessTreeWithAKillOnCloseJobObjectWithoutAShell(t *testing.T) {
|
||||
source, err := os.ReadFile("process_windows.go")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
text := string(source)
|
||||
for _, required := range []string{
|
||||
"context.WithTimeout", "windows.GetSystemDirectory", "filepath.Clean", "filepath.IsAbs",
|
||||
`filepath.Join(systemDirectory, "taskkill.exe")`, "systemTaskkillPath",
|
||||
`exec.CommandContext(ctx, taskkillPath, "/PID", strconv.Itoa(pid), "/T", "/F")`,
|
||||
"io.Discard", "ErrProcessReap",
|
||||
"windows.CreateJobObject", "windows.JOBOBJECT_EXTENDED_LIMIT_INFORMATION",
|
||||
"windows.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE", "windows.SetInformationJobObject",
|
||||
"windows.AssignProcessToJobObject", "windows.TerminateJobObject", "windows.OpenProcess",
|
||||
"windows.CreateToolhelp32Snapshot", "windows.ResumeThread", "windows.CloseHandle",
|
||||
"createSuspendedProcess",
|
||||
} {
|
||||
if !strings.Contains(text, required) {
|
||||
t.Errorf("process_windows.go is missing %q", required)
|
||||
}
|
||||
}
|
||||
for _, forbidden := range []string{
|
||||
"cmd.exe", "powershell", `exec.Command("taskkill.exe"`,
|
||||
`exec.CommandContext(ctx, "taskkill.exe"`, `exec.LookPath("taskkill.exe")`,
|
||||
"taskkill", "cmd.exe", "powershell", "exec.Command(", "exec.CommandContext(",
|
||||
"exec.LookPath(", "windows.GetSystemDirectory",
|
||||
} {
|
||||
if strings.Contains(strings.ToLower(text), strings.ToLower(forbidden)) {
|
||||
t.Errorf("process_windows.go contains unsafe command form %q", forbidden)
|
||||
t.Errorf("process_windows.go contains unsafe or unowned process-tree mechanism %q", forbidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user