Skip to content

Commit aaa8f9c

Browse files
committed
Add read and store steps for SliceElementNode
1 parent 2b897a9 commit aaa8f9c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

go/ql/lib/semmle/go/dataflow/internal/ContainerFlow.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ predicate containerStoreStep(Node node1, Node node2, Content c) {
2424
exists(Write w | w.writesElement(node2.(PostUpdateNode).getPreUpdateNode(), _, node1))
2525
or
2626
node1 = node2.(ImplicitVarargsSlice).getCallNode().getAnImplicitVarargsArgument()
27+
or
28+
// To model data flow from array elements of the base of a `SliceNode` to
29+
// the `SliceNode` itself, we consider there to be a read step with array
30+
// content from the base to the corresponding `SliceElementNode` and then
31+
// a store step with array content from the `SliceelementNode` to the
32+
// `SliceNode` itself.
33+
node2 = node1.(SliceElementNode).getSliceNode()
2734
)
2835
)
2936
or
@@ -57,6 +64,13 @@ predicate containerReadStep(Node node1, Node node2, Content c) {
5764
)
5865
or
5966
node2.(RangeElementNode).getBase() = node1
67+
or
68+
// To model data flow from array elements of the base of a `SliceNode` to
69+
// the `SliceNode` itself, we consider there to be a read step with array
70+
// content from the base to the corresponding `SliceElementNode` and then
71+
// a store step with array content from the `SliceelementNode` to the
72+
// `SliceNode` itself.
73+
node2.(SliceElementNode).getSliceNode().getBase() = node1
6074
)
6175
or
6276
c instanceof CollectionContent and

0 commit comments

Comments
 (0)