diff --git a/syft/pkg/cataloger/kernel/capabilities.yaml b/syft/pkg/cataloger/kernel/capabilities.yaml index e3c92abd5..5888f515a 100644 --- a/syft/pkg/cataloger/kernel/capabilities.yaml +++ b/syft/pkg/cataloger/kernel/capabilities.yaml @@ -31,6 +31,10 @@ catalogers: - '**/vmlinux-*' - '**/vmlinuz' - '**/vmlinuz-*' + - '**/bzImage' + - '**/bzImage-*' + - '**/zImage' + - '**/zImage-*' - '**/lib/modules/**/*.ko' metadata_types: # AUTO-GENERATED - pkg.LinuxKernel diff --git a/syft/pkg/cataloger/kernel/cataloger.go b/syft/pkg/cataloger/kernel/cataloger.go index 6e76518e9..c9ddcb4ec 100644 --- a/syft/pkg/cataloger/kernel/cataloger.go +++ b/syft/pkg/cataloger/kernel/cataloger.go @@ -39,6 +39,10 @@ var kernelArchiveGlobs = []string{ "**/vmlinux-*", "**/vmlinuz", "**/vmlinuz-*", + "**/bzImage", + "**/bzImage-*", + "**/zImage", + "**/zImage-*", } var kernelModuleGlobs = []string{ diff --git a/syft/pkg/cataloger/kernel/parse_linux_kernel_file_test.go b/syft/pkg/cataloger/kernel/parse_linux_kernel_file_test.go new file mode 100644 index 000000000..ea9856e71 --- /dev/null +++ b/syft/pkg/cataloger/kernel/parse_linux_kernel_file_test.go @@ -0,0 +1,37 @@ +package kernel + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestParseLinuxKernelMetadata_bzImage_PositiveCase(t *testing.T) { + magicType := []string{ + "Linux kernel", + "x86 boot executable", + "bzImage", + "version 4.12.29-17011406-standard (oe-user@oe-host) #1 SMP Tue Apr 20 22:18:27 UTC 2021", + } + + got := parseLinuxKernelMetadata(magicType) + + assert.Equal(t, "x86", got.Architecture) + assert.Equal(t, "bzImage", got.Format) + assert.Equal(t, "4.12.29-17011406-standard", got.Version) + assert.NotEmpty(t, got.ExtendedVersion) +} + +func TestParseLinuxKernelMetadata_bzImage_EmptyVersion(t *testing.T) { + magicType := []string{ + "Linux kernel", + "x86 boot executable", + "bzImage", + // no "version ..." token + } + + got := parseLinuxKernelMetadata(magicType) + + assert.Equal(t, "bzImage", got.Format) + assert.Empty(t, got.Version, "version should be empty when no version token is present") +}