From 70396ffa36257ac2a780a30e3415ab3ad51994f2 Mon Sep 17 00:00:00 2001 From: William Ballenthin Date: Thu, 27 May 2021 10:38:40 -0600 Subject: [PATCH] ida: try to fix regex match rendering --- capa/ida/plugin/model.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/capa/ida/plugin/model.py b/capa/ida/plugin/model.py index e6882a93..b9430e2d 100644 --- a/capa/ida/plugin/model.py +++ b/capa/ida/plugin/model.py @@ -557,9 +557,14 @@ class CapaExplorerDataModel(QtCore.QAbstractItemModel): ) if feature["type"] == "regex": - return CapaExplorerStringViewItem( - parent, display, location, "\n".join(map(lambda s: '"' + capa.features.escape_string(s) + '"', feature["matches"].keys())) - ) + for s, locations in feature["matches"].items(): + if location in locations: + return CapaExplorerStringViewItem( + parent, display, location, '"' + capa.features.escape_string(s) + '"' + ) + + # programming error: the given location should always be found in the regex matches + raise ValueError("regex match at location not found") if feature["type"] == "basicblock": return CapaExplorerBlockItem(parent, location)