Skip to content

Commit 43b234e

Browse files
committed
Switch to MaD models for UISceneDelegate methods
1 parent f7cc5f9 commit 43b234e

File tree

2 files changed

+12
-47
lines changed

2 files changed

+12
-47
lines changed

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

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ private class CustomUrlRemoteFlowSource extends SourceModelCsv {
1919
// Use dictionary value contents when available.
2020
// ";UIApplicationDelegate;true;application(_:didFinishLaunchingWithOptions:);;;Parameter[1].MapValue;remote",
2121
// ";UIApplicationDelegate;true;application(_:willFinishLaunchingWithOptions:);;;Parameter[1].MapValue;remote"
22-
// TODO 2: MaD doesn't seem to take into account extensions adopting to protocols even if the subtypes column is set to true.
23-
// ";UIWindowSceneDelegate;true;scene(_:continue:);;;Parameter[1];remote",
24-
// ";UIWindowSceneDelegate;true;scene(_:didUpdate:);;;Parameter[1];remote",
25-
// ";UIWindowSceneDelegate;true;scene(_:openURLContexts:);;;Parameter[1];remote",
26-
// ";UIWindowSceneDelegate;true;scene(_:willConnectTo:options:);;;Parameter[2];remote"
22+
";UISceneDelegate;true;scene(_:continue:);;;Parameter[1];remote",
23+
";UISceneDelegate;true;scene(_:didUpdate:);;;Parameter[1];remote",
24+
";UISceneDelegate;true;scene(_:openURLContexts:);;;Parameter[1];remote",
25+
";UISceneDelegate;true;scene(_:willConnectTo:options:);;;Parameter[2];remote"
2726
]
2827
}
2928
}
@@ -63,40 +62,6 @@ private class LaunchOptionsUrlVarDecl extends VarDecl {
6362
}
6463
}
6564

66-
/** A type or extension declaration adopting the protocol `UISceneDelegate`. */
67-
private class AdoptingUiSceneDelegate extends Decl {
68-
AdoptingUiSceneDelegate() {
69-
exists(ProtocolDecl delegate |
70-
this.(ExtensionDecl).getAProtocol().getABaseTypeDecl*() = delegate or
71-
this.(ClassOrStructDecl).getABaseTypeDecl*() = delegate
72-
|
73-
delegate.getName() = "UISceneDelegate"
74-
)
75-
}
76-
}
77-
78-
/**
79-
* An `OpenURLContexts`, `NSUserActivity`, or `ConnectionOptions` parameter of a `scene` method
80-
* declared in a type adopting `UISceneDelegate`.
81-
*/
82-
// This is a temporary workaround until the TODO 2 above is addressed.
83-
private class UiSceneDelegateSource extends RemoteFlowSource {
84-
UiSceneDelegateSource() {
85-
exists(FuncDecl f, ParamDecl p, AdoptingUiSceneDelegate d |
86-
f.getName() = "scene(_:" + ["continue", "didUpdate", "openURLContexts"] + ":)" and
87-
p = f.getParam(1)
88-
or
89-
f.getName() = "scene(_:willConnectTo:options:)" and
90-
p = f.getParam(2)
91-
|
92-
f.getEnclosingDecl() = d and
93-
this.(DataFlow::ParameterNode).getParameter() = p
94-
)
95-
}
96-
97-
override string getSourceType() { result = "Remote data in UIWindowSceneDelegate.scene" }
98-
}
99-
10065
/**
10166
* A content implying that, if a `UIOpenURLContext` is tainted, then its field `url` is also tainted.
10267
*/

swift/ql/test/library-tests/dataflow/flowsources/FlowSources.expected

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
| customurlschemes.swift:61:52:61:62 | url | external |
2323
| customurlschemes.swift:66:9:66:28 | ...[...] | Remote URL in UIApplicationDelegate.application.launchOptions |
2424
| customurlschemes.swift:71:9:71:28 | ...[...] | Remote URL in UIApplicationDelegate.application.launchOptions |
25-
| customurlschemes.swift:77:59:77:76 | options | Remote data in UIWindowSceneDelegate.scene |
26-
| customurlschemes.swift:78:28:78:38 | continue | Remote data in UIWindowSceneDelegate.scene |
27-
| customurlschemes.swift:79:28:79:39 | didUpdate | Remote data in UIWindowSceneDelegate.scene |
28-
| customurlschemes.swift:80:28:80:65 | openURLContexts | Remote data in UIWindowSceneDelegate.scene |
29-
| customurlschemes.swift:86:59:86:76 | options | Remote data in UIWindowSceneDelegate.scene |
30-
| customurlschemes.swift:87:28:87:38 | continue | Remote data in UIWindowSceneDelegate.scene |
31-
| customurlschemes.swift:88:28:88:39 | didUpdate | Remote data in UIWindowSceneDelegate.scene |
32-
| customurlschemes.swift:89:28:89:65 | openURLContexts | Remote data in UIWindowSceneDelegate.scene |
25+
| customurlschemes.swift:77:59:77:76 | options | external |
26+
| customurlschemes.swift:78:28:78:38 | continue | external |
27+
| customurlschemes.swift:79:28:79:39 | didUpdate | external |
28+
| customurlschemes.swift:80:28:80:65 | openURLContexts | external |
29+
| customurlschemes.swift:86:59:86:76 | options | external |
30+
| customurlschemes.swift:87:28:87:38 | continue | external |
31+
| customurlschemes.swift:88:28:88:39 | didUpdate | external |
32+
| customurlschemes.swift:89:28:89:65 | openURLContexts | external |
3333
| data.swift:18:20:18:54 | call to Data.init(contentsOf:options:) | external |
3434
| file://:0:0:0:0 | .data | external |
3535
| file://:0:0:0:0 | .result | external |

0 commit comments

Comments
 (0)