Skip to content

Commit 3cecf69

Browse files
committed
Swift: Fix spurious results for 'login' functions.
1 parent aa93165 commit 3cecf69

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ private class PrintfCleartextLoggingSink extends CleartextLoggingSink {
134134
* Holds if `f` is a function that might be a logging function.
135135
*/
136136
private predicate logLikeHeuristic(Function f) {
137-
f.getName().regexpMatch("(?i).*log.*") or
138-
f.getDeclaringDecl().(NominalTypeDecl).getName().regexpMatch("(?i).*log.*")
137+
f.getName().regexpMatch("(?i).*log(?!in).*") or
138+
f.getDeclaringDecl().(NominalTypeDecl).getName().regexpMatch("(?i).*log(?!in).*")
139139
}
140140

141141
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,11 @@ func test7(authKey: String, authKey2: Int, authKey3: Float) {
360360
logging(message: authKey) // $ hasCleartextLogging=360
361361
logfile(file: 0, message: authKey) // $ hasCleartextLogging=361
362362
logMessage(NSString(string: authKey)) // $ hasCleartextLogging=362
363-
logInfo(authKey) // $ hasCleartextLogging=363
363+
logInfo(authKey) // $ MISSING: hasCleartextLogging=363
364364
logError(errorMsg: authKey) // $ hasCleartextLogging=364
365365
harmless(authKey) // GOOD: not logging
366366
logarithm(authKey3) // GOOD: not logging
367-
doLogin(login: authKey) // $ SPURIOUS: hasCleartextLogging=367 (not logging)
367+
doLogin(login: authKey) // GOOD: not logging
368368

369369
let logger = LogFile()
370370
let msg = "authKey: " + authKey

0 commit comments

Comments
 (0)