Skip to content

Commit 77c329f

Browse files
committed
Python/JS: Make much more private
1 parent eee56e0 commit 77c329f

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
@@ -75,7 +75,7 @@ private predicate stateInsideBacktracking(State s) {
7575
/**
7676
* A infinitely repeating quantifier that might backtrack.
7777
*/
78-
class MaybeBacktrackingRepetition extends InfiniteRepetitionQuantifier {
78+
private class MaybeBacktrackingRepetition extends InfiniteRepetitionQuantifier {
7979
MaybeBacktrackingRepetition() {
8080
exists(RegExpTerm child |
8181
child instanceof RegExpAlt or
@@ -89,7 +89,7 @@ class MaybeBacktrackingRepetition extends InfiniteRepetitionQuantifier {
8989
/**
9090
* A state in the product automaton.
9191
*/
92-
newtype TStatePair =
92+
private newtype TStatePair =
9393
/**
9494
* We lazily only construct those states that we are actually
9595
* going to need: `(q, q)` for every fork state `q`, and any
@@ -112,7 +112,7 @@ newtype TStatePair =
112112
* Gets a unique number for a `state`.
113113
* Is used to create an ordering of states, where states with the same `toString()` will be ordered differently.
114114
*/
115-
int rankState(State state) {
115+
private int rankState(State state) {
116116
state =
117117
rank[result](State s, Location l |
118118
l = s.getRepr().getLocation()
@@ -124,7 +124,7 @@ int rankState(State state) {
124124
/**
125125
* A state in the product automaton.
126126
*/
127-
class StatePair extends TStatePair {
127+
private class StatePair extends TStatePair {
128128
State q1;
129129
State q2;
130130

@@ -159,7 +159,7 @@ private predicate delta2(StatePair q, StatePair r) { step(q, _, _, r) }
159159
* Gets the minimum length of a path from `q` to `r` in the
160160
* product automaton.
161161
*/
162-
int statePairDist(StatePair q, StatePair r) =
162+
private int statePairDist(StatePair q, StatePair r) =
163163
shortestDistances(isStatePair/1, delta2/2)(q, r, result)
164164

165165
/**
@@ -222,7 +222,7 @@ private predicate isFork(State q, InputSymbol s1, InputSymbol s2, State r1, Stat
222222
* Gets the state pair `(q1, q2)` or `(q2, q1)`; note that only
223223
* one or the other is defined.
224224
*/
225-
StatePair mkStatePair(State q1, State q2) {
225+
private StatePair mkStatePair(State q1, State q2) {
226226
result = MkStatePair(q1, q2) or result = MkStatePair(q2, q1)
227227
}
228228

@@ -268,7 +268,7 @@ private newtype TTrace =
268268
* A list of pairs of input symbols that describe a path in the product automaton
269269
* starting from some fork state.
270270
*/
271-
class Trace extends TTrace {
271+
private class Trace extends TTrace {
272272
/** Gets a textual representation of this element. */
273273
string toString() {
274274
this = Nil() and result = "Nil()"
@@ -282,7 +282,7 @@ class Trace extends TTrace {
282282
/**
283283
* Gets a string corresponding to the trace `t`.
284284
*/
285-
string concretise(Trace t) {
285+
private string concretise(Trace t) {
286286
t = Nil() and result = ""
287287
or
288288
exists(InputSymbol s1, InputSymbol s2, Trace rest | t = Step(s1, s2, rest) |
@@ -316,7 +316,7 @@ private predicate isReachableFromFork(State fork, StatePair r, Trace w, int rem)
316316
* Gets a state in the product automaton from which `(fork, fork)` is
317317
* reachable in zero or more epsilon transitions.
318318
*/
319-
StatePair getAForkPair(State fork) {
319+
private StatePair getAForkPair(State fork) {
320320
isFork(fork, _, _, _, _) and
321321
result = MkStatePair(epsilonPred*(fork), epsilonPred*(fork))
322322
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private predicate stateInsideBacktracking(State s) {
7575
/**
7676
* A infinitely repeating quantifier that might backtrack.
7777
*/
78-
class MaybeBacktrackingRepetition extends InfiniteRepetitionQuantifier {
78+
private class MaybeBacktrackingRepetition extends InfiniteRepetitionQuantifier {
7979
MaybeBacktrackingRepetition() {
8080
exists(RegExpTerm child |
8181
child instanceof RegExpAlt or
@@ -89,7 +89,7 @@ class MaybeBacktrackingRepetition extends InfiniteRepetitionQuantifier {
8989
/**
9090
* A state in the product automaton.
9191
*/
92-
newtype TStatePair =
92+
private newtype TStatePair =
9393
/**
9494
* We lazily only construct those states that we are actually
9595
* going to need: `(q, q)` for every fork state `q`, and any
@@ -112,7 +112,7 @@ newtype TStatePair =
112112
* Gets a unique number for a `state`.
113113
* Is used to create an ordering of states, where states with the same `toString()` will be ordered differently.
114114
*/
115-
int rankState(State state) {
115+
private int rankState(State state) {
116116
state =
117117
rank[result](State s, Location l |
118118
l = s.getRepr().getLocation()
@@ -124,7 +124,7 @@ int rankState(State state) {
124124
/**
125125
* A state in the product automaton.
126126
*/
127-
class StatePair extends TStatePair {
127+
private class StatePair extends TStatePair {
128128
State q1;
129129
State q2;
130130

@@ -159,7 +159,7 @@ private predicate delta2(StatePair q, StatePair r) { step(q, _, _, r) }
159159
* Gets the minimum length of a path from `q` to `r` in the
160160
* product automaton.
161161
*/
162-
int statePairDist(StatePair q, StatePair r) =
162+
private int statePairDist(StatePair q, StatePair r) =
163163
shortestDistances(isStatePair/1, delta2/2)(q, r, result)
164164

165165
/**
@@ -222,7 +222,7 @@ private predicate isFork(State q, InputSymbol s1, InputSymbol s2, State r1, Stat
222222
* Gets the state pair `(q1, q2)` or `(q2, q1)`; note that only
223223
* one or the other is defined.
224224
*/
225-
StatePair mkStatePair(State q1, State q2) {
225+
private StatePair mkStatePair(State q1, State q2) {
226226
result = MkStatePair(q1, q2) or result = MkStatePair(q2, q1)
227227
}
228228

@@ -268,7 +268,7 @@ private newtype TTrace =
268268
* A list of pairs of input symbols that describe a path in the product automaton
269269
* starting from some fork state.
270270
*/
271-
class Trace extends TTrace {
271+
private class Trace extends TTrace {
272272
/** Gets a textual representation of this element. */
273273
string toString() {
274274
this = Nil() and result = "Nil()"
@@ -282,7 +282,7 @@ class Trace extends TTrace {
282282
/**
283283
* Gets a string corresponding to the trace `t`.
284284
*/
285-
string concretise(Trace t) {
285+
private string concretise(Trace t) {
286286
t = Nil() and result = ""
287287
or
288288
exists(InputSymbol s1, InputSymbol s2, Trace rest | t = Step(s1, s2, rest) |
@@ -316,7 +316,7 @@ private predicate isReachableFromFork(State fork, StatePair r, Trace w, int rem)
316316
* Gets a state in the product automaton from which `(fork, fork)` is
317317
* reachable in zero or more epsilon transitions.
318318
*/
319-
StatePair getAForkPair(State fork) {
319+
private StatePair getAForkPair(State fork) {
320320
isFork(fork, _, _, _, _) and
321321
result = MkStatePair(epsilonPred*(fork), epsilonPred*(fork))
322322
}

0 commit comments

Comments
 (0)