From c5fba2d0e46329b3ab5e172d8b17941d24575dea Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Mon, 21 Oct 2024 12:08:17 -0400 Subject: [PATCH] rename testing license scanner Signed-off-by: Alex Goodman --- internal/licenses/scanner.go | 4 ++-- syft/pkg/cataloger/golang/licenses_test.go | 8 ++++---- syft/pkg/cataloger/golang/parse_go_binary_test.go | 2 +- syft/pkg/cataloger/java/archive_parser_test.go | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/licenses/scanner.go b/internal/licenses/scanner.go index 66b7e8563..5efb1d3a3 100644 --- a/internal/licenses/scanner.go +++ b/internal/licenses/scanner.go @@ -35,9 +35,9 @@ func NewDefaultScanner() Scanner { } } -// StaticScanner returns a scanner that uses the built-in license scanner from the licensecheck package. +// TestingOnlyScanner returns a scanner that uses the built-in license scanner from the licensecheck package. // THIS IS ONLY MEANT FOR TEST CODE, NOT PRODUCTION CODE. -func StaticScanner() Scanner { +func TestingOnlyScanner() Scanner { return &scanner{ coverageThreshold: coverageThreshold, scanner: licensecheck.Scan, diff --git a/syft/pkg/cataloger/golang/licenses_test.go b/syft/pkg/cataloger/golang/licenses_test.go index a21b52f98..0acde6de9 100644 --- a/syft/pkg/cataloger/golang/licenses_test.go +++ b/syft/pkg/cataloger/golang/licenses_test.go @@ -28,7 +28,7 @@ func Test_LocalLicenseSearch(t *testing.T) { loc2 := file.NewLocation("github.com/!cap!o!r!g/!cap!project@v4.111.5/LICENSE.txt") loc3 := file.NewLocation("github.com/someorg/strangelicense@v1.2.3/LiCeNsE.tXt") - licenseScanner := licenses.StaticScanner() + licenseScanner := licenses.TestingOnlyScanner() tests := []struct { name string @@ -96,7 +96,7 @@ func Test_RemoteProxyLicenseSearch(t *testing.T) { loc1 := file.NewLocation("github.com/someorg/somename@v0.3.2/LICENSE") loc2 := file.NewLocation("github.com/!cap!o!r!g/!cap!project@v4.111.5/LICENSE.txt") - licenseScanner := licenses.StaticScanner() + licenseScanner := licenses.TestingOnlyScanner() server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { buf := &bytes.Buffer{} @@ -254,7 +254,7 @@ func Test_findVersionPath(t *testing.T) { func Test_walkDirErrors(t *testing.T) { resolver := newGoLicenseResolver("", CatalogerConfig{}) - _, err := resolver.findLicensesInFS(context.Background(), licenses.StaticScanner(), "somewhere", badFS{}) + _, err := resolver.findLicensesInFS(context.Background(), licenses.TestingOnlyScanner(), "somewhere", badFS{}) require.Error(t, err) } @@ -272,7 +272,7 @@ func Test_noLocalGoModDir(t *testing.T) { validTmp := t.TempDir() require.NoError(t, os.MkdirAll(filepath.Join(validTmp, "mod@ver"), 0700|os.ModeDir)) - licenseScanner := licenses.StaticScanner() + licenseScanner := licenses.TestingOnlyScanner() tests := []struct { name string diff --git a/syft/pkg/cataloger/golang/parse_go_binary_test.go b/syft/pkg/cataloger/golang/parse_go_binary_test.go index e4ac65b3e..18d6b4146 100644 --- a/syft/pkg/cataloger/golang/parse_go_binary_test.go +++ b/syft/pkg/cataloger/golang/parse_go_binary_test.go @@ -169,7 +169,7 @@ func TestBuildGoPkgInfo(t *testing.T) { }, } - licenseScanner := licenses.StaticScanner() + licenseScanner := licenses.TestingOnlyScanner() tests := []struct { name string diff --git a/syft/pkg/cataloger/java/archive_parser_test.go b/syft/pkg/cataloger/java/archive_parser_test.go index c7121255f..706c8c0b5 100644 --- a/syft/pkg/cataloger/java/archive_parser_test.go +++ b/syft/pkg/cataloger/java/archive_parser_test.go @@ -31,7 +31,7 @@ import ( func TestSearchMavenForLicenses(t *testing.T) { url := mockMavenRepo(t) - ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.StaticScanner()) + ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.TestingOnlyScanner()) tests := []struct { name string @@ -90,7 +90,7 @@ func TestSearchMavenForLicenses(t *testing.T) { } func TestParseJar(t *testing.T) { - ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.StaticScanner()) + ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.TestingOnlyScanner()) tests := []struct { name string @@ -1354,7 +1354,7 @@ func Test_parseJavaArchive_regressions(t *testing.T) { } func Test_deterministicMatchingPomProperties(t *testing.T) { - ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.StaticScanner()) + ctx := licenses.SetContextLicenseScanner(context.Background(), licenses.TestingOnlyScanner()) tests := []struct { fixture string