Skip to content

Commit

Permalink
Fix issue in generating DOT files with nodes containing colons.
Browse files Browse the repository at this point in the history
Issue documented in pydot/pydot#258 (comment)

Fixes #5.
  • Loading branch information
MegaManSec committed Jan 11, 2024
1 parent 730963e commit b30ee12
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tools/generate-graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create_graph_from_edges(lookup_table):
return graph


def build_lookup_table(input_lines, ignore_dest_user):
def build_lookup_table(input_lines, ignore_dest_user, dot):
lookup_table = set()


Expand All @@ -28,6 +28,13 @@ def build_lookup_table(input_lines, ignore_dest_user):

for match in matches:
user, host, _, dest_user, dest_host = match.groups()

if dot:
user = f'"{user}'
host = f'{host}"'
dest_user = f'"{dest_user}'
dest_host = f'{dest_host}"'

if host == "(127.0.0.1)" or host == "127.0.0.1":
if prev_dest_host is not None:
host = prev_dest_host
Expand Down Expand Up @@ -71,7 +78,7 @@ def build_lookup_table(input_lines, ignore_dest_user):
if args.with_users:
ignore_dest_user = False

lookup_table = build_lookup_table(input_lines, ignore_dest_user)
lookup_table = build_lookup_table(input_lines, ignore_dest_user, args.format == "dot")
graph = create_graph_from_edges(lookup_table)

if len(lookup_table) > 500 and args.format == "dot":
Expand Down

0 comments on commit b30ee12

Please sign in to comment.