Skip to content

Commit 835967a

Browse files
committed
Swift: Fix for autoclosure sinks.
1 parent 795f16b commit 835967a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/TaintTrackingPrivate.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ private module Cached {
6161
se = nodeTo.asExpr()
6262
)
6363
or
64+
// flow through autoclosure expressions (which turn value arguments into closure arguments);
65+
// if the value is tainted, it's helpful to consider the autoclosure itself to be tainted as
66+
// well for the purposes of matching sink models.
67+
nodeFrom.asExpr() = nodeTo.asExpr().(AutoClosureExpr).getExpr()
68+
or
6469
// flow through the read of a content that inherits taint
6570
exists(DataFlow::ContentSet f |
6671
readStep(nodeFrom, f, nodeTo) and

swift/ql/test/query-tests/Security/CWE-312/cleartextLoggingTest.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,15 @@ func test5(password: String, caseNum: Int) {
324324

325325
switch caseNum {
326326
case 0:
327-
assert(false, password) // $ MISSING: hasCleartextLogging=327
327+
assert(false, password) // $ hasCleartextLogging=327
328328
case 1:
329-
assertionFailure(password) // $ MISSING: hasCleartextLogging=329
329+
assertionFailure(password) // $ hasCleartextLogging=329
330330
case 2:
331-
precondition(false, password) // $ MISSING: hasCleartextLogging=331
331+
precondition(false, password) // $ hasCleartextLogging=331
332332
case 3:
333-
preconditionFailure(password) // $ MISSING: hasCleartextLogging=333
333+
preconditionFailure(password) // $ hasCleartextLogging=333
334334
default:
335-
fatalError(password) // $ MISSING: hasCleartextLogging=335
335+
fatalError(password) // $ hasCleartextLogging=335
336336
}
337337
}
338338

0 commit comments

Comments
 (0)