Skip to content

Commit b348803

Browse files
committed
unified: Allow self-return via receiver parameter
1 parent 5c9942f commit b348803

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ module DataFlowInput implements InputSig<Location> {
272272
predicate isUnreachableInCall(NodeRegion nr, DataFlowCall call) { none() } // TODO
273273

274274
predicate allowParameterReturnInSelf(ParameterNode p) {
275+
p.isReceiverParameter(_)
276+
or
275277
captureSsaAllowParameterReturnInSelf(p)
276278
or
277279
exists(DataFlowCallable c, ParameterPosition pos |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,5 @@ func t8() {
8686
var c = C()
8787
c.field = source("t8.1")
8888
c.x = "safe" // trigger the setter
89-
sink(c.otherField) // $ MISSING: hasTaintFlow=t8.1
89+
sink(c.otherField) // $ hasTaintFlow=t8.1
9090
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ edges
1818
| accessors_instance.swift:73:15:73:28 | source(...) | accessors_instance.swift:73:5:73:11 | ... .field | provenance | |
1919
| accessors_instance.swift:74:10:74:10 | c [field] | accessors_instance.swift:69:25:69:28 | self [field] | provenance | |
2020
| accessors_instance.swift:74:10:74:10 | c [field] | accessors_instance.swift:74:10:74:12 | ... .x | provenance | |
21+
| accessors_instance.swift:83:32:83:36 | field | accessors_instance.swift:83:19:83:28 | otherField | provenance | |
22+
| accessors_instance.swift:87:5:87:5 | [post] c [field] | accessors_instance.swift:88:5:88:5 | c [field] | provenance | |
23+
| accessors_instance.swift:87:5:87:11 | ... .field | accessors_instance.swift:87:5:87:5 | [post] c [field] | provenance | |
24+
| accessors_instance.swift:87:15:87:28 | source(...) | accessors_instance.swift:87:5:87:11 | ... .field | provenance | |
25+
| accessors_instance.swift:88:5:88:5 | c [field] | accessors_instance.swift:83:32:83:36 | field | provenance | |
26+
| accessors_instance.swift:88:5:88:5 | c [field] | accessors_instance.swift:89:10:89:10 | c [otherField] | provenance | |
27+
| accessors_instance.swift:89:10:89:10 | c [otherField] | accessors_instance.swift:89:10:89:21 | ... .otherField | provenance | |
2128
| accessors_local.swift:7:21:7:34 | source(...) | accessors_local.swift:8:10:8:10 | x | provenance | |
2229
| accessors_local.swift:15:15:15:28 | source(...) | accessors_local.swift:17:10:17:10 | x | provenance | |
2330
| accessors_local.swift:22:15:22:28 | source(...) | accessors_local.swift:25:10:25:10 | x | provenance | |
@@ -531,6 +538,14 @@ nodes
531538
| accessors_instance.swift:73:15:73:28 | source(...) | semmle.label | source(...) |
532539
| accessors_instance.swift:74:10:74:10 | c [field] | semmle.label | c [field] |
533540
| accessors_instance.swift:74:10:74:12 | ... .x | semmle.label | ... .x |
541+
| accessors_instance.swift:83:19:83:28 | otherField | semmle.label | otherField |
542+
| accessors_instance.swift:83:32:83:36 | field | semmle.label | field |
543+
| accessors_instance.swift:87:5:87:5 | [post] c [field] | semmle.label | [post] c [field] |
544+
| accessors_instance.swift:87:5:87:11 | ... .field | semmle.label | ... .field |
545+
| accessors_instance.swift:87:15:87:28 | source(...) | semmle.label | source(...) |
546+
| accessors_instance.swift:88:5:88:5 | c [field] | semmle.label | c [field] |
547+
| accessors_instance.swift:89:10:89:10 | c [otherField] | semmle.label | c [otherField] |
548+
| accessors_instance.swift:89:10:89:21 | ... .otherField | semmle.label | ... .otherField |
534549
| accessors_local.swift:7:21:7:34 | source(...) | semmle.label | source(...) |
535550
| accessors_local.swift:8:10:8:10 | x | semmle.label | x |
536551
| accessors_local.swift:15:15:15:28 | source(...) | semmle.label | source(...) |
@@ -1133,6 +1148,7 @@ nodes
11331148
| test.swift:274:10:274:12 | f(...) | semmle.label | f(...) |
11341149
subpaths
11351150
| accessors_instance.swift:74:10:74:10 | c [field] | accessors_instance.swift:69:25:69:28 | self [field] | accessors_instance.swift:69:25:69:34 | ... .field | accessors_instance.swift:74:10:74:12 | ... .x |
1151+
| accessors_instance.swift:88:5:88:5 | c [field] | accessors_instance.swift:83:32:83:36 | field | accessors_instance.swift:83:19:83:28 | otherField | accessors_instance.swift:89:10:89:10 | c [otherField] |
11361152
| accessors_local.swift:45:9:45:9 | y | accessors_local.swift:46:21:46:21 | y | accessors_local.swift:46:21:46:21 | y | accessors_local.swift:47:10:47:10 | x |
11371153
| accessors_local.swift:54:5:54:5 | y | accessors_local.swift:52:21:52:21 | y | accessors_local.swift:52:21:52:21 | y | accessors_local.swift:55:10:55:10 | x |
11381154
| calls.swift:31:17:31:30 | source(...) | calls.swift:28:19:28:19 | x | calls.swift:29:16:29:24 | ... + ... | calls.swift:31:10:31:31 | target(...) |
@@ -1161,6 +1177,7 @@ testFailures
11611177
| accessors_instance.swift:60:18:60:23 | ... .x | accessors_instance.swift:57:25:57:38 | source(...) | accessors_instance.swift:60:18:60:23 | ... .x | $@ | accessors_instance.swift:57:25:57:38 | source(...) | source(...) |
11621178
| accessors_instance.swift:61:18:61:18 | x | accessors_instance.swift:57:25:57:38 | source(...) | accessors_instance.swift:61:18:61:18 | x | $@ | accessors_instance.swift:57:25:57:38 | source(...) | source(...) |
11631179
| accessors_instance.swift:74:10:74:12 | ... .x | accessors_instance.swift:73:15:73:28 | source(...) | accessors_instance.swift:74:10:74:12 | ... .x | $@ | accessors_instance.swift:73:15:73:28 | source(...) | source(...) |
1180+
| accessors_instance.swift:89:10:89:21 | ... .otherField | accessors_instance.swift:87:15:87:28 | source(...) | accessors_instance.swift:89:10:89:21 | ... .otherField | $@ | accessors_instance.swift:87:15:87:28 | source(...) | source(...) |
11641181
| 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(...) |
11651182
| 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(...) |
11661183
| 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(...) |

0 commit comments

Comments
 (0)