Skip to content

Commit 24c9ab8

Browse files
committed
Swift: Fix MaD for methods
1 parent 1c8090f commit 24c9ab8

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

swift/ql/lib/codeql/swift/controlflow/CfgNodes.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ class ApplyExprCfgNode extends ExprCfgNode {
125125
}
126126

127127
AbstractFunctionDecl getStaticTarget() { result = e.getStaticTarget() }
128+
129+
Expr getFunction() { result = e.getFunction() }
128130
}
129131

130132
class CallExprCfgNode extends ApplyExprCfgNode {

swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ private import FlowSummaryImpl::Private
1111
private import FlowSummaryImpl::Public
1212
private import codeql.swift.dataflow.ExternalFlow
1313
private import codeql.swift.dataflow.FlowSummary as FlowSummary
14+
private import codeql.swift.controlflow.CfgNodes
1415

1516
class SummarizedCallableBase = AbstractFunctionDecl;
1617

@@ -153,7 +154,9 @@ class InterpretNode extends TInterpretNode {
153154
DataFlowCallable asCallable() { result.getUnderlyingCallable() = this.asElement() }
154155

155156
/** Gets the target of this call, if any. */
156-
AbstractFunctionDecl getCallTarget() { result = this.asCall().asCall().getStaticTarget() }
157+
AbstractFunctionDecl getCallTarget() {
158+
result = this.asCall().asCall().getFunction().(ApplyExpr).getStaticTarget()
159+
}
157160

158161
/** Gets a textual representation of this node. */
159162
string toString() {

swift/ql/src/queries/Security/CWE-079/UnsafeWebViewFetch.ql

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,6 @@ import codeql.swift.dataflow.DataFlow
1717
import codeql.swift.dataflow.TaintTracking
1818
import codeql.swift.dataflow.FlowSources
1919
import DataFlow::PathGraph
20-
import codeql.swift.frameworks.StandardLibrary.String
21-
22-
/**
23-
* A taint source that is `String(contentsOf:)`.
24-
* TODO: this shouldn't be needed when `StringSource` in `String.qll` is working.
25-
*/
26-
class StringContentsOfUrlSource extends RemoteFlowSource {
27-
StringContentsOfUrlSource() {
28-
exists(CallExpr call, AbstractFunctionDecl f |
29-
call.getFunction().(ApplyExpr).getStaticTarget() = f and
30-
f.getName() = "init(contentsOf:)" and
31-
f.getParam(0).getType().getName() = "URL" and
32-
this.asExpr() = call
33-
)
34-
}
35-
36-
override string getSourceType() { result = "" }
37-
}
3820

3921
/**
4022
* A sink that is a candidate result for this query, such as certain arguments

0 commit comments

Comments
 (0)