From d74c961c980f928ca9b78b0ae0ebf89347cd610c Mon Sep 17 00:00:00 2001 From: Pratik Mohapatra Date: Tue, 19 Mar 2024 16:51:32 +0530 Subject: [PATCH] attempt to fix linter violations --- capa/ghidra/capa_explorer.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/capa/ghidra/capa_explorer.py b/capa/ghidra/capa_explorer.py index 9a86fe062e..9b537bee39 100644 --- a/capa/ghidra/capa_explorer.py +++ b/capa/ghidra/capa_explorer.py @@ -15,7 +15,6 @@ import pathlib from typing import Any, Dict, List -from ghidra.app.script import GhidraScript from ghidra.app.cmd.label import AddLabelCmd, CreateNamespacesCmd from ghidra.program.model.symbol import Namespace, SourceType, SymbolType @@ -62,24 +61,6 @@ def create_label(ghidra_addr, name, capa_namespace): return -def run(self): - user_choice = self.askChoices( - "Choose b/w bookmarks & comments", "Preferred action:", ["bookmarks", "comments", "none", "both"], "both" - ) - if user_choice == "bookmarks": - for item in parse_json(self.capa_data): - item.bookmark_functions() - elif user_choice == "comments": - for item in parse_json(self.capa_data): - item.label_matches() - elif user_choice == "both": - for item in parse_json(self.capa_data): - item.bookmark_functions() - item.label_matches() - else: - pass - - class CapaMatchData: def __init__( self, @@ -382,6 +363,22 @@ def main(): popup("capa explorer found no matches.") # type: ignore [name-defined] # noqa: F821 return capa.main.E_EMPTY_REPORT + user_choice = askChoice( # type: ignore [name-defined] # noqa: F821 + "Choose b/w bookmarks & comments", "Preferred action:", ["bookmarks", "comments", "none", "both"], "both" + ) + if user_choice == "bookmarks": + for item in parse_json(capa_data): + item.bookmark_functions() + elif user_choice == "comments": + for item in parse_json(capa_data): + item.label_matches() + elif user_choice == "both": + for item in parse_json(capa_data): + item.bookmark_functions() + item.label_matches() + else: + pass + logger.info("capa explorer analysis complete") popup("capa explorer analysis complete.\nPlease see results in the Bookmarks Window and Namespaces section of the Symbol Tree Window.") # type: ignore [name-defined] # noqa: F821 return 0