Skip to content

Commit 09974b5

Browse files
committed
Swift: Extend sink models.
1 parent 0e4cd7f commit 09974b5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,14 @@ private class LoggingSinks extends SinkModelCsv {
105105
";;false;dump(_:name:indent:maxDepth:maxItems:);;;Argument[0..1];log-injection",
106106
";;false;dump(_:to:name:indent:maxDepth:maxItems:);;;Argument[0];log-injection",
107107
";;false;dump(_:to:name:indent:maxDepth:maxItems:);;;Argument[2];log-injection",
108+
";;false;assert(_:_:file:line:);;;Argument[1];log-injection",
109+
";;false;assertionFailure(_:file:line:);;;Argument[0];log-injection",
110+
";;false;precondition(_:_:file:line:);;;Argument[1];log-injection",
111+
";;false;preconditionFailure(_:file:line:);;;Argument[0];log-injection",
108112
";;false;fatalError(_:file:line:);;;Argument[0];log-injection",
109113
";;false;NSLog(_:_:);;;Argument[0..1];log-injection",
110114
";;false;NSLogv(_:_:);;;Argument[0..1];log-injection",
111-
";;false;vfprintf(_:_:_:);;;Agument[1..2];log-injection",
115+
";;false;vfprintf(_:_:_:);;;Argument[1..2];log-injection",
112116
";Logger;true;log(_:);;;Argument[0];log-injection",
113117
";Logger;true;log(level:_:);;;Argument[1];log-injection",
114118
";Logger;true;trace(_:);;;Argument[1];log-injection",
@@ -119,6 +123,10 @@ private class LoggingSinks extends SinkModelCsv {
119123
";Logger;true;error(_:);;;Argument[1];log-injection",
120124
";Logger;true;critical(_:);;;Argument[1];log-injection",
121125
";Logger;true;fault(_:);;;Argument[1];log-injection",
126+
";;false;os_log(_:);;;Argument[0];log-injection",
127+
";;false;os_log(_:log:_:);;;Argument[2];log-injection",
128+
";;false;os_log(_:dso:log:_:_:);;;Argument[0,4];log-injection",
129+
";;false;os_log(_:dso:log:type:_:);;;Argument[0,4];log-injection",
122130
]
123131
}
124132
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ func test1(password: String, passwordHash : String, passphrase: String, pass_phr
159159
NSLog(pass_phrase) // $ hasCleartextLogging=159
160160

161161
os_log("%@", log: .default, type: .default, "") // safe
162-
os_log("%@", log: .default, type: .default, password) // $ MISSING: hasCleartextLogging=161
163-
os_log("%@ %@ %@", log: .default, type: .default, "", "", password) // $ MISSING: hasCleartextLogging=162
162+
os_log("%@", log: .default, type: .default, password) // $ hasCleartextLogging=162
163+
os_log("%@ %@ %@", log: .default, type: .default, "", "", password) // $ hasCleartextLogging=163
164164

165165
}
166166

0 commit comments

Comments
 (0)