Skip to content

Commit b4b78a1

Browse files
committed
Swift: Minor corrections.
1 parent 50120f6 commit b4b78a1

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private class CleartextLoggingFieldAdditionalFlowStep extends CleartextLoggingAd
9595

9696
/**
9797
* A function that appears to be an imported C `printf` variant.
98-
* TODO: merge code with similar cases from the cleartext logging PR.
98+
* TODO: merge code with similar cases from the format string PR.
9999
*/
100100
class PrintfFormat extends FreeFunction {
101101
int formatParamIndex;
@@ -144,7 +144,6 @@ private predicate logLikeHeuristic(Function f) {
144144
class HeuristicCleartextLoggingSink extends CleartextLoggingSink {
145145
HeuristicCleartextLoggingSink() {
146146
exists(CallExpr ce, Function f, Expr e |
147-
// by function name
148147
logLikeHeuristic(f) and
149148
ce.getStaticTarget() = f and
150149
ce.getAnArgument().getExpr() = e and

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class NSException : NSObject
105105
}
106106

107107
class NSString : NSObject {
108-
convenience init(string aString: String) { self.init() }
108+
convenience init(string aString: String) { self.init() }
109109
}
110110

111111
// from ObjC API; slightly simplified.
@@ -132,7 +132,7 @@ func logMessage(_ msg: NSString) {}
132132
func logInfo(_ infoMsg: String) {}
133133
func logError(errorMsg str: String) {}
134134
func harmless(_ str: String) {} // safe
135-
func logarithm(_ val: Float) {} // safe
135+
func logarithm(_ val: Float) -> Float { return 0.0 } // safe
136136
func doLogin(login: String) {} // safe
137137

138138
// custom
@@ -363,7 +363,7 @@ func test7(authKey: String, authKey2: Int, authKey3: Float) {
363363
logInfo(authKey) // $ MISSING: hasCleartextLogging=363
364364
logError(errorMsg: authKey) // $ hasCleartextLogging=364
365365
harmless(authKey) // GOOD: not logging
366-
logarithm(authKey3) // GOOD: not logging
366+
_ = logarithm(authKey3) // GOOD: not logging
367367
doLogin(login: authKey) // GOOD: not logging
368368

369369
let logger = LogFile()

0 commit comments

Comments
 (0)