Skip to content

Commit 93234c0

Browse files
committed
Swift: Add model for 'withVaList' and accept test changes.
1 parent 9e2dd09 commit 93234c0

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

swift/ql/lib/codeql/swift/frameworks/StandardLibrary/CInterop.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ private import codeql.swift.dataflow.ExternalFlow
77

88
private class CInteropSummaries extends SummaryModelCsv {
99
override predicate row(string row) {
10-
row = ";;false;getVaList(_:);;;Argument[0].CollectionElement;ReturnValue;value"
10+
row =
11+
[
12+
";;false;getVaList(_:);;;Argument[0].CollectionElement;ReturnValue;value",
13+
";;false;withVaList(_:_:);;;Argument[0];Argument[1].Parameter[0];value"
14+
]
1115
}
1216
}

swift/ql/test/query-tests/Security/CWE-134/UncontrolledFormatString.expected

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
edges
2+
| UncontrolledFormatString.swift:57:12:57:22 | format | UncontrolledFormatString.swift:58:22:60:5 | format |
3+
| UncontrolledFormatString.swift:58:22:60:5 | format | UncontrolledFormatString.swift:58:22:60:5 | { ... } [format] |
4+
| UncontrolledFormatString.swift:58:22:60:5 | { ... } [format] | UncontrolledFormatString.swift:59:16:59:16 | this [format] |
5+
| UncontrolledFormatString.swift:59:16:59:16 | this [format] | UncontrolledFormatString.swift:59:16:59:16 | format |
26
| UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:70:28:70:28 | tainted |
37
| UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:73:28:73:28 | tainted |
48
| UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:74:28:74:28 | tainted |
@@ -11,12 +15,19 @@ edges
1115
| UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:84:54:84:54 | tainted |
1216
| UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:85:72:85:72 | tainted |
1317
| UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:88:11:88:11 | tainted |
18+
| UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:89:11:89:11 | tainted |
1419
| UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:91:61:91:61 | tainted |
1520
| UncontrolledFormatString.swift:81:47:81:47 | tainted | UncontrolledFormatString.swift:81:30:81:54 | call to NSString.init(string:) |
1621
| UncontrolledFormatString.swift:82:65:82:65 | tainted | UncontrolledFormatString.swift:82:48:82:72 | call to NSString.init(string:) |
1722
| UncontrolledFormatString.swift:84:54:84:54 | tainted | UncontrolledFormatString.swift:84:37:84:61 | call to NSString.init(string:) |
1823
| UncontrolledFormatString.swift:85:72:85:72 | tainted | UncontrolledFormatString.swift:85:55:85:79 | call to NSString.init(string:) |
24+
| UncontrolledFormatString.swift:89:11:89:11 | tainted | UncontrolledFormatString.swift:57:12:57:22 | format |
1925
nodes
26+
| UncontrolledFormatString.swift:57:12:57:22 | format | semmle.label | format |
27+
| UncontrolledFormatString.swift:58:22:60:5 | format | semmle.label | format |
28+
| UncontrolledFormatString.swift:58:22:60:5 | { ... } [format] | semmle.label | { ... } [format] |
29+
| UncontrolledFormatString.swift:59:16:59:16 | format | semmle.label | format |
30+
| UncontrolledFormatString.swift:59:16:59:16 | this [format] | semmle.label | this [format] |
2031
| UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | semmle.label | call to String.init(contentsOf:) |
2132
| UncontrolledFormatString.swift:70:28:70:28 | tainted | semmle.label | tainted |
2233
| UncontrolledFormatString.swift:73:28:73:28 | tainted | semmle.label | tainted |
@@ -34,9 +45,11 @@ nodes
3445
| UncontrolledFormatString.swift:85:55:85:79 | call to NSString.init(string:) | semmle.label | call to NSString.init(string:) |
3546
| UncontrolledFormatString.swift:85:72:85:72 | tainted | semmle.label | tainted |
3647
| UncontrolledFormatString.swift:88:11:88:11 | tainted | semmle.label | tainted |
48+
| UncontrolledFormatString.swift:89:11:89:11 | tainted | semmle.label | tainted |
3749
| UncontrolledFormatString.swift:91:61:91:61 | tainted | semmle.label | tainted |
3850
subpaths
3951
#select
52+
| UncontrolledFormatString.swift:59:16:59:16 | format | UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:59:16:59:16 | format | This format string depends on $@. | UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | this user-provided value |
4053
| UncontrolledFormatString.swift:70:28:70:28 | tainted | UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:70:28:70:28 | tainted | This format string depends on $@. | UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | this user-provided value |
4154
| UncontrolledFormatString.swift:73:28:73:28 | tainted | UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:73:28:73:28 | tainted | This format string depends on $@. | UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | this user-provided value |
4255
| UncontrolledFormatString.swift:74:28:74:28 | tainted | UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | UncontrolledFormatString.swift:74:28:74:28 | tainted | This format string depends on $@. | UncontrolledFormatString.swift:64:24:64:77 | call to String.init(contentsOf:) | this user-provided value |

swift/ql/test/query-tests/Security/CWE-134/UncontrolledFormatString.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func getVaList(_ args: [CVarArg]) -> CVaListPointer { return (nil as CVaListPoin
5656

5757
func MyLog(_ format: String, _ args: CVarArg...) {
5858
withVaList(args) { arglist in
59-
NSLogv(format, arglist) // BAD [NOT DETECTED]
59+
NSLogv(format, arglist) // BAD
6060
}
6161
}
6262

0 commit comments

Comments
 (0)