Skip to content

Commit eee56e0

Browse files
committed
Python/JS: Make most of the new library private
1 parent cda5c22 commit eee56e0

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

javascript/ql/src/semmle/javascript/security/performance/ExponentialBackTracking.qll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@
6262
* a suffix `x` (possible empty) that is most likely __not__ accepted.
6363
*/
6464

65-
import ReDoSUtil
65+
private import ReDoSUtil
6666

6767
/**
6868
* Holds if state `s` might be inside a backtracking repetition.
6969
*/
7070
pragma[noinline]
71-
predicate stateInsideBacktracking(State s) {
71+
private predicate stateInsideBacktracking(State s) {
7272
s.getRepr().getParent*() instanceof MaybeBacktrackingRepetition
7373
}
7474

@@ -145,15 +145,15 @@ class StatePair extends TStatePair {
145145
*
146146
* Used in `statePairDist`
147147
*/
148-
predicate isStatePair(StatePair p) { any() }
148+
private predicate isStatePair(StatePair p) { any() }
149149

150150
/**
151151
* Holds if there are transitions from the components of `q` to the corresponding
152152
* components of `r`.
153153
*
154154
* Used in `statePairDist`
155155
*/
156-
predicate delta2(StatePair q, StatePair r) { step(q, _, _, r) }
156+
private predicate delta2(StatePair q, StatePair r) { step(q, _, _, r) }
157157

158158
/**
159159
* Gets the minimum length of a path from `q` to `r` in the
@@ -172,7 +172,7 @@ int statePairDist(StatePair q, StatePair r) =
172172
* expression cannot be vulnerable to ReDoS attacks anyway).
173173
*/
174174
pragma[noopt]
175-
predicate isFork(State q, InputSymbol s1, InputSymbol s2, State r1, State r2) {
175+
private predicate isFork(State q, InputSymbol s1, InputSymbol s2, State r1, State r2) {
176176
stateInsideBacktracking(q) and
177177
exists(State q1, State q2 |
178178
q1 = epsilonSucc*(q) and
@@ -230,7 +230,7 @@ StatePair mkStatePair(State q1, State q2) {
230230
* Holds if there are transitions from the components of `q` to the corresponding
231231
* components of `r` labelled with `s1` and `s2`, respectively.
232232
*/
233-
predicate step(StatePair q, InputSymbol s1, InputSymbol s2, StatePair r) {
233+
private predicate step(StatePair q, InputSymbol s1, InputSymbol s2, StatePair r) {
234234
exists(State r1, State r2 | step(q, s1, s2, r1, r2) and r = mkStatePair(r1, r2))
235235
}
236236

@@ -242,7 +242,7 @@ predicate step(StatePair q, InputSymbol s1, InputSymbol s2, StatePair r) {
242242
* inside a repetition that might backtrack.
243243
*/
244244
pragma[noopt]
245-
predicate step(StatePair q, InputSymbol s1, InputSymbol s2, State r1, State r2) {
245+
private predicate step(StatePair q, InputSymbol s1, InputSymbol s2, State r1, State r2) {
246246
exists(State q1, State q2 | q.getLeft() = q1 and q.getRight() = q2 |
247247
deltaClosed(q1, s1, r1) and
248248
deltaClosed(q2, s2, r2) and
@@ -294,7 +294,7 @@ string concretise(Trace t) {
294294
* Holds if `r` is reachable from `(fork, fork)` under input `w`, and there is
295295
* a path from `r` back to `(fork, fork)` with `rem` steps.
296296
*/
297-
predicate isReachableFromFork(State fork, StatePair r, Trace w, int rem) {
297+
private predicate isReachableFromFork(State fork, StatePair r, Trace w, int rem) {
298298
// base case
299299
exists(InputSymbol s1, InputSymbol s2, State q1, State q2 |
300300
isFork(fork, s1, s2, q1, q2) and
@@ -324,7 +324,7 @@ StatePair getAForkPair(State fork) {
324324
/**
325325
* Holds if `fork` is a pumpable fork with word `w`.
326326
*/
327-
predicate isPumpable(State fork, string w) {
327+
private predicate isPumpable(State fork, string w) {
328328
exists(StatePair q, Trace t |
329329
isReachableFromFork(fork, q, t, _) and
330330
q = getAForkPair(fork) and

python/ql/src/semmle/python/security/performance/ExponentialBackTracking.qll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@
6262
* a suffix `x` (possible empty) that is most likely __not__ accepted.
6363
*/
6464

65-
import ReDoSUtil
65+
private import ReDoSUtil
6666

6767
/**
6868
* Holds if state `s` might be inside a backtracking repetition.
6969
*/
7070
pragma[noinline]
71-
predicate stateInsideBacktracking(State s) {
71+
private predicate stateInsideBacktracking(State s) {
7272
s.getRepr().getParent*() instanceof MaybeBacktrackingRepetition
7373
}
7474

@@ -145,15 +145,15 @@ class StatePair extends TStatePair {
145145
*
146146
* Used in `statePairDist`
147147
*/
148-
predicate isStatePair(StatePair p) { any() }
148+
private predicate isStatePair(StatePair p) { any() }
149149

150150
/**
151151
* Holds if there are transitions from the components of `q` to the corresponding
152152
* components of `r`.
153153
*
154154
* Used in `statePairDist`
155155
*/
156-
predicate delta2(StatePair q, StatePair r) { step(q, _, _, r) }
156+
private predicate delta2(StatePair q, StatePair r) { step(q, _, _, r) }
157157

158158
/**
159159
* Gets the minimum length of a path from `q` to `r` in the
@@ -172,7 +172,7 @@ int statePairDist(StatePair q, StatePair r) =
172172
* expression cannot be vulnerable to ReDoS attacks anyway).
173173
*/
174174
pragma[noopt]
175-
predicate isFork(State q, InputSymbol s1, InputSymbol s2, State r1, State r2) {
175+
private predicate isFork(State q, InputSymbol s1, InputSymbol s2, State r1, State r2) {
176176
stateInsideBacktracking(q) and
177177
exists(State q1, State q2 |
178178
q1 = epsilonSucc*(q) and
@@ -230,7 +230,7 @@ StatePair mkStatePair(State q1, State q2) {
230230
* Holds if there are transitions from the components of `q` to the corresponding
231231
* components of `r` labelled with `s1` and `s2`, respectively.
232232
*/
233-
predicate step(StatePair q, InputSymbol s1, InputSymbol s2, StatePair r) {
233+
private predicate step(StatePair q, InputSymbol s1, InputSymbol s2, StatePair r) {
234234
exists(State r1, State r2 | step(q, s1, s2, r1, r2) and r = mkStatePair(r1, r2))
235235
}
236236

@@ -242,7 +242,7 @@ predicate step(StatePair q, InputSymbol s1, InputSymbol s2, StatePair r) {
242242
* inside a repetition that might backtrack.
243243
*/
244244
pragma[noopt]
245-
predicate step(StatePair q, InputSymbol s1, InputSymbol s2, State r1, State r2) {
245+
private predicate step(StatePair q, InputSymbol s1, InputSymbol s2, State r1, State r2) {
246246
exists(State q1, State q2 | q.getLeft() = q1 and q.getRight() = q2 |
247247
deltaClosed(q1, s1, r1) and
248248
deltaClosed(q2, s2, r2) and
@@ -294,7 +294,7 @@ string concretise(Trace t) {
294294
* Holds if `r` is reachable from `(fork, fork)` under input `w`, and there is
295295
* a path from `r` back to `(fork, fork)` with `rem` steps.
296296
*/
297-
predicate isReachableFromFork(State fork, StatePair r, Trace w, int rem) {
297+
private predicate isReachableFromFork(State fork, StatePair r, Trace w, int rem) {
298298
// base case
299299
exists(InputSymbol s1, InputSymbol s2, State q1, State q2 |
300300
isFork(fork, s1, s2, q1, q2) and
@@ -324,7 +324,7 @@ StatePair getAForkPair(State fork) {
324324
/**
325325
* Holds if `fork` is a pumpable fork with word `w`.
326326
*/
327-
predicate isPumpable(State fork, string w) {
327+
private predicate isPumpable(State fork, string w) {
328328
exists(StatePair q, Trace t |
329329
isReachableFromFork(fork, q, t, _) and
330330
q = getAForkPair(fork) and

0 commit comments

Comments
 (0)