Skip to content

Commit c87abcd

Browse files
committed
Java: Adapt to FlowSummaryImpl changes
1 parent 47b59d9 commit c87abcd

6 files changed

Lines changed: 36 additions & 30 deletions

File tree

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowNodes.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ module Private {
439439
result.asCallable() = n.(ImplicitInstanceAccess).getInstanceAccess().getEnclosingCallable() or
440440
result.asCallable() = n.(MallocNode).getClassInstanceExpr().getEnclosingCallable() or
441441
result = nodeGetEnclosingCallable(n.(ImplicitPostUpdateNode).getPreUpdateNode()) or
442-
result.asSummarizedCallable() = n.(FlowSummaryNode).getSummarizedCallable() or
442+
result = n.(FlowSummaryNode).getSummaryNode().getEnclosingCallable() or
443443
result.asCallable() = n.(CaptureNode).getSynthesizedCaptureNode().getEnclosingCallable() or
444444
result.asFieldScope() = n.(FieldValueNode).getField() or
445445
result.asCallable() = any(Expr e | n.(AdditionalNode).nodeAt(e, _)).getEnclosingCallable() or
@@ -531,7 +531,7 @@ module Private {
531531
result = this.getSummaryNode().getSummarizedCallable()
532532
}
533533

534-
override Location getLocation() { result = this.getSummarizedCallable().getLocation() }
534+
override Location getLocation() { result = this.getSummaryNode().getLocation() }
535535

536536
override string toString() { result = this.getSummaryNode().toString() }
537537

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ predicate jumpStep(Node node1, Node node2) {
199199
any(AdditionalValueStep a).step(node1, node2) and
200200
node1.getEnclosingCallable() != node2.getEnclosingCallable()
201201
or
202-
FlowSummaryImpl::Private::Steps::summaryJumpStep(node1.(FlowSummaryNode).getSummaryNode(),
203-
node2.(FlowSummaryNode).getSummaryNode())
202+
FlowSummaryImpl::Private::Steps::summaryJumpStep(node1, node2)
204203
}
205204

206205
/**

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowUtil.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ private predicate simpleLocalFlowStep0(Node node1, Node node2, string model) {
247247
or
248248
cloneStep(node1, node2) and model = "CloneStep"
249249
or
250-
FlowSummaryImpl::Private::Steps::summaryLocalStep(node1, node2.(FlowSummaryNode).getSummaryNode(),
251-
true, model)
250+
FlowSummaryImpl::Private::Steps::summaryLocalStep(node1, node2, true, model)
252251
}
253252

254253
/**

java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@ module Input implements InputSig<Location, DataFlowImplSpecific::JavaDataFlow> {
3737
sc.asCallable() = any(Callable c | c.fromSource() and not c.isStub())
3838
}
3939

40-
class SourceBase = Void;
40+
class SourceBase extends Void {
41+
Location getLocation() { none() }
42+
}
43+
44+
class SinkBase = SourceBase;
4145

42-
class SinkBase = Void;
46+
class FlowSummaryCallBase = SourceBase;
4347

44-
class FlowSummaryCallBase = Void;
48+
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
49+
result.asSummarizedCallable() = c
50+
}
4551

4652
predicate neutralElement(
4753
Input::SummarizedCallableBase c, string kind, string provenance, boolean isExact
@@ -110,7 +116,21 @@ module Input implements InputSig<Location, DataFlowImplSpecific::JavaDataFlow> {
110116

111117
private import Make<Location, DataFlowImplSpecific::JavaDataFlow, Input> as Impl
112118

113-
private module TypesInput implements Impl::Private::TypesInputSig {
119+
private module Input2 implements Impl::Private::InputSig2 {
120+
private import codeql.util.Void
121+
122+
class SourceSinkReportingElement extends Void {
123+
Location getLocation() { none() }
124+
125+
DataFlowCallable getEnclosingCallable() { none() }
126+
127+
SourceSinkReportingElement getASuccessor(Impl::Private::SummaryComponent sc) { none() }
128+
}
129+
}
130+
131+
private import Impl::Private::Make2<Input2> as Impl2
132+
133+
private module TypesInput implements Impl2::TypesInputSig {
114134
DataFlowType getSyntheticGlobalType(Impl::Private::SyntheticGlobal sg) {
115135
exists(sg) and
116136
result instanceof TypeObject
@@ -138,27 +158,15 @@ private module TypesInput implements Impl::Private::TypesInputSig {
138158
exists(rk)
139159
}
140160

141-
DataFlowType getSourceType(Input::SourceBase source, Impl::Private::SummaryComponentStack s) {
142-
none()
143-
}
144-
145-
DataFlowType getSinkType(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { none() }
161+
DataFlowType getSourceSinkType(Input2::SourceSinkReportingElement e) { none() }
146162
}
147163

148-
private module StepsInput implements Impl::Private::StepsInputSig {
149-
Impl::Private::SummaryNode getSummaryNode(Node n) {
150-
result = n.(FlowSummaryNode).getSummaryNode()
151-
}
164+
private module StepsInput implements Impl2::StepsInputSig {
165+
Impl2::SummaryNode getSummaryNode(Node n) { result = n.(FlowSummaryNode).getSummaryNode() }
152166

153167
DataFlowCall getACall(Public::SummarizedCallable sc) {
154168
sc = viableCallable(result).asSummarizedCallable()
155169
}
156-
157-
DataFlowCallable getSourceNodeEnclosingCallable(Input::SourceBase source) { none() }
158-
159-
Node getSourceNode(Input::SourceBase source, Impl::Private::SummaryComponentStack s) { none() }
160-
161-
Node getSinkNode(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { none() }
162170
}
163171

164172
private predicate relatedArgSpec(Callable c, string spec) {
@@ -372,9 +380,10 @@ module SourceSinkInterpretationInput implements
372380

373381
module Private {
374382
import Impl::Private
375-
import Impl::Private::Types<TypesInput>
383+
import Impl2
384+
import Types<TypesInput>
376385

377-
module Steps = Impl::Private::Steps<StepsInput>;
386+
module Steps = Impl2::Steps<StepsInput>;
378387

379388
module External {
380389
import Impl::Private::External

java/ql/lib/semmle/code/java/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ private module Cached {
145145
)
146146
)
147147
or
148-
FlowSummaryImpl::Private::Steps::summaryLocalStep(src,
149-
sink.(DataFlowPrivate::FlowSummaryNode).getSummaryNode(), false, model)
148+
FlowSummaryImpl::Private::Steps::summaryLocalStep(src, sink, false, model)
150149
}
151150

152151
/**

java/ql/test/library-tests/dataflow/local-additional-taint/localAdditionalTaintStep.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ predicate taintFlowUpdate(DataFlow::ParameterNode p1, DataFlow::ParameterNode p2
1313
}
1414

1515
predicate summaryStep(FlowSummaryNode src, FlowSummaryNode sink) {
16-
FlowSummaryImpl::Private::Steps::summaryLocalStep(src, sink.getSummaryNode(), false, _) or
16+
FlowSummaryImpl::Private::Steps::summaryLocalStep(src, sink, false, _) or
1717
FlowSummaryImpl::Private::Steps::summaryReadStep(src.getSummaryNode(), _, sink.getSummaryNode()) or
1818
FlowSummaryImpl::Private::Steps::summaryStoreStep(src.getSummaryNode(), _, sink.getSummaryNode())
1919
}

0 commit comments

Comments
 (0)