Skip to content

Commit 7efe698

Browse files
committed
Address review comment
1 parent 0fb28f4 commit 7efe698

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

ruby/ql/lib/codeql/ruby/security/performance/ExponentialBackTracking.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,6 @@ private class Trace extends TTrace {
277277
result = "Step(" + s1 + ", " + s2 + ", " + t + ")"
278278
)
279279
}
280-
281-
/** Holds if the `i`th pair of this trace is `(s1, s2)`. */
282-
predicate hasPair(int i, InputSymbol s1, InputSymbol s2) {
283-
this = Step(s1, s2, _) and
284-
i = 0
285-
or
286-
exists(Trace t |
287-
this = Step(_, _, t) and
288-
t.hasPair(i - 1, s1, s2)
289-
)
290-
}
291280
}
292281

293282
/**
@@ -329,14 +318,25 @@ private class RelevantTrace extends Trace {
329318
)
330319
}
331320

321+
private Trace getSuffix(int i) {
322+
i = 0 and
323+
result = this
324+
or
325+
this.getSuffix(i - 1) = Step(_, _, result)
326+
}
327+
328+
private predicate hasTuple(int i, InputSymbol s1, InputSymbol s2) {
329+
this.getSuffix(i) = Step(s1, s2, _)
330+
}
331+
332332
/** Gets a string corresponding to this trace. */
333333
// the pragma is needed for the case where `intersect(s1, s2)` has multiple values,
334334
// not for recursion
335335
language[monotonicAggregates]
336336
string concretise() {
337337
result =
338338
concat(int i, InputSymbol s1, InputSymbol s2 |
339-
this.hasPair(i, s1, s2)
339+
this.hasTuple(i, s1, s2)
340340
|
341341
intersect(s1, s2) order by i desc
342342
)

0 commit comments

Comments
 (0)