mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #12941 from geoffw0/textsource
Swift: Add taint sources for UITextField
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
* This file imports all models of frameworks and libraries.
|
||||
*/
|
||||
|
||||
private import StandardLibrary.StandardLibrary
|
||||
private import Xml.Xml
|
||||
private import Alamofire.Alamofire
|
||||
private import StandardLibrary.StandardLibrary
|
||||
private import UIKit.UIKit
|
||||
private import Xml.Xml
|
||||
|
||||
5
swift/ql/lib/codeql/swift/frameworks/UIKit/UIKit.qll
Normal file
5
swift/ql/lib/codeql/swift/frameworks/UIKit/UIKit.qll
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* This file imports all models of UIKit-related frameworks and libraries.
|
||||
*/
|
||||
|
||||
import UITextField
|
||||
15
swift/ql/lib/codeql/swift/frameworks/UIKit/UITextField.qll
Normal file
15
swift/ql/lib/codeql/swift/frameworks/UIKit/UITextField.qll
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Provides models for the `UITextField` Swift class.
|
||||
*/
|
||||
|
||||
import swift
|
||||
private import codeql.swift.dataflow.ExternalFlow
|
||||
|
||||
/**
|
||||
* A model for `UITextField` members that are flow sources.
|
||||
*/
|
||||
private class UITextFieldSource extends SourceModelCsv {
|
||||
override predicate row(string row) {
|
||||
row = [";UITextField;true;text;;;;local", ";UITextField;true;attributedText;;;;local"]
|
||||
}
|
||||
}
|
||||
33
swift/ql/test/library-tests/dataflow/flowsources/uikit.swift
Normal file
33
swift/ql/test/library-tests/dataflow/flowsources/uikit.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
// --- stubs ---
|
||||
|
||||
class NSObject { }
|
||||
class NSAttributedString: NSObject {}
|
||||
class UIResponder: NSObject {}
|
||||
class UIView: UIResponder {}
|
||||
class UIControl: UIView {}
|
||||
class UITextField: UIControl {
|
||||
var text: String? {
|
||||
get { nil }
|
||||
set { }
|
||||
}
|
||||
var attributedText: NSAttributedString? {
|
||||
get { nil }
|
||||
set { }
|
||||
}
|
||||
var placeholder: String? {
|
||||
get { nil }
|
||||
set { }
|
||||
}
|
||||
}
|
||||
class UISearchTextField : UITextField {
|
||||
}
|
||||
|
||||
// --- tests ---
|
||||
|
||||
func testUITextField(textField: UITextField, searchTextField: UISearchTextField) {
|
||||
_ = textField.text // $ source=local
|
||||
_ = textField.attributedText // $ source=local
|
||||
_ = textField.placeholder // GOOD (not input)
|
||||
_ = textField.text?.uppercased() // $ source=local
|
||||
_ = searchTextField.text // $ source=local
|
||||
}
|
||||
Reference in New Issue
Block a user