Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Issue 1
traverse
method is missing some sink states. Namely, if there is a transition from a non-sink state to a sink state (which is defined for this non-sink node in thefinal.json
file), then this sink state will be missed (i.e. drawn solid, see images below).Example 1: states 427, 67 and 371 are sinks in
finalsinks.json
file generated by FlexFringe (this can also be seen in the fragments of S-PDFA, the count of these states is <sink_count
=5), however in the AGs they are non-sinks (note: this example is also after implementing the fix with unknown in this PR: #12). Left AG is before the fix, right AG is after the fix.Example 2: state 82 is a non-sink state(in the left image before the fix), while in
finalsinks.json
file generated by FlexFringe it is a sinkExample 3: states 80 and 81 a non-sink states (in the left image before the fix), while in
finalsinks.json
file generated by FlexFringe they are sinksExample 4: state 70 is a non-sink state (in the left image before the fix), while in
finalsinks.json
file generated by FlexFringe it is a sinkIssue 2
If a sequence ends with a sink, then it will not be added to the
sev_sinks
, asstate
will not be an empty string. Infinal.json
file, there are transitions from non-sinks to sinks, but sinks themselves are not defined (they are infinalsinks.json
file). So, SAGE misses sinks that are at the end of a sequence.Issue 3
Sometimes there is a transition from a red non-sink state to a blue sink state. However, in the default
spdfa-config.ini
printblue
parameter is set to0
. This results in a missing transition infinal.json
file, because of whichID: -1
will be assigned for medium-severity states, even though they do have an ID. This is especially a problem when there are multiple such states in an AG, as they will be merged to one state with ID: -1. Furthermore, it hinders interpretability.Before (fragment):
After (fragment):
Another example + the fragments of S-PDFA (note: here 287 and 289 are the same nodes, as well as 1451 and 1437 - the screenshot of the S-PDFA merge was taken after implementing all the fixes, including PR #12 and PR #11
Issue 4
In
make_AG
method, in three places, it is checked whether states are sinks and if they are, they are made dotted. This is done usingendwith
method, namely:obj.endswith(sink)
. However, this might result in a false positive ifsink
is a string substring of the last part of the objective variant. For example, the conditionobj.endswith(sink)
will evaluate to True ifsink=75
andobj=”DATA_EXFILTRATION|http|375
, which will lead to state 375 coloured dashed, whereas it is not a sink.Proposed fixes
First, replace
endswith
method with strict equals comparison after splitting an objective or a vertex name.Second, at the end of
traverse
method, add a check to add a state in thesev_sinks
set. This fix will prevent skipping sinks that are heads of edges with tails being non-sinks (defined in the main model). Note that ifID: -1
, for low-severity sinks, they will not be added, as-1
is never insinks
(the intended behaviour).Third, set
printblue=1
by default tospdfa-config.json
file. This will remove all theID: -1
from medium-severity states and put the actual IDs as in the files generated by FF.Result
10.0.0.1|NETWORKDOS|mswbtserver
, where before there was oneACCOUNT MANIPULATION|-1
node and after there are two such nodes:ACCOUNT MANIPULATION|snmp|ID: 371
andACCOUNT MANIPULATION|snmp|ID:863
.ID: -1
have disappeared:comm -13 …
), and extract their IDs (sed …
). At the same time, usingjq
we take thebefore-2017.txt.ff.finalsinks.json
file (which is the same asafter-2017.txt.ff.finalsinks.json
file) and print IDs of only those nodes that are sinks. Finally, we take the intersection between the previously found IDs (comm -12 …
) and count them (… | wc -l
). The result is equal to the number of such sink IDs that are only present after the fix (i.e. lost by the original version of SAGE before the fix).Furthermore, in a similar way as above, we have verified all sinks found after all fixes are indeed sinks in FlexFringe and all non-sinks with defined IDs (i.e. ID has not been removed) are indeed non-sinks in FlexFringe: