From 695508aa4c26247980ccb3280280bfa01529082e Mon Sep 17 00:00:00 2001 From: Yacine Elhamer Date: Tue, 25 Apr 2023 08:42:53 +0100 Subject: [PATCH] insn.py: Update extract_insn_api_features() to optimize by means of viv rather than function attributes --- capa/features/extractors/viv/insn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/capa/features/extractors/viv/insn.py b/capa/features/extractors/viv/insn.py index 9e8ee5fa..730472e2 100644 --- a/capa/features/extractors/viv/insn.py +++ b/capa/features/extractors/viv/insn.py @@ -123,7 +123,7 @@ def extract_insn_api_features(fh: FunctionHandle, bb, ih: InsnHandle) -> Iterato return if f.vw.metadata["Format"] == "elf": - if not hasattr(extract_insn_api_features, "symtab"): + if "SymbolTable" not in f.vw.metadata: # the symbol table gets stored as a function's attribute in order to avoid running # this code everytime the call is made, thus preventing the computational overhead. elf = f.vw.parsedbin @@ -138,9 +138,9 @@ def extract_insn_api_features(fh: FunctionHandle, bb, ih: InsnHandle) -> Iterato sh_strtab = Shdr.from_viv(strtab, elf.getSectionBytes(strtab.name)) symtab = SymTab(endian, bitness, sh_symtab, sh_strtab) - extract_insn_api_features.symtab = symtab + f.vw.metadata["SymbolTable"] = symtab - symtab = extract_insn_api_features.symtab + symtab = f.vw.metadata["SymbolTable"] for symbol in symtab.get_symbols(): sym_name = symtab.get_name(symbol) sym_value = symbol.value