Skip to content

Commit

Permalink
Make sure attacker entry points are ints when converting from json
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkickling committed Sep 13, 2024
1 parent c49e9dc commit c1db835
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions maltoolbox/attackgraph/attackgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion tests/attackgraph/test_attackgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from unittest.mock import patch

from maltoolbox.language import LanguageGraph
from maltoolbox.attackgraph import AttackGraph
from maltoolbox.attackgraph import AttackGraph, Attacker
from maltoolbox.model import Model, AttackerAttachment
from maltoolbox.exceptions import AttackGraphException

from test_model import create_application_asset, create_association

Expand Down

0 comments on commit c1db835

Please sign in to comment.