Skip to content

Commit ab2e0fd

Browse files
committed
Data flow: Sync files
1 parent 40043f1 commit ab2e0fd

File tree

5 files changed

+85
-5
lines changed

5 files changed

+85
-5
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplConsistency.qll

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@ module Consistency {
1515
class ConsistencyConfiguration extends TConsistencyConfiguration {
1616
string toString() { none() }
1717

18+
/** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */
19+
predicate uniqueEnclosingCallableExclude(Node n) { none() }
20+
21+
/** Holds if `n` should be excluded from the consistency test `missingLocation`. */
22+
predicate uniqueNodeLocationExclude(Node n) { none() }
23+
24+
/** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */
25+
predicate missingLocationExclude(Node n) { none() }
26+
1827
/** Holds if `n` should be excluded from the consistency test `postWithInFlow`. */
1928
predicate postWithInFlowExclude(Node n) { none() }
2029

2130
/** Holds if `n` should be excluded from the consistency test `argHasPostUpdate`. */
2231
predicate argHasPostUpdateExclude(ArgumentNode n) { none() }
32+
33+
/** Holds if `n` should be excluded from the consistency test `reverseRead`. */
34+
predicate reverseReadExclude(Node n) { none() }
2335
}
2436

2537
private class RelevantNode extends Node {
@@ -46,6 +58,7 @@ module Consistency {
4658
n instanceof RelevantNode and
4759
c = count(nodeGetEnclosingCallable(n)) and
4860
c != 1 and
61+
not any(ConsistencyConfiguration conf).uniqueEnclosingCallableExclude(n) and
4962
msg = "Node should have one enclosing callable but has " + c + "."
5063
)
5164
}
@@ -66,6 +79,7 @@ module Consistency {
6679
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
6780
) and
6881
c != 1 and
82+
not any(ConsistencyConfiguration conf).uniqueNodeLocationExclude(n) and
6983
msg = "Node should have one location but has " + c + "."
7084
)
7185
}
@@ -76,7 +90,8 @@ module Consistency {
7690
strictcount(Node n |
7791
not exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
7892
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
79-
)
93+
) and
94+
not any(ConsistencyConfiguration conf).missingLocationExclude(n)
8095
) and
8196
msg = "Nodes without location: " + c
8297
)
@@ -172,6 +187,7 @@ module Consistency {
172187

173188
query predicate reverseRead(Node n, string msg) {
174189
exists(Node n2 | readStep(n, _, n2) and hasPost(n2) and not hasPost(n)) and
190+
not any(ConsistencyConfiguration conf).reverseReadExclude(n) and
175191
msg = "Origin of readStep is missing a PostUpdateNode."
176192
}
177193

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@ module Consistency {
1515
class ConsistencyConfiguration extends TConsistencyConfiguration {
1616
string toString() { none() }
1717

18+
/** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */
19+
predicate uniqueEnclosingCallableExclude(Node n) { none() }
20+
21+
/** Holds if `n` should be excluded from the consistency test `missingLocation`. */
22+
predicate uniqueNodeLocationExclude(Node n) { none() }
23+
24+
/** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */
25+
predicate missingLocationExclude(Node n) { none() }
26+
1827
/** Holds if `n` should be excluded from the consistency test `postWithInFlow`. */
1928
predicate postWithInFlowExclude(Node n) { none() }
2029

2130
/** Holds if `n` should be excluded from the consistency test `argHasPostUpdate`. */
2231
predicate argHasPostUpdateExclude(ArgumentNode n) { none() }
32+
33+
/** Holds if `n` should be excluded from the consistency test `reverseRead`. */
34+
predicate reverseReadExclude(Node n) { none() }
2335
}
2436

2537
private class RelevantNode extends Node {
@@ -46,6 +58,7 @@ module Consistency {
4658
n instanceof RelevantNode and
4759
c = count(nodeGetEnclosingCallable(n)) and
4860
c != 1 and
61+
not any(ConsistencyConfiguration conf).uniqueEnclosingCallableExclude(n) and
4962
msg = "Node should have one enclosing callable but has " + c + "."
5063
)
5164
}
@@ -66,6 +79,7 @@ module Consistency {
6679
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
6780
) and
6881
c != 1 and
82+
not any(ConsistencyConfiguration conf).uniqueNodeLocationExclude(n) and
6983
msg = "Node should have one location but has " + c + "."
7084
)
7185
}
@@ -76,7 +90,8 @@ module Consistency {
7690
strictcount(Node n |
7791
not exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
7892
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
79-
)
93+
) and
94+
not any(ConsistencyConfiguration conf).missingLocationExclude(n)
8095
) and
8196
msg = "Nodes without location: " + c
8297
)
@@ -172,6 +187,7 @@ module Consistency {
172187

173188
query predicate reverseRead(Node n, string msg) {
174189
exists(Node n2 | readStep(n, _, n2) and hasPost(n2) and not hasPost(n)) and
190+
not any(ConsistencyConfiguration conf).reverseReadExclude(n) and
175191
msg = "Origin of readStep is missing a PostUpdateNode."
176192
}
177193

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplConsistency.qll

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@ module Consistency {
1515
class ConsistencyConfiguration extends TConsistencyConfiguration {
1616
string toString() { none() }
1717

18+
/** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */
19+
predicate uniqueEnclosingCallableExclude(Node n) { none() }
20+
21+
/** Holds if `n` should be excluded from the consistency test `missingLocation`. */
22+
predicate uniqueNodeLocationExclude(Node n) { none() }
23+
24+
/** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */
25+
predicate missingLocationExclude(Node n) { none() }
26+
1827
/** Holds if `n` should be excluded from the consistency test `postWithInFlow`. */
1928
predicate postWithInFlowExclude(Node n) { none() }
2029

2130
/** Holds if `n` should be excluded from the consistency test `argHasPostUpdate`. */
2231
predicate argHasPostUpdateExclude(ArgumentNode n) { none() }
32+
33+
/** Holds if `n` should be excluded from the consistency test `reverseRead`. */
34+
predicate reverseReadExclude(Node n) { none() }
2335
}
2436

2537
private class RelevantNode extends Node {
@@ -46,6 +58,7 @@ module Consistency {
4658
n instanceof RelevantNode and
4759
c = count(nodeGetEnclosingCallable(n)) and
4860
c != 1 and
61+
not any(ConsistencyConfiguration conf).uniqueEnclosingCallableExclude(n) and
4962
msg = "Node should have one enclosing callable but has " + c + "."
5063
)
5164
}
@@ -66,6 +79,7 @@ module Consistency {
6679
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
6780
) and
6881
c != 1 and
82+
not any(ConsistencyConfiguration conf).uniqueNodeLocationExclude(n) and
6983
msg = "Node should have one location but has " + c + "."
7084
)
7185
}
@@ -76,7 +90,8 @@ module Consistency {
7690
strictcount(Node n |
7791
not exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
7892
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
79-
)
93+
) and
94+
not any(ConsistencyConfiguration conf).missingLocationExclude(n)
8095
) and
8196
msg = "Nodes without location: " + c
8297
)
@@ -172,6 +187,7 @@ module Consistency {
172187

173188
query predicate reverseRead(Node n, string msg) {
174189
exists(Node n2 | readStep(n, _, n2) and hasPost(n2) and not hasPost(n)) and
190+
not any(ConsistencyConfiguration conf).reverseReadExclude(n) and
175191
msg = "Origin of readStep is missing a PostUpdateNode."
176192
}
177193

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImplConsistency.qll

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@ module Consistency {
1515
class ConsistencyConfiguration extends TConsistencyConfiguration {
1616
string toString() { none() }
1717

18+
/** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */
19+
predicate uniqueEnclosingCallableExclude(Node n) { none() }
20+
21+
/** Holds if `n` should be excluded from the consistency test `missingLocation`. */
22+
predicate uniqueNodeLocationExclude(Node n) { none() }
23+
24+
/** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */
25+
predicate missingLocationExclude(Node n) { none() }
26+
1827
/** Holds if `n` should be excluded from the consistency test `postWithInFlow`. */
1928
predicate postWithInFlowExclude(Node n) { none() }
2029

2130
/** Holds if `n` should be excluded from the consistency test `argHasPostUpdate`. */
2231
predicate argHasPostUpdateExclude(ArgumentNode n) { none() }
32+
33+
/** Holds if `n` should be excluded from the consistency test `reverseRead`. */
34+
predicate reverseReadExclude(Node n) { none() }
2335
}
2436

2537
private class RelevantNode extends Node {
@@ -46,6 +58,7 @@ module Consistency {
4658
n instanceof RelevantNode and
4759
c = count(nodeGetEnclosingCallable(n)) and
4860
c != 1 and
61+
not any(ConsistencyConfiguration conf).uniqueEnclosingCallableExclude(n) and
4962
msg = "Node should have one enclosing callable but has " + c + "."
5063
)
5164
}
@@ -66,6 +79,7 @@ module Consistency {
6679
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
6780
) and
6881
c != 1 and
82+
not any(ConsistencyConfiguration conf).uniqueNodeLocationExclude(n) and
6983
msg = "Node should have one location but has " + c + "."
7084
)
7185
}
@@ -76,7 +90,8 @@ module Consistency {
7690
strictcount(Node n |
7791
not exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
7892
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
79-
)
93+
) and
94+
not any(ConsistencyConfiguration conf).missingLocationExclude(n)
8095
) and
8196
msg = "Nodes without location: " + c
8297
)
@@ -172,6 +187,7 @@ module Consistency {
172187

173188
query predicate reverseRead(Node n, string msg) {
174189
exists(Node n2 | readStep(n, _, n2) and hasPost(n2) and not hasPost(n)) and
190+
not any(ConsistencyConfiguration conf).reverseReadExclude(n) and
175191
msg = "Origin of readStep is missing a PostUpdateNode."
176192
}
177193

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplConsistency.qll

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@ module Consistency {
1515
class ConsistencyConfiguration extends TConsistencyConfiguration {
1616
string toString() { none() }
1717

18+
/** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */
19+
predicate uniqueEnclosingCallableExclude(Node n) { none() }
20+
21+
/** Holds if `n` should be excluded from the consistency test `missingLocation`. */
22+
predicate uniqueNodeLocationExclude(Node n) { none() }
23+
24+
/** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */
25+
predicate missingLocationExclude(Node n) { none() }
26+
1827
/** Holds if `n` should be excluded from the consistency test `postWithInFlow`. */
1928
predicate postWithInFlowExclude(Node n) { none() }
2029

2130
/** Holds if `n` should be excluded from the consistency test `argHasPostUpdate`. */
2231
predicate argHasPostUpdateExclude(ArgumentNode n) { none() }
32+
33+
/** Holds if `n` should be excluded from the consistency test `reverseRead`. */
34+
predicate reverseReadExclude(Node n) { none() }
2335
}
2436

2537
private class RelevantNode extends Node {
@@ -46,6 +58,7 @@ module Consistency {
4658
n instanceof RelevantNode and
4759
c = count(nodeGetEnclosingCallable(n)) and
4860
c != 1 and
61+
not any(ConsistencyConfiguration conf).uniqueEnclosingCallableExclude(n) and
4962
msg = "Node should have one enclosing callable but has " + c + "."
5063
)
5164
}
@@ -66,6 +79,7 @@ module Consistency {
6679
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
6780
) and
6881
c != 1 and
82+
not any(ConsistencyConfiguration conf).uniqueNodeLocationExclude(n) and
6983
msg = "Node should have one location but has " + c + "."
7084
)
7185
}
@@ -76,7 +90,8 @@ module Consistency {
7690
strictcount(Node n |
7791
not exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
7892
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
79-
)
93+
) and
94+
not any(ConsistencyConfiguration conf).missingLocationExclude(n)
8095
) and
8196
msg = "Nodes without location: " + c
8297
)
@@ -172,6 +187,7 @@ module Consistency {
172187

173188
query predicate reverseRead(Node n, string msg) {
174189
exists(Node n2 | readStep(n, _, n2) and hasPost(n2) and not hasPost(n)) and
190+
not any(ConsistencyConfiguration conf).reverseReadExclude(n) and
175191
msg = "Origin of readStep is missing a PostUpdateNode."
176192
}
177193

0 commit comments

Comments
 (0)