Skip to content

Commit 7916bd3

Browse files
committed
Swift: Generalize 'write' models.
1 parent 09974b5 commit 7916bd3

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ private import Numeric
2020
private import PointerTypes
2121
private import Sequence
2222
private import Set
23+
private import Stream
2324
private import String
2425
private import Url
2526
private import UrlSession
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Provides models for `TextOutputStream` and related Swift classes.
3+
*/
4+
5+
import swift
6+
private import codeql.swift.dataflow.ExternalFlow
7+
8+
/**
9+
* A model for members of `TextOutputStream` and similar classes that permit taint flow.
10+
*/
11+
private class StringSummaries extends SummaryModelCsv {
12+
override predicate row(string row) {
13+
row =
14+
[
15+
";TextOutputStream;true;write(_:);;;Argument[0];Argument[-1];taint",
16+
";TextOutputStreamable;true;write(to:);;;Argument[-1];Argument[0];taint",
17+
]
18+
}
19+
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ private class StringSummaries extends SummaryModelCsv {
111111
";String;true;init(validatingPlatformString:);;;Argument[0].CollectionElement;ReturnValue.OptionalSome;taint",
112112
";String;true;localizedStringWithFormat(_:_:);;;Argument[0];ReturnValue;taint",
113113
";String;true;localizedStringWithFormat(_:_:);;;Argument[1].CollectionElement;ReturnValue;taint",
114-
";String;true;write(_:);;;Argument[0];Argument[-1];taint",
115-
";String;true;write(to:);;;Argument[-1];Argument[0];taint",
116114
";String;true;insert(contentsOf:at:);;;Argument[0];Argument[-1];taint",
117115
";String;true;replaceSubrange(_:with:);;;Argument[1];Argument[-1];taint",
118116
";String;true;max();;;Argument[-1];ReturnValue;taint",

0 commit comments

Comments
 (0)