Skip to content

Commit 483bd0e

Browse files
committed
Python: Fix shared taint tracking tests
Since there was a .ql file, qltest tried to run a test in test/experimental/dataflow/taintracking/ which failed since there was no code.
1 parent d96ef73 commit 483bd0e

File tree

5 files changed

+30
-24
lines changed

5 files changed

+30
-24
lines changed

python/ql/test/experimental/dataflow/tainttracking/TestTaint.ql renamed to python/ql/test/experimental/dataflow/tainttracking/TestTaintLib.qll

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,31 @@ private string repr(Expr e) {
4242
result = repr(e.(Attribute).getObject()) + "." + e.(Attribute).getName()
4343
}
4444

45-
from Call call, Expr arg, boolean expected_taint, boolean has_taint, string test_res
46-
where
47-
call.getLocation().getFile().getShortName() = "test.py" and
48-
(
49-
call.getFunc().(Name).getId() = "ensure_tainted" and
50-
expected_taint = true
51-
or
52-
call.getFunc().(Name).getId() = "ensure_not_tainted" and
53-
expected_taint = false
54-
) and
55-
arg = call.getAnArg() and
56-
(
57-
// TODO: Replace with `hasFlowToExpr` once that is working
58-
if
59-
exists(TaintTracking::Configuration c |
60-
c.hasFlowTo(any(DataFlow::Node n | n.(DataFlow::CfgNode).getNode() = arg.getAFlowNode()))
61-
)
62-
then has_taint = true
63-
else has_taint = false
64-
) and
65-
if expected_taint = has_taint then test_res = "ok " else test_res = "fail"
66-
select arg.getLocation().toString(), test_res, call.getScope().(Function).getName(), repr(arg)
45+
query predicate test_taint(string arg_location, string test_res, string function_name, string repr) {
46+
exists(Call call, Expr arg, boolean expected_taint, boolean has_taint |
47+
call.getLocation().getFile().getShortName() = "test.py" and
48+
(
49+
call.getFunc().(Name).getId() = "ensure_tainted" and
50+
expected_taint = true
51+
or
52+
call.getFunc().(Name).getId() = "ensure_not_tainted" and
53+
expected_taint = false
54+
) and
55+
arg = call.getAnArg() and
56+
(
57+
// TODO: Replace with `hasFlowToExpr` once that is working
58+
if
59+
exists(TaintTracking::Configuration c |
60+
c.hasFlowTo(any(DataFlow::Node n | n.(DataFlow::CfgNode).getNode() = arg.getAFlowNode()))
61+
)
62+
then has_taint = true
63+
else has_taint = false
64+
) and
65+
(if expected_taint = has_taint then test_res = "ok " else test_res = "fail") and
66+
// select
67+
arg_location = arg.getLocation().toString() and
68+
test_res = test_res and
69+
function_name = call.getScope().(Function).getName() and
70+
repr = repr(arg)
71+
)
72+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import experimental.dataflow.tainttracking.TestTaintLib

python/ql/test/experimental/dataflow/tainttracking/string-py3/TestTaint.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import experimental.dataflow.tainttracking.TestTaintLib

python/ql/test/experimental/dataflow/tainttracking/string/TestTaint.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)