Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_tested_spec_package(name):
filename = Path(name).name + '.spec'
pkg_path = list(get_tested_path(name).parent.glob(filename))[0]
return FakePkg(pkg_path)
def test_lto_archive_text(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('stripped-lto.a'), 'x.a')
out = output.print_results(output.results)
assert 'E: lto-no-text-in-archive' in out
assert 'E: static-library-without-debuginfo' in out
def test_unused_dependency_in_package_for_executable(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('appletviewer'), '/usr/bin/appletviewer')
assert not test.readelf_parser.parsing_failed_reason()
assert not test.ldd_parser.parsing_failed_reason
out = output.print_results(output.results)
assert 'W: unused-direct-shlib-dependency ' in out
def test_lto_archive_preinit_array(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('libclang_rt.asan-preinit-x86_64.a'), 'x.a')
assert 'E: lto-no-text-in-archive' not in output.print_results(output.results)
def test_stripped_archive(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('stripped-archive.a'), 'x.a')
out = output.print_results(output.results)
assert 'E: static-library-without-symtab' in out
def test_lto_archive_text_function_sections(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('function-sections.a'), 'x.a')
assert 'E: lto-no-text-in-archive' not in output.print_results(output.results)
def test_executable_stack(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('executable-stack'), 'a.out')
assert 'E: executable-stack' in output.results[0]
def validate_file(self, pname):
try:
if pname.suffix == '.rpm' or pname.suffix == '.spm':
with Pkg(pname, self.config.configuration['ExtractDir']) as pkg:
self.run_checks(pkg)
elif pname.suffix == '.spec':
with FakePkg(pname) as pkg:
self.run_spec_checks(pkg)
except Exception as e:
print_warning(f'(none): E: while reading {pname}: {e}')
if fname.endswith('.spec'):
self._spec_file = pkgfile.path
self._spec_name = pkgfile.name
if fname == pkg.name + '.spec':
wrong_spec = False
break
else:
wrong_spec = True
# method call
self._check_no_spec_file(pkg)
self._check_invalid_spec_name(pkg, wrong_spec)
if self._spec_file:
# check content of spec file
with Pkg.FakePkg(self._spec_file) as package:
self.check_spec(package)