fix: address reportPossiblyUnbound diagnostics (chunk 3)

- elf.py: fix bug where vdso_guess except handler set symtab_guess=None
- result_document.py: add assert_never after StaticAnalysis/DynamicAnalysis
- binexport2/helpers.py: guard empty operand_expressions with early return
- tests/fixtures.py: restructure kernel32-64.dll_ workaround to single if/else
This commit is contained in:
Willi Ballenthin
2026-04-22 16:57:55 +03:00
committed by Willi Ballenthin
parent ad8ed3b0b3
commit b34079208c
4 changed files with 10 additions and 4 deletions

View File

@@ -575,6 +575,9 @@ class BinExport2InstructionPattern:
if len(self.operands) != len(operand_expressions):
return None
if not operand_expressions:
return None
captured = None
for operand_index, found_expressions in enumerate(operand_expressions):
@@ -645,7 +648,7 @@ class BinExport2InstructionPattern:
else:
# There were no captures, so
# return arbitrary non-None expression
return BinExport2InstructionPattern.MatchResult(operand_index, expression_index, found_expression)
return BinExport2InstructionPattern.MatchResult(operand_index, expression_index, found_expression) # type: ignore # loops always run: operand_expressions non-empty (guarded) and expressions are validated non-empty
class BinExport2InstructionPatternMatcher:

View File

@@ -1557,7 +1557,7 @@ def detect_elf_os(f) -> str:
logger.debug("guess: vdso strings: %s", vdso_guess)
except Exception as e:
logger.warning("Error guessing OS from vdso strings: %s", e)
symtab_guess = None
vdso_guess = None
ret = None

View File

@@ -749,6 +749,8 @@ class ResultDocument(FrozenModel):
)
elif isinstance(self.meta.analysis, DynamicAnalysis):
capabilities = Capabilities(matches, self.meta.analysis.feature_counts)
else:
assert_never(self.meta.analysis)
return self.meta, capabilities

View File

@@ -183,9 +183,10 @@ def get_binja_extractor(path: Path):
if path.name.endswith("kernel32-64.dll_"):
old_pdb = settings.get_bool("pdb.loadGlobalSymbols")
settings.set_bool("pdb.loadGlobalSymbols", False)
bv = binaryninja.load(str(path))
if path.name.endswith("kernel32-64.dll_"):
bv = binaryninja.load(str(path))
settings.set_bool("pdb.loadGlobalSymbols", old_pdb)
else:
bv = binaryninja.load(str(path))
# TODO(xusheng6): Temporary fix for https://github.com/mandiant/capa/issues/2507. Remove this once it is fixed in
# binja