Skip to content

Commit 69dd2c0

Browse files
committed
Swift: Add a test of taint sources.
1 parent 9f1bbf2 commit 69dd2c0

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| string.swift:27:21:27:21 | call to init(contentsOf:) | external |
2+
| string.swift:27:21:27:44 | call to init(contentsOf:) | external |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import swift
2+
import codeql.swift.dataflow.FlowSources
3+
4+
from RemoteFlowSource source
5+
select source, concat(source.getSourceType(), ", ")
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
// --- stubs ---
3+
4+
struct URL
5+
{
6+
init?(string: String) {}
7+
}
8+
9+
extension String {
10+
init(contentsOf: URL) throws {
11+
var data = ""
12+
13+
// ...
14+
15+
self.init(data)
16+
}
17+
}
18+
19+
// --- tests ---
20+
21+
func testStrings() {
22+
do
23+
{
24+
let string1 = String()
25+
let string2 = String(repeating: "abc", count: 10)
26+
let url = URL(string: "http://example.com/")
27+
let string3 = try String(contentsOf: url!) // SOURCE
28+
} catch {
29+
// ...
30+
}
31+
}

0 commit comments

Comments
 (0)