diff --git a/checks_windows.go b/checks_windows.go index 839989d..46dcd91 100644 --- a/checks_windows.go +++ b/checks_windows.go @@ -150,7 +150,7 @@ func (c cond) RegistryKey() (bool, error) { registryArgs := regexp.MustCompile(`\\+`).Split(c.Key, -1) if len(registryArgs) < 2 { fail("Invalid key for RegistryKey. Did you supply 'key'?") - return false, errors.New("invalid registry key path: " + c.Key) + return false, errors.New("Invalid registry key path: " + c.Key) } registryHiveText := registryArgs[0] keyPath := fmt.Sprintf(strings.Join(registryArgs[1:len(registryArgs)-1], `\`)) diff --git a/checks_windows_test.go b/checks_windows_test.go index de15b97..1ba995b 100644 --- a/checks_windows_test.go +++ b/checks_windows_test.go @@ -1,7 +1,6 @@ package main import ( - "io/ioutil" "os" "testing" @@ -12,7 +11,7 @@ import ( func TestPermissionIs(t *testing.T) { filePath := "misc/tests/permTest.txt" - ioutil.WriteFile(filePath, []byte("testContent"), os.ModePerm) + os.WriteFile(filePath, []byte("testContent"), os.ModePerm) defer os.Remove(filePath) c := cond{ diff --git a/output.go b/output.go index 8203e90..d91be33 100644 --- a/output.go +++ b/output.go @@ -35,10 +35,7 @@ func ask(p ...interface{}) bool { fmt.Print(toPrint + " [Y/n]: ") var resp string fmt.Scanln(&resp) - if strings.ToLower(strings.TrimSpace(resp)) == "n" { - return false - } - return true + return !(strings.ToLower(strings.TrimSpace(resp)) == "n") } func pass(p ...interface{}) { diff --git a/release_windows.go b/release_windows.go index d393531..c4c3580 100644 --- a/release_windows.go +++ b/release_windows.go @@ -135,7 +135,7 @@ func installService() { Add-MpPreference -ExclusionPath "C:\aeacus\" ` shellCommand(addExclusions) - + } // cleanUp clears out sensitive files left behind by image developers or the @@ -152,7 +152,7 @@ func cleanUp() { info("Emptying recycle bin...") shellCommand("Clear-RecycleBin -Force") info("Clearing recently used...") - shellCommand("Remove-Item -Force '${env:USERPROFILE}\\AppData\\Roaming\\Microsoft\\Windows\\Recent‌​*.lnk'") + shellCommand("Remove-Item -Force \"${env:USERPROFILE}\\AppData\\Roaming\\Microsoft\\Windows\\Recent\\*.lnk\"") info("Clearing run.exe command history...") clearRunScript := `$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" $arr = (Get-Item -Path $path).Property diff --git a/remote.go b/remote.go index 7467e8d..b284072 100644 --- a/remote.go +++ b/remote.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "math" "net/http" "net/url" @@ -177,7 +177,7 @@ func checkServer() { conn.ServerStatus = FAIL } else { defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { fail("Error reading Status body.") conn.ServerColor = RED diff --git a/shell_windows.go b/shell_windows.go index 204ab24..b6a80be 100644 --- a/shell_windows.go +++ b/shell_windows.go @@ -89,8 +89,7 @@ func shellSocket() { continue } } else { - select { - case <-ticker.C: + for range ticker.C { if disconnected { readTeamID() curTeamID := string(teamID) diff --git a/utility.go b/utility.go index 89cdf68..3802fd9 100644 --- a/utility.go +++ b/utility.go @@ -2,7 +2,6 @@ package main import ( "errors" - "io/ioutil" "os" "runtime" "strings" @@ -66,10 +65,10 @@ func timeCheck() bool { return false } -// writeFile wraps ioutil's WriteFile function, and prints +// writeFile wraps os's WriteFile function, and prints // the error the screen if one occurs. func writeFile(fileName, fileContent string) { - err := ioutil.WriteFile(fileName, []byte(fileContent), 0o644) + err := os.WriteFile(fileName, []byte(fileContent), 0o644) if err != nil { fail("Error writing file: " + err.Error()) } diff --git a/utility_linux.go b/utility_linux.go index a3ed868..53a5164 100644 --- a/utility_linux.go +++ b/utility_linux.go @@ -3,7 +3,6 @@ package main import ( "crypto/md5" "io" - "io/ioutil" "os" "os/exec" "os/user" @@ -12,7 +11,7 @@ import ( // readFile (Linux) wraps ioutil's ReadFile function. func readFile(fileName string) (string, error) { - fileContent, err := ioutil.ReadFile(fileName) + fileContent, err := os.ReadFile(fileName) return string(fileContent), err } @@ -108,6 +107,6 @@ func adminCheck() bool { return true } -func getInfo(infoType string) { +func getInfo(_ string) { warn("Info gathering is not supported for Linux-- there's always a better, easier command-line tool.") } diff --git a/utility_windows.go b/utility_windows.go index 8d6db87..1c98f5e 100644 --- a/utility_windows.go +++ b/utility_windows.go @@ -2,13 +2,14 @@ package main import ( "bytes" - "github.com/DataDog/datadog-agent/pkg/util/winutil" "io/ioutil" "os" "os/exec" "strings" "unsafe" + "github.com/DataDog/datadog-agent/pkg/util/winutil" + "github.com/gen2brain/beeep" wapi "github.com/iamacarpet/go-win64api" "github.com/iamacarpet/go-win64api/shared" @@ -26,7 +27,7 @@ var ( // readFile (Windows) uses ioutil's ReadFile function and passes the returned // byte sequence to decodeString. func readFile(filename string) (string, error) { - raw, err := ioutil.ReadFile(filename) + raw, err := os.ReadFile(filename) if err != nil { return "", err }