diff --git a/internal/cmd/root_test.go b/internal/cmd/root_test.go index 59618f2..c0a66e5 100644 --- a/internal/cmd/root_test.go +++ b/internal/cmd/root_test.go @@ -20,7 +20,6 @@ import ( "bytes" "flag" "fmt" - "io/ioutil" "os" "path" "strings" @@ -229,7 +228,7 @@ func createFakeStdIn(t *testing.T) (oldStdIn *os.File, tmpFile *os.File) { } func createFakeStdInWithString(t *testing.T, inputString string) (oldStdIn *os.File, tmpFile *os.File) { content := []byte(inputString) - tmpFile, err := ioutil.TempFile("", "tempfile") + tmpFile, err := os.CreateTemp("", "tempfile") if err != nil { t.Error(err) } @@ -322,7 +321,7 @@ func TestConfigOssi_skip_update_check(t *testing.T) { } func setupConfig(t *testing.T) (tempDir string) { - tempDir, err := ioutil.TempDir("", "config-test") + tempDir, err := os.MkdirTemp("", "config-test") assert.NoError(t, err) return tempDir } @@ -387,7 +386,7 @@ func setupTestOSSIConfigFileValues(t *testing.T, tempDir string) { const credentials = configuration.ViperKeyUsername + ": ossiUsernameValue\n" + configuration.ViperKeyToken + ": ossiTokenValue" - assert.Nil(t, ioutil.WriteFile(cfgFile, []byte(credentials), 0644)) + assert.Nil(t, os.WriteFile(cfgFile, []byte(credentials), 0644)) } type ossiFactoryMock struct { @@ -403,12 +402,12 @@ type mockOssiServer struct { auditPackagesErr error } -//noinspection GoUnusedParameter +// noinspection GoUnusedParameter func (s mockOssiServer) AuditPackages(purls []string) ([]ossIndexTypes.Coordinate, error) { return s.auditPackagesResults, s.auditPackagesErr } -//noinspection GoUnusedParameter +// noinspection GoUnusedParameter func (s mockOssiServer) Audit(purls []string) (results map[string]ossIndexTypes.Coordinate, err error) { results = make(map[string]ossIndexTypes.Coordinate) diff --git a/internal/cmd/sleuth_test.go b/internal/cmd/sleuth_test.go index 9a059a6..d915230 100644 --- a/internal/cmd/sleuth_test.go +++ b/internal/cmd/sleuth_test.go @@ -25,7 +25,6 @@ import ( "github.com/sonatype-nexus-community/nancy/internal/customerrors" "github.com/sonatype-nexus-community/nancy/types" "github.com/stretchr/testify/assert" - "io/ioutil" "os" "strings" "testing" @@ -102,7 +101,7 @@ func TestConfigOssi_exclude_vulnerabilities_file_not_found_does_not_matter(t *te } func TestConfigOssi_exclude_vulnerabilities_passed_as_directory_does_not_matter(t *testing.T) { - dir, _ := ioutil.TempDir("", "prefix") + dir, _ := os.MkdirTemp("", "prefix") validateConfigOssi(t, types.Configuration{CveList: types.CveListFlag{}, Formatter: defaultAuditLogFormatter}, []string{sleuthCmd.Use, "--exclude-vulnerability-file=" + dir}...) } @@ -131,7 +130,7 @@ func TestConfigOssi_additional_exclude_vulnerabilities_with_empty_additional(t * func TestConfigOssi_exclude_vulnerabilities_does_not_need_to_be_passed_if_default_value_is_used(t *testing.T) { defaultFileName := ".nancy-ignore" - err := ioutil.WriteFile(defaultFileName, []byte("DEF-111\nDEF-222"), 0644) + err := os.WriteFile(defaultFileName, []byte("DEF-111\nDEF-222"), 0644) if err != nil { t.Fatal(err) } diff --git a/packages/dep_int_test.go b/packages/dep_int_test.go index e942ca4..004a1ad 100644 --- a/packages/dep_int_test.go +++ b/packages/dep_int_test.go @@ -21,7 +21,6 @@ import ( "github.com/Flaque/filet" "github.com/golang/dep" "github.com/stretchr/testify/require" - "io/ioutil" "log" "os" "testing" @@ -84,25 +83,25 @@ func doGoPathSimulatedSetup(t *testing.T) (string, string, error) { if e != nil { t.Error(e) } - lockBytes, e := ioutil.ReadFile("testdata/Gopkg.lock") + lockBytes, e := os.ReadFile("testdata/Gopkg.lock") if e != nil { t.Error(e) } - e = ioutil.WriteFile(fmt.Sprint(projectDir, "/Gopkg.lock"), lockBytes, 0644) + e = os.WriteFile(fmt.Sprint(projectDir, "/Gopkg.lock"), lockBytes, 0644) if e != nil { t.Error(e) } - tomlBytes, e := ioutil.ReadFile("testdata/Gopkg.toml") + tomlBytes, e := os.ReadFile("testdata/Gopkg.toml") if e != nil { t.Error(e) } - e = ioutil.WriteFile(fmt.Sprint(projectDir, "/Gopkg.toml"), tomlBytes, 0644) + e = os.WriteFile(fmt.Sprint(projectDir, "/Gopkg.toml"), tomlBytes, 0644) if e != nil { t.Error(e) } - files, e := ioutil.ReadDir(projectDir) + files, e := os.ReadDir(projectDir) if e != nil { t.Error(e) } diff --git a/parse/parse.go b/parse/parse.go index dbd98bf..05c5f36 100644 --- a/parse/parse.go +++ b/parse/parse.go @@ -20,7 +20,6 @@ import ( "bufio" "encoding/json" "io" - "io/ioutil" "strings" "github.com/sonatype-nexus-community/nancy/types" @@ -46,7 +45,7 @@ func GoList(stdIn *bufio.Scanner) (deps types.ProjectList, err error) { func GoListAgnostic(stdIn io.Reader) (deps types.ProjectList, err error) { // stdIn should never be massive, so taking this approach over reading from a stream // multiple times - johnnyFiveNeedInput, err := ioutil.ReadAll(stdIn) + johnnyFiveNeedInput, err := io.ReadAll(stdIn) if err != nil { return } diff --git a/settings/appsettings.go b/settings/appsettings.go index 1075bfa..a4b1f4e 100644 --- a/settings/appsettings.go +++ b/settings/appsettings.go @@ -19,7 +19,6 @@ package settings import ( ossIndexTypes "github.com/sonatype-nexus-community/go-sona-types/ossindex/types" "gopkg.in/yaml.v3" - "io/ioutil" "os" "path" "path/filepath" @@ -39,7 +38,7 @@ func (upd *UpdateCheck) WriteToDisk() error { return err } - err = ioutil.WriteFile(upd.FileUsed, enc, 0600) + err = os.WriteFile(upd.FileUsed, enc, 0600) return err } @@ -53,7 +52,7 @@ func (upd *UpdateCheck) Load() error { upd.FileUsed = appSettingsPath - content, err := ioutil.ReadFile(appSettingsPath) // #nosec + content, err := os.ReadFile(appSettingsPath) // #nosec if err != nil { return err }