Skip to content

Commit 5dec1dc

Browse files
committed
unified: Pass the incoming value into setter calls
1 parent 82487f8 commit 5dec1dc

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎unified/ql/lib/codeql/unified/internal/dataflow/DataFlowInstantiation.qll‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ module DataFlowInput implements InputSig<Location> {
107107
or
108108
n.(BuilderNode).isImplicitArgument(call, pos, false)
109109
or
110+
exists(Expr access |
111+
call.asSetterCall() = access and
112+
n.isIncomingValue(access) and
113+
pos.asPositional() = 0
114+
)
115+
or
110116
exists(FlowSummaryOutput::SummaryNode callee |
111117
FlowSummaryOutput::summaryArgumentNode(callee, getSummaryNode(n), pos) and
112118
call.isSummaryCall(_, callee)

‎unified/ql/test/library-tests/dataflow/accessors_local.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ func t3() {
2828
func t4() {
2929
var x: String {
3030
get {}
31-
set { sink(newValue) } // $ MISSING: hasValueFlow=t4.1
31+
set { sink(newValue) } // $ hasValueFlow=t4.1
3232
}
3333
x = source("t4.1")
3434
}
3535

3636
func t5() {
3737
var x: String {
3838
get { source("t5.1") }
39-
set { sink(newValue) } // $ MISSING: hasValueFlow=t5.1
39+
set { sink(newValue) } // $ hasValueFlow=t5.1
4040
}
4141
x = x
4242
}

‎unified/ql/test/library-tests/dataflow/test.expected‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ edges
44
| accessors_local.swift:7:21:7:34 | source(...) | accessors_local.swift:8:10:8:10 | x | provenance | |
55
| accessors_local.swift:15:15:15:28 | source(...) | accessors_local.swift:17:10:17:10 | x | provenance | |
66
| accessors_local.swift:22:15:22:28 | source(...) | accessors_local.swift:25:10:25:10 | x | provenance | |
7+
| accessors_local.swift:31:9:31:11 | newValue | accessors_local.swift:31:20:31:27 | newValue | provenance | |
8+
| accessors_local.swift:33:5:33:5 | x | accessors_local.swift:31:9:31:11 | newValue | provenance | |
9+
| accessors_local.swift:33:9:33:22 | source(...) | accessors_local.swift:33:5:33:5 | x | provenance | |
10+
| accessors_local.swift:38:15:38:28 | source(...) | accessors_local.swift:41:9:41:9 | x | provenance | |
11+
| accessors_local.swift:39:9:39:11 | newValue | accessors_local.swift:39:20:39:27 | newValue | provenance | |
12+
| accessors_local.swift:41:5:41:5 | x | accessors_local.swift:39:9:39:11 | newValue | provenance | |
13+
| accessors_local.swift:41:9:41:9 | x | accessors_local.swift:41:5:41:5 | x | provenance | |
714
| accessors_static.swift:56:32:56:45 | source(...) | accessors_static.swift:64:18:64:18 | x | provenance | |
815
| calls.swift:7:19:7:19 | x | calls.swift:8:14:8:14 | x | provenance | |
916
| calls.swift:10:12:10:25 | source(...) | calls.swift:7:19:7:19 | x | provenance | |
@@ -472,6 +479,15 @@ nodes
472479
| accessors_local.swift:17:10:17:10 | x | semmle.label | x |
473480
| accessors_local.swift:22:15:22:28 | source(...) | semmle.label | source(...) |
474481
| accessors_local.swift:25:10:25:10 | x | semmle.label | x |
482+
| accessors_local.swift:31:9:31:11 | newValue | semmle.label | newValue |
483+
| accessors_local.swift:31:20:31:27 | newValue | semmle.label | newValue |
484+
| accessors_local.swift:33:5:33:5 | x | semmle.label | x |
485+
| accessors_local.swift:33:9:33:22 | source(...) | semmle.label | source(...) |
486+
| accessors_local.swift:38:15:38:28 | source(...) | semmle.label | source(...) |
487+
| accessors_local.swift:39:9:39:11 | newValue | semmle.label | newValue |
488+
| accessors_local.swift:39:20:39:27 | newValue | semmle.label | newValue |
489+
| accessors_local.swift:41:5:41:5 | x | semmle.label | x |
490+
| accessors_local.swift:41:9:41:9 | x | semmle.label | x |
475491
| accessors_static.swift:56:32:56:45 | source(...) | semmle.label | source(...) |
476492
| accessors_static.swift:64:18:64:18 | x | semmle.label | x |
477493
| calls.swift:7:19:7:19 | x | semmle.label | x |
@@ -1055,6 +1071,8 @@ testFailures
10551071
| accessors_local.swift:8:10:8:10 | x | accessors_local.swift:7:21:7:34 | source(...) | accessors_local.swift:8:10:8:10 | x | $@ | accessors_local.swift:7:21:7:34 | source(...) | source(...) |
10561072
| accessors_local.swift:17:10:17:10 | x | accessors_local.swift:15:15:15:28 | source(...) | accessors_local.swift:17:10:17:10 | x | $@ | accessors_local.swift:15:15:15:28 | source(...) | source(...) |
10571073
| accessors_local.swift:25:10:25:10 | x | accessors_local.swift:22:15:22:28 | source(...) | accessors_local.swift:25:10:25:10 | x | $@ | accessors_local.swift:22:15:22:28 | source(...) | source(...) |
1074+
| accessors_local.swift:31:20:31:27 | newValue | accessors_local.swift:33:9:33:22 | source(...) | accessors_local.swift:31:20:31:27 | newValue | $@ | accessors_local.swift:33:9:33:22 | source(...) | source(...) |
1075+
| accessors_local.swift:39:20:39:27 | newValue | accessors_local.swift:38:15:38:28 | source(...) | accessors_local.swift:39:20:39:27 | newValue | $@ | accessors_local.swift:38:15:38:28 | source(...) | source(...) |
10581076
| accessors_static.swift:64:18:64:18 | x | accessors_static.swift:56:32:56:45 | source(...) | accessors_static.swift:64:18:64:18 | x | $@ | accessors_static.swift:56:32:56:45 | source(...) | source(...) |
10591077
| calls.swift:8:14:8:14 | x | calls.swift:10:12:10:25 | source(...) | calls.swift:8:14:8:14 | x | $@ | calls.swift:10:12:10:25 | source(...) | source(...) |
10601078
| calls.swift:17:10:17:17 | target(...) | calls.swift:15:16:15:29 | source(...) | calls.swift:17:10:17:17 | target(...) | $@ | calls.swift:15:16:15:29 | source(...) | source(...) |

0 commit comments

Comments
 (0)