Skip to content

Commit e16277e

Browse files
committed
Swift: Add source model for UITextField.
1 parent 22507c1 commit e16277e

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ private import internal.FlowSummaryImplSpecific
7979
* ensuring that they are visible to the taint tracking / data flow library.
8080
*/
8181
private module Frameworks {
82+
private import codeql.swift.frameworks.Alamofire.Alamofire
8283
private import codeql.swift.frameworks.StandardLibrary.Collection
8384
private import codeql.swift.frameworks.StandardLibrary.CustomUrlSchemes
8485
private import codeql.swift.frameworks.StandardLibrary.Data
@@ -94,7 +95,7 @@ private module Frameworks {
9495
private import codeql.swift.frameworks.StandardLibrary.Url
9596
private import codeql.swift.frameworks.StandardLibrary.UrlSession
9697
private import codeql.swift.frameworks.StandardLibrary.WebView
97-
private import codeql.swift.frameworks.Alamofire.Alamofire
98+
private import codeql.swift.frameworks.UIKit.UITextField
9899
private import codeql.swift.security.CleartextLoggingExtensions
99100
private import codeql.swift.security.CleartextStorageDatabaseExtensions
100101
private import codeql.swift.security.ECBEncryptionExtensions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Provides models for the `UITextField` Swift class.
3+
*/
4+
5+
import swift
6+
private import codeql.swift.dataflow.ExternalFlow
7+
8+
/**
9+
* A model for `UITextField` members that are flow sources.
10+
*/
11+
private class UITextFieldSource extends SourceModelCsv {
12+
override predicate row(string row) {
13+
row = [";UITextField;true;text;;;;local", ";UITextField;true;attributedText;;;;local"]
14+
}
15+
}

swift/ql/test/library-tests/dataflow/flowsources/uikit.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class UITextField: UIControl {
2323
// --- tests ---
2424

2525
func testUITextField(textField: UITextField) {
26-
_ = textField.text // $ MISSING: source=local
27-
_ = textField.attributedText // $ MISSING: source=local
26+
_ = textField.text // $ source=local
27+
_ = textField.attributedText // $ source=local
2828
_ = textField.placeholder // GOOD (not input)
29-
_ = textField.text?.uppercased() // $ MISSING: source=local
29+
_ = textField.text?.uppercased() // $ source=local
3030
}

0 commit comments

Comments
 (0)