Skip to content

Commit

Permalink
binexport: fix lints and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-hunhoff committed Jun 4, 2024
1 parent 9e94987 commit 45b7b59
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion capa/features/extractors/binexport2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ def _find_base_address(self):
def _compute_thunks(self):
for addr, idx in self.idx.vertex_index_by_address.items():
vertex: BinExport2.CallGraph.Vertex = self.be2.call_graph.vertex[idx]
if not capa.features.extractors.binexport2.helpers.is_vertex_type(vertex, BinExport2.CallGraph.Vertex.Type.THUNK):
if not capa.features.extractors.binexport2.helpers.is_vertex_type(
vertex, BinExport2.CallGraph.Vertex.Type.THUNK
):
continue

curr_idx: int = idx
Expand Down
1 change: 1 addition & 0 deletions capa/features/extractors/binexport2/basicblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from capa.features.basicblock import BasicBlock
from capa.features.extractors.binexport2 import FunctionContext, BasicBlockContext
from capa.features.extractors.base_extractor import BBHandle, FunctionHandle
from capa.features.extractors.binexport2.binexport2_pb2 import BinExport2


def extract_bb_tight_loop(fh: FunctionHandle, bbh: BBHandle) -> Iterator[Tuple[Feature, Address]]:
Expand Down
4 changes: 3 additions & 1 deletion capa/features/extractors/binexport2/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def get_functions(self) -> Iterator[FunctionHandle]:
be2_vertex: BinExport2.CallGraph.Vertex = self.be2.call_graph.vertex[vertex_idx]

# skip thunks
if capa.features.extractors.binexport2.helpers.is_vertex_type(be2_vertex, BinExport2.CallGraph.Vertex.Type.THUNK):
if capa.features.extractors.binexport2.helpers.is_vertex_type(
be2_vertex, BinExport2.CallGraph.Vertex.Type.THUNK
):
continue

yield FunctionHandle(
Expand Down
4 changes: 3 additions & 1 deletion capa/features/extractors/binexport2/insn.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def extract_insn_api_features(fh: FunctionHandle, _bbh: BBHandle, ih: InsnHandle
vertex_idx: int = be2_index.vertex_index_by_address[addr]
vertex: BinExport2.CallGraph.Vertex = be2.call_graph.vertex[vertex_idx]

if not capa.features.extractors.binexport2.helpers.is_vertex_type(vertex, BinExport2.CallGraph.Vertex.Type.IMPORTED):
if not capa.features.extractors.binexport2.helpers.is_vertex_type(
vertex, BinExport2.CallGraph.Vertex.Type.IMPORTED
):
continue

if not vertex.HasField("mangled_name"):
Expand Down

0 comments on commit 45b7b59

Please sign in to comment.