mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* Add Basic Nix Cataloger Signed-off-by: Julio Tain Sueiras <juliosueiras@gmail.com> * Update nix def for the latest syft definition Signed-off-by: Julio Tain Sueiras <juliosueiras@gmail.com> * capture nix package files on pkg.NixStoreMetadata Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix unit tests and linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update JSON schema Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * address review comments Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * Update syft/pkg/cataloger/nix/parse_nix_store_path_test.go Co-authored-by: Florian Klink <flokli@flokli.de> Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * support unstable version conventions Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update json schema relative to main branch Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update syft json with v7.1.1 schema Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix CLI tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove extra continue statement Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add Nix to list of supported ecosystems Signed-off-by: Alex Goodman <alex.goodman@anchore.com> --------- Signed-off-by: Julio Tain Sueiras <juliosueiras@gmail.com> Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Co-authored-by: Julio Tain Sueiras <juliosueiras@gmail.com> Co-authored-by: Florian Klink <flokli@flokli.de>
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package nix
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/anchore/syft/syft/artifact"
|
|
"github.com/anchore/syft/syft/pkg"
|
|
"github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest"
|
|
"github.com/anchore/syft/syft/source"
|
|
)
|
|
|
|
func TestCataloger_Catalog(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
fixture string
|
|
wantPkgs []pkg.Package
|
|
wantRel []artifact.Relationship
|
|
}{
|
|
{
|
|
fixture: "test-fixtures/fixture-1",
|
|
wantPkgs: []pkg.Package{
|
|
{
|
|
Name: "glibc",
|
|
Version: "2.34-210",
|
|
PURL: "pkg:nix/glibc@2.34-210?output=bin&outputhash=h0cnbmfcn93xm5dg2x27ixhag1cwndga",
|
|
Locations: source.NewLocationSet(source.NewLocation("nix/store/h0cnbmfcn93xm5dg2x27ixhag1cwndga-glibc-2.34-210-bin")),
|
|
FoundBy: catalogerName,
|
|
Type: pkg.NixPkg,
|
|
MetadataType: pkg.NixStoreMetadataType,
|
|
Metadata: pkg.NixStoreMetadata{
|
|
OutputHash: "h0cnbmfcn93xm5dg2x27ixhag1cwndga",
|
|
Output: "bin",
|
|
Files: []string{
|
|
"nix/store/h0cnbmfcn93xm5dg2x27ixhag1cwndga-glibc-2.34-210-bin/lib",
|
|
"nix/store/h0cnbmfcn93xm5dg2x27ixhag1cwndga-glibc-2.34-210-bin/lib/glibc.so",
|
|
"nix/store/h0cnbmfcn93xm5dg2x27ixhag1cwndga-glibc-2.34-210-bin/share",
|
|
"nix/store/h0cnbmfcn93xm5dg2x27ixhag1cwndga-glibc-2.34-210-bin/share/man",
|
|
"nix/store/h0cnbmfcn93xm5dg2x27ixhag1cwndga-glibc-2.34-210-bin/share/man/glibc.1",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.fixture, func(t *testing.T) {
|
|
c := NewStoreCataloger()
|
|
|
|
pkgtest.NewCatalogTester().
|
|
FromDirectory(t, tt.fixture).
|
|
Expects(tt.wantPkgs, tt.wantRel).
|
|
TestCataloger(t, c)
|
|
})
|
|
}
|
|
}
|