feat: add .bpl extension to PE cataloger (#4954)

BPL (Borland Package Library) files are standard PE/DLL format used by
Delphi and C++Builder. Adding the extension to the glob list so syft
picks them up during directory scans without users needing to rename
to .dll first.
---------
Signed-off-by: jfjrh2014 <jfjrh2014@gmail.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Co-authored-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
Marcus 2026-06-08 14:07:15 +00:00 committed by GitHub
parent c5c423ab37
commit 908eb57890
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 39 additions and 4 deletions

View File

@ -161,7 +161,7 @@ func DefaultPackageTaskFactories() Factories {
pkgcataloging.DeclaredTag, pkgcataloging.DirectoryTag, pkgcataloging.InstalledTag, pkgcataloging.ImageTag, "binary",
),
newSimplePackageTaskFactory(binary.NewELFPackageCataloger, pkgcataloging.DeclaredTag, pkgcataloging.DirectoryTag, pkgcataloging.InstalledTag, pkgcataloging.ImageTag, "binary", "elf-package", "elf"),
newSimplePackageTaskFactory(binary.NewPEPackageCataloger, pkgcataloging.DeclaredTag, pkgcataloging.DirectoryTag, pkgcataloging.InstalledTag, pkgcataloging.ImageTag, "binary", "pe-package", "pe", "dll", "exe"),
newSimplePackageTaskFactory(binary.NewPEPackageCataloger, pkgcataloging.DeclaredTag, pkgcataloging.DirectoryTag, pkgcataloging.InstalledTag, pkgcataloging.ImageTag, "binary", "pe-package", "pe", "dll", "exe", "bpl"),
newSimplePackageTaskFactory(githubactions.NewActionUsageCataloger, pkgcataloging.DeclaredTag, pkgcataloging.DirectoryTag, "github", "github-actions"),
newSimplePackageTaskFactory(githubactions.NewWorkflowUsageCataloger, pkgcataloging.DeclaredTag, pkgcataloging.DirectoryTag, "github", "github-actions"),
newSimplePackageTaskFactory(java.NewJvmDistributionCataloger, pkgcataloging.DeclaredTag, pkgcataloging.DirectoryTag, pkgcataloging.InstalledTag, pkgcataloging.ImageTag, "java", "jvm", "jdk", "jre"),

View File

@ -957,6 +957,7 @@ catalogers:
function: NewPEPackageCataloger
selectors: # AUTO-GENERATED
- binary
- bpl
- declared
- directory
- dll
@ -973,6 +974,7 @@ catalogers:
criteria: # AUTO-GENERATED
- '**/*.dll'
- '**/*.exe'
- '**/*.bpl'
metadata_types: # AUTO-GENERATED
- pkg.PEBinary
package_types: # AUTO-GENERATED

View File

@ -12,10 +12,11 @@ import (
"github.com/anchore/syft/syft/pkg/cataloger/internal/pe"
)
// NewPEPackageCataloger returns a cataloger that interprets packages from DLL and EXE files.
// NewPEPackageCataloger returns a cataloger that interprets packages from DLL, EXE, and BPL files.
// 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")
WithParserByGlobs(parsePE, "**/*.dll", "**/*.exe", "**/*.bpl")
}
func parsePE(_ context.Context, _ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {

View File

@ -62,3 +62,30 @@ func Test_PEPackageCataloger(t *testing.T) {
}
}
func Test_PEPackageCataloger_Globs(t *testing.T) {
tests := []struct {
name string
fixture string
expected []string
}{
{
name: "obtain PE binary files (dll, exe, bpl)",
fixture: "testdata/glob-paths",
expected: []string{
"src/library.dll",
"src/program.exe",
"src/archive.bpl",
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
pkgtest.NewCatalogTester().
FromDirectory(t, test.fixture).
ExpectsResolverContentQueries(test.expected).
TestCataloger(t, NewPEPackageCataloger())
})
}
}

View File

@ -9,3 +9,4 @@ classifiers/bin
!VERSION*
!classifiers/snippets/**/bin/
!*.exe
!*.dll

View File

@ -0,0 +1 @@
bogus PE contents

View File

@ -0,0 +1 @@
bogus PE contents

View File

@ -0,0 +1 @@
not a binary

View File

@ -0,0 +1 @@
bogus PE contents