test: add integration corner cases for Alpine

Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
Alfredo Deza 2020-08-03 12:31:52 -04:00
parent 905cae5377
commit e0db0c1145
2 changed files with 49 additions and 0 deletions

View file

@ -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)
}
}

View file

@ -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/"