Skip to content

Commit 9dfebe3

Browse files
committed
Rename {Source,Sink}Node to {Source,Sink}Element
1 parent 1b31c90 commit 9dfebe3

File tree

5 files changed

+64
-60
lines changed

5 files changed

+64
-60
lines changed

rust/ql/lib/codeql/rust/dataflow/FlowSink.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private module Sinks {
1313
/** Provides the `Range` class used to define the extent of `FlowSink`. */
1414
module FlowSink {
1515
/** A flow source. */
16-
abstract class Range extends Impl::Public::SinkNode {
16+
abstract class Range extends Impl::Public::SinkElement {
1717
bindingset[this]
1818
Range() { any() }
1919

rust/ql/lib/codeql/rust/dataflow/FlowSource.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private module Sources {
1313
/** Provides the `Range` class used to define the extent of `FlowSource`. */
1414
module FlowSource {
1515
/** A flow source. */
16-
abstract class Range extends Impl::Public::SourceNode {
16+
abstract class Range extends Impl::Public::SourceElement {
1717
bindingset[this]
1818
Range() { any() }
1919

rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ module Node {
191191
result = this.getSummaryNode().getSummarizedCallable()
192192
}
193193

194-
/** Gets the source node that this node belongs to, if any */
195-
FlowSummaryImpl::Public::SourceNode getSourceNode() {
196-
result = this.getSummaryNode().getSourceNode()
194+
/** Gets the AST source node that this node belongs to, if any */
195+
FlowSummaryImpl::Public::SourceElement getSourceElement() {
196+
result = this.getSummaryNode().getSourceElement()
197197
}
198198

199-
/** Gets the sink node that this node belongs to, if any */
200-
FlowSummaryImpl::Public::SinkNode getSinkNode() { result = this.getSummaryNode().getSinkNode() }
199+
/** Gets the AST sink node that this node belongs to, if any */
200+
FlowSummaryImpl::Public::SinkElement getSinkElement() {
201+
result = this.getSummaryNode().getSinkElement()
202+
}
201203

202204
/** Holds is this node is a source node of kind `kind`. */
203205
predicate isSource(string kind) {
@@ -210,9 +212,9 @@ module Node {
210212
}
211213

212214
override CfgScope getCfgScope() {
213-
result = this.getSummaryNode().getSourceNode().getEnclosingCfgScope()
215+
result = this.getSummaryNode().getSourceElement().getEnclosingCfgScope()
214216
or
215-
result = this.getSummaryNode().getSinkNode().getEnclosingCfgScope()
217+
result = this.getSummaryNode().getSinkElement().getEnclosingCfgScope()
216218
}
217219

218220
override DataFlowCallable getEnclosingCallable() {
@@ -225,9 +227,9 @@ module Node {
225227
exists(this.getSummarizedCallable()) and
226228
result instanceof EmptyLocation
227229
or
228-
result = this.getSourceNode().getLocation()
230+
result = this.getSourceElement().getLocation()
229231
or
230-
result = this.getSinkNode().getLocation()
232+
result = this.getSinkElement().getLocation()
231233
}
232234

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

rust/ql/lib/utils/test/InlineFlowTest.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private module FlowTestImpl implements InputSig<Location, RustDataFlow> {
3434
or
3535
sourceNode(src, _) and
3636
exists(CallExprBase call |
37-
call = src.(Node::FlowSummaryNode).getSourceNode().getCall() and
37+
call = src.(Node::FlowSummaryNode).getSourceElement().getCall() and
3838
result = call.getArgList().getArg(0).toString()
3939
)
4040
}

shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,10 @@ module Make<
295295
predicate hasExactModel() { none() }
296296
}
297297

298-
/** A source node. */
299-
abstract class SourceNode extends SourceBaseFinal {
298+
/** A source element. */
299+
abstract class SourceElement extends SourceBaseFinal {
300300
bindingset[this]
301-
SourceNode() { any() }
301+
SourceElement() { any() }
302302

303303
/**
304304
* Holds if this element is a flow source of kind `kind`, where data
@@ -308,10 +308,10 @@ module Make<
308308
abstract predicate isSource(string output, string kind, Provenance provenance, string model);
309309
}
310310

311-
/** A sink node. */
312-
abstract class SinkNode extends SinkBaseFinal {
311+
/** A sink element. */
312+
abstract class SinkElement extends SinkBaseFinal {
313313
bindingset[this]
314-
SinkNode() { any() }
314+
SinkElement() { any() }
315315

316316
/**
317317
* Holds if this element is a flow sink of kind `kind`, where data
@@ -537,9 +537,9 @@ module Make<
537537
c.propagatesFlow(_, spec, _, _)
538538
)
539539
or
540-
any(SourceNode s).isSource(spec, _, _, _)
540+
any(SourceElement s).isSource(spec, _, _, _)
541541
or
542-
any(SinkNode s).isSink(spec, _, _, _)
542+
any(SinkElement s).isSink(spec, _, _, _)
543543
}
544544

545545
import AccessPathSyntax::AccessPath<summarySpec/1>
@@ -891,7 +891,7 @@ module Make<
891891

892892
pragma[nomagic]
893893
private predicate sourceOutputStateEntry(
894-
SourceNode source, SummaryComponentStack s, string kind, string model
894+
SourceElement source, SummaryComponentStack s, string kind, string model
895895
) {
896896
exists(string outSpec |
897897
source.isSource(outSpec, kind, _, model) and
@@ -901,7 +901,7 @@ module Make<
901901

902902
pragma[nomagic]
903903
private predicate sourceOutputState(
904-
SourceNode source, SummaryComponentStack s, string kind, string model
904+
SourceElement source, SummaryComponentStack s, string kind, string model
905905
) {
906906
sourceOutputStateEntry(source, s, kind, model)
907907
or
@@ -914,7 +914,7 @@ module Make<
914914

915915
pragma[nomagic]
916916
private predicate sinkInputStateExit(
917-
SinkNode sink, SummaryComponentStack s, string kind, string model
917+
SinkElement sink, SummaryComponentStack s, string kind, string model
918918
) {
919919
exists(string inSpec |
920920
sink.isSink(inSpec, kind, _, model) and
@@ -924,7 +924,7 @@ module Make<
924924

925925
pragma[nomagic]
926926
private predicate sinkInputState(
927-
SinkNode sink, SummaryComponentStack s, string kind, string model
927+
SinkElement sink, SummaryComponentStack s, string kind, string model
928928
) {
929929
sinkInputStateExit(sink, s, kind, model)
930930
or
@@ -978,15 +978,17 @@ module Make<
978978
/** Holds if this state is a valid output state for `source`. */
979979
pragma[nomagic]
980980
predicate isSourceOutputState(
981-
SourceNode source, SummaryComponentStack s, string kind, string model
981+
SourceElement source, SummaryComponentStack s, string kind, string model
982982
) {
983983
sourceOutputState(source, s, kind, model) and
984984
this = TSourceOutputState(s)
985985
}
986986

987987
/** Holds if this state is a valid input state for `sink`. */
988988
pragma[nomagic]
989-
predicate isSinkInputState(SinkNode sink, SummaryComponentStack s, string kind, string model) {
989+
predicate isSinkInputState(
990+
SinkElement sink, SummaryComponentStack s, string kind, string model
991+
) {
990992
sinkInputState(sink, s, kind, model) and
991993
this = TSinkInputState(s)
992994
}
@@ -1022,10 +1024,10 @@ module Make<
10221024
TSummaryParameterNode(SummarizedCallable c, ParameterPosition pos) {
10231025
summaryParameterNodeRange(c, pos)
10241026
} or
1025-
TSourceOutputNode(SourceNode source, SummaryNodeState state, string kind, string model) {
1027+
TSourceOutputNode(SourceElement source, SummaryNodeState state, string kind, string model) {
10261028
state.isSourceOutputState(source, _, kind, model)
10271029
} or
1028-
TSinkInputNode(SinkNode sink, SummaryNodeState state, string kind, string model) {
1030+
TSinkInputNode(SinkElement sink, SummaryNodeState state, string kind, string model) {
10291031
state.isSinkInputState(sink, _, kind, model)
10301032
}
10311033

@@ -1034,9 +1036,9 @@ module Make<
10341036

10351037
abstract SummarizedCallable getSummarizedCallable();
10361038

1037-
abstract SourceNode getSourceNode();
1039+
abstract SourceElement getSourceElement();
10381040

1039-
abstract SinkNode getSinkNode();
1041+
abstract SinkElement getSinkElement();
10401042

10411043
predicate isHidden() { any() }
10421044
}
@@ -1051,9 +1053,9 @@ module Make<
10511053

10521054
override SummarizedCallable getSummarizedCallable() { result = c }
10531055

1054-
override SourceNode getSourceNode() { none() }
1056+
override SourceElement getSourceElement() { none() }
10551057

1056-
override SinkNode getSinkNode() { none() }
1058+
override SinkElement getSinkElement() { none() }
10571059
}
10581060

10591061
private class SummaryParamNode extends SummaryNode, TSummaryParameterNode {
@@ -1066,13 +1068,13 @@ module Make<
10661068

10671069
override SummarizedCallable getSummarizedCallable() { result = c }
10681070

1069-
override SourceNode getSourceNode() { none() }
1071+
override SourceElement getSourceElement() { none() }
10701072

1071-
override SinkNode getSinkNode() { none() }
1073+
override SinkElement getSinkElement() { none() }
10721074
}
10731075

10741076
class SourceOutputNode extends SummaryNode, TSourceOutputNode {
1075-
private SourceNode source_;
1077+
private SourceElement source_;
10761078
private SummaryNodeState state_;
10771079
private string kind_;
10781080
private string model_;
@@ -1097,7 +1099,7 @@ module Make<
10971099
* A local flow step should be added from this node to a data flow node representing
10981100
* `sc` inside `source`.
10991101
*/
1100-
predicate isExit(SourceNode source, SummaryComponent sc, string model) {
1102+
predicate isExit(SourceElement source, SummaryComponent sc, string model) {
11011103
source = source_ and
11021104
model = model_ and
11031105
state_.isSourceOutputState(source, TSingletonSummaryComponentStack(sc), _, model)
@@ -1113,13 +1115,13 @@ module Make<
11131115

11141116
override SummarizedCallable getSummarizedCallable() { none() }
11151117

1116-
override SourceNode getSourceNode() { result = source_ }
1118+
override SourceElement getSourceElement() { result = source_ }
11171119

1118-
override SinkNode getSinkNode() { none() }
1120+
override SinkElement getSinkElement() { none() }
11191121
}
11201122

11211123
class SinkInputNode extends SummaryNode, TSinkInputNode {
1122-
private SinkNode sink_;
1124+
private SinkElement sink_;
11231125
private SummaryNodeState state_;
11241126
private string kind_;
11251127
private string model_;
@@ -1132,7 +1134,7 @@ module Make<
11321134
* A local flow step should be added to this node from a data flow node representing
11331135
* `sc` inside `sink`.
11341136
*/
1135-
predicate isEntry(SinkNode sink, SummaryComponent sc, string model) {
1137+
predicate isEntry(SinkElement sink, SummaryComponent sc, string model) {
11361138
sink = sink_ and
11371139
model = model_ and
11381140
state_.isSinkInputState(sink, TSingletonSummaryComponentStack(sc), _, model)
@@ -1161,9 +1163,9 @@ module Make<
11611163

11621164
override SummarizedCallable getSummarizedCallable() { none() }
11631165

1164-
override SourceNode getSourceNode() { none() }
1166+
override SourceElement getSourceElement() { none() }
11651167

1166-
override SinkNode getSinkNode() { result = sink_ }
1168+
override SinkElement getSinkElement() { result = sink_ }
11671169
}
11681170

11691171
/**
@@ -1209,15 +1211,15 @@ module Make<
12091211
}
12101212

12111213
pragma[noinline]
1212-
private SummaryNode sourceNodeOutputState(SourceNode source, SummaryComponentStack s) {
1214+
private SummaryNode sourceElementOutputState(SourceElement source, SummaryComponentStack s) {
12131215
exists(SummaryNodeState state, string kind, string model |
12141216
state.isSourceOutputState(source, s, kind, model) and
12151217
result = TSourceOutputNode(source, state, kind, model)
12161218
)
12171219
}
12181220

12191221
pragma[noinline]
1220-
private SummaryNode sinkNodeInputState(SinkNode sink, SummaryComponentStack s) {
1222+
private SummaryNode sinkElementInputState(SinkElement sink, SummaryComponentStack s) {
12211223
exists(SummaryNodeState state, string kind, string model |
12221224
state.isSinkInputState(sink, s, kind, model) and
12231225
result = TSinkInputNode(sink, state, kind, model)
@@ -1348,9 +1350,9 @@ module Make<
13481350

13491351
DataFlowType getSyntheticGlobalType(SyntheticGlobal sg);
13501352

1351-
DataFlowType getSourceNodeType(SourceBase source, SummaryComponent sc);
1353+
DataFlowType getSourceType(SourceBase source, SummaryComponent sc);
13521354

1353-
DataFlowType getSinkNodeType(SinkBase sink, SummaryComponent sc);
1355+
DataFlowType getSinkType(SinkBase sink, SummaryComponent sc);
13541356
}
13551357

13561358
/**
@@ -1430,27 +1432,27 @@ module Make<
14301432
)
14311433
)
14321434
or
1433-
exists(SourceNode source |
1435+
exists(SourceElement source |
14341436
exists(SummaryComponent sc |
14351437
n.(SourceOutputNode).isExit(source, sc, _) and
1436-
result = getSourceNodeType(source, sc)
1438+
result = getSourceType(source, sc)
14371439
)
14381440
or
14391441
exists(SummaryComponentStack s, ContentSet cont |
1440-
n = sourceNodeOutputState(source, s) and
1442+
n = sourceElementOutputState(source, s) and
14411443
s.head() = TContentSummaryComponent(cont) and
14421444
result = getContentType(cont)
14431445
)
14441446
)
14451447
or
1446-
exists(SinkNode sink |
1448+
exists(SinkElement sink |
14471449
exists(SummaryComponent sc |
14481450
n.(SinkInputNode).isEntry(sink, sc, _) and
1449-
result = getSinkNodeType(sink, sc)
1451+
result = getSinkType(sink, sc)
14501452
)
14511453
or
14521454
exists(SummaryComponentStack s, ContentSet cont |
1453-
n = sinkNodeInputState(sink, s) and
1455+
n = sinkElementInputState(sink, s) and
14541456
s.head() = TContentSummaryComponent(cont) and
14551457
result = getContentType(cont)
14561458
)
@@ -1511,14 +1513,14 @@ module Make<
15111513
}
15121514

15131515
predicate sourceLocalStep(SourceOutputNode nodeFrom, Node nodeTo, string model) {
1514-
exists(SummaryComponent sc, SourceNode source |
1516+
exists(SummaryComponent sc, SourceElement source |
15151517
nodeFrom.isExit(source, sc, model) and
15161518
nodeTo = StepsInput::getSourceNode(source, sc)
15171519
)
15181520
}
15191521

15201522
predicate sinkLocalStep(Node nodeFrom, SinkInputNode nodeTo, string model) {
1521-
exists(SummaryComponent sc, SinkNode sink |
1523+
exists(SummaryComponent sc, SinkElement sink |
15221524
nodeFrom = StepsInput::getSinkNode(sink, sc) and
15231525
nodeTo.isEntry(sink, sc, model)
15241526
)
@@ -1540,9 +1542,9 @@ module Make<
15401542
SummaryComponent::content(c) = s.head()
15411543
)
15421544
or
1543-
exists(SinkNode sink, SummaryComponentStack s |
1544-
pred = sinkNodeInputState(sink, s.tail()) and
1545-
succ = sinkNodeInputState(sink, s) and
1545+
exists(SinkElement sink, SummaryComponentStack s |
1546+
pred = sinkElementInputState(sink, s.tail()) and
1547+
succ = sinkElementInputState(sink, s) and
15461548
SummaryComponent::content(c) = s.head()
15471549
)
15481550
}
@@ -1558,9 +1560,9 @@ module Make<
15581560
SummaryComponent::content(c) = s.head()
15591561
)
15601562
or
1561-
exists(SourceNode source, SummaryComponentStack s |
1562-
pred = sourceNodeOutputState(source, s) and
1563-
succ = sourceNodeOutputState(source, s.tail()) and
1563+
exists(SourceElement source, SummaryComponentStack s |
1564+
pred = sourceElementOutputState(source, s) and
1565+
succ = sourceElementOutputState(source, s.tail()) and
15641566
SummaryComponent::content(c) = s.head()
15651567
)
15661568
}

0 commit comments

Comments
 (0)