Skip to content

Commit b99e44c

Browse files
committed
Swift: Fix the Data test.
1 parent e90b630 commit b99e44c

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

swift/ql/test/query-tests/Security/CWE-321/HardcodedEncryptionKey.expected

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ edges
6464
| rncryptor.swift:60:19:60:38 | call to Data.init(_:) | rncryptor.swift:81:102:81:102 | myConstKey |
6565
| rncryptor.swift:60:19:60:38 | call to Data.init(_:) | rncryptor.swift:83:92:83:92 | myConstKey |
6666
| rncryptor.swift:60:24:60:24 | abcdef123456 | rncryptor.swift:60:19:60:38 | call to Data.init(_:) |
67-
| sqlite3_c_api.swift:33:19:33:38 | call to Data.init(_:) | sqlite3_c_api.swift:40:2:40:2 | myConstKey |
68-
| sqlite3_c_api.swift:33:24:33:24 | abcdef123456 | sqlite3_c_api.swift:33:19:33:38 | call to Data.init(_:) |
69-
| sqlite3_c_api.swift:40:2:40:2 | myConstKey | sqlite3_c_api.swift:40:31:40:31 | buffer [Collection element] |
70-
| sqlite3_c_api.swift:40:31:40:31 | buffer [Collection element] | sqlite3_c_api.swift:41:36:41:36 | buffer |
71-
| sqlite3_c_api.swift:40:31:40:31 | buffer [Collection element] | sqlite3_c_api.swift:42:38:42:38 | buffer |
67+
| sqlite3_c_api.swift:41:19:41:38 | call to Data.init(_:) | sqlite3_c_api.swift:48:2:48:2 | myConstKey |
68+
| sqlite3_c_api.swift:41:24:41:24 | abcdef123456 | sqlite3_c_api.swift:41:19:41:38 | call to Data.init(_:) |
69+
| sqlite3_c_api.swift:48:2:48:2 | myConstKey | sqlite3_c_api.swift:48:31:48:31 | buffer [Collection element] |
70+
| sqlite3_c_api.swift:48:31:48:31 | buffer [Collection element] | sqlite3_c_api.swift:49:36:49:36 | buffer |
71+
| sqlite3_c_api.swift:48:31:48:31 | buffer [Collection element] | sqlite3_c_api.swift:50:38:50:38 | buffer |
7272
nodes
7373
| SQLite.swift:43:13:43:13 | hardcoded_key | semmle.label | hardcoded_key |
7474
| SQLite.swift:45:23:45:23 | hardcoded_key | semmle.label | hardcoded_key |
@@ -143,12 +143,12 @@ nodes
143143
| rncryptor.swift:80:94:80:94 | myConstKey | semmle.label | myConstKey |
144144
| rncryptor.swift:81:102:81:102 | myConstKey | semmle.label | myConstKey |
145145
| rncryptor.swift:83:92:83:92 | myConstKey | semmle.label | myConstKey |
146-
| sqlite3_c_api.swift:33:19:33:38 | call to Data.init(_:) | semmle.label | call to Data.init(_:) |
147-
| sqlite3_c_api.swift:33:24:33:24 | abcdef123456 | semmle.label | abcdef123456 |
148-
| sqlite3_c_api.swift:40:2:40:2 | myConstKey | semmle.label | myConstKey |
149-
| sqlite3_c_api.swift:40:31:40:31 | buffer [Collection element] | semmle.label | buffer [Collection element] |
150-
| sqlite3_c_api.swift:41:36:41:36 | buffer | semmle.label | buffer |
151-
| sqlite3_c_api.swift:42:38:42:38 | buffer | semmle.label | buffer |
146+
| sqlite3_c_api.swift:41:19:41:38 | call to Data.init(_:) | semmle.label | call to Data.init(_:) |
147+
| sqlite3_c_api.swift:41:24:41:24 | abcdef123456 | semmle.label | abcdef123456 |
148+
| sqlite3_c_api.swift:48:2:48:2 | myConstKey | semmle.label | myConstKey |
149+
| sqlite3_c_api.swift:48:31:48:31 | buffer [Collection element] | semmle.label | buffer [Collection element] |
150+
| sqlite3_c_api.swift:49:36:49:36 | buffer | semmle.label | buffer |
151+
| sqlite3_c_api.swift:50:38:50:38 | buffer | semmle.label | buffer |
152152
subpaths
153153
| misc.swift:53:25:53:25 | myConstKey | misc.swift:30:7:30:7 | value | file://:0:0:0:0 | [post] self | misc.swift:53:2:53:2 | [post] config |
154154
| misc.swift:53:25:53:25 | myConstKey | misc.swift:30:7:30:7 | value | file://:0:0:0:0 | [post] self [encryptionKey] | misc.swift:53:2:53:2 | [post] config [encryptionKey] |
@@ -204,5 +204,5 @@ subpaths
204204
| rncryptor.swift:80:94:80:94 | myConstKey | rncryptor.swift:60:24:60:24 | abcdef123456 | rncryptor.swift:80:94:80:94 | myConstKey | The key 'myConstKey' has been initialized with hard-coded values from $@. | rncryptor.swift:60:24:60:24 | abcdef123456 | abcdef123456 |
205205
| rncryptor.swift:81:102:81:102 | myConstKey | rncryptor.swift:60:24:60:24 | abcdef123456 | rncryptor.swift:81:102:81:102 | myConstKey | The key 'myConstKey' has been initialized with hard-coded values from $@. | rncryptor.swift:60:24:60:24 | abcdef123456 | abcdef123456 |
206206
| rncryptor.swift:83:92:83:92 | myConstKey | rncryptor.swift:60:24:60:24 | abcdef123456 | rncryptor.swift:83:92:83:92 | myConstKey | The key 'myConstKey' has been initialized with hard-coded values from $@. | rncryptor.swift:60:24:60:24 | abcdef123456 | abcdef123456 |
207-
| sqlite3_c_api.swift:41:36:41:36 | buffer | sqlite3_c_api.swift:33:24:33:24 | abcdef123456 | sqlite3_c_api.swift:41:36:41:36 | buffer | The key 'buffer' has been initialized with hard-coded values from $@. | sqlite3_c_api.swift:33:24:33:24 | abcdef123456 | abcdef123456 |
208-
| sqlite3_c_api.swift:42:38:42:38 | buffer | sqlite3_c_api.swift:33:24:33:24 | abcdef123456 | sqlite3_c_api.swift:42:38:42:38 | buffer | The key 'buffer' has been initialized with hard-coded values from $@. | sqlite3_c_api.swift:33:24:33:24 | abcdef123456 | abcdef123456 |
207+
| sqlite3_c_api.swift:49:36:49:36 | buffer | sqlite3_c_api.swift:41:24:41:24 | abcdef123456 | sqlite3_c_api.swift:49:36:49:36 | buffer | The key 'buffer' has been initialized with hard-coded values from $@. | sqlite3_c_api.swift:41:24:41:24 | abcdef123456 | abcdef123456 |
208+
| sqlite3_c_api.swift:50:38:50:38 | buffer | sqlite3_c_api.swift:41:24:41:24 | abcdef123456 | sqlite3_c_api.swift:50:38:50:38 | buffer | The key 'buffer' has been initialized with hard-coded values from $@. | sqlite3_c_api.swift:41:24:41:24 | abcdef123456 | abcdef123456 |

swift/ql/test/query-tests/Security/CWE-321/sqlite3_c_api.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11

22
// --- stubs ---
33

4-
struct Data {
4+
protocol ContiguousBytes {
5+
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
6+
}
7+
8+
struct Data : ContiguousBytes {
59
init<S>(_ elements: S) { count = 0 }
610

11+
func withUnsafeBytes<ResultType>(_ body: (UnsafeRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
12+
return 0 as! ResultType
13+
}
14+
715
func withUnsafeBytes<ResultType, ContentType>(_ body: (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
8-
return 0 as! ResultType//body(0 as UnsafePointer<ContentType>())
16+
return 0 as! ResultType
917
}
1018

1119
var count: Int

0 commit comments

Comments
 (0)