contrib: use LIEF 0.12.0 for symbol and security checks

This commit is contained in:
fanquake
2022-03-14 09:07:55 +00:00
parent 3297f5c11c
commit 983e0a2058
3 changed files with 9 additions and 21 deletions

View File

@ -12,10 +12,6 @@ from typing import List
import lief #type:ignore
# temporary constant, to be replaced with lief.ELF.ARCH.RISCV
# https://github.com/lief-project/LIEF/pull/562
LIEF_ELF_ARCH_RISCV = lief.ELF.ARCH(243)
def check_ELF_RELRO(binary) -> bool:
'''
Check for read-only relocations.
@ -101,7 +97,6 @@ def check_ELF_separate_code(binary):
for segment in binary.segments:
if segment.type == lief.ELF.SEGMENT_TYPES.LOAD:
for section in segment.sections:
assert(section.name not in flags_per_section)
flags_per_section[section.name] = segment.flags
# Spot-check ELF LOAD program header flags per section
# If these sections exist, check them against the expected R/W/E flags
@ -222,7 +217,7 @@ CHECKS = {
lief.ARCHITECTURES.ARM: BASE_ELF,
lief.ARCHITECTURES.ARM64: BASE_ELF,
lief.ARCHITECTURES.PPC: BASE_ELF,
LIEF_ELF_ARCH_RISCV: BASE_ELF,
lief.ARCHITECTURES.RISCV: BASE_ELF,
},
lief.EXE_FORMATS.PE: {
lief.ARCHITECTURES.X86: BASE_PE,
@ -250,12 +245,9 @@ if __name__ == '__main__':
continue
if arch == lief.ARCHITECTURES.NONE:
if binary.header.machine_type == LIEF_ELF_ARCH_RISCV:
arch = LIEF_ELF_ARCH_RISCV
else:
print(f'{filename}: unknown architecture')
retval = 1
continue
print(f'{filename}: unknown architecture')
retval = 1
continue
failed: List[str] = []
for (name, func) in CHECKS[etype][arch]: