Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 46ca564

Browse files
committed
introduce a printable state class
1 parent 8a3e87f commit 46ca564

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

javascript/ql/src/Performance/ReDoS.ql

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,13 +734,9 @@ predicate step(StatePair q, InputSymbol s1, InputSymbol s2, State r1, State r2)
734734
stateInsideBacktracking(r2)
735735
}
736736

737-
/**
738-
* A list of pairs of input symbols that describe a path in the product automaton
739-
* starting from some fork state.
740-
*/
741-
newtype Trace =
737+
private newtype TTrace =
742738
Nil() or
743-
Step(InputSymbol s1, InputSymbol s2, Trace t) {
739+
Step(InputSymbol s1, InputSymbol s2, TTrace t) {
744740
exists(StatePair p |
745741
isReachableFromFork(_, p, t, _) and
746742
step(p, s1, s2, _)
@@ -749,6 +745,20 @@ newtype Trace =
749745
t = Nil() and isFork(_, s1, s2, _, _)
750746
}
751747

748+
/**
749+
* A list of pairs of input symbols that describe a path in the product automaton
750+
* starting from some fork state.
751+
*/
752+
class Trace extends TTrace {
753+
string toString() {
754+
this = Nil() and result = "Nil()"
755+
or
756+
exists(InputSymbol s1, InputSymbol s2, Trace t | this = Step(s1, s2, t) |
757+
result = "Step(" + s1 + ", " + s2 + ", " + t + ")"
758+
)
759+
}
760+
}
761+
752762
/**
753763
* Gets the minimum char that is matched by both the character classes `c` and `d`.
754764
*/

0 commit comments

Comments
 (0)