@@ -2,6 +2,7 @@ package tools
@@ -16,13 +17,7 @@ func TestGetSafeReadOnlyCommands(t *testing.T) {
16 // Check for cross-platform commands that should always be present
17 // Check for cross-platform commands that should always be present
17 crossPlatformCommands := []string{"echo", "hostname", "whoami", "git status", "go version"}
18 crossPlatformCommands := []string{"echo", "hostname", "whoami", "git status", "go version"}
18 for _, cmd := range crossPlatformCommands {
19 for _, cmd := range crossPlatformCommands {
19− found := false
20+ found := slices.Contains(commands, cmd)
20− for _, safeCmd := range commands {
26 if !found {
21 if !found {
27 t.Errorf("Expected cross-platform command %q to be in safe commands", cmd)
22 t.Errorf("Expected cross-platform command %q to be in safe commands", cmd)
@@ -32,13 +27,7 @@ func TestGetSafeReadOnlyCommands(t *testing.T) {
32 // Check for Windows-specific commands
27 // Check for Windows-specific commands
33 windowsCommands := []string{"dir", "type", "Get-Process"}
28 windowsCommands := []string{"dir", "type", "Get-Process"}
34 for _, cmd := range windowsCommands {
29 for _, cmd := range windowsCommands {
35− found := false
30+ found := slices.Contains(commands, cmd)
36− for _, safeCmd := range commands {
42 if !found {
31 if !found {
43 t.Errorf("Expected Windows command %q to be in safe commands on Windows", cmd)
32 t.Errorf("Expected Windows command %q to be in safe commands on Windows", cmd)
@@ -47,13 +36,7 @@ func TestGetSafeReadOnlyCommands(t *testing.T) {
47 // Check that Unix commands are NOT present on Windows
36 // Check that Unix commands are NOT present on Windows
48 unixCommands := []string{"ls", "pwd", "ps"}
37 unixCommands := []string{"ls", "pwd", "ps"}
49 for _, cmd := range unixCommands {
38 for _, cmd := range unixCommands {
50− found := false
39+ found := slices.Contains(commands, cmd)
51− for _, safeCmd := range commands {
57 if found {
40 if found {
58 t.Errorf("Unix command %q should not be in safe commands on Windows", cmd)
41 t.Errorf("Unix command %q should not be in safe commands on Windows", cmd)
@@ -62,13 +45,7 @@ func TestGetSafeReadOnlyCommands(t *testing.T) {
62 // Check for Unix-specific commands
45 // Check for Unix-specific commands
63 unixCommands := []string{"ls", "pwd", "ps"}
46 unixCommands := []string{"ls", "pwd", "ps"}
64 for _, cmd := range unixCommands {
47 for _, cmd := range unixCommands {
65− found := false
48+ found := slices.Contains(commands, cmd)
66− for _, safeCmd := range commands {
72 if !found {
49 if !found {
73 t.Errorf("Expected Unix command %q to be in safe commands on Unix", cmd)
50 t.Errorf("Expected Unix command %q to be in safe commands on Unix", cmd)
@@ -77,13 +54,7 @@ func TestGetSafeReadOnlyCommands(t *testing.T) {
77 // Check that Windows-specific commands are NOT present on Unix
54 // Check that Windows-specific commands are NOT present on Unix
78 windowsOnlyCommands := []string{"dir", "Get-Process", "systeminfo"}
55 windowsOnlyCommands := []string{"dir", "Get-Process", "systeminfo"}
79 for _, cmd := range windowsOnlyCommands {
56 for _, cmd := range windowsOnlyCommands {
80− found := false
57+ found := slices.Contains(commands, cmd)
81− for _, safeCmd := range commands {
87 if found {
58 if found {
88 t.Errorf("Windows-only command %q should not be in safe commands on Unix", cmd)
59 t.Errorf("Windows-only command %q should not be in safe commands on Unix", cmd)