mirror of
https://github.com/anchore/syft.git
synced 2026-06-10 06:18:24 +02:00
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:
parent
c5c423ab37
commit
908eb57890
@ -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"),
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,4 +8,5 @@ classifiers/bin
|
||||
# allow for go-hint files and binaries
|
||||
!VERSION*
|
||||
!classifiers/snippets/**/bin/
|
||||
!*.exe
|
||||
!*.exe
|
||||
!*.dll
|
||||
1
syft/pkg/cataloger/binary/testdata/glob-paths/src/archive.bpl
vendored
Normal file
1
syft/pkg/cataloger/binary/testdata/glob-paths/src/archive.bpl
vendored
Normal file
@ -0,0 +1 @@
|
||||
bogus PE contents
|
||||
1
syft/pkg/cataloger/binary/testdata/glob-paths/src/library.dll
vendored
Normal file
1
syft/pkg/cataloger/binary/testdata/glob-paths/src/library.dll
vendored
Normal file
@ -0,0 +1 @@
|
||||
bogus PE contents
|
||||
1
syft/pkg/cataloger/binary/testdata/glob-paths/src/notes.txt
vendored
Normal file
1
syft/pkg/cataloger/binary/testdata/glob-paths/src/notes.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
not a binary
|
||||
1
syft/pkg/cataloger/binary/testdata/glob-paths/src/program.exe
vendored
Normal file
1
syft/pkg/cataloger/binary/testdata/glob-paths/src/program.exe
vendored
Normal file
@ -0,0 +1 @@
|
||||
bogus PE contents
|
||||
Loading…
x
Reference in New Issue
Block a user