Skip to content

Commit 2402504

Browse files
committed
Add missing SummaryPostUpdateNode
1 parent baf7986 commit 2402504

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,14 @@ private module PostUpdateNodes {
574574

575575
override DataFlowCallable getEnclosingCallable() { result = TDataFlowFunc(n.getScope()) }
576576
}
577+
578+
class SummaryPostUpdateNode extends SummaryNode, PostUpdateNodeImpl {
579+
SummaryPostUpdateNode() { FlowSummaryImpl::Private::summaryPostUpdateNode(this, _) }
580+
581+
override Node getPreUpdateNode() {
582+
FlowSummaryImpl::Private::summaryPostUpdateNode(this, result)
583+
}
584+
}
577585
}
578586

579587
private import PostUpdateNodes

swift/ql/test/library-tests/dataflow/taint/Taint.expected

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ edges
144144
| webview.swift:38:5:38:47 | [summary param] this in toRect() : | file://:0:0:0:0 | [summary] to write: return (return) in toRect() : |
145145
| webview.swift:39:5:39:47 | [summary param] this in toSize() : | file://:0:0:0:0 | [summary] to write: return (return) in toSize() : |
146146
| webview.swift:40:5:40:84 | [summary param] this in atIndex(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in atIndex(_:) : |
147+
| webview.swift:41:5:41:53 | [summary param] 1 in defineProperty(_:descriptor:) : | file://:0:0:0:0 | [summary] to write: argument this in defineProperty(_:descriptor:) : |
147148
| webview.swift:42:5:42:89 | [summary param] this in forProperty(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in forProperty(_:) : |
149+
| webview.swift:43:5:43:38 | [summary param] 0 in setValue(_:at:) : | file://:0:0:0:0 | [summary] to write: argument this in setValue(_:at:) : |
150+
| webview.swift:44:5:44:48 | [summary param] 0 in setValue(_:forProperty:) : | file://:0:0:0:0 | [summary] to write: argument this in setValue(_:forProperty:) : |
148151
| webview.swift:52:11:52:18 | call to source() : | webview.swift:52:10:52:41 | .body |
149152
| webview.swift:56:13:56:20 | call to source() : | webview.swift:59:10:59:10 | source : |
150153
| webview.swift:56:13:56:20 | call to source() : | webview.swift:60:10:60:10 | source : |
@@ -172,6 +175,9 @@ edges
172175
| webview.swift:56:13:56:20 | call to source() : | webview.swift:84:25:84:25 | s : |
173176
| webview.swift:56:13:56:20 | call to source() : | webview.swift:85:24:85:24 | s : |
174177
| webview.swift:56:13:56:20 | call to source() : | webview.swift:86:24:86:24 | s : |
178+
| webview.swift:56:13:56:20 | call to source() : | webview.swift:89:39:89:39 | s : |
179+
| webview.swift:56:13:56:20 | call to source() : | webview.swift:93:17:93:17 | s : |
180+
| webview.swift:56:13:56:20 | call to source() : | webview.swift:97:17:97:17 | s : |
175181
| webview.swift:59:10:59:10 | source : | webview.swift:25:5:25:41 | [summary param] this in toObject() : |
176182
| webview.swift:59:10:59:10 | source : | webview.swift:59:10:59:26 | call to toObject() |
177183
| webview.swift:60:10:60:10 | source : | webview.swift:26:5:26:55 | [summary param] this in toObjectOf(_:) : |
@@ -224,8 +230,20 @@ edges
224230
| webview.swift:85:24:85:24 | s : | webview.swift:85:10:85:49 | call to init(rect:in:) |
225231
| webview.swift:86:24:86:24 | s : | webview.swift:24:5:24:40 | [summary param] 0 in init(size:in:) : |
226232
| webview.swift:86:24:86:24 | s : | webview.swift:86:10:86:49 | call to init(size:in:) |
233+
| webview.swift:89:5:89:5 | [post] v1 : | webview.swift:90:10:90:10 | v1 |
234+
| webview.swift:89:39:89:39 | s : | webview.swift:41:5:41:53 | [summary param] 1 in defineProperty(_:descriptor:) : |
235+
| webview.swift:89:39:89:39 | s : | webview.swift:89:5:89:5 | [post] v1 : |
236+
| webview.swift:93:5:93:5 | [post] v2 : | webview.swift:94:10:94:10 | v2 |
237+
| webview.swift:93:17:93:17 | s : | webview.swift:43:5:43:38 | [summary param] 0 in setValue(_:at:) : |
238+
| webview.swift:93:17:93:17 | s : | webview.swift:93:5:93:5 | [post] v2 : |
239+
| webview.swift:97:5:97:5 | [post] v3 : | webview.swift:98:10:98:10 | v3 |
240+
| webview.swift:97:17:97:17 | s : | webview.swift:44:5:44:48 | [summary param] 0 in setValue(_:forProperty:) : |
241+
| webview.swift:97:17:97:17 | s : | webview.swift:97:5:97:5 | [post] v3 : |
227242
nodes
228243
| file://:0:0:0:0 | [summary] to write: argument 1.parameter 0 in dataTask(with:completionHandler:) : | semmle.label | [summary] to write: argument 1.parameter 0 in dataTask(with:completionHandler:) : |
244+
| file://:0:0:0:0 | [summary] to write: argument this in defineProperty(_:descriptor:) : | semmle.label | [summary] to write: argument this in defineProperty(_:descriptor:) : |
245+
| file://:0:0:0:0 | [summary] to write: argument this in setValue(_:at:) : | semmle.label | [summary] to write: argument this in setValue(_:at:) : |
246+
| file://:0:0:0:0 | [summary] to write: argument this in setValue(_:forProperty:) : | semmle.label | [summary] to write: argument this in setValue(_:forProperty:) : |
229247
| file://:0:0:0:0 | [summary] to write: return (return) in atIndex(_:) : | semmle.label | [summary] to write: return (return) in atIndex(_:) : |
230248
| file://:0:0:0:0 | [summary] to write: return (return) in forProperty(_:) : | semmle.label | [summary] to write: return (return) in forProperty(_:) : |
231249
| file://:0:0:0:0 | [summary] to write: return (return) in init(bool:in:) : | semmle.label | [summary] to write: return (return) in init(bool:in:) : |
@@ -387,7 +405,10 @@ nodes
387405
| webview.swift:38:5:38:47 | [summary param] this in toRect() : | semmle.label | [summary param] this in toRect() : |
388406
| webview.swift:39:5:39:47 | [summary param] this in toSize() : | semmle.label | [summary param] this in toSize() : |
389407
| webview.swift:40:5:40:84 | [summary param] this in atIndex(_:) : | semmle.label | [summary param] this in atIndex(_:) : |
408+
| webview.swift:41:5:41:53 | [summary param] 1 in defineProperty(_:descriptor:) : | semmle.label | [summary param] 1 in defineProperty(_:descriptor:) : |
390409
| webview.swift:42:5:42:89 | [summary param] this in forProperty(_:) : | semmle.label | [summary param] this in forProperty(_:) : |
410+
| webview.swift:43:5:43:38 | [summary param] 0 in setValue(_:at:) : | semmle.label | [summary param] 0 in setValue(_:at:) : |
411+
| webview.swift:44:5:44:48 | [summary param] 0 in setValue(_:forProperty:) : | semmle.label | [summary param] 0 in setValue(_:forProperty:) : |
391412
| webview.swift:52:10:52:41 | .body | semmle.label | .body |
392413
| webview.swift:52:11:52:18 | call to source() : | semmle.label | call to source() : |
393414
| webview.swift:56:13:56:20 | call to source() : | semmle.label | call to source() : |
@@ -443,6 +464,15 @@ nodes
443464
| webview.swift:85:24:85:24 | s : | semmle.label | s : |
444465
| webview.swift:86:10:86:49 | call to init(size:in:) | semmle.label | call to init(size:in:) |
445466
| webview.swift:86:24:86:24 | s : | semmle.label | s : |
467+
| webview.swift:89:5:89:5 | [post] v1 : | semmle.label | [post] v1 : |
468+
| webview.swift:89:39:89:39 | s : | semmle.label | s : |
469+
| webview.swift:90:10:90:10 | v1 | semmle.label | v1 |
470+
| webview.swift:93:5:93:5 | [post] v2 : | semmle.label | [post] v2 : |
471+
| webview.swift:93:17:93:17 | s : | semmle.label | s : |
472+
| webview.swift:94:10:94:10 | v2 | semmle.label | v2 |
473+
| webview.swift:97:5:97:5 | [post] v3 : | semmle.label | [post] v3 : |
474+
| webview.swift:97:17:97:17 | s : | semmle.label | s : |
475+
| webview.swift:98:10:98:10 | v3 | semmle.label | v3 |
446476
subpaths
447477
| url.swift:59:31:59:31 | tainted : | url.swift:8:2:8:25 | [summary param] 0 in init(string:) : | file://:0:0:0:0 | [summary] to write: return (return) in init(string:) : | url.swift:59:19:59:38 | call to init(string:) : |
448478
| url.swift:83:24:83:24 | tainted : | url.swift:9:2:9:43 | [summary param] 0 in init(string:relativeTo:) : | file://:0:0:0:0 | [summary] to write: return (return) in init(string:relativeTo:) : | url.swift:83:12:83:48 | call to init(string:relativeTo:) : |
@@ -490,6 +520,9 @@ subpaths
490520
| webview.swift:84:25:84:25 | s : | webview.swift:22:5:22:42 | [summary param] 0 in init(range:in:) : | file://:0:0:0:0 | [summary] to write: return (return) in init(range:in:) : | webview.swift:84:10:84:51 | call to init(range:in:) |
491521
| webview.swift:85:24:85:24 | s : | webview.swift:23:5:23:40 | [summary param] 0 in init(rect:in:) : | file://:0:0:0:0 | [summary] to write: return (return) in init(rect:in:) : | webview.swift:85:10:85:49 | call to init(rect:in:) |
492522
| webview.swift:86:24:86:24 | s : | webview.swift:24:5:24:40 | [summary param] 0 in init(size:in:) : | file://:0:0:0:0 | [summary] to write: return (return) in init(size:in:) : | webview.swift:86:10:86:49 | call to init(size:in:) |
523+
| webview.swift:89:39:89:39 | s : | webview.swift:41:5:41:53 | [summary param] 1 in defineProperty(_:descriptor:) : | file://:0:0:0:0 | [summary] to write: argument this in defineProperty(_:descriptor:) : | webview.swift:89:5:89:5 | [post] v1 : |
524+
| webview.swift:93:17:93:17 | s : | webview.swift:43:5:43:38 | [summary param] 0 in setValue(_:at:) : | file://:0:0:0:0 | [summary] to write: argument this in setValue(_:at:) : | webview.swift:93:5:93:5 | [post] v2 : |
525+
| webview.swift:97:17:97:17 | s : | webview.swift:44:5:44:48 | [summary param] 0 in setValue(_:forProperty:) : | file://:0:0:0:0 | [summary] to write: argument this in setValue(_:forProperty:) : | webview.swift:97:5:97:5 | [post] v3 : |
493526
#select
494527
| string.swift:7:13:7:13 | "..." | string.swift:5:11:5:18 | call to source() : | string.swift:7:13:7:13 | "..." | result |
495528
| string.swift:9:13:9:13 | "..." | string.swift:5:11:5:18 | call to source() : | string.swift:9:13:9:13 | "..." | result |
@@ -571,3 +604,6 @@ subpaths
571604
| webview.swift:84:10:84:51 | call to init(range:in:) | webview.swift:56:13:56:20 | call to source() : | webview.swift:84:10:84:51 | call to init(range:in:) | result |
572605
| webview.swift:85:10:85:49 | call to init(rect:in:) | webview.swift:56:13:56:20 | call to source() : | webview.swift:85:10:85:49 | call to init(rect:in:) | result |
573606
| webview.swift:86:10:86:49 | call to init(size:in:) | webview.swift:56:13:56:20 | call to source() : | webview.swift:86:10:86:49 | call to init(size:in:) | result |
607+
| webview.swift:90:10:90:10 | v1 | webview.swift:56:13:56:20 | call to source() : | webview.swift:90:10:90:10 | v1 | result |
608+
| webview.swift:94:10:94:10 | v2 | webview.swift:56:13:56:20 | call to source() : | webview.swift:94:10:94:10 | v2 | result |
609+
| webview.swift:98:10:98:10 | v3 | webview.swift:56:13:56:20 | call to source() : | webview.swift:98:10:98:10 | v3 | result |

swift/ql/test/library-tests/dataflow/taint/webview.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ func testJsValue() {
8787

8888
let v1 = JSValue(object: "", in: context)
8989
v1.defineProperty("", descriptor: s as Any)
90-
sink(v1) // $ MISSING: tainted=56
90+
sink(v1) // $ tainted=56
9191

9292
let v2 = JSValue(object: "", in: context)
9393
v2.setValue(s as Any, at: 0)
94-
sink(v2) // $ MISSING: tainted=56
94+
sink(v2) // $ tainted=56
9595

9696
let v3 = JSValue(object: "", in: context)
97-
v2.setValue(s as Any, forProperty: "")
98-
sink(v3) // $ MISSING: tainted=56
97+
v3.setValue(s as Any, forProperty: "")
98+
sink(v3) // $ tainted=56
9999
}

0 commit comments

Comments
 (0)