Skip to content

Commit 20187d4

Browse files
committed
wip
1 parent 0d76d01 commit 20187d4

File tree

5 files changed

+777
-23
lines changed

5 files changed

+777
-23
lines changed

python/ql/test/TestUtilities/dataflow/testConfig.qll

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ import semmle.python.dataflow.new.DataFlow
2525

2626
module TestConfig implements DataFlow::ConfigSig {
2727
predicate isSource(DataFlow::Node node) {
28-
node.(DataFlow::CfgNode).getNode().(NameNode).getId() = "SOURCE"
29-
or
30-
node.(DataFlow::CfgNode).getNode().getNode().(StringLiteral).getS() = "source"
31-
or
32-
node.(DataFlow::CfgNode).getNode().getNode().(IntegerLiteral).getN() = "42"
33-
or
34-
node.(DataFlow::CfgNode).getNode().getNode().(FloatLiteral).getN() = "42.0"
35-
// No support for complex numbers
28+
// node.getLocation().getStartLine() = 201 and
29+
(
30+
node.(DataFlow::CfgNode).getNode().(NameNode).getId() = "SOURCE"
31+
or
32+
node.(DataFlow::CfgNode).getNode().getNode().(StringLiteral).getS() = "source"
33+
or
34+
node.(DataFlow::CfgNode).getNode().getNode().(IntegerLiteral).getN() = "42"
35+
or
36+
node.(DataFlow::CfgNode).getNode().getNode().(FloatLiteral).getN() = "42.0"
37+
// No support for complex numbers
38+
)
3639
}
3740

3841
predicate isSink(DataFlow::Node node) {
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
missingAnnotationOnSink
2-
| test.py:204:10:204:18 | test.py:204 | ERROR, you should add `# $ MISSING: flow` annotation | a.obj.foo |
3-
| test.py:569:6:569:15 | test.py:569 | ERROR, you should add `# $ MISSING: flow` annotation | a2.obj.foo |
4-
| test.py:618:6:618:15 | test.py:618 | ERROR, you should add `# $ MISSING: flow` annotation | a2.obj.foo |
5-
| test_global.py:165:6:165:15 | test_global.py:165 | ERROR, you should add `# $ MISSING: flow` annotation | a2.obj.foo |
62
testFailures
7-
| test.py:204:21:204:56 | Comment # $ flow="SOURCE, l:-3 -> a.obj.foo" | Missing result: flow="SOURCE, l:-3 -> a.obj.foo" |
8-
| test.py:569:18:569:54 | Comment # $ flow="SOURCE, l:-3 -> a2.obj.foo" | Missing result: flow="SOURCE, l:-3 -> a2.obj.foo" |
9-
| test.py:618:18:618:54 | Comment # $ flow="SOURCE, l:-3 -> a2.obj.foo" | Missing result: flow="SOURCE, l:-3 -> a2.obj.foo" |
10-
| test_global.py:165:18:165:54 | Comment # $ flow="SOURCE, l:-3 -> a2.obj.foo" | Missing result: flow="SOURCE, l:-3 -> a2.obj.foo" |

shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,8 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
959959
this.asNode().(ArgNode).argumentOf(call_, pos_.asArgumentPosition())
960960
or
961961
// this.asNodeReverse() = getAnOutNodeExt(call_, pos_.asReturnKind()) and
962-
this.asNodeReverse() = getAnOutNode(call_, pos_.asReturnKind().(ValueReturnKind).getKind()) and //and
963-
not this.asNodeReverse() instanceof PostUpdateNode // needed for swift
962+
this.asNodeReverse() = getAnOutNode(call_, pos_.asReturnKind().(ValueReturnKind).getKind()) //and //and
963+
// not this.asNodeReverse() instanceof PostUpdateNode // needed for swift
964964
// call_.toString().matches("%GetBox1%")
965965
}
966966

@@ -1090,9 +1090,6 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
10901090
cached
10911091
predicate clearsContentSet(NodeEx n, ContentSet c) { clearsContent(n.asNode(), c) }
10921092

1093-
cached
1094-
predicate expectsContentCached(Node n, ContentSet c) { expectsContent(n, c) }
1095-
10961093
cached
10971094
predicate expectsContentSet(NodeEx n, ContentSet c) {
10981095
expectsContent([n.asNode(), n.asNodeReverse()], c)
@@ -1467,7 +1464,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
14671464
argumentValueFlowsThroughCand(arg, node, false)
14681465
)
14691466
) and
1470-
not expectsContentCached(node, _)
1467+
not expectsContent(node, _)
14711468
}
14721469

14731470
pragma[nomagic]

swift/ql/test/TestUtilities/InlineFlowTest.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ private predicate defaultSink(DataFlow::Node sink) {
5858
}
5959

6060
module DefaultFlowConfig implements DataFlow::ConfigSig {
61-
predicate isSource(DataFlow::Node source) { defaultSource(source) }
61+
predicate isSource(DataFlow::Node source) {
62+
defaultSource(source) and source.getLocation().getStartLine() = 56
63+
}
6264

6365
predicate isSink(DataFlow::Node sink) { defaultSink(sink) }
66+
67+
predicate neverSkip(DataFlow::Node n) { any() }
6468
}
6569

6670
module NoFlowConfig implements DataFlow::ConfigSig {

0 commit comments

Comments
 (0)