Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing sinks in attack graphs #14

Merged
merged 5 commits into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions sage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2244,6 +2244,7 @@ def traverse(dfa, sinks, sequence, statelist=False):
#print('This seq', sequence.split(" "))
for event in sequence.split(" "):
sym = event.split(":")[0]
sev = rev_smallmapping[sym.split('|')[0]]

#print('curr symbol ', sym, 'state no.', dfa[state][sym])

Expand All @@ -2258,14 +2259,12 @@ def traverse(dfa, sinks, sequence, statelist=False):
# in_main_model.add(state[0])
if state == "":
# return -1 for low sev symbols
sev = rev_smallmapping[sym.split('|')[0]]
#print(sev)
if len(str(sev)) >= 2:
#print('high-sev sink found', sev)
#print(stlst[-1], sinks[stlst[-1]], stlst)
try:
state = sinks[stlst[-1]][sym][0]
sev_sinks.add(state)
except:
#print('didnt work for', sequence, 'done so far:', stlst)
state = '-1'
Expand Down Expand Up @@ -2303,6 +2302,8 @@ def traverse(dfa, sinks, sequence, statelist=False):
else:
return (dfa[state]["type"] == "1", stlst)
stlst.append(state)
if state in sinks and len(str(sev)) >= 2:
sev_sinks.add(state)
if not statelist:
return dfa[state]["type"] == "1"
else:
Expand Down Expand Up @@ -2737,7 +2738,7 @@ def make_AG(condensed_v_data, condensed_data, state_groups, sev_sinks, datafile,

sinkflag = False
for sink in sev_sinks:
if obj.endswith(sink):
if obj.split("|")[-1] == sink:
sinkflag = True
break
if sinkflag:
Expand Down Expand Up @@ -2775,7 +2776,7 @@ def make_AG(condensed_v_data, condensed_data, state_groups, sev_sinks, datafile,
else:
sinkflag = False
for sink in sev_sinks:
if vname.endswith(sink): # else if a high-sev sink, make dotted too
if vname.split("|")[-1] == sink: # else if a high-sev sink, make dotted too
sinkflag = True
break
if sinkflag:
Expand Down Expand Up @@ -2824,7 +2825,7 @@ def make_AG(condensed_v_data, condensed_data, state_groups, sev_sinks, datafile,
else:
sinkflag = False
for sink in sev_sinks:
if vname.endswith(sink):
if vname.split("|")[-1] == sink:
sinkflag = True
break
if sinkflag:
Expand Down