From de8efcd4b9992efb34805a82e0c3dba54c93c281 Mon Sep 17 00:00:00 2001 From: Jared Tate <13957390+JaredTate@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:45:57 -0600 Subject: [PATCH] Test Win Fix --- contrib/devtools/security-check.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py index 1934d2808a..100da966eb 100755 --- a/contrib/devtools/security-check.py +++ b/contrib/devtools/security-check.py @@ -11,6 +11,10 @@ import lief +# 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. @@ -232,7 +236,7 @@ def check_MACHO_branch_protection(binary) -> bool: lief.ARCHITECTURES.ARM: BASE_ELF, lief.ARCHITECTURES.ARM64: BASE_ELF, lief.ARCHITECTURES.PPC: BASE_ELF, - lief.ARCHITECTURES.RISCV: BASE_ELF, + LIEF_ELF_ARCH_RISCV: BASE_ELF, }, lief.EXE_FORMATS.PE: { lief.ARCHITECTURES.X86: BASE_PE, @@ -260,9 +264,12 @@ def check_MACHO_branch_protection(binary) -> bool: continue if arch == lief.ARCHITECTURES.NONE: - print(f'{filename}: unknown architecture') - retval = 1 - continue + if binary.header.machine_type == LIEF_ELF_ARCH_RISCV: + arch = LIEF_ELF_ARCH_RISCV + else: + print(f'{filename}: unknown architecture') + retval = 1 + continue failed: list[str] = [] for (name, func) in CHECKS[etype][arch]: