From 881c7984aa600d66336d3a33bf45e2f0262cdb19 Mon Sep 17 00:00:00 2001 From: Willi Ballenthin Date: Wed, 2 Sep 2020 13:05:18 -0600 Subject: [PATCH] ida plugin: search for matches across all columns --- capa/ida/plugin/proxy.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/capa/ida/plugin/proxy.py b/capa/ida/plugin/proxy.py index b35408cf..db0d77ac 100644 --- a/capa/ida/plugin/proxy.py +++ b/capa/ida/plugin/proxy.py @@ -116,7 +116,7 @@ class CapaExplorerRangeProxyModel(QtCore.QSortFilterProxyModel): class CapaExplorerSearchProxyModel(QtCore.QSortFilterProxyModel): """A SortFilterProxyModel that accepts rows with a substring match for a configurable query. - Looks for matches in the RULE_INFORMATION column (e.g. column 0). + Looks for matches in the text of all rows. Displays the entire tree row if any of the tree branches, that is, you can filter by rule name, or also filter by "characteristic(nzsor)" to filter matches with some feature. @@ -175,17 +175,25 @@ class CapaExplorerSearchProxyModel(QtCore.QSortFilterProxyModel): source_model = self.sourceModel() - index = source_model.index(row, 0, parent) - data = source_model.data(index, Qt.DisplayRole) + for column in ( + CapaExplorerDataModel.COLUMN_INDEX_RULE_INFORMATION, + CapaExplorerDataModel.COLUMN_INDEX_VIRTUAL_ADDRESS, + CapaExplorerDataModel.COLUMN_INDEX_DETAILS, + ): + index = source_model.index(row, column, parent) + data = source_model.data(index, Qt.DisplayRole) - if not data: - return False + if not data: + continue - if not isinstance(data, str): - # sanity check: should already be a string, but double check - return False + if not isinstance(data, str): + # sanity check: should already be a string, but double check + continue - return self.query in data + if self.query in data: + return True + + return False def set_query(self, query): self.query = query