| skipped 23 lines |
24 | 24 | | "github.com/anchore/syft/syft/source" |
25 | 25 | | ) |
26 | 26 | | |
27 | | - | func addAlpineMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 27 | + | func addAlpineMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
28 | 28 | | packages := catalog.PackagesByPath("/lib/apk/db/installed") |
29 | 29 | | if len(packages) != 1 { |
30 | 30 | | t.Logf("Alpine Packages: %+v", packages) |
| skipped 55 lines |
86 | 86 | | }) |
87 | 87 | | } |
88 | 88 | | |
89 | | - | func addJavascriptMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 89 | + | func addJavascriptMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
90 | 90 | | packages := catalog.PackagesByPath("/javascript/pkg-json/package.json") |
91 | 91 | | if len(packages) != 1 { |
92 | 92 | | t.Logf("Javascript Packages: %+v", packages) |
| skipped 25 lines |
118 | 118 | | }) |
119 | 119 | | } |
120 | 120 | | |
121 | | - | func addPythonMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 121 | + | func addPythonMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
122 | 122 | | packages := catalog.PackagesByPath("/python/dist-info/METADATA") |
123 | 123 | | if len(packages) != 1 { |
124 | 124 | | for _, p := range packages { |
| skipped 30 lines |
155 | 155 | | }) |
156 | 156 | | } |
157 | 157 | | |
158 | | - | func addDotnetMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 158 | + | func addDotnetMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
159 | 159 | | packages := catalog.PackagesByPath("/dotnet/TestLibrary.deps.json") |
160 | 160 | | if len(packages) != 1 { |
161 | 161 | | for _, p := range packages { |
| skipped 30 lines |
192 | 192 | | }) |
193 | 193 | | } |
194 | 194 | | |
195 | | - | func addRubyMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 195 | + | func addRubyMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
196 | 196 | | packages := catalog.PackagesByPath("/ruby/specifications/bundler.gemspec") |
197 | 197 | | if len(packages) != 1 { |
198 | 198 | | t.Logf("Ruby Packages: %+v", packages) |
| skipped 26 lines |
225 | 225 | | }) |
226 | 226 | | } |
227 | 227 | | |
228 | | - | func addGolangMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 228 | + | func addGolangMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
229 | 229 | | modPackages := catalog.PackagesByPath("/golang/go.mod") |
230 | 230 | | if len(modPackages) != 1 { |
231 | 231 | | t.Logf("Golang Mod Packages: %+v", modPackages) |
| skipped 44 lines |
276 | 276 | | } |
277 | 277 | | } |
278 | 278 | | |
279 | | - | func addJavaMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 279 | + | func addJavaMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
280 | 280 | | packages := make([]syftPkg.Package, 0) |
281 | 281 | | for p := range catalog.Enumerate(syftPkg.JavaPkg) { |
282 | 282 | | packages = append(packages, p) |
| skipped 34 lines |
317 | 317 | | }) |
318 | 318 | | } |
319 | 319 | | |
320 | | - | func addDpkgMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 320 | + | func addDpkgMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
321 | 321 | | packages := catalog.PackagesByPath("/var/lib/dpkg/status") |
322 | 322 | | if len(packages) != 1 { |
323 | 323 | | t.Logf("Dpkg Packages: %+v", packages) |
| skipped 34 lines |
358 | 358 | | }) |
359 | 359 | | } |
360 | 360 | | |
361 | | - | func addPortageMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 361 | + | func addPortageMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
362 | 362 | | packages := catalog.PackagesByPath("/var/db/pkg/app-containers/skopeo-1.5.1/CONTENTS") |
363 | 363 | | if len(packages) != 1 { |
364 | 364 | | t.Logf("Portage Packages: %+v", packages) |
| skipped 32 lines |
397 | 397 | | }) |
398 | 398 | | } |
399 | 399 | | |
400 | | - | func addRhelMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 400 | + | func addRhelMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
401 | 401 | | packages := catalog.PackagesByPath("/var/lib/rpm/Packages") |
402 | 402 | | if len(packages) != 1 { |
403 | 403 | | t.Logf("RPMDB Packages: %+v", packages) |
| skipped 33 lines |
437 | 437 | | }) |
438 | 438 | | } |
439 | 439 | | |
440 | | - | func addSlesMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 440 | + | func addSlesMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
441 | 441 | | packages := catalog.PackagesByPath("/var/lib/rpm/Packages") |
442 | 442 | | if len(packages) != 1 { |
443 | 443 | | t.Logf("Sles Packages: %+v", packages) |
| skipped 33 lines |
477 | 477 | | }) |
478 | 478 | | } |
479 | 479 | | |
480 | | - | func addHaskellMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore, theResult *match.Matches) { |
| 480 | + | func addHaskellMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore, theResult *match.Matches) { |
481 | 481 | | packages := catalog.PackagesByPath("/haskell/stack.yaml") |
482 | 482 | | if len(packages) < 1 { |
483 | 483 | | t.Logf("Haskel Packages: %+v", packages) |
| skipped 34 lines |
518 | 518 | | |
519 | 519 | | tests := []struct { |
520 | 520 | | fixtureImage string |
521 | | - | expectedFn func(source.Source, *syftPkg.Catalog, *mockStore) match.Matches |
| 521 | + | expectedFn func(source.Source, *syftPkg.Collection, *mockStore) match.Matches |
522 | 522 | | }{ |
523 | 523 | | { |
524 | 524 | | fixtureImage: "image-debian-match-coverage", |
525 | | - | expectedFn: func(theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore) match.Matches { |
| 525 | + | expectedFn: func(theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore) match.Matches { |
526 | 526 | | expectedMatches := match.NewMatches() |
527 | 527 | | addPythonMatches(t, theSource, catalog, theStore, &expectedMatches) |
528 | 528 | | addRubyMatches(t, theSource, catalog, theStore, &expectedMatches) |
| skipped 8 lines |
537 | 537 | | }, |
538 | 538 | | { |
539 | 539 | | fixtureImage: "image-centos-match-coverage", |
540 | | - | expectedFn: func(theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore) match.Matches { |
| 540 | + | expectedFn: func(theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore) match.Matches { |
541 | 541 | | expectedMatches := match.NewMatches() |
542 | 542 | | addRhelMatches(t, theSource, catalog, theStore, &expectedMatches) |
543 | 543 | | return expectedMatches |
| skipped 1 lines |
545 | 545 | | }, |
546 | 546 | | { |
547 | 547 | | fixtureImage: "image-alpine-match-coverage", |
548 | | - | expectedFn: func(theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore) match.Matches { |
| 548 | + | expectedFn: func(theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore) match.Matches { |
549 | 549 | | expectedMatches := match.NewMatches() |
550 | 550 | | addAlpineMatches(t, theSource, catalog, theStore, &expectedMatches) |
551 | 551 | | return expectedMatches |
| skipped 1 lines |
553 | 553 | | }, |
554 | 554 | | { |
555 | 555 | | fixtureImage: "image-sles-match-coverage", |
556 | | - | expectedFn: func(theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore) match.Matches { |
| 556 | + | expectedFn: func(theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore) match.Matches { |
557 | 557 | | expectedMatches := match.NewMatches() |
558 | 558 | | addSlesMatches(t, theSource, catalog, theStore, &expectedMatches) |
559 | 559 | | return expectedMatches |
| skipped 1 lines |
561 | 561 | | }, |
562 | 562 | | { |
563 | 563 | | fixtureImage: "image-portage-match-coverage", |
564 | | - | expectedFn: func(theSource source.Source, catalog *syftPkg.Catalog, theStore *mockStore) match.Matches { |
| 564 | + | expectedFn: func(theSource source.Source, catalog *syftPkg.Collection, theStore *mockStore) match.Matches { |
565 | 565 | | expectedMatches := match.NewMatches() |
566 | 566 | | addPortageMatches(t, theSource, catalog, theStore, &expectedMatches) |
567 | 567 | | return expectedMatches |
| skipped 25 lines |
593 | 593 | | // enable all catalogers to cover non default cases |
594 | 594 | | config.Catalogers = []string{"all"} |
595 | 595 | | |
596 | | - | theCatalog, _, theDistro, err := syft.CatalogPackages(theSource, config) |
| 596 | + | collection, _, theDistro, err := syft.CatalogPackages(theSource, config) |
597 | 597 | | require.NoError(t, err) |
598 | 598 | | |
599 | 599 | | matchers := matcher.NewDefaultMatchers(matcher.Config{}) |
| skipped 8 lines |
608 | 608 | | ExclusionProvider: ep, |
609 | 609 | | } |
610 | 610 | | |
611 | | - | actualResults := grype.FindVulnerabilitiesForPackage(str, theDistro, matchers, pkg.FromCatalog(theCatalog, pkg.SynthesisConfig{})) |
| 611 | + | actualResults := grype.FindVulnerabilitiesForPackage(str, theDistro, matchers, pkg.FromCollection(collection, pkg.SynthesisConfig{})) |
612 | 612 | | |
613 | 613 | | for _, m := range actualResults.Sorted() { |
614 | 614 | | for _, d := range m.Details { |
| skipped 2 lines |
617 | 617 | | } |
618 | 618 | | |
619 | 619 | | // build expected matches from what's discovered from the catalog |
620 | | - | expectedMatches := test.expectedFn(*theSource, theCatalog, theStore) |
| 620 | + | expectedMatches := test.expectedFn(*theSource, collection, theStore) |
621 | 621 | | |
622 | 622 | | assertMatches(t, expectedMatches.Sorted(), actualResults.Sorted()) |
623 | 623 | | }) |
| skipped 34 lines |