Skip to content

Commit bbc03a1

Browse files
add false negatives to the test case
1 parent bb3bf64 commit bbc03a1

File tree

2 files changed

+50
-55
lines changed

2 files changed

+50
-55
lines changed
Lines changed: 47 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,65 @@
11
edges
2-
| test.swift:76:3:76:3 | this string is constant : | test.swift:91:18:91:36 | call to getConstantString() : |
3-
| test.swift:90:26:90:121 | [...] : | test.swift:105:21:105:21 | key |
4-
| test.swift:90:26:90:121 | [...] : | test.swift:106:21:106:21 | key |
5-
| test.swift:90:26:90:121 | [...] : | test.swift:116:22:116:22 | key |
2+
| test.swift:76:3:76:3 | this string is constant : | test.swift:92:18:92:36 | call to getConstantString() : |
63
| test.swift:90:26:90:121 | [...] : | test.swift:117:22:117:22 | key |
7-
| test.swift:90:26:90:121 | [...] : | test.swift:127:26:127:26 | key |
8-
| test.swift:90:26:90:121 | [...] : | test.swift:134:25:134:25 | key |
9-
| test.swift:90:26:90:121 | [...] : | test.swift:139:25:139:25 | key |
10-
| test.swift:90:26:90:121 | [...] : | test.swift:144:26:144:26 | key |
11-
| test.swift:90:26:90:121 | [...] : | test.swift:149:26:149:26 | key |
4+
| test.swift:90:26:90:121 | [...] : | test.swift:118:22:118:22 | key |
5+
| test.swift:90:26:90:121 | [...] : | test.swift:128:26:128:26 | key |
6+
| test.swift:90:26:90:121 | [...] : | test.swift:135:25:135:25 | key |
7+
| test.swift:90:26:90:121 | [...] : | test.swift:140:25:140:25 | key |
8+
| test.swift:90:26:90:121 | [...] : | test.swift:145:26:145:26 | key |
129
| test.swift:90:26:90:121 | [...] : | test.swift:150:26:150:26 | key |
13-
| test.swift:90:26:90:121 | [...] : | test.swift:160:24:160:24 | key |
14-
| test.swift:90:26:90:121 | [...] : | test.swift:162:24:162:24 | key |
15-
| test.swift:91:18:91:36 | call to getConstantString() : | test.swift:107:21:107:21 | keyString |
16-
| test.swift:91:18:91:36 | call to getConstantString() : | test.swift:108:21:108:21 | keyString |
17-
| test.swift:91:18:91:36 | call to getConstantString() : | test.swift:118:22:118:22 | keyString |
18-
| test.swift:91:18:91:36 | call to getConstantString() : | test.swift:119:22:119:22 | keyString |
19-
| test.swift:91:18:91:36 | call to getConstantString() : | test.swift:128:26:128:26 | keyString |
20-
| test.swift:91:18:91:36 | call to getConstantString() : | test.swift:151:26:151:26 | keyString |
21-
| test.swift:91:18:91:36 | call to getConstantString() : | test.swift:152:26:152:26 | keyString |
22-
| test.swift:91:18:91:36 | call to getConstantString() : | test.swift:161:24:161:24 | keyString |
23-
| test.swift:91:18:91:36 | call to getConstantString() : | test.swift:163:24:163:24 | keyString |
10+
| test.swift:90:26:90:121 | [...] : | test.swift:151:26:151:26 | key |
11+
| test.swift:90:26:90:121 | [...] : | test.swift:161:24:161:24 | key |
12+
| test.swift:90:26:90:121 | [...] : | test.swift:163:24:163:24 | key |
13+
| test.swift:92:18:92:36 | call to getConstantString() : | test.swift:108:21:108:21 | keyString |
14+
| test.swift:92:18:92:36 | call to getConstantString() : | test.swift:109:21:109:21 | keyString |
15+
| test.swift:92:18:92:36 | call to getConstantString() : | test.swift:119:22:119:22 | keyString |
16+
| test.swift:92:18:92:36 | call to getConstantString() : | test.swift:120:22:120:22 | keyString |
17+
| test.swift:92:18:92:36 | call to getConstantString() : | test.swift:129:26:129:26 | keyString |
18+
| test.swift:92:18:92:36 | call to getConstantString() : | test.swift:152:26:152:26 | keyString |
19+
| test.swift:92:18:92:36 | call to getConstantString() : | test.swift:153:26:153:26 | keyString |
20+
| test.swift:92:18:92:36 | call to getConstantString() : | test.swift:162:24:162:24 | keyString |
21+
| test.swift:92:18:92:36 | call to getConstantString() : | test.swift:164:24:164:24 | keyString |
2422
nodes
2523
| test.swift:76:3:76:3 | this string is constant : | semmle.label | this string is constant : |
2624
| test.swift:90:26:90:121 | [...] : | semmle.label | [...] : |
27-
| test.swift:91:18:91:36 | call to getConstantString() : | semmle.label | call to getConstantString() : |
28-
| test.swift:105:21:105:21 | key | semmle.label | key |
29-
| test.swift:106:21:106:21 | key | semmle.label | key |
30-
| test.swift:107:21:107:21 | keyString | semmle.label | keyString |
25+
| test.swift:92:18:92:36 | call to getConstantString() : | semmle.label | call to getConstantString() : |
3126
| test.swift:108:21:108:21 | keyString | semmle.label | keyString |
32-
| test.swift:116:22:116:22 | key | semmle.label | key |
27+
| test.swift:109:21:109:21 | keyString | semmle.label | keyString |
3328
| test.swift:117:22:117:22 | key | semmle.label | key |
34-
| test.swift:118:22:118:22 | keyString | semmle.label | keyString |
29+
| test.swift:118:22:118:22 | key | semmle.label | key |
3530
| test.swift:119:22:119:22 | keyString | semmle.label | keyString |
36-
| test.swift:127:26:127:26 | key | semmle.label | key |
37-
| test.swift:128:26:128:26 | keyString | semmle.label | keyString |
38-
| test.swift:134:25:134:25 | key | semmle.label | key |
39-
| test.swift:139:25:139:25 | key | semmle.label | key |
40-
| test.swift:144:26:144:26 | key | semmle.label | key |
41-
| test.swift:149:26:149:26 | key | semmle.label | key |
31+
| test.swift:120:22:120:22 | keyString | semmle.label | keyString |
32+
| test.swift:128:26:128:26 | key | semmle.label | key |
33+
| test.swift:129:26:129:26 | keyString | semmle.label | keyString |
34+
| test.swift:135:25:135:25 | key | semmle.label | key |
35+
| test.swift:140:25:140:25 | key | semmle.label | key |
36+
| test.swift:145:26:145:26 | key | semmle.label | key |
4237
| test.swift:150:26:150:26 | key | semmle.label | key |
43-
| test.swift:151:26:151:26 | keyString | semmle.label | keyString |
38+
| test.swift:151:26:151:26 | key | semmle.label | key |
4439
| test.swift:152:26:152:26 | keyString | semmle.label | keyString |
45-
| test.swift:160:24:160:24 | key | semmle.label | key |
46-
| test.swift:161:24:161:24 | keyString | semmle.label | keyString |
47-
| test.swift:162:24:162:24 | key | semmle.label | key |
48-
| test.swift:163:24:163:24 | keyString | semmle.label | keyString |
40+
| test.swift:153:26:153:26 | keyString | semmle.label | keyString |
41+
| test.swift:161:24:161:24 | key | semmle.label | key |
42+
| test.swift:162:24:162:24 | keyString | semmle.label | keyString |
43+
| test.swift:163:24:163:24 | key | semmle.label | key |
44+
| test.swift:164:24:164:24 | keyString | semmle.label | keyString |
4945
subpaths
5046
#select
51-
| test.swift:105:21:105:21 | key | test.swift:90:26:90:121 | [...] : | test.swift:105:21:105:21 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
52-
| test.swift:106:21:106:21 | key | test.swift:90:26:90:121 | [...] : | test.swift:106:21:106:21 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
53-
| test.swift:107:21:107:21 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:107:21:107:21 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
5447
| test.swift:108:21:108:21 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:108:21:108:21 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
55-
| test.swift:116:22:116:22 | key | test.swift:90:26:90:121 | [...] : | test.swift:116:22:116:22 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
48+
| test.swift:109:21:109:21 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:109:21:109:21 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
5649
| test.swift:117:22:117:22 | key | test.swift:90:26:90:121 | [...] : | test.swift:117:22:117:22 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
57-
| test.swift:118:22:118:22 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:118:22:118:22 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
50+
| test.swift:118:22:118:22 | key | test.swift:90:26:90:121 | [...] : | test.swift:118:22:118:22 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
5851
| test.swift:119:22:119:22 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:119:22:119:22 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
59-
| test.swift:127:26:127:26 | key | test.swift:90:26:90:121 | [...] : | test.swift:127:26:127:26 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
60-
| test.swift:128:26:128:26 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:128:26:128:26 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
61-
| test.swift:134:25:134:25 | key | test.swift:90:26:90:121 | [...] : | test.swift:134:25:134:25 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
62-
| test.swift:139:25:139:25 | key | test.swift:90:26:90:121 | [...] : | test.swift:139:25:139:25 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
63-
| test.swift:144:26:144:26 | key | test.swift:90:26:90:121 | [...] : | test.swift:144:26:144:26 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
64-
| test.swift:149:26:149:26 | key | test.swift:90:26:90:121 | [...] : | test.swift:149:26:149:26 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
52+
| test.swift:120:22:120:22 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:120:22:120:22 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
53+
| test.swift:128:26:128:26 | key | test.swift:90:26:90:121 | [...] : | test.swift:128:26:128:26 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
54+
| test.swift:129:26:129:26 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:129:26:129:26 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
55+
| test.swift:135:25:135:25 | key | test.swift:90:26:90:121 | [...] : | test.swift:135:25:135:25 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
56+
| test.swift:140:25:140:25 | key | test.swift:90:26:90:121 | [...] : | test.swift:140:25:140:25 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
57+
| test.swift:145:26:145:26 | key | test.swift:90:26:90:121 | [...] : | test.swift:145:26:145:26 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
6558
| test.swift:150:26:150:26 | key | test.swift:90:26:90:121 | [...] : | test.swift:150:26:150:26 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
66-
| test.swift:151:26:151:26 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:151:26:151:26 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
59+
| test.swift:151:26:151:26 | key | test.swift:90:26:90:121 | [...] : | test.swift:151:26:151:26 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
6760
| test.swift:152:26:152:26 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:152:26:152:26 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
68-
| test.swift:160:24:160:24 | key | test.swift:90:26:90:121 | [...] : | test.swift:160:24:160:24 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
69-
| test.swift:161:24:161:24 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:161:24:161:24 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
70-
| test.swift:162:24:162:24 | key | test.swift:90:26:90:121 | [...] : | test.swift:162:24:162:24 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
71-
| test.swift:163:24:163:24 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:163:24:163:24 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
61+
| test.swift:153:26:153:26 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:153:26:153:26 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
62+
| test.swift:161:24:161:24 | key | test.swift:90:26:90:121 | [...] : | test.swift:161:24:161:24 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
63+
| test.swift:162:24:162:24 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:162:24:162:24 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |
64+
| test.swift:163:24:163:24 | key | test.swift:90:26:90:121 | [...] : | test.swift:163:24:163:24 | key | The key 'key' has been initialized with hard-coded values from $@. | test.swift:90:26:90:121 | [...] : | [...] |
65+
| test.swift:164:24:164:24 | keyString | test.swift:76:3:76:3 | this string is constant : | test.swift:164:24:164:24 | keyString | The key 'keyString' has been initialized with hard-coded values from $@. | test.swift:76:3:76:3 | this string is constant : | this string is constant |

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func getRandomArray() -> Array<UInt8> {
8888

8989
func test() {
9090
let key: Array<UInt8> = [0x2a, 0x3a, 0x80, 0x05, 0xaf, 0x46, 0x58, 0x2d, 0x66, 0x52, 0x10, 0xae, 0x86, 0xd3, 0x8e, 0x8f]
91+
let key2 = getConstantArray()
9192
let keyString = getConstantString()
9293

9394
let randomArray = getRandomArray()
@@ -102,8 +103,8 @@ func test() {
102103
let ivString = String(cString: iv)
103104

104105
// AES test cases
105-
let ab1 = AES(key: key, blockMode: blockMode, padding: padding) // BAD
106-
let ab2 = AES(key: key, blockMode: blockMode) // BAD
106+
let ab1 = AES(key: key2, blockMode: blockMode, padding: padding) // BAD [NOT DETECTED]
107+
let ab2 = AES(key: key2, blockMode: blockMode) // BAD [NOT DETECTED]
107108
let ab3 = AES(key: keyString, iv: ivString) // BAD
108109
let ab4 = AES(key: keyString, iv: ivString, padding: padding) // BAD
109110

0 commit comments

Comments
 (0)