mirror of
https://github.com/anchore/syft.git
synced 2026-05-20 04:05:24 +02:00
feat: support zImage and bzImage in linux-kernel-cataloger (#4751)
Signed-off-by: Nadim Zubidat <nadimz@users.noreply.github.com>
This commit is contained in:
parent
19b4f41270
commit
c09f42e024
@ -31,6 +31,10 @@ catalogers:
|
||||
- '**/vmlinux-*'
|
||||
- '**/vmlinuz'
|
||||
- '**/vmlinuz-*'
|
||||
- '**/bzImage'
|
||||
- '**/bzImage-*'
|
||||
- '**/zImage'
|
||||
- '**/zImage-*'
|
||||
- '**/lib/modules/**/*.ko'
|
||||
metadata_types: # AUTO-GENERATED
|
||||
- pkg.LinuxKernel
|
||||
|
||||
@ -39,6 +39,10 @@ var kernelArchiveGlobs = []string{
|
||||
"**/vmlinux-*",
|
||||
"**/vmlinuz",
|
||||
"**/vmlinuz-*",
|
||||
"**/bzImage",
|
||||
"**/bzImage-*",
|
||||
"**/zImage",
|
||||
"**/zImage-*",
|
||||
}
|
||||
|
||||
var kernelModuleGlobs = []string{
|
||||
|
||||
37
syft/pkg/cataloger/kernel/parse_linux_kernel_file_test.go
Normal file
37
syft/pkg/cataloger/kernel/parse_linux_kernel_file_test.go
Normal file
@ -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")
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user