def run_elf_checks(self, pkg, pkgfile_path, path): self.readelf_parser = ReadelfParser(pkgfile_path, path) failed_reason = self.readelf_parser.parsing_failed_reason() if failed_reason: self.output.add_info('E', pkg, 'readelf-failed', path, failed_reason) return if not self.readelf_parser.is_archive: self.ldd_parser = LddParser(pkgfile_path, path) failed_reason = self.ldd_parser.parsing_failed_reason if failed_reason: self.output.add_info('E', pkg, 'ldd-failed', path, failed_reason) return self.objdump_parser = ObjdumpParser(pkgfile_path, path) failed_reason = self.objdump_parser.parsing_failed_reason if failed_reason: self.output.add_info('E', pkg, 'objdump-failed', path, failed_reason) return with concurrent.futures.ThreadPoolExecutor() as executor: futures = [] for fn in self.check_functions: futures.append(executor.submit(fn, pkg, pkgfile_path, path)) concurrent.futures.wait(futures)
def run_elf_checks(self, pkg, pkgfile_path, path): if self.is_archive and not self._is_standard_archive( pkg, pkgfile_path, path): return self.readelf_parser = ReadelfParser(pkgfile_path, path) failed_reason = self.readelf_parser.parsing_failed_reason() if failed_reason: self.output.add_info('E', pkg, 'readelf-failed', path, failed_reason) return if not self.is_archive: if self.is_dynamically_linked: is_installed_pkg = isinstance(pkg, InstalledPkg) or isinstance( pkg, FakePkg) self.ldd_parser = LddParser(pkgfile_path, path, is_installed_pkg) failed_reason = self.ldd_parser.parsing_failed_reason if failed_reason: self.output.add_info('E', pkg, 'ldd-failed', path, failed_reason) return self.objdump_parser = ObjdumpParser(pkgfile_path, path) failed_reason = self.objdump_parser.parsing_failed_reason if failed_reason: self.output.add_info('E', pkg, 'objdump-failed', path, failed_reason) return with concurrent.futures.ThreadPoolExecutor() as executor: futures = [] for fn in self.check_functions: futures.append(executor.submit(fn, pkg, pkgfile_path, path)) concurrent.futures.wait(futures) for future in futures: err = future.exception() if err: raise err
def run_elf_checks(self, pkg, pkgfile): if self.is_archive and not self._is_standard_archive(pkg, pkgfile): self.is_nonstandard_archive = True return self.readelf_parser = ReadelfParser(pkgfile.path, pkgfile.name) failed_reason = self.readelf_parser.parsing_failed_reason() if failed_reason: self.output.add_info('E', pkg, 'readelf-failed', pkgfile.name, failed_reason) return if not self.is_archive: if self.is_dynamically_linked: is_installed_pkg = isinstance(pkg, (InstalledPkg, FakePkg)) self.ldd_parser = LddParser(pkgfile.path, pkgfile.name, is_installed_pkg) failed_reason = self.ldd_parser.parsing_failed_reason if failed_reason: self.output.add_info('E', pkg, 'ldd-failed', pkgfile.name, failed_reason) return if (self.config.configuration['MandatoryOptflags'] or self.config.configuration['ForbiddenOptflags']): self.objdump_parser = ObjdumpParser(pkgfile.path, pkgfile.name) failed_reason = self.objdump_parser.parsing_failed_reason if failed_reason: self.output.add_info('E', pkg, 'objdump-failed', pkgfile.name, failed_reason) return # NOTE: the speed benefit of the ThreadPoolExecutor is limited due to # Global Interpreter Lock (GIL). with concurrent.futures.ThreadPoolExecutor() as executor: futures = [] for fn in self.check_functions: futures.append(executor.submit(fn, pkg, pkgfile)) concurrent.futures.wait(futures) for future in futures: err = future.exception() if err: raise err
def lddparser(path, system_path=None): if system_path is None: system_path = path return LddParser(get_full_path(path), system_path)