@@ -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+ }
0 commit comments