From 0685d36220717c3efc65e8610cae397cdc54e3e9 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Tue, 25 May 2021 10:58:35 +0200 Subject: [PATCH] explorer: use bitmask + enum for analyze option --- capa/ida/plugin/form.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/capa/ida/plugin/form.py b/capa/ida/plugin/form.py index 29d8305c..99cdafd9 100644 --- a/capa/ida/plugin/form.py +++ b/capa/ida/plugin/form.py @@ -44,6 +44,13 @@ CAPA_SETTINGS_RULE_PATH = "rule_path" CAPA_SETTINGS_RULEGEN_AUTHOR = "rulegen_author" CAPA_SETTINGS_RULEGEN_SCOPE = "rulegen_scope" +from enum import IntFlag + + +class Options(IntFlag): + DEFAULT = 0 + ANALYZE = 1 # Runs the analysis when starting the explorer + def write_file(path, data): """ """ @@ -230,7 +237,7 @@ class CapaSettingsInputDialog(QtWidgets.QDialog): class CapaExplorerForm(idaapi.PluginForm): """form element for plugin interface""" - def __init__(self, name, option=0): + def __init__(self, name, option=Options.DEFAULT): """initialize form elements""" super(CapaExplorerForm, self).__init__() @@ -278,7 +285,7 @@ class CapaExplorerForm(idaapi.PluginForm): self.Show() - if option == 1: + if (option & Options.ANALYZE) == Options.ANALYZE: self.analyze_program() def OnCreate(self, form):