support regex feature capa explorer

This commit is contained in:
Michael Hunhoff
2020-07-15 14:55:29 -06:00
parent 78dae308c2
commit 67cfb3866c

View File

@@ -488,18 +488,15 @@ class CapaExplorerDataModel(QtCore.QAbstractItemModel):
}
"""
display = self.capa_doc_feature_to_display(feature)
details = ""
if feature["type"] == "regex":
details = feature["match"]
if len(locations) == 1:
# only one location for feature so no need to nest children
parent2 = self.render_capa_doc_feature(
parent, feature, next(iter(locations)), doc, display=display, details=details
parent, feature, next(iter(locations)), doc, display=display,
)
else:
# feature has multiple children, nest under one parent feature node
parent2 = CapaExplorerFeatureItem(parent, display, details=details)
parent2 = CapaExplorerFeatureItem(parent, display)
for location in sorted(locations):
self.render_capa_doc_feature(parent2, feature, location, doc)
@@ -539,6 +536,9 @@ class CapaExplorerDataModel(QtCore.QAbstractItemModel):
parent, display, source=doc["rules"].get(feature[feature["type"]], {}).get("source", "")
)
if feature["type"] == "regex":
return CapaExplorerFeatureItem(parent, display, location, details=feature["match"])
if feature["type"] == "basicblock":
return CapaExplorerBlockItem(parent, location)