Skip to content

Commit b4e23d9

Browse files
committed
Dataflow: Address review comments
1 parent 31a8657 commit b4e23d9

File tree

1 file changed

+38
-47
lines changed

1 file changed

+38
-47
lines changed

shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll

Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,21 +1020,21 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
10201020

10211021
private predicate sinkNode = Stage1::sinkNode/2;
10221022

1023-
private predicate sourceLabel(NodeEx node, string label) {
1023+
private predicate sourceModel(NodeEx node, string model) {
10241024
sourceNode(node, _) and
10251025
exists(Node n | n = node.asNode() |
1026-
exists(string model | knownSourceModel(n, model) and label = model)
1026+
knownSourceModel(n, model)
10271027
or
1028-
not knownSourceModel(n, _) and label = ""
1028+
not knownSourceModel(n, _) and model = ""
10291029
)
10301030
}
10311031

1032-
private predicate sinkLabel(NodeEx node, string label) {
1032+
private predicate sinkModel(NodeEx node, string model) {
10331033
sinkNode(node, _) and
10341034
exists(Node n | n = node.asNode() |
1035-
exists(string model | knownSinkModel(n, model) and label = model)
1035+
knownSinkModel(n, model)
10361036
or
1037-
not knownSinkModel(n, _) and label = ""
1037+
not knownSinkModel(n, _) and model = ""
10381038
)
10391039
}
10401040

@@ -1048,21 +1048,15 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
10481048
}
10491049

10501050
pragma[noinline]
1051-
private predicate localFlowStepNodeCand1(NodeEx node1, NodeEx node2, string label) {
1052-
exists(string model |
1053-
Stage1::revFlow(node2) and
1054-
localFlowStepEx(node1, node2, model) and
1055-
label = model
1056-
)
1051+
private predicate localFlowStepNodeCand1(NodeEx node1, NodeEx node2, string model) {
1052+
Stage1::revFlow(node2) and
1053+
localFlowStepEx(node1, node2, model)
10571054
}
10581055

10591056
pragma[noinline]
1060-
private predicate additionalLocalFlowStepNodeCand1(NodeEx node1, NodeEx node2, string label) {
1061-
exists(string model |
1062-
Stage1::revFlow(node2) and
1063-
additionalLocalFlowStep(node1, node2, model) and
1064-
label = model
1065-
)
1057+
private predicate additionalLocalFlowStepNodeCand1(NodeEx node1, NodeEx node2, string model) {
1058+
Stage1::revFlow(node2) and
1059+
additionalLocalFlowStep(node1, node2, model)
10661060
}
10671061

10681062
pragma[nomagic]
@@ -3495,7 +3489,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
34953489
sc instanceof SummaryCtxNone and
34963490
t = node.getDataFlowType() and
34973491
ap = TAccessPathNil() and
3498-
summaryLabel = ""
3492+
summaryLabel = "-"
34993493
or
35003494
// ... or a step from an existing PathNode to another node.
35013495
pathStep(_, node, state, cc, sc, t, ap, summaryLabel, _)
@@ -3685,7 +3679,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
36853679
abstract FlowState getState();
36863680

36873681
/** Holds if this node is a source. */
3688-
abstract predicate isSource(string label);
3682+
abstract predicate isSource(string model);
36893683

36903684
abstract PathNodeImpl getASuccessorImpl(string label);
36913685

@@ -3858,11 +3852,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
38583852
module PathGraph implements PathGraphSig<PathNode> {
38593853
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
38603854
query predicate edges(PathNode a, PathNode b, string key, string val) {
3861-
exists(string label |
3862-
a.(PathNodeImpl).getANonHiddenSuccessor(label) = b and
3863-
key = "provenance" and
3864-
val = label
3865-
)
3855+
a.(PathNodeImpl).getANonHiddenSuccessor(val) = b and
3856+
key = "provenance"
38663857
}
38673858

38683859
/** Holds if `n` is a node in the graph of data flow path explanations. */
@@ -3918,10 +3909,10 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
39183909
}
39193910

39203911
private predicate isSourceWithLabel(string labelprefix) {
3921-
exists(string label |
3922-
this.isSource(label) and
3923-
label != "" and
3924-
labelprefix = "Src:" + label + " "
3912+
exists(string model |
3913+
this.isSource(model) and
3914+
model != "" and
3915+
labelprefix = "Src:" + model + " "
39253916
)
39263917
}
39273918

@@ -3937,29 +3928,29 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
39373928
)
39383929
or
39393930
// a final step to a sink
3940-
exists(string l2, string l3 | result = this.getSuccMid(l2).projectToSink(l3) |
3931+
exists(string l2, string sinkmodel | result = this.getSuccMid(l2).projectToSink(sinkmodel) |
39413932
not this.isSourceWithLabel(_) and
3942-
if l3 != "" then label = l2 + " Sink:" + l3 else label = l2
3933+
if sinkmodel != "" then label = l2 + " Sink:" + sinkmodel else label = l2
39433934
or
39443935
exists(string l1 |
39453936
this.isSourceWithLabel(l1) and
3946-
if l3 != "" then label = l1 + l2 + " Sink:" + l3 else label = l1 + l2
3937+
if sinkmodel != "" then label = l1 + l2 + " Sink:" + sinkmodel else label = l1 + l2
39473938
)
39483939
)
39493940
}
39503941

3951-
override predicate isSource(string label) {
3942+
override predicate isSource(string model) {
39523943
sourceNode(node, state) and
3953-
sourceLabel(node, label) and
3944+
sourceModel(node, model) and
39543945
sourceCallCtx(cc) and
39553946
sc instanceof SummaryCtxNone and
39563947
t = node.getDataFlowType() and
39573948
ap = TAccessPathNil()
39583949
}
39593950

3960-
predicate isAtSink(string label) {
3951+
predicate isAtSink(string model) {
39613952
sinkNode(node, state) and
3962-
sinkLabel(node, label) and
3953+
sinkModel(node, model) and
39633954
ap instanceof AccessPathNil and
39643955
if hasSinkCallCtx()
39653956
then
@@ -3978,8 +3969,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
39783969
else any()
39793970
}
39803971

3981-
PathNodeSink projectToSink(string label) {
3982-
this.isAtSink(label) and
3972+
PathNodeSink projectToSink(string model) {
3973+
this.isAtSink(model) and
39833974
result.getNodeEx() = node and
39843975
result.getState() = state
39853976
}
@@ -4004,8 +3995,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
40043995
result = TPathNodeSinkGroup(this.getSinkGroup()) and label = ""
40053996
}
40063997

4007-
override predicate isSource(string label) {
4008-
sourceNode(node, state) and sourceLabel(node, label)
3998+
override predicate isSource(string model) {
3999+
sourceNode(node, state) and sourceModel(node, model)
40094000
}
40104001

40114002
string getSinkGroup() { Config::sinkGrouping(node.asNode(), result) }
@@ -4024,7 +4015,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
40244015
result.getSourceGroup() = sourceGroup and label = ""
40254016
}
40264017

4027-
override predicate isSource(string label) { none() }
4018+
override predicate isSource(string model) { none() }
40284019

40294020
override string toString() { result = sourceGroup }
40304021

@@ -4042,7 +4033,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
40424033

40434034
override PathNodeImpl getASuccessorImpl(string label) { none() }
40444035

4045-
override predicate isSource(string label) { none() }
4036+
override predicate isSource(string model) { none() }
40464037

40474038
override string toString() { result = sinkGroup }
40484039

@@ -4110,7 +4101,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
41104101
t = mid.getType() and
41114102
ap = mid.getAp() and
41124103
isStoreStep = false and
4113-
summaryLabel = "" and
4104+
summaryLabel = "-" and
41144105
label = ""
41154106
or
41164107
additionalJumpStep(mid.getNodeExOutgoing(), node, label) and
@@ -4121,7 +4112,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
41214112
t = node.getDataFlowType() and
41224113
ap = TAccessPathNil() and
41234114
isStoreStep = false and
4124-
summaryLabel = ""
4115+
summaryLabel = "-"
41254116
or
41264117
additionalJumpStateStep(mid.getNodeExOutgoing(), mid.getState(), node, state) and
41274118
cc instanceof CallContextAny and
@@ -4130,7 +4121,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
41304121
t = node.getDataFlowType() and
41314122
ap = TAccessPathNil() and
41324123
isStoreStep = false and
4133-
summaryLabel = "" and
4124+
summaryLabel = "-" and
41344125
label = ""
41354126
or
41364127
exists(Content c, DataFlowType t0, AccessPath ap0 |
@@ -4155,15 +4146,15 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
41554146
t = mid.getType() and
41564147
ap = mid.getAp() and
41574148
isStoreStep = false and
4158-
summaryLabel = "" and
4149+
(if sc instanceof SummaryCtxNone then summaryLabel = "-" else summaryLabel = "") and
41594150
label = ""
41604151
or
41614152
pathOutOfCallable(mid, node, state, cc) and
41624153
t = mid.getType() and
41634154
ap = mid.getAp() and
41644155
sc instanceof SummaryCtxNone and
41654156
isStoreStep = false and
4166-
summaryLabel = "" and
4157+
summaryLabel = "-" and
41674158
label = ""
41684159
or
41694160
pathThroughCallable(mid, node, state, cc, t, ap, label) and

0 commit comments

Comments
 (0)