Skip to content

Commit 7cb9d07

Browse files
committed
Rust: Fix default source and sink in inline flow test
1 parent c8c15a0 commit 7cb9d07

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
models
22
edges
33
nodes
4+
| main.rs:17:10:17:18 | CallExpr | semmle.label | CallExpr |
45
subpaths
56
testFailures
6-
| main.rs:17:22:17:40 | Comment | Missing result: hasValueFlow=1 |
77
| main.rs:22:14:22:32 | Comment | Missing result: hasValueFlow=1 |
88
| main.rs:33:14:33:32 | Comment | Missing result: hasValueFlow=1 |
99
#select
10+
| main.rs:17:10:17:18 | CallExpr | main.rs:17:10:17:18 | CallExpr | main.rs:17:10:17:18 | CallExpr | $@ | main.rs:17:10:17:18 | CallExpr | CallExpr |

rust/ql/test/utils/InlineFlowTest.qll

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ private import codeql.rust.dataflow.internal.DataFlowImpl
1010
private import codeql.rust.dataflow.internal.TaintTrackingImpl
1111
private import internal.InlineExpectationsTestImpl as InlineExpectationsTestImpl
1212

13+
// Holds if the target expression of `call` is a path and the string representation of the path is `name`.
14+
private predicate callTargetName(CallExpr call, string name) {
15+
call.getExpr().(PathExpr).getPath().toString() = name
16+
}
17+
1318
private module FlowTestImpl implements InputSig<Location, RustDataFlow> {
14-
predicate defaultSource(DataFlow::Node source) {
15-
source.asExpr().(CallExpr).getExpr().toString() = "source"
16-
}
19+
predicate defaultSource(DataFlow::Node source) { callTargetName(source.asExpr(), "source") }
1720

1821
predicate defaultSink(DataFlow::Node sink) {
19-
any(CallExpr call | call = sink.asExpr() and call.getExpr().toString() = "sink")
20-
.getArgList()
21-
.getAnArg() = sink.asExpr()
22+
any(CallExpr call | callTargetName(call, "sink")).getArgList().getAnArg() = sink.asExpr()
2223
}
2324

2425
private string getSourceArgString(DataFlow::Node src) {

0 commit comments

Comments
 (0)