Skip to content

Commit 7fad4dc

Browse files
committed
Java: Adapt to FlowSummaryImpl changes
1 parent af079ff commit 7fad4dc

2 files changed

Lines changed: 50 additions & 18 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/FlowSummaryImpl.qll

Lines changed: 48 additions & 16 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,40 @@ 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+
128+
bindingset[source, s]
129+
SourceSinkReportingElement getSourceEntryElement(
130+
Impl::Public::SourceElement source, Impl::Private::SummaryComponentStack s
131+
) {
132+
none()
133+
}
134+
135+
bindingset[e, s]
136+
Node getSourceExitNode(SourceSinkReportingElement e, Impl::Private::SummaryComponentStack s) {
137+
none()
138+
}
139+
140+
SourceSinkReportingElement getSinkExitElement(
141+
Impl::Public::SinkElement sink, Impl::Private::SummaryComponent sc
142+
) {
143+
none()
144+
}
145+
146+
bindingset[e, sc]
147+
Node getSinkEntryNode(SourceSinkReportingElement e, Impl::Private::SummaryComponent sc) { none() }
148+
}
149+
150+
private import Impl::Private::Make2<Input2> as Impl2
151+
152+
private module TypesInput implements Impl2::TypesInputSig {
114153
DataFlowType getSyntheticGlobalType(Impl::Private::SyntheticGlobal sg) {
115154
exists(sg) and
116155
result instanceof TypeObject
@@ -145,20 +184,12 @@ private module TypesInput implements Impl::Private::TypesInputSig {
145184
DataFlowType getSinkType(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { none() }
146185
}
147186

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

153190
DataFlowCall getACall(Public::SummarizedCallable sc) {
154191
sc = viableCallable(result).asSummarizedCallable()
155192
}
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() }
162193
}
163194

164195
private predicate relatedArgSpec(Callable c, string spec) {
@@ -372,9 +403,10 @@ module SourceSinkInterpretationInput implements
372403

373404
module Private {
374405
import Impl::Private
375-
import Impl::Private::Types<TypesInput>
406+
import Impl2
407+
import Types<TypesInput>
376408

377-
module Steps = Impl::Private::Steps<StepsInput>;
409+
module Steps = Impl2::Steps<StepsInput>;
378410

379411
module External {
380412
import Impl::Private::External

0 commit comments

Comments
 (0)