From 9f24ad48f1f248acdb48c0eb40207e726415a304 Mon Sep 17 00:00:00 2001 From: Joakim Loxdal Date: Fri, 13 Sep 2024 16:19:11 +0200 Subject: [PATCH] Make sure attacker entry points are ints when converting from json --- maltoolbox/attackgraph/attackgraph.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/maltoolbox/attackgraph/attackgraph.py b/maltoolbox/attackgraph/attackgraph.py index 93bbff8..fe656bc 100644 --- a/maltoolbox/attackgraph/attackgraph.py +++ b/maltoolbox/attackgraph/attackgraph.py @@ -329,7 +329,10 @@ def _from_dict( attacker = ag_attacker, attacker_id = int(attacker['id']), entry_points = attacker['entry_points'].keys(), - reached_attack_steps = attacker['reached_attack_steps'].keys() + reached_attack_steps = [ + int(node_id) # Convert to int since they can be strings + for node_id in attacker['reached_attack_steps'].keys() + ] ) return attack_graph @@ -653,7 +656,7 @@ def add_attacker( self.next_attacker_id = max(attacker.id + 1, self.next_attacker_id) for node_id in reached_attack_steps: - node = self.get_node_by_id(int(node_id)) + node = self.get_node_by_id(node_id) if node: attacker.compromise(node) else: