diff --git a/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/CInterop.qll b/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/CInterop.qll new file mode 100644 index 00000000000..ac7d5c5b67e --- /dev/null +++ b/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/CInterop.qll @@ -0,0 +1,12 @@ +/** + * Provides models for Swift "C Interoperability" functions. + */ + +import swift +private import codeql.swift.dataflow.ExternalFlow + +private class CInteropSummaries extends SummaryModelCsv { + override predicate row(string row) { + row = ";;false;getVaList(_:);;;Argument[0].ArrayElement;ReturnValue;value" + } +} diff --git a/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/StandardLibrary.qll b/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/StandardLibrary.qll index 93d60dba092..9d29277bc11 100644 --- a/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/StandardLibrary.qll +++ b/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/StandardLibrary.qll @@ -3,6 +3,7 @@ */ private import Array +private import CInterop private import Collection private import CustomUrlSchemes private import Data diff --git a/swift/ql/lib/codeql/swift/security/CleartextLoggingExtensions.qll b/swift/ql/lib/codeql/swift/security/CleartextLoggingExtensions.qll index 21bf855d1fc..a38fdbafbdd 100644 --- a/swift/ql/lib/codeql/swift/security/CleartextLoggingExtensions.qll +++ b/swift/ql/lib/codeql/swift/security/CleartextLoggingExtensions.qll @@ -94,7 +94,7 @@ private class LoggingSinks extends SinkModelCsv { ";;false;NSLog(_:_:);;;Argument[0];log-injection", ";;false;NSLog(_:_:);;;Argument[1].ArrayElement;log-injection", ";;false;NSLogv(_:_:);;;Argument[0];log-injection", - ";;false;NSLogv(_:_:);;;Argument[1].ArrayElement;log-injection", + ";;false;NSLogv(_:_:);;;Argument[1];log-injection", ";;false;vfprintf(_:_:_:);;;Agument[1..2];log-injection", ";Logger;true;log(_:);;;Argument[0];log-injection", ";Logger;true;log(level:_:);;;Argument[1];log-injection", diff --git a/swift/ql/test/query-tests/Security/CWE-312/cleartextLoggingTest.swift b/swift/ql/test/query-tests/Security/CWE-312/cleartextLoggingTest.swift index 8f8cd40c7cf..e1dd1a890cb 100644 --- a/swift/ql/test/query-tests/Security/CWE-312/cleartextLoggingTest.swift +++ b/swift/ql/test/query-tests/Security/CWE-312/cleartextLoggingTest.swift @@ -96,8 +96,8 @@ func test1(password: String, passwordHash : String, passphrase: String, pass_phr NSLog("%@", password as! CVarArg) // $ MISSING: hasCleartextLogging=96 NSLog("%@ %@", "" as! CVarArg, password as! CVarArg) // $ MISSING: hasCleartextLogging=97 NSLog("\(password)") // $ hasCleartextLogging=98 - NSLogv("%@", getVaList([password as! CVarArg])) // $ MISSING: hasCleartextLogging=99 - NSLogv("%@ %@", getVaList(["" as! CVarArg, password as! CVarArg])) // $ MISSING: hasCleartextLogging=100 + NSLogv("%@", getVaList([password as! CVarArg])) // $ hasCleartextLogging=99 + NSLogv("%@ %@", getVaList(["" as! CVarArg, password as! CVarArg])) // $ hasCleartextLogging=100 NSLog(passwordHash) // SAfe NSLogv("%@", getVaList([passwordHash as! CVarArg])) // Safe