Add Conan (C/C++) conan.lock file support (#1230)

Co-authored-by: Christopher Phillips <christopher.phillips@anchore.com>
This commit is contained in:
Hiroaki KAWAI
2022-09-29 18:45:59 +00:00
committed by GitHub
co-authored by Christopher Phillips
parent e6502536a7
commit b9b13d5525
19 changed files with 1925 additions and 58 deletions
@@ -0,0 +1,47 @@
package cpp
import (
"os"
"testing"
"github.com/go-test/deep"
"github.com/anchore/syft/syft/pkg"
)
func TestParseConanlock(t *testing.T) {
expected := []*pkg.Package{
{
Name: "zlib",
Version: "1.2.12",
Language: pkg.CPP,
Type: pkg.ConanPkg,
MetadataType: pkg.ConanLockMetadataType,
Metadata: pkg.ConanLockMetadata{
Ref: "zlib/1.2.12",
Options: map[string]string{
"fPIC": "True",
"shared": "False",
},
Path: "all/conanfile.py",
Context: "host",
},
},
}
fixture, err := os.Open("test-fixtures/conan.lock")
if err != nil {
t.Fatalf("failed to open fixture: %+v", err)
}
// TODO: no relationships are under test yet
actual, _, err := parseConanlock(fixture.Name(), fixture)
if err != nil {
t.Error(err)
}
differences := deep.Equal(expected, actual)
if differences != nil {
t.Errorf("returned package list differed from expectation: %+v", differences)
}
}