Skip to content

Commit 197f036

Browse files
committed
Swift: Support local MaD steps in both dataflow and taintflow.
1 parent 9d069b3 commit 197f036

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ private module Cached {
147147
or
148148
// flow through `!`
149149
nodeFrom.asExpr() = nodeTo.asExpr().(ForceValueExpr).getSubExpr()
150+
or
151+
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, true)
150152
}
151153

152154
/**
@@ -160,7 +162,10 @@ private module Cached {
160162

161163
/** This is the local flow predicate that is exposed. */
162164
cached
163-
predicate localFlowStepImpl(Node nodeFrom, Node nodeTo) { localFlowStepCommon(nodeFrom, nodeTo) }
165+
predicate localFlowStepImpl(Node nodeFrom, Node nodeTo) {
166+
localFlowStepCommon(nodeFrom, nodeTo) or
167+
FlowSummaryImpl::Private::Steps::summaryThroughStepValue(nodeFrom, nodeTo, _)
168+
}
164169

165170
cached
166171
newtype TContentSet = TSingletonContent(Content c)
@@ -489,6 +494,8 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
489494
node2.(PostUpdateNode).getPreUpdateNode().asExpr() = ref.getBase() and
490495
c.isSingleton(any(Content::FieldContent ct | ct.getField() = ref.getMember()))
491496
)
497+
or
498+
FlowSummaryImpl::Private::Steps::summaryStoreStep(node1, c, node2)
492499
}
493500

494501
predicate isLValue(Expr e) { any(AssignExpr assign).getDest() = e }

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ private import TaintTrackingPublic
44
private import codeql.swift.dataflow.DataFlow
55
private import codeql.swift.dataflow.Ssa
66
private import codeql.swift.controlflow.CfgNodes
7+
private import FlowSummaryImpl as FlowSummaryImpl
78

89
/**
910
* Holds if `node` should be a sanitizer in all global taint flow configurations
@@ -57,6 +58,8 @@ private module Cached {
5758
nodeFrom.asExpr() = call.getAnArgument().getExpr() and
5859
nodeTo.asExpr() = call
5960
)
61+
or
62+
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, false)
6063
}
6164

6265
/**

0 commit comments

Comments
 (0)