sarif-to-dot: to reduce graph clutter, add option --no-edges-to-scalars

This commit is contained in:
Michael Hohn
2022-01-26 00:41:31 -08:00
committed by =Michael Hohn
parent d7d566c5db
commit 153eba8346
2 changed files with 15 additions and 6 deletions

View File

@@ -137,7 +137,7 @@ def write_node(fp, typedef, sig):
""".format(name=typedef, head=typedef, body=label)
fp.write(node)
def write_edges(fp, typedef, sig):
def write_edges(args, fp, typedef, sig):
""" Write edges in dot format.
"""
if sig in ["string", "int", "bool"]:
@@ -158,10 +158,13 @@ def write_edges(fp, typedef, sig):
field_name, field_type = field
label = ""
dest = str(field_type)
edge = """ {src_node}:"{src_port}" -> {dest} [label="{label}"];
""".format(src_node=typedef, src_port=field_name, dest=field_type,
label=label)
fp.write(edge)
if dest in ["String", "Int", "Bool"] and args.no_edges_to_scalars:
pass
else:
edge = """ {src_node}:"{src_port}" -> {dest} [label="{label}"];
""".format(src_node=typedef, src_port=field_name, dest=field_type,
label=label)
fp.write(edge)
else:
raise Exception("unknown signature: " + str(sig))