Skip to content

Commit ee43cbd

Browse files
committed
SCA: Skip binaries with invalid ELF sections
Some of the prebuilt binaries in our packages are compiled for e.g. Android and other systems, and they should be skipped by SCA. Signed-off-by: Sergio Durigan Junior <[email protected]>
1 parent 3796ede commit ee43cbd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/sca/sca.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ var ignoredLibs = []string{
9292
"libc.musl-aarch64.so.1",
9393
}
9494

95+
// List of ELF sections that should not appear in binaries being
96+
// analyzed by us. If they do, we can skip the analysis.
97+
var invalidELFSections = []string {
98+
".note.android.ident",
99+
}
100+
95101
// SCAFS represents the minimum required filesystem accessors which are needed by
96102
// the SCA engine.
97103
type SCAFS interface {
@@ -702,6 +708,12 @@ func generateSharedObjectNameDeps(ctx context.Context, hdl SCAHandle, generated
702708
log.Debugf("skipping binary %s; unsupported architecture %s", path, ef.Machine.String())
703709
return nil
704710
}
711+
for _, elfSection := range invalidELFSections {
712+
if ef.Section(elfSection) != nil {
713+
log.Debugf("skipping binary %s; invalid ELF section %v found", path, elfSection)
714+
return nil
715+
}
716+
}
705717

706718
interp, err := findInterpreter(ef)
707719
if err != nil {

0 commit comments

Comments
 (0)