Skip to content

Commit 61ebe22

Browse files
committed
JS: Adapt to FlowSummaryImpl changes
1 parent 7fad4dc commit 61ebe22

4 files changed

Lines changed: 63 additions & 17 deletions

File tree

javascript/ql/lib/semmle/javascript/dataflow/internal/DataFlowPrivate.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class FlowSummaryNode extends DataFlow::Node, TFlowSummaryNode {
6565

6666
cached
6767
override string toString() { result = this.getSummaryNode().toString() }
68+
69+
override Location getLocation() { result = this.getSummaryNode().getLocation() }
6870
}
6971

7072
class FlowSummaryDynamicParameterArrayNode extends DataFlow::Node,
@@ -541,7 +543,7 @@ predicate isArgumentNode(ArgumentNode n, DataFlowCall call, ArgumentPosition pos
541543
DataFlowCallable nodeGetEnclosingCallable(Node node) {
542544
result.asSourceCallable() = node.getContainer()
543545
or
544-
result.asLibraryCallable() = node.(FlowSummaryNode).getSummarizedCallable()
546+
result = node.(FlowSummaryNode).getSummaryNode().getEnclosingCallable()
545547
or
546548
result.asLibraryCallable() = node.(FlowSummaryDynamicParameterArrayNode).getSummarizedCallable()
547549
or

javascript/ql/lib/semmle/javascript/dataflow/internal/FlowSummaryPrivate.qll

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,28 @@ private import sharedlib.FlowSummaryImpl::Private as Private
1212
private import sharedlib.FlowSummaryImpl::Public
1313
private import codeql.dataflow.internal.AccessPathSyntax as AccessPathSyntax
1414
private import semmle.javascript.internal.flow_summaries.ExceptionFlow
15+
private import codeql.util.Void
1516

1617
/**
1718
* A class of callables that are candidates for flow summary modeling.
1819
*/
19-
class SummarizedCallableBase = string;
20+
class SummarizedCallableBase extends string {
21+
bindingset[this]
22+
SummarizedCallableBase() { exists(this) }
2023

21-
class SourceBase extends Unit {
22-
SourceBase() { none() }
24+
Location getLocation() { none() }
2325
}
2426

25-
class SinkBase extends Unit {
26-
SinkBase() { none() }
27+
class SourceBase extends Void {
28+
Location getLocation() { none() }
29+
}
30+
31+
class SinkBase = SourceBase;
32+
33+
class FlowSummaryCallBase = SourceBase;
34+
35+
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
36+
result.asLibraryCallable() = c
2737
}
2838

2939
/** Gets the parameter position representing a callback itself, if any. */
@@ -141,8 +151,41 @@ string encodeArgumentPosition(ArgumentPosition pos) {
141151
/** Gets the return kind corresponding to specification `"ReturnValue"`. */
142152
ReturnKind getStandardReturnValueKind() { result = MkNormalReturnKind() and Stage::ref() }
143153

144-
private module FlowSummaryStepInput implements Private::StepsInputSig {
145-
Private::SummaryNode getSummaryNode(DataFlow::Node n) {
154+
private module Input2 implements Private::InputSig2 {
155+
private import codeql.util.Void
156+
157+
class SourceSinkReportingElement extends Void {
158+
Location getLocation() { none() }
159+
160+
DataFlowCallable getEnclosingCallable() { none() }
161+
}
162+
163+
bindingset[source, s]
164+
SourceSinkReportingElement getSourceEntryElement(
165+
SourceElement source, Private::SummaryComponentStack s
166+
) {
167+
none()
168+
}
169+
170+
bindingset[e, s]
171+
DataFlow::Node getSourceExitNode(SourceSinkReportingElement e, Private::SummaryComponentStack s) {
172+
none()
173+
}
174+
175+
SourceSinkReportingElement getSinkExitElement(SinkElement sink, Private::SummaryComponent sc) {
176+
none()
177+
}
178+
179+
bindingset[e, sc]
180+
DataFlow::Node getSinkEntryNode(SourceSinkReportingElement e, Private::SummaryComponent sc) {
181+
none()
182+
}
183+
}
184+
185+
import Private::Make2<Input2> as Impl2
186+
187+
private module FlowSummaryStepInput implements Impl2::StepsInputSig {
188+
Impl2::SummaryNode getSummaryNode(DataFlow::Node n) {
146189
result = n.(FlowSummaryNode).getSummaryNode()
147190
}
148191

@@ -156,12 +199,6 @@ private module FlowSummaryStepInput implements Private::StepsInputSig {
156199
]
157200
)
158201
}
159-
160-
DataFlowCallable getSourceNodeEnclosingCallable(SourceBase source) { none() }
161-
162-
DataFlow::Node getSourceNode(SourceBase source, Private::SummaryComponentStack s) { none() }
163-
164-
DataFlow::Node getSinkNode(SinkBase sink, Private::SummaryComponent sc) { none() }
165202
}
166203

167204
module Steps = Private::Steps<FlowSummaryStepInput>;

javascript/ql/lib/semmle/javascript/dataflow/internal/sharedlib/DataFlowArg.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ module JSFlowSummary implements FlowSummaryImpl::InputSig<Location, JSDataFlow>
2929
private import semmle.javascript.dataflow.internal.FlowSummaryPrivate as FlowSummaryPrivate
3030
import FlowSummaryPrivate
3131

32-
class FlowSummaryCallBase = Void;
33-
3432
overlay[local]
3533
predicate callableFromSource(SummarizedCallableBase c) { none() }
3634

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
private import semmle.javascript.Locations
22
private import codeql.dataflow.internal.FlowSummaryImpl
33
private import DataFlowArg
4-
import Make<Location, JSDataFlow, JSFlowSummary>
4+
private import semmle.javascript.dataflow.internal.FlowSummaryPrivate as Priv
5+
6+
private module Impl = Make<Location, JSDataFlow, JSFlowSummary>;
7+
8+
module Private {
9+
import Impl::Private
10+
import Priv::Impl2
11+
}
12+
13+
module Public = Impl::Public;

0 commit comments

Comments
 (0)