colton: developing ghidra backend tests

This commit is contained in:
colton-gabertan
2023-05-26 17:51:48 -07:00
parent ffe089d444
commit 50afc2f9b2
2 changed files with 26 additions and 0 deletions

View File

@@ -1333,6 +1333,7 @@ def ghidra_main():
globl_features: List[Tuple[Feature, Address]] = []
globl_features.extend(capa.features.extractors.ghidra.global_.extract_os())
globl_features.extend(capa.features.extractors.ghidra.global_.extract_arch())
print(globl_features)

View File

@@ -0,0 +1,25 @@
import logging
import fixtures
from fixtures import *
import capa.main
logger = logging.getLogger(__file__)
# We need to skip the ghidra test if we cannot import ghidra modules, e.g., in GitHub CI.
ghidra_present: bool = False
try:
import ghidra.program.flatapi as flatapi
ghidraapi = flatapi.FlatProgramAPI(currentProgram)
try:
current_program_test = ghidraapi.getCurrentProgram()
except RuntimeError as e:
logger.warning("Ghidra runtime not detected")
else:
ghidra_present = True
except ImportError:
pass