Skip to content

Commit 9a6d651

Browse files
committed
Rust: More renaming and adjusting for generic element content type
1 parent 66b6ae7 commit 9a6d651

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ final class ReferenceContent extends Content, TReferenceContent {
766766
*
767767
* Examples include the elements of a set, array, vector, or stack.
768768
*/
769-
final class CollectionContent extends Content, TArrayElement {
770-
CollectionContent() { this = TArrayElement() }
769+
final class ElementContent extends Content, TElementContent {
770+
ElementContent() { this = TElementContent() }
771771

772772
override string toString() { result = "element" }
773773
}
@@ -1091,19 +1091,19 @@ module RustDataFlow implements InputSig<Location> {
10911091
)
10921092
or
10931093
exists(IndexExprCfgNode arr |
1094-
c instanceof CollectionContent and
1094+
c instanceof ElementContent and
10951095
node1.asExpr() = arr.getBase() and
10961096
node2.asExpr() = arr
10971097
)
10981098
or
10991099
exists(ForExprCfgNode for |
1100-
c instanceof CollectionContent and
1100+
c instanceof ElementContent and
11011101
node1.asExpr() = for.getIterable() and
11021102
node2.asPat() = for.getPat()
11031103
)
11041104
or
11051105
exists(SlicePatCfgNode pat |
1106-
c instanceof CollectionContent and
1106+
c instanceof ElementContent and
11071107
node1.asPat() = pat and
11081108
node2.asPat() = pat.getAPat()
11091109
)
@@ -1183,7 +1183,7 @@ module RustDataFlow implements InputSig<Location> {
11831183
node2.asExpr() = tuple
11841184
)
11851185
or
1186-
c instanceof CollectionContent and
1186+
c instanceof ElementContent and
11871187
node1.asExpr() =
11881188
[
11891189
node2.asExpr().(ArrayRepeatExprCfgNode).getRepeatOperand(),
@@ -1193,7 +1193,7 @@ module RustDataFlow implements InputSig<Location> {
11931193
tupleAssignment(node1, node2.(PostUpdateNode).getPreUpdateNode(), c)
11941194
or
11951195
exists(AssignmentExprCfgNode assignment, IndexExprCfgNode index |
1196-
c instanceof CollectionContent and
1196+
c instanceof ElementContent and
11971197
assignment.getLhs() = index and
11981198
node1.asExpr() = assignment.getRhs() and
11991199
node2.(PostUpdateNode).getPreUpdateNode().asExpr() = index.getBase()
@@ -1566,7 +1566,7 @@ private module Cached {
15661566
TVariantFieldContent(VariantCanonicalPath v, string field) {
15671567
field = v.getVariant().getFieldList().(RecordFieldList).getAField().getName().getText()
15681568
} or
1569-
TArrayElement() or
1569+
TElementContent() or
15701570
TTuplePositionContent(int pos) {
15711571
pos in [0 .. max([
15721572
any(TuplePat pat).getNumberOfFields(),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ module Input implements InputSig<Location, RustDataFlow> {
7979
arg = s.getExtendedCanonicalPath() + "::" + field
8080
)
8181
or
82-
result = "ArrayElement" and
83-
c = TArrayElement() and
82+
result = "Element" and
83+
c = TElementContent() and
8484
arg = ""
8585
or
8686
exists(int pos |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* - `Parameter[n]`: the `n`-th parameter of a callback. May be a range of form `x..y` (inclusive)
2929
* and/or a comma-separated list.
3030
* - `ReturnValue`: the value returned by a function call.
31-
* - `ArrayElement`: an element of an array.
31+
* - `Element`: an element in a collection.
3232
* - `Variant[v::f]`: field `f` of the variant with canonical path `v`, for example
3333
* `Variant[crate::ihex::Record::Data::value]`.
3434
* - `Variant[v(i)]`: position `i` inside the variant with canonical path `v`, for example

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> {
4444
// source is a collection.
4545
exists(SingletonContentSet cs |
4646
RustDataFlow::readStep(pred, cs, succ) and
47-
cs.getContent() instanceof CollectionContent
47+
cs.getContent() instanceof ElementContent
4848
)
4949
or
5050
exists(FormatArgsExprCfgNode format | succ.asExpr() = format |
@@ -64,7 +64,7 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> {
6464
predicate defaultImplicitTaintRead(Node::Node node, ContentSet cs) {
6565
exists(node) and
6666
exists(Content c | c = cs.(SingletonContentSet).getContent() |
67-
c instanceof CollectionContent or
67+
c instanceof ElementContent or
6868
c instanceof ReferenceContent
6969
)
7070
}

rust/ql/test/library-tests/dataflow/models/models.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ models
66
| 5 | Source: repo::test; crate::enum_source; test-source; ReturnValue.Variant[crate::MyFieldEnum::D::field_d] |
77
| 6 | Source: repo::test; crate::simple_source; test-source; ReturnValue |
88
| 7 | Summary: repo::test; crate::coerce; Argument[0]; ReturnValue; taint |
9-
| 8 | Summary: repo::test; crate::get_array_element; Argument[0].ArrayElement; ReturnValue; value |
9+
| 8 | Summary: repo::test; crate::get_array_element; Argument[0].Element; ReturnValue; value |
1010
| 9 | Summary: repo::test; crate::get_struct_field; Argument[0].Struct[crate::MyStruct::field1]; ReturnValue; value |
1111
| 10 | Summary: repo::test; crate::get_tuple_element; Argument[0].Tuple[0]; ReturnValue; value |
1212
| 11 | Summary: repo::test; crate::get_var_field; Argument[0].Variant[crate::MyFieldEnum::C::field_c]; ReturnValue; value |
1313
| 12 | Summary: repo::test; crate::get_var_pos; Argument[0].Variant[crate::MyPosEnum::A(0)]; ReturnValue; value |
14-
| 13 | Summary: repo::test; crate::set_array_element; Argument[0]; ReturnValue.ArrayElement; value |
14+
| 13 | Summary: repo::test; crate::set_array_element; Argument[0]; ReturnValue.Element; value |
1515
| 14 | Summary: repo::test; crate::set_tuple_element; Argument[0]; ReturnValue.Tuple[1]; value |
1616
| 15 | Summary: repo::test; crate::set_var_field; Argument[0]; ReturnValue.Variant[crate::MyFieldEnum::D::field_d]; value |
1717
| 16 | Summary: repo::test; crate::set_var_pos; Argument[0]; ReturnValue.Variant[crate::MyPosEnum::B(0)]; value |

rust/ql/test/library-tests/dataflow/models/models.ext.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extensions:
2424
- ["repo::test", "crate::set_var_field", "Argument[0]", "ReturnValue.Variant[crate::MyFieldEnum::D::field_d]", "value", "manual"]
2525
- ["repo::test", "crate::get_struct_field", "Argument[0].Struct[crate::MyStruct::field1]", "ReturnValue", "value", "manual"]
2626
- ["repo::test", "crate::set_struct_field", "Argument[0]", "ReturnValue.Struct[crate::MyStruct::field2]", "value", "manual"]
27-
- ["repo::test", "crate::get_array_element", "Argument[0].ArrayElement", "ReturnValue", "value", "manual"]
28-
- ["repo::test", "crate::set_array_element", "Argument[0]", "ReturnValue.ArrayElement", "value", "manual"]
27+
- ["repo::test", "crate::get_array_element", "Argument[0].Element", "ReturnValue", "value", "manual"]
28+
- ["repo::test", "crate::set_array_element", "Argument[0]", "ReturnValue.Element", "value", "manual"]
2929
- ["repo::test", "crate::get_tuple_element", "Argument[0].Tuple[0]", "ReturnValue", "value", "manual"]
3030
- ["repo::test", "crate::set_tuple_element", "Argument[0]", "ReturnValue.Tuple[1]", "value", "manual"]

0 commit comments

Comments
 (0)