chore: migrate fixtures to testdata (#4651)

* migrate fixtures to testdata

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: correct broken symlinks after testdata migration

The migration from test-fixtures to testdata broke several symlinks:
- elf-test-fixtures symlinks pointed to old test-fixtures paths
- elf-test-fixtures needed to be renamed to elf-testdata
- image-pkg-coverage symlink pointed to test-fixtures instead of testdata

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: handle missing classifiers/bin directory in Makefile

The clean-fingerprint target was failing when classifiers/bin doesn't
exist (e.g., on fresh clone without downloaded binaries).

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: add gitignore negation for jar/zip fixtures in test/cli

The jar and zip files in test/cli/testdata/image-unknowns were being
gitignored by the root .gitignore patterns. This caused them to be
untracked and not included when building docker images in CI, resulting
in Test_Unknowns failures since the test expects errors from corrupt
archive files that weren't present.

Add a .gitignore in test/cli/testdata to negate the exclusions for
these specific test fixture files.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* switch fixture cache to v2

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* test: update expected versions for rebuilt fixtures

Update test expectations for packages that have been updated in
upstream repositories when docker images are rebuilt:
- glibc: 2.42-r4 → 2.43-r1 (wolfi)
- php: 8.2.29 → 8.2.30 (ubuntu/apache)

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* upgrade go

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: add go-shlex dependency for testdata manager tool

The manager tool in syft/pkg/cataloger/binary/testdata/ imports
go-shlex, but since it's in a testdata directory, Go doesn't track
its dependencies. This caused CI failures when go.mod didn't
explicitly list the dependency.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* refactor: move binary classifier manager to internal/

Move the manager tool from testdata/manager to internal/manager so
that Go properly tracks its dependencies. Code in testdata directories
is ignored by Go for dependency tracking, which caused CI failures
when go.mod didn't explicitly list transitive dependencies.

This is a cleaner solution than manually adding dependencies to go.mod
for code that happens to live in testdata.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: add gitignore negations for test fixtures blocked by root patterns

Multiple test fixtures were being blocked by root-level gitignore patterns
like bin/, *.jar, *.tar, and *.exe. This adds targeted .gitignore files with
negation patterns to allow these specific test fixtures to be tracked:

- syft/linux/testdata/os/busybox/bin/busybox (blocked by bin/)
- syft/pkg/cataloger/java/testdata/corrupt/example.{jar,tar} (blocked by *.jar, *.tar)
- syft/pkg/cataloger/binary/testdata/classifiers/snippets/go-version-hint/**/bin/go (blocked by bin/)
- syft/pkg/cataloger/bitnami/testdata/no-rel/.../bin/redis-server (blocked by bin/)

Also updates the bitnami test expectation to include the newly required
.gitignore files in the test fixture.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* test: update glibc version expectation (2.43-r1 -> 2.43-r2)

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* add capability drift check as unit step

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* dont clear test observations before drift detection

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* bump stereoscope commit to main

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2026-03-06 19:42:04 +00:00
committed by GitHub
parent 35278f3d3d
commit b5e85c3ea5
1589 changed files with 1184 additions and 1058 deletions
+35 -35
View File
@@ -18,7 +18,7 @@ func TestIdentifyRelease(t *testing.T) {
release *Release
}{
{
fixture: "test-fixtures/os/alpine",
fixture: "testdata/os/alpine",
release: &Release{
PrettyName: "Alpine Linux v3.11",
Name: "Alpine Linux",
@@ -30,7 +30,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/amazon",
fixture: "testdata/os/amazon",
release: &Release{
PrettyName: "Amazon Linux 2",
Name: "Amazon Linux",
@@ -47,7 +47,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/busybox",
fixture: "testdata/os/busybox",
release: &Release{
PrettyName: "BusyBox v1.31.1",
Name: "busybox",
@@ -58,7 +58,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/centos",
fixture: "testdata/os/centos",
release: &Release{
PrettyName: "CentOS Linux 8 (Core)",
Name: "CentOS Linux",
@@ -74,7 +74,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/debian/from-os-release",
fixture: "testdata/os/debian/from-os-release",
release: &Release{
PrettyName: "Debian GNU/Linux 8 (jessie)",
Name: "Debian GNU/Linux",
@@ -88,7 +88,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/debian/from-debian_version",
fixture: "testdata/os/debian/from-debian_version",
release: &Release{
PrettyName: "Distroless",
Name: "Debian GNU/Linux",
@@ -102,7 +102,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/fedora",
fixture: "testdata/os/fedora",
release: &Release{
PrettyName: "Fedora Linux 36 (Container Image)",
Name: "Fedora Linux",
@@ -121,7 +121,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/redhat/from-os-release",
fixture: "testdata/os/redhat/from-os-release",
release: &Release{
PrettyName: "Red Hat Enterprise Linux Server 7.3 (Maipo)",
Name: "Red Hat Enterprise Linux Server",
@@ -135,7 +135,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/redhat/from-redhat-release",
fixture: "testdata/os/redhat/from-redhat-release",
release: &Release{
PrettyName: "Red Hat Enterprise Linux release 8.10 (Ootpa)",
Name: "Red Hat Enterprise Linux",
@@ -146,7 +146,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/ubuntu",
fixture: "testdata/os/ubuntu",
release: &Release{
PrettyName: "Ubuntu 20.04 LTS",
Name: "Ubuntu",
@@ -162,7 +162,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/oraclelinux",
fixture: "testdata/os/oraclelinux",
release: &Release{
PrettyName: "Oracle Linux Server 8.3",
Name: "Oracle Linux Server",
@@ -178,10 +178,10 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/empty",
fixture: "testdata/os/empty",
},
{
fixture: "test-fixtures/os/custom",
fixture: "testdata/os/custom",
release: &Release{
PrettyName: "CentOS Linux 8 (Core)",
Name: "Scientific Linux",
@@ -198,7 +198,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/opensuse-leap",
fixture: "testdata/os/opensuse-leap",
release: &Release{
PrettyName: "openSUSE Leap 15.2",
Name: "openSUSE Leap",
@@ -215,7 +215,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/sles",
fixture: "testdata/os/sles",
release: &Release{
PrettyName: "SUSE Linux Enterprise Server 15 SP2",
Name: "SLES",
@@ -227,7 +227,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/photon",
fixture: "testdata/os/photon",
release: &Release{
PrettyName: "VMware Photon OS/Linux",
Name: "VMware Photon OS",
@@ -240,7 +240,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/arch",
fixture: "testdata/os/arch",
release: &Release{
PrettyName: "Arch Linux",
Name: "Arch Linux",
@@ -253,7 +253,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/partial-fields/missing-id",
fixture: "testdata/partial-fields/missing-id",
release: &Release{
Name: "Debian GNU/Linux",
IDLike: []string{"debian"},
@@ -261,7 +261,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/partial-fields/unknown-id",
fixture: "testdata/partial-fields/unknown-id",
release: &Release{
Name: "Debian GNU/Linux",
ID: "my-awesome-distro",
@@ -270,14 +270,14 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/partial-fields/missing-version",
fixture: "testdata/partial-fields/missing-version",
release: &Release{
Name: "Debian GNU/Linux",
IDLike: []string{"debian"},
},
},
{
fixture: "test-fixtures/os/centos6",
fixture: "testdata/os/centos6",
release: &Release{
PrettyName: "centos",
Name: "centos",
@@ -289,7 +289,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/centos5",
fixture: "testdata/os/centos5",
release: &Release{
PrettyName: "CentOS release 5.7 (Final)",
Name: "CentOS",
@@ -300,7 +300,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/mariner",
fixture: "testdata/os/mariner",
release: &Release{
PrettyName: "CBL-Mariner/Linux",
Name: "Common Base Linux Mariner",
@@ -314,7 +314,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/rockylinux",
fixture: "testdata/os/rockylinux",
release: &Release{
PrettyName: "Rocky Linux 8.4 (Green Obsidian)",
Name: "Rocky Linux",
@@ -331,7 +331,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/almalinux",
fixture: "testdata/os/almalinux",
release: &Release{
PrettyName: "AlmaLinux 8.4 (Electric Cheetah)",
Name: "AlmaLinux",
@@ -349,7 +349,7 @@ func TestIdentifyRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/os/wolfi",
fixture: "testdata/os/wolfi",
release: &Release{
PrettyName: "Wolfi",
Name: "Wolfi",
@@ -382,7 +382,7 @@ func TestParseOsRelease(t *testing.T) {
release *Release
}{
{
fixture: "test-fixtures/ubuntu-20.04",
fixture: "testdata/ubuntu-20.04",
release: &Release{
PrettyName: "Ubuntu 20.04 LTS",
@@ -400,7 +400,7 @@ func TestParseOsRelease(t *testing.T) {
},
{
fixture: "test-fixtures/debian-8",
fixture: "testdata/debian-8",
release: &Release{
PrettyName: "Debian GNU/Linux 8 (jessie)",
@@ -416,7 +416,7 @@ func TestParseOsRelease(t *testing.T) {
},
{
fixture: "test-fixtures/centos-8",
fixture: "testdata/centos-8",
release: &Release{
PrettyName: "CentOS Linux 8 (Core)",
@@ -435,7 +435,7 @@ func TestParseOsRelease(t *testing.T) {
},
{
fixture: "test-fixtures/rhel-8",
fixture: "testdata/rhel-8",
release: &Release{
PrettyName: "Red Hat Enterprise Linux 8.1 (Ootpa)",
@@ -451,7 +451,7 @@ func TestParseOsRelease(t *testing.T) {
},
{
fixture: "test-fixtures/unprintable",
fixture: "testdata/unprintable",
release: &Release{
PrettyName: "Debian GNU/Linux 8 (jessie)",
@@ -489,7 +489,7 @@ func TestParseSystemReleaseCPE(t *testing.T) {
release *Release
}{
{
fixture: "test-fixtures/os/centos6/etc/system-release-cpe",
fixture: "testdata/os/centos6/etc/system-release-cpe",
release: &Release{
PrettyName: "centos",
Name: "centos",
@@ -501,7 +501,7 @@ func TestParseSystemReleaseCPE(t *testing.T) {
},
},
{
fixture: "test-fixtures/bad-system-release-cpe",
fixture: "testdata/bad-system-release-cpe",
release: nil,
},
}
@@ -528,7 +528,7 @@ func TestParseRedhatRelease(t *testing.T) {
release *Release
}{
{
fixture: "test-fixtures/os/centos5/etc/redhat-release",
fixture: "testdata/os/centos5/etc/redhat-release",
name: "Centos 5",
release: &Release{
PrettyName: "CentOS release 5.7 (Final)",
@@ -540,7 +540,7 @@ func TestParseRedhatRelease(t *testing.T) {
},
},
{
fixture: "test-fixtures/bad-redhat-release",
fixture: "testdata/bad-redhat-release",
name: "Centos 5 Bad Redhat Release",
release: nil,
},
@@ -0,0 +1,2 @@
# override root level ignores for test fixtures
!bin/
@@ -0,0 +1,2 @@
# override root level ignores for test fixtures
!*