diff --git a/Makefile b/Makefile index e421c5050..ab34401d6 100644 --- a/Makefile +++ b/Makefile @@ -130,7 +130,7 @@ unit: fixtures ## Run unit tests (with coverage) .PHONY: integration integration: ## Run integration tests $(call title,Running integration tests) - go test -tags=integration ./test/integration + go test -tags=integration -v ./test/integration # note: this is used by CI to determine if the integration test fixture cache (docker image tars) should be busted integration-fingerprint: diff --git a/test/integration/regression_test.go b/test/integration/regression_test.go new file mode 100644 index 000000000..572ddae8d --- /dev/null +++ b/test/integration/regression_test.go @@ -0,0 +1,38 @@ +// +build integration + +package integration + +import ( + "testing" + + "github.com/anchore/syft/syft/pkg" + + "github.com/anchore/stereoscope/pkg/imagetest" + "github.com/anchore/syft/syft" + "github.com/anchore/syft/syft/scope" +) + +func TestRegression212ApkBufferSize(t *testing.T) { + // This is a regression test for issue #212 (https://github.com/anchore/syft/issues/212) in which the apk db could + // not be processed due to a scanner buffer that was too small + + fixtureImageName := "image-large-apk-data" + _, cleanup := imagetest.GetFixtureImage(t, "docker-archive", fixtureImageName) + tarPath := imagetest.GetFixtureImageTarPath(t, fixtureImageName) + defer cleanup() + + catalog, _, _, err := syft.Catalog("docker-archive:"+tarPath, scope.SquashedScope) + if err != nil { + t.Fatalf("failed to catalog image: %+v", err) + } + + expectedPkgs := 57 + actualPkgs := 0 + for range catalog.Enumerate(pkg.ApkPkg) { + actualPkgs += 1 + } + + if actualPkgs != expectedPkgs { + t.Errorf("unexpected number of APK packages: %d != %d", expectedPkgs, actualPkgs) + } +} diff --git a/test/integration/test-fixtures/image-large-apk-data/Dockerfile b/test/integration/test-fixtures/image-large-apk-data/Dockerfile new file mode 100644 index 000000000..465f33bcf --- /dev/null +++ b/test/integration/test-fixtures/image-large-apk-data/Dockerfile @@ -0,0 +1,2 @@ +FROM alpine:latest +RUN apk add tzdata vim alpine-sdk