Skip to content

Commit 09ab248

Browse files
committed
Data flow: Add more consistency checks
1 parent 73370e7 commit 09ab248

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

csharp/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,3 @@ private module Input implements InputSig<CsharpDataFlow> {
7575
}
7676

7777
import MakeConsistency<CsharpDataFlow, CsharpTaintTracking, Input>
78-
79-
query predicate multipleToString(DataFlow::Node n, string s) {
80-
s = strictconcat(n.toString(), ",") and
81-
strictcount(n.toString()) > 1
82-
}

ruby/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,3 @@ private module Input implements InputSig<RubyDataFlow> {
3838
}
3939

4040
import MakeConsistency<RubyDataFlow, RubyTaintTracking, Input>
41-
42-
query predicate multipleToString(DataFlow::Node n, string s) {
43-
s = strictconcat(n.toString(), ",") and
44-
strictcount(n.toString()) > 1
45-
}

shared/dataflow/codeql/dataflow/internal/DataFlowImplConsistency.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ module MakeConsistency<
147147
)
148148
}
149149

150+
query predicate multipleNodeToString(Node n, string msg) {
151+
msg = "Multiple toStrings: " + strictconcat(n.toString(), ",") and
152+
strictcount(n.toString()) > 1
153+
}
154+
150155
query predicate missingToString(string msg) {
151156
exists(int c |
152157
c = strictcount(Node n | not exists(n.toString())) and
@@ -287,4 +292,15 @@ module MakeConsistency<
287292
not Input::identityLocalStepExclude(n) and
288293
msg = "Node steps to itself"
289294
}
295+
296+
query predicate missingArgumentCall(ArgumentNode arg, string msg) {
297+
not isArgumentNode(arg, _, _) and
298+
msg = "Missing call for argument node."
299+
}
300+
301+
query predicate multipleArgumentCall(ArgumentNode arg, DataFlowCall call, string msg) {
302+
isArgumentNode(arg, call, _) and
303+
strictcount(DataFlowCall call0 | isArgumentNode(arg, call0, _)) > 1 and
304+
msg = "Multiple calls for argument node."
305+
}
290306
}

0 commit comments

Comments
 (0)