From 5b415c5aa135d353ab694af23a5b24df4f828bd1 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Thu, 19 Oct 2023 20:06:45 +0800 Subject: [PATCH 1/2] chore: remove refs to deprecated io/ioutil Signed-off-by: guoguangwu --- client/command/alias/alias.go | 4 ++-- client/command/alias/install.go | 9 ++++----- client/command/dllhijack/dllhijack.go | 6 +++--- client/command/filesystem/upload.go | 3 +-- client/command/jobs/https.go | 6 +++--- client/command/processes/procdump.go | 3 +-- client/command/reaction/helpers.go | 6 +++--- client/command/registry/reg-write.go | 4 ++-- client/command/screenshot/screenshot.go | 3 +-- client/command/shikata-ga-nai/sgn.go | 6 +++--- client/command/tasks/fetch.go | 3 +-- client/command/update/update.go | 3 +-- client/command/wireguard/wg-config.go | 4 ++-- client/prelude/bof.go | 4 ++-- client/prelude/bridge.go | 4 ++-- client/version/updates.go | 4 ++-- implant/sliver/forwarder/socks.go | 4 ++-- implant/sliver/netstat/netstat_linux.go | 5 ++--- implant/sliver/proxy/provider.go | 3 +-- implant/sliver/proxy/provider_test.go | 11 +++++------ implant/sliver/ps/ps_linux.go | 5 ++--- implant/sliver/shell/ssh/ssh.go | 3 +-- implant/sliver/taskrunner/task_linux.go | 3 +-- .../httpclient/drivers/win/tools/defines.go | 4 ++-- server/cryptography/minisign/private.go | 4 ++-- server/cryptography/minisign/public.go | 4 ++-- server/cryptography/minisign/signature.go | 4 ++-- 27 files changed, 55 insertions(+), 67 deletions(-) diff --git a/client/command/alias/alias.go b/client/command/alias/alias.go index c418427ba9..55472489ad 100644 --- a/client/command/alias/alias.go +++ b/client/command/alias/alias.go @@ -21,7 +21,7 @@ package alias import ( "encoding/json" "fmt" - "io/ioutil" + "os" "strings" "github.com/bishopfox/sliver/client/assets" @@ -115,7 +115,7 @@ func getInstalledManifests() map[string]*AliasManifest { manifestPaths := assets.GetInstalledAliasManifests() installedManifests := map[string]*AliasManifest{} for _, manifestPath := range manifestPaths { - data, err := ioutil.ReadFile(manifestPath) + data, err := os.ReadFile(manifestPath) if err != nil { continue } diff --git a/client/command/alias/install.go b/client/command/alias/install.go index e63ea0f374..2953412881 100644 --- a/client/command/alias/install.go +++ b/client/command/alias/install.go @@ -20,7 +20,6 @@ package alias import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -50,7 +49,7 @@ func AliasesInstallCmd(cmd *cobra.Command, con *console.SliverConsoleClient, arg // Install an extension from a directory func installFromDir(aliasLocalPath string, con *console.SliverConsoleClient) { - manifestData, err := ioutil.ReadFile(filepath.Join(aliasLocalPath, ManifestFileName)) + manifestData, err := os.ReadFile(filepath.Join(aliasLocalPath, ManifestFileName)) if err != nil { con.PrintErrorf("Error reading %s: %s", ManifestFileName, err) return @@ -78,7 +77,7 @@ func installFromDir(aliasLocalPath string, con *console.SliverConsoleClient) { con.PrintErrorf("Error creating alias directory: %s\n", err) return } - err = ioutil.WriteFile(filepath.Join(installPath, ManifestFileName), manifestData, 0o600) + err = os.WriteFile(filepath.Join(installPath, ManifestFileName), manifestData, 0o600) if err != nil { con.PrintErrorf("Failed to write %s: %s\n", ManifestFileName, err) forceRemoveAll(installPath) @@ -133,7 +132,7 @@ func InstallFromFile(aliasGzFilePath string, autoOverwrite bool, con *console.Sl con.PrintErrorf("Failed to create alias directory: %s\n", err) return nil } - err = ioutil.WriteFile(filepath.Join(installPath, ManifestFileName), manifestData, 0o600) + err = os.WriteFile(filepath.Join(installPath, ManifestFileName), manifestData, 0o600) if err != nil { con.PrintErrorf("Failed to write %s: %s\n", ManifestFileName, err) forceRemoveAll(installPath) @@ -166,7 +165,7 @@ func installArtifact(aliasGzFilePath string, installPath, artifactPath string, c if _, err := os.Stat(artifactDir); os.IsNotExist(err) { os.MkdirAll(artifactDir, 0o700) } - err = ioutil.WriteFile(localArtifactPath, data, 0o600) + err = os.WriteFile(localArtifactPath, data, 0o600) if err != nil { return err } diff --git a/client/command/dllhijack/dllhijack.go b/client/command/dllhijack/dllhijack.go index 48eb91dd19..897986edc7 100644 --- a/client/command/dllhijack/dllhijack.go +++ b/client/command/dllhijack/dllhijack.go @@ -21,7 +21,7 @@ package dllhijack import ( "context" "fmt" - "io/ioutil" + "o" "github.com/spf13/cobra" @@ -58,7 +58,7 @@ func DllHijackCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []s } if localReferenceFilePath != "" { - localRefData, err = ioutil.ReadFile(localReferenceFilePath) + localRefData, err = os.ReadFile(localReferenceFilePath) if err != nil { con.PrintErrorf("Could not load the reference file from the client: %s\n", err) return @@ -70,7 +70,7 @@ func DllHijackCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []s con.PrintErrorf("please use either --profile or --File") return } - targetDLLData, err = ioutil.ReadFile(localFile) + targetDLLData, err = os.ReadFile(localFile) if err != nil { con.PrintErrorf("Error: %s\n", err) return diff --git a/client/command/filesystem/upload.go b/client/command/filesystem/upload.go index 9e163699dc..aa40dbc021 100644 --- a/client/command/filesystem/upload.go +++ b/client/command/filesystem/upload.go @@ -21,7 +21,6 @@ package filesystem import ( "context" "fmt" - "io/ioutil" "os" "path/filepath" @@ -72,7 +71,7 @@ func UploadCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []stri dst := remotePath - fileBuf, err := ioutil.ReadFile(src) + fileBuf, err := os.ReadFile(src) if err != nil { con.PrintErrorf("%s\n", err) return diff --git a/client/command/jobs/https.go b/client/command/jobs/https.go index 474c32b799..8a8c12c8fd 100644 --- a/client/command/jobs/https.go +++ b/client/command/jobs/https.go @@ -22,7 +22,7 @@ import ( "context" "crypto/tls" "fmt" - "io/ioutil" + "os" "time" "github.com/spf13/cobra" @@ -92,11 +92,11 @@ func getLocalCertificatePair(cmd *cobra.Command) ([]byte, []byte, error) { if certPath == "" && keyPath == "" { return nil, nil, nil } - cert, err := ioutil.ReadFile(certPath) + cert, err := os.ReadFile(certPath) if err != nil { return nil, nil, err } - key, err := ioutil.ReadFile(keyPath) + key, err := os.ReadFile(keyPath) if err != nil { return nil, nil, err } diff --git a/client/command/processes/procdump.go b/client/command/processes/procdump.go index 904de72bab..f9da7f4be8 100644 --- a/client/command/processes/procdump.go +++ b/client/command/processes/procdump.go @@ -21,7 +21,6 @@ package processes import ( "context" "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -112,7 +111,7 @@ func PrintProcessDump(dump *sliverpb.ProcessDump, saveTo string, hostname string var saveToFile *os.File if saveTo == "" { tmpFileName := filepath.Base(fmt.Sprintf("procdump_%s_%d_*", hostname, pid)) - saveToFile, err = ioutil.TempFile("", tmpFileName) + saveToFile, err = os.CreateTemp("", tmpFileName) if err != nil { con.PrintErrorf("Error creating temporary file: %s\n", err) return diff --git a/client/command/reaction/helpers.go b/client/command/reaction/helpers.go index 0e7d22b247..dd6de74eb0 100644 --- a/client/command/reaction/helpers.go +++ b/client/command/reaction/helpers.go @@ -21,7 +21,7 @@ package reaction import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path" "strconv" "strings" @@ -49,13 +49,13 @@ func SaveReactions(reactions []core.Reaction) error { if err != nil { return err } - return ioutil.WriteFile(reactionFilePath, data, 0o600) + return os.WriteFile(reactionFilePath, data, 0o600) } // LoadReactions - Save the reactions to the reaction file func LoadReactions() (int, error) { reactionFilePath := GetReactionFilePath() - data, err := ioutil.ReadFile(reactionFilePath) + data, err := os.ReadFile(reactionFilePath) if err != nil { return 0, err } diff --git a/client/command/registry/reg-write.go b/client/command/registry/reg-write.go index e477b5682e..f47ac811fa 100644 --- a/client/command/registry/reg-write.go +++ b/client/command/registry/reg-write.go @@ -21,7 +21,7 @@ package registry import ( "context" "encoding/hex" - "io/ioutil" + "os" "strconv" "strings" @@ -100,7 +100,7 @@ func RegWriteCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []st return } } else { - v, err = ioutil.ReadFile(binPath) + v, err = os.ReadFile(binPath) if err != nil { con.PrintErrorf("%s\n", err) return diff --git a/client/command/screenshot/screenshot.go b/client/command/screenshot/screenshot.go index f15a884a41..237ba31ecf 100644 --- a/client/command/screenshot/screenshot.go +++ b/client/command/screenshot/screenshot.go @@ -21,7 +21,6 @@ package screenshot import ( "context" "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -107,7 +106,7 @@ func PrintScreenshot(screenshot *sliverpb.Screenshot, hostname string, cmd *cobr var err error if saveTo == "" { tmpFileName := filepath.Base(fmt.Sprintf("screenshot_%s_%s_*.png", filepath.Base(hostname), timestamp)) - saveToFile, err = ioutil.TempFile("", tmpFileName) + saveToFile, err = os.CreateTemp("", tmpFileName) if err != nil { con.PrintErrorf("%s\n", err) return diff --git a/client/command/shikata-ga-nai/sgn.go b/client/command/shikata-ga-nai/sgn.go index f63f4b6c07..e16e18c667 100644 --- a/client/command/shikata-ga-nai/sgn.go +++ b/client/command/shikata-ga-nai/sgn.go @@ -21,7 +21,7 @@ package sgn import ( "context" "encoding/hex" - "io/ioutil" + "os" "path/filepath" "github.com/spf13/cobra" @@ -33,7 +33,7 @@ import ( // ShikataGaNaiCmd - Command wrapper for the Shikata Ga Nai shellcode encoder func ShikataGaNaiCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string) { shellcodeFile := args[0] - rawShellcode, err := ioutil.ReadFile(shellcodeFile) + rawShellcode, err := os.ReadFile(shellcodeFile) if err != nil { con.PrintErrorf("Failed to read shellcode file: %s", err) return @@ -73,7 +73,7 @@ func ShikataGaNaiCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args outputFile += ".sgn" } - err = ioutil.WriteFile(outputFile, shellcodeResp.Data, 0o644) + err = os.WriteFile(outputFile, shellcodeResp.Data, 0o644) if err != nil { con.PrintErrorf("Failed to write shellcode file: %s", err) return diff --git a/client/command/tasks/fetch.go b/client/command/tasks/fetch.go index 61a11deb67..adeeb63367 100644 --- a/client/command/tasks/fetch.go +++ b/client/command/tasks/fetch.go @@ -20,7 +20,6 @@ package tasks import ( "context" - "io/ioutil" "os" "strings" "time" @@ -782,7 +781,7 @@ func promptSaveToFile(data []byte, con *console.SliverConsoleClient) { return } } - err = ioutil.WriteFile(saveTo, data, 0o600) + err = os.WriteFile(saveTo, data, 0o600) if err != nil { con.PrintErrorf("Failed to save file: %s\n", err) return diff --git a/client/command/update/update.go b/client/command/update/update.go index 06b6596b1e..df996b4986 100644 --- a/client/command/update/update.go +++ b/client/command/update/update.go @@ -23,7 +23,6 @@ import ( "crypto/tls" "fmt" "io" - "io/ioutil" "net" "net/http" "net/url" @@ -120,7 +119,7 @@ func UpdateCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []stri lastCheck := []byte(fmt.Sprintf("%d", now.Unix())) appDir := assets.GetRootAppDir() lastUpdateCheckPath := path.Join(appDir, consts.LastUpdateCheckFileName) - err = ioutil.WriteFile(lastUpdateCheckPath, lastCheck, 0o600) + err = os.WriteFile(lastUpdateCheckPath, lastCheck, 0o600) if err != nil { con.Printf("Failed to save update check time %s", err) } diff --git a/client/command/wireguard/wg-config.go b/client/command/wireguard/wg-config.go index 1568b51f04..2e7c3bb13e 100644 --- a/client/command/wireguard/wg-config.go +++ b/client/command/wireguard/wg-config.go @@ -23,8 +23,8 @@ import ( "context" "encoding/base64" "encoding/hex" - "io/ioutil" "net" + "os" "strings" "text/template" @@ -95,7 +95,7 @@ func WGConfigCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []st if !strings.HasSuffix(save, ".conf") { save += ".conf" } - err = ioutil.WriteFile(save, output.Bytes(), 0o600) + err = os.WriteFile(save, output.Bytes(), 0o600) if err != nil { con.PrintErrorf("Error: %s\n", err) return diff --git a/client/prelude/bof.go b/client/prelude/bof.go index 7423378584..e3c7a6f191 100644 --- a/client/prelude/bof.go +++ b/client/prelude/bof.go @@ -22,7 +22,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "os" "path" "github.com/bishopfox/sliver/client/assets" @@ -139,7 +139,7 @@ func registerLoader(implant ActiveImplant, rpc rpcpb.SliverRPCClient) error { coffLoaderPath = "COFFLoader.x86.dll" } loaderPath := path.Join(assets.GetExtensionsDir(), coffLoaderName, coffLoaderPath) - loaderData, err := ioutil.ReadFile(loaderPath) + loaderData, err := os.ReadFile(loaderPath) if err != nil { return err } diff --git a/client/prelude/bridge.go b/client/prelude/bridge.go index 67275dcd69..c1833f5300 100644 --- a/client/prelude/bridge.go +++ b/client/prelude/bridge.go @@ -24,7 +24,7 @@ import ( "encoding/hex" "encoding/json" "fmt" - "io/ioutil" + "io" "net" "net/http" "strings" @@ -161,7 +161,7 @@ func requestPayload(target string) ([]byte, error) { if resp.StatusCode != 200 { return nil, fmt.Errorf("invalid status code: %d", resp.StatusCode) } - return ioutil.ReadAll(resp.Body) + return io.ReadAll(resp.Body) } func (a *OperatorImplantBridge) refreshBeacon() { diff --git a/client/version/updates.go b/client/version/updates.go index 963d7040ef..b0001cd359 100644 --- a/client/version/updates.go +++ b/client/version/updates.go @@ -3,7 +3,7 @@ package version import ( "encoding/json" "errors" - "io/ioutil" + "io" "net/http" "os" "strconv" @@ -77,7 +77,7 @@ func CheckForUpdates(client *http.Client, prereleases bool) (*Release, error) { return nil, err } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/implant/sliver/forwarder/socks.go b/implant/sliver/forwarder/socks.go index 13f83a66db..3218c6b224 100644 --- a/implant/sliver/forwarder/socks.go +++ b/implant/sliver/forwarder/socks.go @@ -21,7 +21,7 @@ package forwarder // {{if .Config.WGc2Enabled}} import ( "fmt" - "io/ioutil" + "io" "log" "net" @@ -61,7 +61,7 @@ func (s *WGSocksServer) LocalAddr() string { func (s *WGSocksServer) Start() error { var err error server := socks5.NewServer( - socks5.WithLogger(socks5.NewLogger(log.New(ioutil.Discard, "", log.LstdFlags))), + socks5.WithLogger(socks5.NewLogger(log.New(io.Discard, "", log.LstdFlags))), ) select { case <-s.done: diff --git a/implant/sliver/netstat/netstat_linux.go b/implant/sliver/netstat/netstat_linux.go index fe58d8b238..1d191c59a2 100644 --- a/implant/sliver/netstat/netstat_linux.go +++ b/implant/sliver/netstat/netstat_linux.go @@ -34,7 +34,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net" "os" "path" @@ -212,7 +211,7 @@ func getProcName(s []byte) string { func (p *procFd) iterFdDir() { // link name is of the form socket:[5860846] fddir := path.Join(p.base, "/fd") - fi, err := ioutil.ReadDir(fddir) + fi, err := os.ReadDir(fddir) if err != nil { return } @@ -252,7 +251,7 @@ func (p *procFd) iterFdDir() { func extractProcInfo(sktab []SockTabEntry) { var basedir = "/proc" - fi, err := ioutil.ReadDir(basedir) + fi, err := os.ReadDir(basedir) if err != nil { return } diff --git a/implant/sliver/proxy/provider.go b/implant/sliver/proxy/provider.go index 83834abc12..832095bf2a 100644 --- a/implant/sliver/proxy/provider.go +++ b/implant/sliver/proxy/provider.go @@ -17,7 +17,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" // {{if .Config.Debug}} "log" @@ -247,7 +246,7 @@ func (p *provider) unmarshalProxyConfigFile() (map[string]string, error) { } else if stat.Size() > 1048576 { return nil, errors.New(fmt.Sprintf("proxy configuration file too large: %s", f)) } - out, err := ioutil.ReadFile(f) + out, err := os.ReadFile(f) if err != nil { return nil, errors.New(fmt.Sprintf("failed to read proxy configuration file: %s: %s", f, err)) } diff --git a/implant/sliver/proxy/provider_test.go b/implant/sliver/proxy/provider_test.go index 3ad9997ecf..0b3c6e3865 100644 --- a/implant/sliver/proxy/provider_test.go +++ b/implant/sliver/proxy/provider_test.go @@ -16,7 +16,6 @@ import ( "errors" "fmt" "github.com/stretchr/testify/assert" - "io/ioutil" "net/url" "os" "path/filepath" @@ -48,7 +47,7 @@ var dataProviderReadConfigFileProxy = []struct { } func TestProvider_ReadConfigFileProxy(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "TestReadConfigFileProxy") + tmpDir, err := os.MkdirTemp("", "TestReadConfigFileProxy") defer os.RemoveAll(tmpDir) for _, tt := range dataProviderReadConfigFileProxy { t.Run(tt.content, func(t *testing.T) { @@ -72,7 +71,7 @@ func TestProvider_ReadConfigFileProxy(t *testing.T) { func TestProvider_ReadConfigFileProxy_noFile(t *testing.T) { a := assert.New(t) - tmpDir, err := ioutil.TempDir("", "TestParseConfigFileProxies") + tmpDir, err := os.MkdirTemp("", "TestParseConfigFileProxies") if !a.NoError(err) { return } @@ -87,7 +86,7 @@ func TestProvider_ReadConfigFileProxy_noFile(t *testing.T) { func TestProvider_ParseConfigFileProxies_isDir(t *testing.T) { a := assert.New(t) - tmpDir, err := ioutil.TempDir("", "TestParseConfigFileProxies") + tmpDir, err := os.MkdirTemp("", "TestParseConfigFileProxies") if !a.NoError(err) { return } @@ -98,7 +97,7 @@ func TestProvider_ParseConfigFileProxies_isDir(t *testing.T) { func TestProvider_ParseConfigFileProxies_emptyFile(t *testing.T) { a := assert.New(t) - tmpDir, err := ioutil.TempDir("", "TestParseConfigFileProxies") + tmpDir, err := os.MkdirTemp("", "TestParseConfigFileProxies") if !a.NoError(err) { return } @@ -118,7 +117,7 @@ func TestProvider_ParseConfigFileProxies_emptyFile(t *testing.T) { func TestProvider_ParseConfigFileProxies_tooLarge(t *testing.T) { a := assert.New(t) - tmpDir, err := ioutil.TempDir("", "TestParseConfigFileProxies") + tmpDir, err := os.MkdirTemp("", "TestParseConfigFileProxies") if !a.NoError(err) { return } diff --git a/implant/sliver/ps/ps_linux.go b/implant/sliver/ps/ps_linux.go index bc75e6cd4e..b5a6c6e80f 100644 --- a/implant/sliver/ps/ps_linux.go +++ b/implant/sliver/ps/ps_linux.go @@ -5,7 +5,6 @@ package ps import ( "fmt" "io" - "io/ioutil" "os" "os/user" "strconv" @@ -86,7 +85,7 @@ func getProcessOwner(pid int) (string, error) { func getProcessCmdLine(pid int) ([]string, error) { cmdLinePath := fmt.Sprintf("/proc/%d/cmdline", pid) - data, err := ioutil.ReadFile(cmdLinePath) + data, err := os.ReadFile(cmdLinePath) if err != nil { return []string{""}, err } @@ -129,7 +128,7 @@ func getProcessArchitecture(pid int) (string, error) { // Refresh reloads all the data associated with this process. func (p *UnixProcess) Refresh() error { statPath := fmt.Sprintf("/proc/%d/stat", p.pid) - dataBytes, err := ioutil.ReadFile(statPath) + dataBytes, err := os.ReadFile(statPath) if err != nil { return err } diff --git a/implant/sliver/shell/ssh/ssh.go b/implant/sliver/shell/ssh/ssh.go index a6a28d7861..c0ca07b340 100644 --- a/implant/sliver/shell/ssh/ssh.go +++ b/implant/sliver/shell/ssh/ssh.go @@ -3,7 +3,6 @@ package ssh import ( "bytes" "fmt" - "io/ioutil" // {{if .Config.Debug}} "log" @@ -31,7 +30,7 @@ func getClient(host string, port uint16, username string, password string, privK authMethods = append(authMethods, ssh.PublicKeys(signer)) } else if krb5conf != "" && keytab != nil && realm != "" { // Then try kerberos auth - krb5ConfData, err := ioutil.ReadFile(krb5conf) + krb5ConfData, err := os.ReadFile(krb5conf) if err != nil { return nil, err } diff --git a/implant/sliver/taskrunner/task_linux.go b/implant/sliver/taskrunner/task_linux.go index 880e70585f..fe93cecbb9 100644 --- a/implant/sliver/taskrunner/task_linux.go +++ b/implant/sliver/taskrunner/task_linux.go @@ -21,7 +21,6 @@ package taskrunner import ( "bytes" "fmt" - "io/ioutil" "os" "os/exec" "runtime" @@ -80,7 +79,7 @@ func Sideload(procName string, procArgs []string, _ uint32, data []byte, args st fd, _, _ := syscall.Syscall(uintptr(nrMemfdCreate), uintptr(unsafe.Pointer(memfd)), 1, 0) pid := os.Getpid() fdPath := fmt.Sprintf("/proc/%d/fd/%d", pid, fd) - err = ioutil.WriteFile(fdPath, data, 0755) + err = os.WriteFile(fdPath, data, 0755) if err != nil { //{{if .Config.Debug}} log.Printf("Error writing file to memfd: %s\n", err) diff --git a/implant/sliver/transports/httpclient/drivers/win/tools/defines.go b/implant/sliver/transports/httpclient/drivers/win/tools/defines.go index 76880d699c..ece657fd06 100644 --- a/implant/sliver/transports/httpclient/drivers/win/tools/defines.go +++ b/implant/sliver/transports/httpclient/drivers/win/tools/defines.go @@ -3,7 +3,7 @@ package main import ( "flag" "fmt" - "io/ioutil" + "io" "os" "os/user" "path/filepath" @@ -138,7 +138,7 @@ func processFile( } defer f.Close() - if b, err = ioutil.ReadAll(f); err != nil { + if b, err = io.ReadAll(f); err != nil { return fmt.Errorf("failed to read %s: %w", file, err) } diff --git a/server/cryptography/minisign/private.go b/server/cryptography/minisign/private.go index 76f1b528cf..e8ff2b6add 100644 --- a/server/cryptography/minisign/private.go +++ b/server/cryptography/minisign/private.go @@ -13,7 +13,7 @@ import ( "encoding/binary" "errors" "io" - "io/ioutil" + "os" "strconv" "strings" "time" @@ -25,7 +25,7 @@ import ( // PrivateKeyFromFile reads and decrypts the private key // file with the given password. func PrivateKeyFromFile(password, path string) (PrivateKey, error) { - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { return PrivateKey{}, err } diff --git a/server/cryptography/minisign/public.go b/server/cryptography/minisign/public.go index f445034fcf..b11cad08d4 100644 --- a/server/cryptography/minisign/public.go +++ b/server/cryptography/minisign/public.go @@ -7,7 +7,7 @@ import ( "encoding/binary" "errors" "fmt" - "io/ioutil" + "os" "strconv" "strings" ) @@ -15,7 +15,7 @@ import ( // PublicKeyFromFile reads a new PublicKey from the // given file. func PublicKeyFromFile(path string) (PublicKey, error) { - bytes, err := ioutil.ReadFile(path) + bytes, err := os.ReadFile(path) if err != nil { return PublicKey{}, err } diff --git a/server/cryptography/minisign/signature.go b/server/cryptography/minisign/signature.go index e49900dbd2..3a4e6ecf30 100644 --- a/server/cryptography/minisign/signature.go +++ b/server/cryptography/minisign/signature.go @@ -10,7 +10,7 @@ import ( "encoding/binary" "errors" "fmt" - "io/ioutil" + "os" "strconv" "strings" ) @@ -18,7 +18,7 @@ import ( // SignatureFromFile reads a new Signature from the // given file. func SignatureFromFile(file string) (Signature, error) { - bytes, err := ioutil.ReadFile(file) + bytes, err := os.ReadFile(file) if err != nil { return Signature{}, err } From 0b7596373afaaea0692b4edb00b0e7ad220f9f6b Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Fri, 20 Oct 2023 09:04:54 +0800 Subject: [PATCH 2/2] fix: typo Signed-off-by: guoguangwu --- client/command/dllhijack/dllhijack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/command/dllhijack/dllhijack.go b/client/command/dllhijack/dllhijack.go index 897986edc7..fe11066b15 100644 --- a/client/command/dllhijack/dllhijack.go +++ b/client/command/dllhijack/dllhijack.go @@ -21,7 +21,7 @@ package dllhijack import ( "context" "fmt" - "o" + "os" "github.com/spf13/cobra"