diff --git a/cmd/license_policy_config.go b/cmd/license_policy_config.go index 3c8c443c..bc70c112 100644 --- a/cmd/license_policy_config.go +++ b/cmd/license_policy_config.go @@ -20,7 +20,6 @@ package cmd import ( "encoding/json" "fmt" - "io/ioutil" "os" "regexp" "strings" @@ -173,7 +172,7 @@ func (config *LicenseComplianceConfig) innerLoadLicensePolicies(filename string) getLogger().Infof("Loading license policy config file: `%s`...", config.policyConfigFile) // attempt to read in contents of the policy config. - buffer, errRead := ioutil.ReadFile(config.policyConfigFile) + buffer, errRead := os.ReadFile(config.policyConfigFile) if errRead != nil { err = fmt.Errorf("unable to `ReadFile`: `%s`", config.policyConfigFile) return diff --git a/go.mod b/go.mod index a9b40ebc..e4602ec6 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/sergi/go-diff v1.3.1 // indirect github.com/spf13/pflag v1.0.5 // indirect diff --git a/go.sum b/go.sum index 900f26f8..d558c399 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,6 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= -github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mrutkows/go-jsondiff v0.2.0 h1:T+05e1QSe7qB6vhkVtv3NImD3ni+Jdxpj69iMsptAqY= github.com/mrutkows/go-jsondiff v0.2.0/go.mod h1:TuasE0Ldrf4r1Gp0uIatS9SnPZPYybjmTGjB7WXKWl4= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= diff --git a/schema/schema_custom_validation.go b/schema/schema_custom_validation.go index 2468731f..3b9d32b6 100644 --- a/schema/schema_custom_validation.go +++ b/schema/schema_custom_validation.go @@ -20,7 +20,7 @@ package schema import ( "encoding/json" "fmt" - "io/ioutil" + "os" "github.com/CycloneDX/sbom-utility/utils" ) @@ -45,7 +45,8 @@ func LoadCustomValidationConfig(filename string) (err error) { // Note we actively supply informative error messages to help user // understand exactly how the load failed getLogger().Infof("Loading custom validation config file: `%s`...", cfgFilename) - buffer, err := ioutil.ReadFile(cfgFilename) + // #nosec G304 (suppress warning) + buffer, err := os.ReadFile(cfgFilename) if err != nil { return fmt.Errorf("unable to `ReadFile`: `%s`", cfgFilename) } diff --git a/schema/schema_formats.go b/schema/schema_formats.go index c2355a39..6e65f9ce 100644 --- a/schema/schema_formats.go +++ b/schema/schema_formats.go @@ -20,7 +20,7 @@ package schema import ( "encoding/json" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "reflect" @@ -197,7 +197,8 @@ func LoadSchemaConfig(filename string) (err error) { // Note we actively supply informative error messages to help user // understand exactly how the load failed getLogger().Tracef("Reading schema config file: `%s`...", cfgFilename) - buffer, err := ioutil.ReadFile(cfgFilename) + // #nosec G304 (suppress warning) + buffer, err := os.ReadFile(cfgFilename) if err != nil { return fmt.Errorf("unable to `ReadFile`: `%s`", cfgFilename) } @@ -356,10 +357,14 @@ func (sbom *Sbom) UnmarshalSBOMAsJsonMap() error { // read our opened jsonFile as a byte array. var errReadAll error - sbom.rawBytes, errReadAll = ioutil.ReadAll(jsonFile) - if errReadAll != nil { - getLogger().Error(errReadAll) + + { // #nosec + sbom.rawBytes, errReadAll = io.ReadAll(jsonFile) + if errReadAll != nil { + getLogger().Error(errReadAll) + } } + getLogger().Tracef("read data from: `%s`", sbom.filename) getLogger().Tracef("\n >> rawBytes[:100]=[%s]", sbom.rawBytes[:100])