Skip to content

Commit adbd2c4

Browse files
committed
Swift: Fix member variable sinks in swift/path-ionjection.
1 parent 268db8b commit adbd2c4

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

swift/ql/lib/codeql/swift/security/PathInjectionExtensions.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ private class PathInjectionSinks extends SinkModelCsv {
132132
";Realm.Configuration;true;init(fileURL:inMemoryIdentifier:syncConfiguration:encryptionKey:readOnly:schemaVersion:migrationBlock:deleteRealmIfMigrationNeeded:shouldCompactOnLaunch:objectTypes:);;;Argument[0];path-injection",
133133
";Realm.Configuration;true;init(fileURL:inMemoryIdentifier:syncConfiguration:encryptionKey:readOnly:schemaVersion:migrationBlock:deleteRealmIfMigrationNeeded:shouldCompactOnLaunch:objectTypes:seedFilePath:);;;Argument[0];path-injection",
134134
";Realm.Configuration;true;init(fileURL:inMemoryIdentifier:syncConfiguration:encryptionKey:readOnly:schemaVersion:migrationBlock:deleteRealmIfMigrationNeeded:shouldCompactOnLaunch:objectTypes:seedFilePath:);;;Argument[10];path-injection",
135-
";Realm.Configuration;true;fileURL;;;;path-injection",
136-
";Realm.Configuration;true;seedFilePath;;;;path-injection",
135+
";Realm.Configuration;true;fileURL;;;PostUpdate;path-injection",
136+
";Realm.Configuration;true;seedFilePath;;;PostUpdate;path-injection",
137137
]
138138
}
139139
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| file://:0:0:0:0 | self | Unexpected result: hasPathInjection=208 |

swift/ql/test/query-tests/Security/CWE-022/PathInjectionTest.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ class PathInjectionTest extends InlineExpectationsTest {
1212
override predicate hasActualResult(Location location, string element, string tag, string value) {
1313
exists(DataFlow::Node source, DataFlow::Node sink, Expr sinkExpr |
1414
PathInjectionFlow::flow(source, sink) and
15-
sinkExpr = sink.asExpr() and
15+
(
16+
sinkExpr = sink.asExpr() or
17+
sinkExpr = sink.(DataFlow::PostUpdateNode).getPreUpdateNode().asExpr()
18+
) and
1619
location = sinkExpr.getLocation() and
1720
element = sinkExpr.toString() and
1821
tag = "hasPathInjection" and

swift/ql/test/query-tests/Security/CWE-022/testPathInjection.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ func test() {
317317

318318
var config = Realm.Configuration() // GOOD
319319
config.fileURL = safeUrl // GOOD
320-
config.fileURL = remoteUrl // $ MISSING: hasPathInjection=208
320+
config.fileURL = remoteUrl // $ hasPathInjection=208
321321
config.seedFilePath = safeUrl // GOOD
322-
config.seedFilePath = remoteUrl // $ MISSING: hasPathInjection=208
322+
config.seedFilePath = remoteUrl // $ hasPathInjection=208
323323
}
324324

325325
func testSanitizers() {

0 commit comments

Comments
 (0)