mirror of
https://github.com/anchore/syft.git
synced 2026-11-05 08:56:41 +01:00
* prototype: start bitnami cataloger Bitnami images have spdx SBOMs at predictable paths, and Syft could more accurately identify the software in these images by scanning those SBOMs. Start work on this by forking the sbom-cataloger as a new bitnami-cataloger. Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com> * wire up bitnami cataloger to run on images by default Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com> * feat: add support for Bitnami cataloguer Signed-off-by: juan131 <jariza@vmware.com> * feat: use a better SPDX sample for unit tests Signed-off-by: juan131 <jariza@vmware.com> * bugfix: only report bitnami pkgs Signed-off-by: juan131 <jariza@vmware.com> * feat: adapt JSON schema, spdxutil and packagemetadata Signed-off-by: juan131 <jariza@vmware.com> * bugfix: integration tests Signed-off-by: juan131 <jariza@vmware.com> * feat: implement FileOwner interface Signed-off-by: juan131 <jariza@vmware.com> * bugfix: update json schema Signed-off-by: juan131 <jariza@vmware.com> * [wip] add bitnami owned files and fix binary package ownership filtering Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * feat: obtain bitnami pkg files based on SPDX relationships tree Signed-off-by: juan131 <jariza@vmware.com> * preserve type switches Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * rename bitnami entry metadata type Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * restrict find main pkg logic Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add missing graalvm source info Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bugfix: integration tests Signed-off-by: juan131 <jariza@vmware.com> * bugfix: mod tidy Signed-off-by: juan131 <jariza@vmware.com> --------- Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com> Signed-off-by: juan131 <jariza@vmware.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Will Murphy <willmurphyscode@users.noreply.github.com> Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package bitnami
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/anchore/syft/syft/pkg"
|
|
)
|
|
|
|
func Test_parseBitnamiPURL(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
purl string
|
|
want *pkg.BitnamiSBOMEntry
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "Valid Bitnami pURL",
|
|
purl: "pkg:bitnami/redis@7.4.1-0?arch=arm64&distro=debian-12",
|
|
want: &pkg.BitnamiSBOMEntry{
|
|
Name: "redis",
|
|
Version: "7.4.1",
|
|
Revision: "0",
|
|
Architecture: "arm64",
|
|
Distro: "debian-12",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "Invalid pURL",
|
|
purl: "this/is/not/a/purl",
|
|
want: nil,
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "Invalid version",
|
|
purl: "pkg:bitnami/redis@7.4.1.0?arch=arm64&distro=debian-12",
|
|
want: nil,
|
|
wantErr: true,
|
|
},
|
|
}
|
|
t.Parallel()
|
|
for _, testToRun := range tests {
|
|
test := testToRun
|
|
t.Run(test.name, func(tt *testing.T) {
|
|
tt.Parallel()
|
|
got, err := parseBitnamiPURL(test.purl)
|
|
if (err != nil) != test.wantErr {
|
|
tt.Errorf("parseBitnamiPURL() error = %v, wantErr %v", err, test.wantErr)
|
|
return
|
|
}
|
|
if !reflect.DeepEqual(got, test.want) {
|
|
tt.Errorf("parseBitnamiPURL() = %v, want %v", got, test.want)
|
|
}
|
|
})
|
|
}
|
|
}
|