Skip to content

Commit ebf7231

Browse files
committed
Swift: Make the 'completePath' models work.
1 parent 9b5556e commit ebf7231

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

swift/ql/lib/codeql/swift/frameworks/StandardLibrary/NsString.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ private class NsStringSummaries extends SummaryModelCsv {
103103
";NSString;true;data(using:);;;Argument[-1];ReturnValue;taint",
104104
";NSString;true;data(using:allowLossyConversion:);;;Argument[-1];ReturnValue;taint",
105105
";NSString;true;path(withComponents:);;;Argument[0];ReturnValue;taint",
106-
";NSString;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[0];taint",
107-
";NSString;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[2];taint",
106+
";NSString;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[0].CollectionElement;taint",
107+
";NSString;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[2].CollectionElement.CollectionElement;taint",
108108
";NSString;true;getFileSystemRepresentation(_:maxLength:);;;Argument[-1];Argument[0];taint",
109109
";NSString;true;appendingPathComponent(_:);;;Argument[-1..0];ReturnValue;taint",
110110
";NSString;true;appendingPathComponent(_:conformingTo:);;;Argument[-1..0];ReturnValue;taint",

swift/ql/lib/codeql/swift/frameworks/StandardLibrary/String.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ private class StringSummaries extends SummaryModelCsv {
4545
";StringProtocol;true;applyingTransform(_:reverse:);;;Argument[-1];ReturnValue;taint",
4646
";StringProtocol;true;cString(using:);;;Argument[-1];ReturnValue;taint",
4747
";StringProtocol;true;capitalized(with:);;;Argument[-1];ReturnValue;taint",
48-
";StringProtocol;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[0].OptionalSome.CollectionElement;taint",
49-
";StringProtocol;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[2].OptionalSome.CollectionElement.CollectionElement;taint",
48+
";StringProtocol;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[0].CollectionElement;taint",
49+
";StringProtocol;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[2].CollectionElement.CollectionElement;taint",
5050
";StringProtocol;true;components(separatedBy:);;;Argument[-1];ReturnValue;taint",
5151
";StringProtocol;true;data(using:allowLossyConversion:);;;Argument[-1];ReturnValue;taint",
5252
";StringProtocol;true;folding(options:locale:);;;Argument[-1];ReturnValue;taint",

swift/ql/test/query-tests/Security/CWE-022/testPathInjection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ func testPathInjection2(s1: UnsafeMutablePointer<String>, s2: UnsafeMutablePoint
479479

480480
_ = remoteString.completePath(into: s3, caseSensitive: false, matchesInto: nil, filterTypes: nil)
481481
_ = NSData().write(toFile: s3.pointee, atomically: true) // $ MISSING: hasPathInjection=445
482-
_ = NSData().write(toFile: s3[0], atomically: true) // $ MISSING: hasPathInjection=445
482+
_ = NSData().write(toFile: s3[0], atomically: true) // $ hasPathInjection=445
483483

484484
_ = fm.fileAttributes(atPath: remoteString, traverseLink: true) // $ hasPathInjection=445
485485
_ = try fm.attributesOfItem(atPath: remoteString) // $ hasPathInjection=445

0 commit comments

Comments
 (0)