From e0db0c1145c06a198ba5678e939f3acb5fecb3b4 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Mon, 3 Aug 2020 12:31:52 -0400 Subject: [PATCH] test: add integration corner cases for Alpine Signed-off-by: Alfredo Deza --- test/integration/corner_cases_test.go | 43 +++++++++++++++++++ .../corner-cases/apk/vnc/etc/os-release | 6 +++ 2 files changed, 49 insertions(+) create mode 100644 test/integration/corner_cases_test.go create mode 100644 test/integration/test-fixtures/corner-cases/apk/vnc/etc/os-release diff --git a/test/integration/corner_cases_test.go b/test/integration/corner_cases_test.go new file mode 100644 index 00000000..f4f9629d --- /dev/null +++ b/test/integration/corner_cases_test.go @@ -0,0 +1,43 @@ +package integration + +import ( + "fmt" + "testing" + + v1 "github.com/anchore/grype-db/pkg/db/v1" + "github.com/anchore/grype/grype" + "github.com/anchore/grype/grype/vulnerability" + "github.com/anchore/syft/syft/scope" +) + +func TestApkNoVersion(t *testing.T) { + store := mockStore{ + backend: map[string]map[string][]v1.Vulnerability{ + "nvd": { + "libvncserver": []v1.Vulnerability{ + { + ID: "CVE-2010-5304", + VersionConstraint: "< 0.9.9", + VersionFormat: "unknown", + }, + }, + }, + }, + } + + results, _, _, err := grype.FindVulnerabilities( + vulnerability.NewProviderFromStore(&store), + "dir://test-fixtures/corner-cases/apk", + scope.AllLayersScope, + ) + if err != nil { + t.Fatalf("failed to find vulnerabilities: %+v", err) + } + + for result := range results.Enumerate() { + fmt.Printf("%v\n", result) + } + if len(results.Enumerate()) != 1 { + t.Errorf("vulnerability count does not match '%d' != '%d'", len(results.Enumerate()), 1) + } +} diff --git a/test/integration/test-fixtures/corner-cases/apk/vnc/etc/os-release b/test/integration/test-fixtures/corner-cases/apk/vnc/etc/os-release new file mode 100644 index 00000000..be51cc6e --- /dev/null +++ b/test/integration/test-fixtures/corner-cases/apk/vnc/etc/os-release @@ -0,0 +1,6 @@ +NAME="Alpine Linux" +ID=alpine +VERSION_ID=3.12.0 +PRETTY_NAME="Alpine Linux v3.12" +HOME_URL="https://alpinelinux.org/" +BUG_REPORT_URL="https://bugs.alpinelinux.org/"