mirror of
https://github.com/anchore/syft.git
synced 2025-11-21 02:13:17 +01:00
* [wip] Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * distinct the package metadata functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * remove metadata type from package core model Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * incorporate review feedback for names Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add RPM archive metadata and split parser helpers Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * clarify the python package metadata type Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * rename the KB metadata type Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * break hackage and composer types by use case Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * linting fix Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix encoding and decoding for syft-json and cyclonedx Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump json schema to 11 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update cyclonedx-json snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update cyclonedx-xml snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update spdx-json snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update spdx-tv snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update syft-json snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * correct metadata type in stack yaml parser test Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix bom-ref redactor for cyclonedx-xml Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add tests for legacy package metadata names Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * regenerate json schema v11 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix legacy HackageMetadataType reflect type value check Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix linting Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * packagemetadata discovery should account for type shadowing Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix linting Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix cli tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump json schema version to v12 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update json schema to incorporate changes from main Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add syft-json legacy config option Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add tests around v11-v12 json decoding Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add docs for SYFT_JSON_LEGACY Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * rename structs to be compliant with new naming scheme Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
129 lines
3.6 KiB
Go
129 lines
3.6 KiB
Go
package cpp
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/anchore/syft/syft/artifact"
|
|
"github.com/anchore/syft/syft/file"
|
|
"github.com/anchore/syft/syft/pkg"
|
|
"github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest"
|
|
)
|
|
|
|
func TestParseConaninfo(t *testing.T) {
|
|
fixture := "test-fixtures/conaninfo/mfast/1.2.2/my_user/my_channel/package/9d1f076b471417647c2022a78d5e2c1f834289ac/conaninfo.txt"
|
|
expected := []pkg.Package{
|
|
{
|
|
Name: "mfast",
|
|
Version: "1.2.2",
|
|
PURL: "pkg:conan/my_user/mfast@1.2.2?channel=my_channel",
|
|
Locations: file.NewLocationSet(file.NewLocation(fixture)),
|
|
Language: pkg.CPP,
|
|
Type: pkg.ConanPkg,
|
|
Metadata: pkg.ConaninfoEntry{
|
|
Ref: "mfast/1.2.2@my_user/my_channel#c6f6387c9b99780f0ee05e25f99d0f39",
|
|
PackageID: "9d1f076b471417647c2022a78d5e2c1f834289ac",
|
|
},
|
|
},
|
|
{
|
|
Name: "boost",
|
|
Version: "1.75.0",
|
|
PURL: "pkg:conan/boost@1.75.0",
|
|
Locations: file.NewLocationSet(file.NewLocation(fixture)),
|
|
Language: pkg.CPP,
|
|
Type: pkg.ConanPkg,
|
|
Metadata: pkg.ConaninfoEntry{
|
|
Ref: "boost/1.75.0:dc8aedd23a0f0a773a5fcdcfe1ae3e89c4205978",
|
|
PackageID: "dc8aedd23a0f0a773a5fcdcfe1ae3e89c4205978",
|
|
},
|
|
},
|
|
{
|
|
Name: "zlib",
|
|
Version: "1.2.13",
|
|
PURL: "pkg:conan/zlib@1.2.13",
|
|
Locations: file.NewLocationSet(file.NewLocation(fixture)),
|
|
Language: pkg.CPP,
|
|
Type: pkg.ConanPkg,
|
|
Metadata: pkg.ConaninfoEntry{
|
|
Ref: "zlib/1.2.13:dfbe50feef7f3c6223a476cd5aeadb687084a646",
|
|
PackageID: "dfbe50feef7f3c6223a476cd5aeadb687084a646",
|
|
},
|
|
},
|
|
{
|
|
Name: "bzip2",
|
|
Version: "1.0.8",
|
|
PURL: "pkg:conan/bzip2@1.0.8",
|
|
Locations: file.NewLocationSet(file.NewLocation(fixture)),
|
|
Language: pkg.CPP,
|
|
Type: pkg.ConanPkg,
|
|
Metadata: pkg.ConaninfoEntry{
|
|
Ref: "bzip2/1.0.8:c32092bf4d4bb47cf962af898e02823f499b017e",
|
|
PackageID: "c32092bf4d4bb47cf962af898e02823f499b017e",
|
|
},
|
|
},
|
|
{
|
|
Name: "libbacktrace",
|
|
Version: "cci.20210118",
|
|
PURL: "pkg:conan/libbacktrace@cci.20210118",
|
|
Locations: file.NewLocationSet(file.NewLocation(fixture)),
|
|
Language: pkg.CPP,
|
|
Type: pkg.ConanPkg,
|
|
Metadata: pkg.ConaninfoEntry{
|
|
Ref: "libbacktrace/cci.20210118:dfbe50feef7f3c6223a476cd5aeadb687084a646",
|
|
PackageID: "dfbe50feef7f3c6223a476cd5aeadb687084a646",
|
|
},
|
|
},
|
|
{
|
|
Name: "tinyxml2",
|
|
Version: "9.0.0",
|
|
PURL: "pkg:conan/tinyxml2@9.0.0",
|
|
Locations: file.NewLocationSet(file.NewLocation(fixture)),
|
|
Language: pkg.CPP,
|
|
Type: pkg.ConanPkg,
|
|
Metadata: pkg.ConaninfoEntry{
|
|
Ref: "tinyxml2/9.0.0:6557f18ca99c0b6a233f43db00e30efaa525e27e",
|
|
PackageID: "6557f18ca99c0b6a233f43db00e30efaa525e27e",
|
|
},
|
|
},
|
|
}
|
|
|
|
// relationships require IDs to be set to be sorted similarly
|
|
for i := range expected {
|
|
expected[i].SetID()
|
|
}
|
|
|
|
var expectedRelationships = []artifact.Relationship{
|
|
{
|
|
From: expected[1], // boost
|
|
To: expected[0], // mfast
|
|
Type: artifact.DependencyOfRelationship,
|
|
Data: nil,
|
|
},
|
|
{
|
|
From: expected[5], // tinyxml2
|
|
To: expected[0], // mfast
|
|
Type: artifact.DependencyOfRelationship,
|
|
Data: nil,
|
|
},
|
|
{
|
|
From: expected[2], // zlib
|
|
To: expected[0], // mfast
|
|
Type: artifact.DependencyOfRelationship,
|
|
Data: nil,
|
|
},
|
|
{
|
|
From: expected[3], // bzip2
|
|
To: expected[0], // mfast
|
|
Type: artifact.DependencyOfRelationship,
|
|
Data: nil,
|
|
},
|
|
{
|
|
From: expected[4], // libbacktrace
|
|
To: expected[0], // mfast
|
|
Type: artifact.DependencyOfRelationship,
|
|
Data: nil,
|
|
},
|
|
}
|
|
|
|
pkgtest.TestFileParser(t, fixture, parseConaninfo, expected, expectedRelationships)
|
|
}
|