diff --git a/syft/pkg/cataloger/binary/capabilities.yaml b/syft/pkg/cataloger/binary/capabilities.yaml index a40db6e16..18e265ae0 100644 --- a/syft/pkg/cataloger/binary/capabilities.yaml +++ b/syft/pkg/cataloger/binary/capabilities.yaml @@ -1055,6 +1055,9 @@ catalogers: detector: # AUTO-GENERATED method: glob # AUTO-GENERATED criteria: # AUTO-GENERATED + - '**/*.DLL' + - '**/*.EXE' + - '**/*.BPL' - '**/*.dll' - '**/*.exe' - '**/*.bpl' diff --git a/syft/pkg/cataloger/binary/pe_package_cataloger.go b/syft/pkg/cataloger/binary/pe_package_cataloger.go index 16292be76..74abb379d 100644 --- a/syft/pkg/cataloger/binary/pe_package_cataloger.go +++ b/syft/pkg/cataloger/binary/pe_package_cataloger.go @@ -16,7 +16,7 @@ import ( // BPL (Borland Package Library) files are PE-format binaries used by Delphi and C++Builder. func NewPEPackageCataloger() pkg.Cataloger { return generic.NewCataloger("pe-binary-package-cataloger"). - WithParserByGlobs(parsePE, "**/*.dll", "**/*.exe", "**/*.bpl") + WithParserByGlobs(parsePE, "**/*.DLL", "**/*.EXE", "**/*.BPL", "**/*.dll", "**/*.exe", "**/*.bpl") } func parsePE(_ context.Context, _ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) { diff --git a/syft/pkg/cataloger/binary/pe_package_cataloger_test.go b/syft/pkg/cataloger/binary/pe_package_cataloger_test.go index 7ba3eae3f..18b5c7d40 100644 --- a/syft/pkg/cataloger/binary/pe_package_cataloger_test.go +++ b/syft/pkg/cataloger/binary/pe_package_cataloger_test.go @@ -70,12 +70,16 @@ func Test_PEPackageCataloger_Globs(t *testing.T) { expected []string }{ { - name: "obtain PE binary files (dll, exe, bpl)", + name: "obtain PE binary files (dll, exe, bpl), including uppercase extensions", fixture: "testdata/glob-paths", expected: []string{ "src/library.dll", "src/program.exe", "src/archive.bpl", + // uppercase extensions appear on Windows/ISO 9660 filesystems and must also match + "src/winlibrary.DLL", + "src/winprogram.EXE", + "src/winarchive.BPL", }, }, } diff --git a/syft/pkg/cataloger/binary/testdata/glob-paths/src/winarchive.BPL b/syft/pkg/cataloger/binary/testdata/glob-paths/src/winarchive.BPL new file mode 100644 index 000000000..159643c0f --- /dev/null +++ b/syft/pkg/cataloger/binary/testdata/glob-paths/src/winarchive.BPL @@ -0,0 +1 @@ +bogus PE contents diff --git a/syft/pkg/cataloger/binary/testdata/glob-paths/src/winlibrary.DLL b/syft/pkg/cataloger/binary/testdata/glob-paths/src/winlibrary.DLL new file mode 100644 index 000000000..159643c0f --- /dev/null +++ b/syft/pkg/cataloger/binary/testdata/glob-paths/src/winlibrary.DLL @@ -0,0 +1 @@ +bogus PE contents diff --git a/syft/pkg/cataloger/binary/testdata/glob-paths/src/winprogram.EXE b/syft/pkg/cataloger/binary/testdata/glob-paths/src/winprogram.EXE new file mode 100644 index 000000000..159643c0f --- /dev/null +++ b/syft/pkg/cataloger/binary/testdata/glob-paths/src/winprogram.EXE @@ -0,0 +1 @@ +bogus PE contents diff --git a/syft/pkg/cataloger/dotnet/capabilities.yaml b/syft/pkg/cataloger/dotnet/capabilities.yaml index aa6b9c499..b6cf64d64 100644 --- a/syft/pkg/cataloger/dotnet/capabilities.yaml +++ b/syft/pkg/cataloger/dotnet/capabilities.yaml @@ -39,6 +39,10 @@ catalogers: - '**/*.deps.json' - '**/*.dll' - '**/*.exe' + - '**/*.bpl' + - '**/*.DLL' + - '**/*.EXE' + - '**/*.BPL' metadata_types: # AUTO-GENERATED - pkg.DotnetDepsEntry - pkg.DotnetPortableExecutableEntry @@ -173,6 +177,10 @@ catalogers: criteria: - '**/*.dll' - '**/*.exe' + - '**/*.bpl' + - '**/*.DLL' + - '**/*.EXE' + - '**/*.BPL' metadata_types: # AUTO-GENERATED - pkg.DotnetPortableExecutableEntry package_types: # AUTO-GENERATED diff --git a/syft/pkg/cataloger/dotnet/cataloger_test.go b/syft/pkg/cataloger/dotnet/cataloger_test.go index 04b2caf20..dae8d9db9 100644 --- a/syft/pkg/cataloger/dotnet/cataloger_test.go +++ b/syft/pkg/cataloger/dotnet/cataloger_test.go @@ -36,6 +36,10 @@ func TestCataloger_Globs(t *testing.T) { "src/something.bpl", "src/something.dll", "src/something.exe", + // uppercase extensions appear on Windows/ISO 9660 filesystems and must also match + "src/winsomething.DLL", + "src/winsomething.EXE", + "src/winsomething.BPL", }, }, { @@ -47,6 +51,10 @@ func TestCataloger_Globs(t *testing.T) { "src/something.deps.json", "src/something.dll", "src/something.exe", + // uppercase extensions appear on Windows/ISO 9660 filesystems and must also match + "src/winsomething.DLL", + "src/winsomething.EXE", + "src/winsomething.BPL", }, // the binary cataloger probes executables by MIME type to find embedded bundles, // but the glob fixtures aren't real binaries so those queries go unfulfilled diff --git a/syft/pkg/cataloger/dotnet/deps_binary_cataloger.go b/syft/pkg/cataloger/dotnet/deps_binary_cataloger.go index ea96b1710..15f19de22 100644 --- a/syft/pkg/cataloger/dotnet/deps_binary_cataloger.go +++ b/syft/pkg/cataloger/dotnet/deps_binary_cataloger.go @@ -27,6 +27,10 @@ const ( dllGlob = "**/*.dll" exeGlob = "**/*.exe" bplGlob = "**/*.bpl" + // uppercase variants match PE files on case-preserving Windows/ISO 9660 filesystems (doublestar globs are case-sensitive) + dllGlobUpper = "**/*.DLL" + exeGlobUpper = "**/*.EXE" + bplGlobUpper = "**/*.BPL" ) var elfMagic = []byte{0x7f, 'E', 'L', 'F'} @@ -483,7 +487,7 @@ func readDepsJSON(resolver file.Resolver, loc file.Location) (*depsJSON, error) // findPEFiles locates and parses all PE files (dll/exe). func findPEFiles(resolver file.Resolver) ([]logicalPE, error, error) { - peLocs, err := resolver.FilesByGlob(dllGlob, exeGlob, bplGlob) + peLocs, err := resolver.FilesByGlob(dllGlob, exeGlob, bplGlob, dllGlobUpper, exeGlobUpper, bplGlobUpper) if err != nil { return nil, nil, fmt.Errorf("unable to find PE files: %w", err) } diff --git a/syft/pkg/cataloger/dotnet/testdata/glob-paths/src/winsomething.BPL b/syft/pkg/cataloger/dotnet/testdata/glob-paths/src/winsomething.BPL new file mode 100644 index 000000000..159643c0f --- /dev/null +++ b/syft/pkg/cataloger/dotnet/testdata/glob-paths/src/winsomething.BPL @@ -0,0 +1 @@ +bogus PE contents diff --git a/syft/pkg/cataloger/dotnet/testdata/glob-paths/src/winsomething.DLL b/syft/pkg/cataloger/dotnet/testdata/glob-paths/src/winsomething.DLL new file mode 100644 index 000000000..159643c0f --- /dev/null +++ b/syft/pkg/cataloger/dotnet/testdata/glob-paths/src/winsomething.DLL @@ -0,0 +1 @@ +bogus PE contents diff --git a/syft/pkg/cataloger/dotnet/testdata/glob-paths/src/winsomething.EXE b/syft/pkg/cataloger/dotnet/testdata/glob-paths/src/winsomething.EXE new file mode 100644 index 000000000..159643c0f --- /dev/null +++ b/syft/pkg/cataloger/dotnet/testdata/glob-paths/src/winsomething.EXE @@ -0,0 +1 @@ +bogus PE contents