From 07619c00d97928e7010f0a725e7381cca96d5ded Mon Sep 17 00:00:00 2001 From: Xueqin Cui <72771658+cuixq@users.noreply.github.com> Date: Tue, 10 Sep 2024 10:04:17 +1000 Subject: [PATCH] chore: update Go to version 1.22.7 (#1233) A few Go vulnerabilities are reported so this PR updates Go to the fixed version 1.22.7. Also `golang.org/x/mod@v0.21.0` requires Go 1.22.0 as mentioned in https://github.com/google/osv-scanner/pull/1204. Due to this version update, there are two new lint checks: [copyloopvar](https://github.com/karamaru-alpha/copyloopvar) and [intrange](https://github.com/ckaznocha/intrange). --- cmd/osv-reporter/main_test.go | 1 - cmd/osv-scanner/fix/main_test.go | 1 - cmd/osv-scanner/fix_test.go | 1 - cmd/osv-scanner/main_test.go | 10 ---------- cmd/osv-scanner/update_test.go | 1 - docs/installation.md | 2 +- go.mod | 2 +- internal/ci/vulnerability_result_diff_test.go | 2 -- internal/image/image_test.go | 1 - internal/manifest/maven_test.go | 1 - internal/output/form_test.go | 1 - internal/output/helpers_test.go | 3 --- internal/output/identifiers_test.go | 2 -- internal/output/result_test.go | 3 --- internal/output/sarif_internal_test.go | 1 - internal/output/sarif_test.go | 2 -- internal/remediation/in_place_test.go | 1 - internal/remediation/override_test.go | 1 - internal/remediation/relax/npm_test.go | 1 - internal/remediation/relax_test.go | 1 - internal/remediation/remediation_test.go | 1 - internal/resolution/datasource/npmrc_test.go | 1 - internal/resolution/manifest/maven.go | 2 +- internal/resolution/resolve_test.go | 1 - internal/semantic/compare_test.go | 1 - internal/semantic/version-alpine.go | 4 ++-- internal/semantic/version-debian.go | 2 +- internal/semantic/version-maven.go | 4 ++-- internal/semantic/version-packagist.go | 2 +- internal/semantic/version-pypi.go | 2 +- internal/semantic/version-rubygems.go | 2 +- internal/semantic/version-semver.go | 2 +- internal/semantic/version.go | 2 +- internal/url/url_test.go | 1 - internal/utility/severity/severity_test.go | 1 - internal/utility/vulns/vulnerabilities_test.go | 1 - pkg/config/config_internal_test.go | 5 ----- pkg/depsdev/license.go | 1 - pkg/grouper/grouper.go | 4 ++-- pkg/lockfile/csv_test.go | 4 ---- pkg/lockfile/go-binary_test.go | 1 - pkg/lockfile/node-modules_test.go | 1 - pkg/lockfile/parse-cargo-lock_test.go | 1 - pkg/lockfile/parse-composer-lock_test.go | 1 - pkg/lockfile/parse-conan-lock_test.go | 1 - pkg/lockfile/parse-gemfile-lock_test.go | 1 - pkg/lockfile/parse-go-lock_test.go | 1 - pkg/lockfile/parse-gradle-lock_test.go | 1 - .../parse-gradle-verification-metadata_test.go | 1 - pkg/lockfile/parse-maven-lock_test.go | 2 -- pkg/lockfile/parse-mix-lock_test.go | 1 - pkg/lockfile/parse-npm-lock_test.go | 1 - pkg/lockfile/parse-nuget-lock_test.go | 1 - pkg/lockfile/parse-pipenv-lock_test.go | 1 - pkg/lockfile/parse-pnpm-lock_test.go | 1 - pkg/lockfile/parse-poetry-lock_test.go | 1 - pkg/lockfile/parse-pubspec-lock_test.go | 1 - pkg/lockfile/parse-requirements-txt_test.go | 1 - pkg/lockfile/parse-yarn-lock_test.go | 1 - pkg/lockfile/parse_test.go | 1 - pkg/models/purl_to_package_test.go | 1 - pkg/models/vulnerabilities_test.go | 1 - pkg/osv/osv.go | 3 +-- pkg/osvscanner/osvscanner_internal_test.go | 1 - pkg/osvscanner/vulnerability_result_internal_test.go | 1 - pkg/spdx/verify_test.go | 1 - renovate.json | 2 +- scripts/generate_mock_resolution_universe/main.go | 1 - 68 files changed, 17 insertions(+), 96 deletions(-) diff --git a/cmd/osv-reporter/main_test.go b/cmd/osv-reporter/main_test.go index e05f8eb724..3aad24b670 100644 --- a/cmd/osv-reporter/main_test.go +++ b/cmd/osv-reporter/main_test.go @@ -29,7 +29,6 @@ func Test_splitLastArg(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := splitLastArg(tt.args); !reflect.DeepEqual(got, tt.want) { diff --git a/cmd/osv-scanner/fix/main_test.go b/cmd/osv-scanner/fix/main_test.go index 39a2fb1537..db5382ce08 100644 --- a/cmd/osv-scanner/fix/main_test.go +++ b/cmd/osv-scanner/fix/main_test.go @@ -120,7 +120,6 @@ func TestParseUpgradeConfig(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx, err := parseFlags(t, flags, tt.args) diff --git a/cmd/osv-scanner/fix_test.go b/cmd/osv-scanner/fix_test.go index e8b4289f1c..dd4591d0a4 100644 --- a/cmd/osv-scanner/fix_test.go +++ b/cmd/osv-scanner/fix_test.go @@ -63,7 +63,6 @@ func TestRun_Fix(t *testing.T) { // TODO: add tests with the cli flags } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cmd/osv-scanner/main_test.go b/cmd/osv-scanner/main_test.go index 9570bbd33b..b97279cdf9 100644 --- a/cmd/osv-scanner/main_test.go +++ b/cmd/osv-scanner/main_test.go @@ -320,7 +320,6 @@ func TestRun(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -346,7 +345,6 @@ func TestRunCallAnalysis(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -479,7 +477,6 @@ func TestRun_LockfileWithExplicitParseAs(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -505,7 +502,6 @@ func TestRun_GithubActions(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -598,7 +594,6 @@ func TestRun_LocalDatabases(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -667,7 +662,6 @@ func TestRun_Licenses(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -724,7 +718,6 @@ func TestRun_OCIImage(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -767,7 +760,6 @@ func TestRun_SubCommands(t *testing.T) { // TODO: add tests for other future subcommands } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -824,7 +816,6 @@ func TestRun_InsertDefaultCommand(t *testing.T) { } for _, tt := range tests { - tt := tt stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} argsActual := insertDefaultCommand(tt.originalArgs, commands, defaultCommand, stdout, stderr) @@ -860,7 +851,6 @@ func TestRun_MavenTransitive(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() testCli(t, tt) diff --git a/cmd/osv-scanner/update_test.go b/cmd/osv-scanner/update_test.go index 3c69efdebc..74c5bf3d21 100644 --- a/cmd/osv-scanner/update_test.go +++ b/cmd/osv-scanner/update_test.go @@ -26,7 +26,6 @@ func TestRun_Update(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() tc := cliTestCase{ diff --git a/docs/installation.md b/docs/installation.md index 2dcaa999c6..f50714f793 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -77,7 +77,7 @@ Alternatively, you can install this from source by running: go install github.com/google/osv-scanner/cmd/osv-scanner@v1 ``` -This requires Go 1.21.12+ to be installed. +This requires Go 1.22.7+ to be installed. ## Build from source diff --git a/go.mod b/go.mod index 6b30d58365..e3869f83e9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/google/osv-scanner -go 1.21.12 +go 1.22.7 require ( deps.dev/api/v3 v3.0.0-20240807013505-16da96fe8b66 diff --git a/internal/ci/vulnerability_result_diff_test.go b/internal/ci/vulnerability_result_diff_test.go index 7e9dd0f23f..12a2abd035 100644 --- a/internal/ci/vulnerability_result_diff_test.go +++ b/internal/ci/vulnerability_result_diff_test.go @@ -69,7 +69,6 @@ func TestDiffVulnerabilityResults(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got := ci.DiffVulnerabilityResults(tt.args.oldRes, tt.args.newRes) @@ -123,7 +122,6 @@ func TestDiffVulnerabilityByUniqueVulnCountResults(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got := ci.DiffVulnerabilityResultsByOccurrences(tt.args.oldRes, tt.args.newRes) diff --git a/internal/image/image_test.go b/internal/image/image_test.go index 1319da5644..90bd028524 100644 --- a/internal/image/image_test.go +++ b/internal/image/image_test.go @@ -74,7 +74,6 @@ func TestScanImage(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/manifest/maven_test.go b/internal/manifest/maven_test.go index 58ec5c989c..882affb701 100644 --- a/internal/manifest/maven_test.go +++ b/internal/manifest/maven_test.go @@ -51,7 +51,6 @@ func TestMavenResolverExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := manifest.MavenResolverExtractor{} diff --git a/internal/output/form_test.go b/internal/output/form_test.go index ef85b95ba4..78310acabd 100644 --- a/internal/output/form_test.go +++ b/internal/output/form_test.go @@ -48,7 +48,6 @@ func TestForm(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/output/helpers_test.go b/internal/output/helpers_test.go index 7e83fa9504..ff4276e1d7 100644 --- a/internal/output/helpers_test.go +++ b/internal/output/helpers_test.go @@ -1019,7 +1019,6 @@ func testOutputWithVulnerabilities(t *testing.T, run outputTestRunner) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -1619,7 +1618,6 @@ func testOutputWithLicenseViolations(t *testing.T, run outputTestRunner) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -1999,7 +1997,6 @@ func testOutputWithMixedIssues(t *testing.T, run outputTestRunner) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/output/identifiers_test.go b/internal/output/identifiers_test.go index c1ae79fd9b..1ebd4ddb0e 100644 --- a/internal/output/identifiers_test.go +++ b/internal/output/identifiers_test.go @@ -33,7 +33,6 @@ func Test_idSortFunc(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -68,7 +67,6 @@ func Test_idSortFuncUsage(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/output/result_test.go b/internal/output/result_test.go index e85882ef96..48aaa25a86 100644 --- a/internal/output/result_test.go +++ b/internal/output/result_test.go @@ -38,7 +38,6 @@ func Test_groupFixedVersions(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got := groupFixedVersions(tt.args) @@ -72,8 +71,6 @@ func Test_mapIDsToGroupedSARIFFinding(t *testing.T) { }, } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/output/sarif_internal_test.go b/internal/output/sarif_internal_test.go index 0b584210b2..66f953db87 100644 --- a/internal/output/sarif_internal_test.go +++ b/internal/output/sarif_internal_test.go @@ -28,7 +28,6 @@ func Test_createSARIFHelpText(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got := createSARIFHelpText(&tt.args) diff --git a/internal/output/sarif_test.go b/internal/output/sarif_test.go index 7773e664d8..4d6a3304e2 100644 --- a/internal/output/sarif_test.go +++ b/internal/output/sarif_test.go @@ -35,7 +35,6 @@ func TestGroupFixedVersions(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got := output.GroupFixedVersions(tt.args) @@ -73,7 +72,6 @@ func TestPrintSARIFReport(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/remediation/in_place_test.go b/internal/remediation/in_place_test.go index 67e079da77..ef12d7489f 100644 --- a/internal/remediation/in_place_test.go +++ b/internal/remediation/in_place_test.go @@ -132,7 +132,6 @@ func TestComputeInPlacePatches(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() g, cl := parseInPlaceFixture(t, tt.universePath, tt.lockfilePath) diff --git a/internal/remediation/override_test.go b/internal/remediation/override_test.go index 8bb902da9c..1e7bdaad67 100644 --- a/internal/remediation/override_test.go +++ b/internal/remediation/override_test.go @@ -62,7 +62,6 @@ func TestComputeOverridePatches(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() res, cl := parseRemediationFixture(t, tt.universePath, tt.manifestPath) diff --git a/internal/remediation/relax/npm_test.go b/internal/remediation/relax/npm_test.go index 4a550a0e02..83713ddea4 100644 --- a/internal/remediation/relax/npm_test.go +++ b/internal/remediation/relax/npm_test.go @@ -166,7 +166,6 @@ func TestRelaxNpm(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() cl := resolve.NewLocalClient() diff --git a/internal/remediation/relax_test.go b/internal/remediation/relax_test.go index 4c2915c92d..7910b2ea46 100644 --- a/internal/remediation/relax_test.go +++ b/internal/remediation/relax_test.go @@ -32,7 +32,6 @@ func TestComputeRelaxPatches(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() res, cl := parseRemediationFixture(t, tt.universePath, tt.manifestPath) diff --git a/internal/remediation/remediation_test.go b/internal/remediation/remediation_test.go index 3025d12d0c..4303772837 100644 --- a/internal/remediation/remediation_test.go +++ b/internal/remediation/remediation_test.go @@ -198,7 +198,6 @@ func TestMatchVuln(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/resolution/datasource/npmrc_test.go b/internal/resolution/datasource/npmrc_test.go index 6d5c321911..46793b64ab 100644 --- a/internal/resolution/datasource/npmrc_test.go +++ b/internal/resolution/datasource/npmrc_test.go @@ -283,7 +283,6 @@ func TestNpmRegistryAuthOpts(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() header := make(http.Header) diff --git a/internal/resolution/manifest/maven.go b/internal/resolution/manifest/maven.go index 487b664a7e..12b79cddbe 100644 --- a/internal/resolution/manifest/maven.go +++ b/internal/resolution/manifest/maven.go @@ -294,7 +294,7 @@ func (MavenManifestIO) Write(df lockfile.DepFile, w io.Writer, patch ManifestPat currentPath := df.Path() parent := specific.Parent visited := make(map[maven.ProjectKey]bool, mavenutil.MaxParent) - for n := 0; n < mavenutil.MaxParent; n++ { + for range mavenutil.MaxParent { if parent.GroupID == "" || parent.ArtifactID == "" || parent.Version == "" { break } diff --git a/internal/resolution/resolve_test.go b/internal/resolution/resolve_test.go index 98dc9460a5..ad038b5d56 100644 --- a/internal/resolution/resolve_test.go +++ b/internal/resolution/resolve_test.go @@ -206,7 +206,6 @@ func TestResolve(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() cl := clienttest.NewMockResolutionClient(t, tt.universe) diff --git a/internal/semantic/compare_test.go b/internal/semantic/compare_test.go index 132ef578a8..71f326a915 100644 --- a/internal/semantic/compare_test.go +++ b/internal/semantic/compare_test.go @@ -236,7 +236,6 @@ func TestVersion_Compare_Ecosystems(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/semantic/version-alpine.go b/internal/semantic/version-alpine.go index 4491ce0d51..722b989b4d 100644 --- a/internal/semantic/version-alpine.go +++ b/internal/semantic/version-alpine.go @@ -106,7 +106,7 @@ type AlpineVersion struct { func (v AlpineVersion) compareComponents(w AlpineVersion) int { numberOfComponents := max(len(v.components), len(w.components)) - for i := 0; i < numberOfComponents; i++ { + for i := range numberOfComponents { diff := v.components.Fetch(i).Cmp(w.components.Fetch(i)) if diff != 0 { @@ -150,7 +150,7 @@ func (as alpineSuffix) Cmp(bs alpineSuffix) int { func (v AlpineVersion) compareSuffixes(w AlpineVersion) int { numberOfSuffixes := max(len(v.suffixes), len(w.suffixes)) - for i := 0; i < numberOfSuffixes; i++ { + for i := range numberOfSuffixes { diff := v.fetchSuffix(i).Cmp(w.fetchSuffix(i)) if diff != 0 { diff --git a/internal/semantic/version-debian.go b/internal/semantic/version-debian.go index 8b85ed12bd..df1c797195 100644 --- a/internal/semantic/version-debian.go +++ b/internal/semantic/version-debian.go @@ -91,7 +91,7 @@ func compareDebianVersions(a, b string) int { apSplit := strings.Split(ap, "") bpSplit := strings.Split(bp, "") - for i := 0; i < max(len(ap), len(bp)); i++ { + for i := range max(len(ap), len(bp)) { aw := weighDebianChar(fetch(apSplit, i, "")) bw := weighDebianChar(fetch(bpSplit, i, "")) diff --git a/internal/semantic/version-maven.go b/internal/semantic/version-maven.go index 73dbae4ca4..9c86c1b746 100644 --- a/internal/semantic/version-maven.go +++ b/internal/semantic/version-maven.go @@ -107,7 +107,7 @@ func (mv MavenVersion) equal(mw MavenVersion) bool { return false } - for i := 0; i < len(mv.tokens); i++ { + for i := range len(mv.tokens) { if !mv.tokens[i].equal(mw.tokens[i]) { return false } @@ -141,7 +141,7 @@ func (mv MavenVersion) lessThan(mw MavenVersion) bool { var left mavenVersionToken var right mavenVersionToken - for i := 0; i < numberOfTokens; i++ { + for i := range numberOfTokens { // the shorter one padded with enough "null" values with matching prefix to // have the same length as the longer one. Padded "null" values depend on // the prefix of the other version: 0 for '.', "" for '-' diff --git a/internal/semantic/version-packagist.go b/internal/semantic/version-packagist.go index 2d54405258..ae0b21ee2d 100644 --- a/internal/semantic/version-packagist.go +++ b/internal/semantic/version-packagist.go @@ -57,7 +57,7 @@ func comparePackagistComponents(a, b []string) int { var compare int - for i := 0; i < minLength; i++ { + for i := range minLength { ai, aIsNumber := convertToBigInt(a[i]) bi, bIsNumber := convertToBigInt(b[i]) diff --git a/internal/semantic/version-pypi.go b/internal/semantic/version-pypi.go index 9a6670504c..ab3f1af76e 100644 --- a/internal/semantic/version-pypi.go +++ b/internal/semantic/version-pypi.go @@ -286,7 +286,7 @@ func (pv PyPIVersion) compareLocal(pw PyPIVersion) int { var compare int - for i := 0; i < minVersionLength; i++ { + for i := range minVersionLength { ai, aIsNumber := convertToBigInt(pv.local[i]) bi, bIsNumber := convertToBigInt(pw.local[i]) diff --git a/internal/semantic/version-rubygems.go b/internal/semantic/version-rubygems.go index 103caeea77..d289fe5efd 100644 --- a/internal/semantic/version-rubygems.go +++ b/internal/semantic/version-rubygems.go @@ -77,7 +77,7 @@ func compareRubyGemsComponents(a, b []string) int { var compare int - for i := 0; i < numberOfComponents; i++ { + for i := range numberOfComponents { as := fetch(a, i, "0") bs := fetch(b, i, "0") diff --git a/internal/semantic/version-semver.go b/internal/semantic/version-semver.go index 8449e4e674..31307b8180 100644 --- a/internal/semantic/version-semver.go +++ b/internal/semantic/version-semver.go @@ -43,7 +43,7 @@ func compareSemverBuildComponents(a, b []string) int { var compare int - for i := 0; i < minComponentLength; i++ { + for i := range minComponentLength { ai, aIsNumber := convertToBigInt(a[i]) bi, bIsNumber := convertToBigInt(b[i]) diff --git a/internal/semantic/version.go b/internal/semantic/version.go index b5de3988c1..fdcaeab1ff 100644 --- a/internal/semantic/version.go +++ b/internal/semantic/version.go @@ -25,7 +25,7 @@ func (components *Components) Fetch(n int) *big.Int { func (components *Components) Cmp(b Components) int { numberOfComponents := max(len(*components), len(b)) - for i := 0; i < numberOfComponents; i++ { + for i := range numberOfComponents { diff := components.Fetch(i).Cmp(b.Fetch(i)) if diff != 0 { diff --git a/internal/url/url_test.go b/internal/url/url_test.go index 595786ad50..e48cec3ba4 100644 --- a/internal/url/url_test.go +++ b/internal/url/url_test.go @@ -17,7 +17,6 @@ func TestURLFromFilePath(t *testing.T) { if tc.filePath == "" { continue } - tc := tc t.Run(tc.filePath, func(t *testing.T) { t.Parallel() diff --git a/internal/utility/severity/severity_test.go b/internal/utility/severity/severity_test.go index cedb63ec26..006d098741 100644 --- a/internal/utility/severity/severity_test.go +++ b/internal/utility/severity/severity_test.go @@ -75,7 +75,6 @@ func TestSeverity_CalculateScore(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/utility/vulns/vulnerabilities_test.go b/internal/utility/vulns/vulnerabilities_test.go index 6a15ca135b..9ba61f1173 100644 --- a/internal/utility/vulns/vulnerabilities_test.go +++ b/internal/utility/vulns/vulnerabilities_test.go @@ -117,7 +117,6 @@ func TestVulnerabilities_Includes(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/config/config_internal_test.go b/pkg/config/config_internal_test.go index 59f5e7c347..e3205fe977 100644 --- a/pkg/config/config_internal_test.go +++ b/pkg/config/config_internal_test.go @@ -200,7 +200,6 @@ func TestConfig_ShouldIgnore(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -634,7 +633,6 @@ func TestConfig_ShouldIgnorePackage(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -753,7 +751,6 @@ func TestConfig_ShouldIgnorePackageVersion(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -870,7 +867,6 @@ func TestConfig_ShouldOverridePackageLicense(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -986,7 +982,6 @@ func TestConfig_ShouldOverridePackageVersionLicense(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/depsdev/license.go b/pkg/depsdev/license.go index 41fb0b9a24..aca27bacc0 100644 --- a/pkg/depsdev/license.go +++ b/pkg/depsdev/license.go @@ -81,7 +81,6 @@ func MakeVersionRequestsWithContext(ctx context.Context, queries []*depsdevpb.Ge licenses[i] = []models.License{models.License("UNKNOWN")} continue } - i := i g.Go(func() error { resp, err := client.GetVersion(ctx, queries[i]) if err != nil { diff --git a/pkg/grouper/grouper.go b/pkg/grouper/grouper.go index c8802d3101..a385e23ce1 100644 --- a/pkg/grouper/grouper.go +++ b/pkg/grouper/grouper.go @@ -26,12 +26,12 @@ func Group(vulns []IDAliases) []models.GroupInfo { groups := make([]int, len(vulns)) // Initially make every vulnerability its own group. - for i := 0; i < len(vulns); i++ { + for i := range len(vulns) { groups[i] = i } // Do a pair-wise (n^2) comparison and merge all intersecting vulns. - for i := 0; i < len(vulns); i++ { + for i := range len(vulns) { for j := i + 1; j < len(vulns); j++ { if hasAliasIntersection(vulns[i], vulns[j]) { // Merge the two groups. Use the smaller index as the representative ID. diff --git a/pkg/lockfile/csv_test.go b/pkg/lockfile/csv_test.go index 9b32658ec4..e0af55a2bf 100644 --- a/pkg/lockfile/csv_test.go +++ b/pkg/lockfile/csv_test.go @@ -139,7 +139,6 @@ func TestFromCSVRows(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -241,7 +240,6 @@ func TestFromCSVRows_Errors(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -481,7 +479,6 @@ func TestFromCSVFile(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -529,7 +526,6 @@ func TestFromCSVFile_Errors(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/lockfile/go-binary_test.go b/pkg/lockfile/go-binary_test.go index 1851591dc0..ed3e2e9682 100644 --- a/pkg/lockfile/go-binary_test.go +++ b/pkg/lockfile/go-binary_test.go @@ -62,7 +62,6 @@ func TestGoBinaryExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.GoBinaryExtractor{} diff --git a/pkg/lockfile/node-modules_test.go b/pkg/lockfile/node-modules_test.go index 73297ac72c..d576db2f81 100644 --- a/pkg/lockfile/node-modules_test.go +++ b/pkg/lockfile/node-modules_test.go @@ -105,7 +105,6 @@ func TestNodeModulesExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.NodeModulesExtractor{} diff --git a/pkg/lockfile/parse-cargo-lock_test.go b/pkg/lockfile/parse-cargo-lock_test.go index d1d80b8e0a..6952cb3109 100644 --- a/pkg/lockfile/parse-cargo-lock_test.go +++ b/pkg/lockfile/parse-cargo-lock_test.go @@ -47,7 +47,6 @@ func TestCargoLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.CargoLockExtractor{} diff --git a/pkg/lockfile/parse-composer-lock_test.go b/pkg/lockfile/parse-composer-lock_test.go index 6b7048b5a0..e2e1f3ee0c 100644 --- a/pkg/lockfile/parse-composer-lock_test.go +++ b/pkg/lockfile/parse-composer-lock_test.go @@ -47,7 +47,6 @@ func TestComposerLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.ComposerLockExtractor{} diff --git a/pkg/lockfile/parse-conan-lock_test.go b/pkg/lockfile/parse-conan-lock_test.go index 7b407c24e3..b72f9d34a2 100644 --- a/pkg/lockfile/parse-conan-lock_test.go +++ b/pkg/lockfile/parse-conan-lock_test.go @@ -46,7 +46,6 @@ func TestConanLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.ConanLockExtractor{} diff --git a/pkg/lockfile/parse-gemfile-lock_test.go b/pkg/lockfile/parse-gemfile-lock_test.go index cb9a20e6b4..2cf3c24d2a 100644 --- a/pkg/lockfile/parse-gemfile-lock_test.go +++ b/pkg/lockfile/parse-gemfile-lock_test.go @@ -47,7 +47,6 @@ func TestGemfileLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.GemfileLockExtractor{} diff --git a/pkg/lockfile/parse-go-lock_test.go b/pkg/lockfile/parse-go-lock_test.go index 942e25b74e..14ccd66e95 100644 --- a/pkg/lockfile/parse-go-lock_test.go +++ b/pkg/lockfile/parse-go-lock_test.go @@ -47,7 +47,6 @@ func TestGoLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.GoLockExtractor{} diff --git a/pkg/lockfile/parse-gradle-lock_test.go b/pkg/lockfile/parse-gradle-lock_test.go index f0bea68a8c..34d3b3e19f 100644 --- a/pkg/lockfile/parse-gradle-lock_test.go +++ b/pkg/lockfile/parse-gradle-lock_test.go @@ -72,7 +72,6 @@ func TestGradleLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.GradleLockExtractor{} diff --git a/pkg/lockfile/parse-gradle-verification-metadata_test.go b/pkg/lockfile/parse-gradle-verification-metadata_test.go index 72d849c489..68c5768bc9 100644 --- a/pkg/lockfile/parse-gradle-verification-metadata_test.go +++ b/pkg/lockfile/parse-gradle-verification-metadata_test.go @@ -72,7 +72,6 @@ func TestGradleVerificationMetadataExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.GradleVerificationMetadataExtractor{} diff --git a/pkg/lockfile/parse-maven-lock_test.go b/pkg/lockfile/parse-maven-lock_test.go index 421704779c..b49064e712 100644 --- a/pkg/lockfile/parse-maven-lock_test.go +++ b/pkg/lockfile/parse-maven-lock_test.go @@ -47,7 +47,6 @@ func TestMavenLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.MavenLockExtractor{} @@ -277,7 +276,6 @@ func TestMavenLockDependency_ResolveVersion(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/lockfile/parse-mix-lock_test.go b/pkg/lockfile/parse-mix-lock_test.go index 6de2af892f..534f6e707f 100644 --- a/pkg/lockfile/parse-mix-lock_test.go +++ b/pkg/lockfile/parse-mix-lock_test.go @@ -47,7 +47,6 @@ func TestMixLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.MixLockExtractor{} diff --git a/pkg/lockfile/parse-npm-lock_test.go b/pkg/lockfile/parse-npm-lock_test.go index c0a8a73935..83d19a014c 100644 --- a/pkg/lockfile/parse-npm-lock_test.go +++ b/pkg/lockfile/parse-npm-lock_test.go @@ -46,7 +46,6 @@ func TestNpmLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.NpmLockExtractor{} diff --git a/pkg/lockfile/parse-nuget-lock_test.go b/pkg/lockfile/parse-nuget-lock_test.go index c6642cd5ba..2bb1c236e0 100644 --- a/pkg/lockfile/parse-nuget-lock_test.go +++ b/pkg/lockfile/parse-nuget-lock_test.go @@ -46,7 +46,6 @@ func TestNuGetLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.NuGetLockExtractor{} diff --git a/pkg/lockfile/parse-pipenv-lock_test.go b/pkg/lockfile/parse-pipenv-lock_test.go index b9abbd0bbf..0da3ac930e 100644 --- a/pkg/lockfile/parse-pipenv-lock_test.go +++ b/pkg/lockfile/parse-pipenv-lock_test.go @@ -47,7 +47,6 @@ func TestPipenvLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.PipenvLockExtractor{} diff --git a/pkg/lockfile/parse-pnpm-lock_test.go b/pkg/lockfile/parse-pnpm-lock_test.go index b436fe57f7..a08c11596f 100644 --- a/pkg/lockfile/parse-pnpm-lock_test.go +++ b/pkg/lockfile/parse-pnpm-lock_test.go @@ -47,7 +47,6 @@ func TestPnpmLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.PnpmLockExtractor{} diff --git a/pkg/lockfile/parse-poetry-lock_test.go b/pkg/lockfile/parse-poetry-lock_test.go index c02cafb9ba..4b719e5d19 100644 --- a/pkg/lockfile/parse-poetry-lock_test.go +++ b/pkg/lockfile/parse-poetry-lock_test.go @@ -47,7 +47,6 @@ func TestPoetryLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.PoetryLockExtractor{} diff --git a/pkg/lockfile/parse-pubspec-lock_test.go b/pkg/lockfile/parse-pubspec-lock_test.go index 3720914856..4f20df34fb 100644 --- a/pkg/lockfile/parse-pubspec-lock_test.go +++ b/pkg/lockfile/parse-pubspec-lock_test.go @@ -47,7 +47,6 @@ func TestPubspecLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.PubspecLockExtractor{} diff --git a/pkg/lockfile/parse-requirements-txt_test.go b/pkg/lockfile/parse-requirements-txt_test.go index 98e4e337fb..659a25e58f 100644 --- a/pkg/lockfile/parse-requirements-txt_test.go +++ b/pkg/lockfile/parse-requirements-txt_test.go @@ -47,7 +47,6 @@ func TestRequirementsTxtExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.RequirementsTxtExtractor{} diff --git a/pkg/lockfile/parse-yarn-lock_test.go b/pkg/lockfile/parse-yarn-lock_test.go index f961285a3e..854436d47e 100644 --- a/pkg/lockfile/parse-yarn-lock_test.go +++ b/pkg/lockfile/parse-yarn-lock_test.go @@ -46,7 +46,6 @@ func TestYarnLockExtractor_ShouldExtract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() e := lockfile.YarnLockExtractor{} diff --git a/pkg/lockfile/parse_test.go b/pkg/lockfile/parse_test.go index 4b2905c6c4..a13d02310c 100644 --- a/pkg/lockfile/parse_test.go +++ b/pkg/lockfile/parse_test.go @@ -305,7 +305,6 @@ func TestPackages_Ecosystems(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/models/purl_to_package_test.go b/pkg/models/purl_to_package_test.go index 310607690b..a14c715378 100644 --- a/pkg/models/purl_to_package_test.go +++ b/pkg/models/purl_to_package_test.go @@ -83,7 +83,6 @@ func TestPURLToPackage(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := models.PURLToPackage(tt.args.purl) diff --git a/pkg/models/vulnerabilities_test.go b/pkg/models/vulnerabilities_test.go index 2d06f2d7e5..1c3a205db9 100644 --- a/pkg/models/vulnerabilities_test.go +++ b/pkg/models/vulnerabilities_test.go @@ -45,7 +45,6 @@ func TestVulnerabilities_MarshalJSON(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := tt.vs.MarshalJSON() diff --git a/pkg/osv/osv.go b/pkg/osv/osv.go index 05572528cb..3d696b5a05 100644 --- a/pkg/osv/osv.go +++ b/pkg/osv/osv.go @@ -282,7 +282,6 @@ func HydrateWithClient(resp *BatchedResponse, client *http.Client) (*HydratedBat for resultIdx, vuln := range response.Vulns { id := vuln.ID batchIdx := batchIdx - resultIdx := resultIdx g.Go(func() error { // exit early if another hydration request has already failed // results are thrown away later, so avoid needless work @@ -312,7 +311,7 @@ func makeRetryRequest(action func() (*http.Response, error)) (*http.Response, er var resp *http.Response var err error - for i := 0; i < maxRetryAttempts; i++ { + for i := range maxRetryAttempts { // rand is initialized with a random number (since go1.20), and is also safe to use concurrently // we do not need to use a cryptographically secure random jitter, this is just to spread out the retry requests // #nosec G404 diff --git a/pkg/osvscanner/osvscanner_internal_test.go b/pkg/osvscanner/osvscanner_internal_test.go index d08a99e906..5f82bacdc2 100644 --- a/pkg/osvscanner/osvscanner_internal_test.go +++ b/pkg/osvscanner/osvscanner_internal_test.go @@ -37,7 +37,6 @@ func Test_filterResults(t *testing.T) { }, } for _, tt := range tests { - tt := tt // Reinitialize for t.Parallel() t.Run(tt.name, func(t *testing.T) { t.Parallel() r := &reporter.VoidReporter{} diff --git a/pkg/osvscanner/vulnerability_result_internal_test.go b/pkg/osvscanner/vulnerability_result_internal_test.go index a26ceed90f..2a3959e14b 100644 --- a/pkg/osvscanner/vulnerability_result_internal_test.go +++ b/pkg/osvscanner/vulnerability_result_internal_test.go @@ -197,7 +197,6 @@ func Test_assembleResult(t *testing.T) { }, }} for _, tt := range tests { - tt := tt // Reinitialize for t.Parallel() t.Run(tt.name, func(t *testing.T) { t.Parallel() got := buildVulnerabilityResults(tt.args.r, tt.args.packages, tt.args.vulnsResp, tt.args.licensesResp, tt.args.actions, tt.args.config) diff --git a/pkg/spdx/verify_test.go b/pkg/spdx/verify_test.go index 54fa2f98db..f0e0cecd4b 100644 --- a/pkg/spdx/verify_test.go +++ b/pkg/spdx/verify_test.go @@ -27,7 +27,6 @@ func Test_unrecognized(t *testing.T) { }, } for _, tt := range tests { - tt := tt // Reinitialize for t.Parallel() t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := Unrecognized(tt.licenses); !reflect.DeepEqual(got, tt.want) { diff --git a/renovate.json b/renovate.json index 148b17d67c..3e42801e6c 100644 --- a/renovate.json +++ b/renovate.json @@ -27,7 +27,7 @@ } ], "constraints": { - "go": "1.21.12" + "go": "1.22.7" }, "ignorePaths": ["**/fixtures/**", "**/fixtures-go/**"], "ignoreDeps": ["golang.org/x/vuln"] diff --git a/scripts/generate_mock_resolution_universe/main.go b/scripts/generate_mock_resolution_universe/main.go index 1d18e8dc0f..c69cba82a3 100644 --- a/scripts/generate_mock_resolution_universe/main.go +++ b/scripts/generate_mock_resolution_universe/main.go @@ -293,7 +293,6 @@ func main() { group := &errgroup.Group{} for _, filename := range os.Args[1:] { - filename := filename if io, err := manifest.GetManifestIO(filename); err == nil { if remediation.SupportsRelax(io) { group.Go(func() error {