Skip to content

Commit 8b0da01

Browse files
committed
Swift: allow self./super. sinks in StaticInitializationVector
Assumption: the extra path is not an issue in practice as the body of the cryptographic library's init methods are not normally extracted, only the stubs in this test are.
1 parent 3da54eb commit 8b0da01

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

swift/ql/src/queries/Security/CWE-1204/StaticInitializationVector.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ class EncryptionInitializationSink extends Expr {
3838
"AES", "ChaCha20", "Blowfish", "Rabbit", "CBC", "CFB", "GCM", "OCB", "OFB", "PCBC",
3939
"CCM", "CTR"
4040
], fName) and
41-
call.getArgumentWithLabel("iv").getExpr() = this and
42-
not call.isSelfCall() and
43-
not call.isSuperCall()
41+
call.getArgumentWithLabel("iv").getExpr() = this
4442
)
4543
}
4644
}

swift/ql/test/query-tests/Security/CWE-1204/StaticInitializationVector.expected

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
edges
2+
| test.swift:53:19:53:34 | iv : | test.swift:54:17:54:17 | iv |
23
| test.swift:85:3:85:3 | this string is constant : | test.swift:101:17:101:35 | call to getConstantString() : |
34
| test.swift:99:25:99:120 | [...] : | test.swift:128:33:128:33 | iv |
45
| test.swift:99:25:99:120 | [...] : | test.swift:135:22:135:22 | iv |
@@ -7,6 +8,7 @@ edges
78
| test.swift:99:25:99:120 | [...] : | test.swift:145:22:145:22 | iv |
89
| test.swift:99:25:99:120 | [...] : | test.swift:146:22:146:22 | iv |
910
| test.swift:99:25:99:120 | [...] : | test.swift:147:22:147:22 | iv |
11+
| test.swift:99:25:99:120 | [...] : | test.swift:147:22:147:22 | iv : |
1012
| test.swift:99:25:99:120 | [...] : | test.swift:153:22:153:22 | iv |
1113
| test.swift:99:25:99:120 | [...] : | test.swift:157:24:157:24 | iv |
1214
| test.swift:99:25:99:120 | [...] : | test.swift:161:22:161:22 | iv |
@@ -19,7 +21,10 @@ edges
1921
| test.swift:101:17:101:35 | call to getConstantString() : | test.swift:122:41:122:41 | ivString |
2022
| test.swift:101:17:101:35 | call to getConstantString() : | test.swift:123:41:123:41 | ivString |
2123
| test.swift:101:17:101:35 | call to getConstantString() : | test.swift:130:39:130:39 | ivString |
24+
| test.swift:147:22:147:22 | iv : | test.swift:53:19:53:34 | iv : |
2225
nodes
26+
| test.swift:53:19:53:34 | iv : | semmle.label | iv : |
27+
| test.swift:54:17:54:17 | iv | semmle.label | iv |
2328
| test.swift:85:3:85:3 | this string is constant : | semmle.label | this string is constant : |
2429
| test.swift:99:25:99:120 | [...] : | semmle.label | [...] : |
2530
| test.swift:101:17:101:35 | call to getConstantString() : | semmle.label | call to getConstantString() : |
@@ -36,6 +41,7 @@ nodes
3641
| test.swift:145:22:145:22 | iv | semmle.label | iv |
3742
| test.swift:146:22:146:22 | iv | semmle.label | iv |
3843
| test.swift:147:22:147:22 | iv | semmle.label | iv |
44+
| test.swift:147:22:147:22 | iv : | semmle.label | iv : |
3945
| test.swift:153:22:153:22 | iv | semmle.label | iv |
4046
| test.swift:157:24:157:24 | iv | semmle.label | iv |
4147
| test.swift:161:22:161:22 | iv | semmle.label | iv |
@@ -44,6 +50,7 @@ nodes
4450
| test.swift:168:22:168:22 | iv | semmle.label | iv |
4551
subpaths
4652
#select
53+
| test.swift:54:17:54:17 | iv | test.swift:99:25:99:120 | [...] : | test.swift:54:17:54:17 | iv | The static value '[...]' is used as an initialization vector for encryption. |
4754
| test.swift:112:36:112:36 | ivString | test.swift:85:3:85:3 | this string is constant : | test.swift:112:36:112:36 | ivString | The static value 'this string is constant' is used as an initialization vector for encryption. |
4855
| test.swift:113:36:113:36 | ivString | test.swift:85:3:85:3 | this string is constant : | test.swift:113:36:113:36 | ivString | The static value 'this string is constant' is used as an initialization vector for encryption. |
4956
| test.swift:118:41:118:41 | ivString | test.swift:85:3:85:3 | this string is constant : | test.swift:118:41:118:41 | ivString | The static value 'this string is constant' is used as an initialization vector for encryption. |
@@ -62,4 +69,4 @@ subpaths
6269
| test.swift:161:22:161:22 | iv | test.swift:99:25:99:120 | [...] : | test.swift:161:22:161:22 | iv | The static value '[...]' is used as an initialization vector for encryption. |
6370
| test.swift:162:22:162:22 | iv | test.swift:99:25:99:120 | [...] : | test.swift:162:22:162:22 | iv | The static value '[...]' is used as an initialization vector for encryption. |
6471
| test.swift:167:22:167:22 | iv | test.swift:99:25:99:120 | [...] : | test.swift:167:22:167:22 | iv | The static value '[...]' is used as an initialization vector for encryption. |
65-
| test.swift:168:22:168:22 | iv | test.swift:99:25:99:120 | [...] : | test.swift:168:22:168:22 | iv | The static value '[...]' is used as an initialization vector for encryption. |
72+
| test.swift:168:22:168:22 | iv | test.swift:99:25:99:120 | [...] : | test.swift:168:22:168:22 | iv | The static value '[...]' is used as an initialization vector for encryption. |

0 commit comments

Comments
 (0)