mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: More renaming and adjusting for generic element content type
This commit is contained in:
@@ -766,8 +766,8 @@ final class ReferenceContent extends Content, TReferenceContent {
|
||||
*
|
||||
* Examples include the elements of a set, array, vector, or stack.
|
||||
*/
|
||||
final class CollectionContent extends Content, TArrayElement {
|
||||
CollectionContent() { this = TArrayElement() }
|
||||
final class ElementContent extends Content, TElementContent {
|
||||
ElementContent() { this = TElementContent() }
|
||||
|
||||
override string toString() { result = "element" }
|
||||
}
|
||||
@@ -1091,19 +1091,19 @@ module RustDataFlow implements InputSig<Location> {
|
||||
)
|
||||
or
|
||||
exists(IndexExprCfgNode arr |
|
||||
c instanceof CollectionContent and
|
||||
c instanceof ElementContent and
|
||||
node1.asExpr() = arr.getBase() and
|
||||
node2.asExpr() = arr
|
||||
)
|
||||
or
|
||||
exists(ForExprCfgNode for |
|
||||
c instanceof CollectionContent and
|
||||
c instanceof ElementContent and
|
||||
node1.asExpr() = for.getIterable() and
|
||||
node2.asPat() = for.getPat()
|
||||
)
|
||||
or
|
||||
exists(SlicePatCfgNode pat |
|
||||
c instanceof CollectionContent and
|
||||
c instanceof ElementContent and
|
||||
node1.asPat() = pat and
|
||||
node2.asPat() = pat.getAPat()
|
||||
)
|
||||
@@ -1183,7 +1183,7 @@ module RustDataFlow implements InputSig<Location> {
|
||||
node2.asExpr() = tuple
|
||||
)
|
||||
or
|
||||
c instanceof CollectionContent and
|
||||
c instanceof ElementContent and
|
||||
node1.asExpr() =
|
||||
[
|
||||
node2.asExpr().(ArrayRepeatExprCfgNode).getRepeatOperand(),
|
||||
@@ -1193,7 +1193,7 @@ module RustDataFlow implements InputSig<Location> {
|
||||
tupleAssignment(node1, node2.(PostUpdateNode).getPreUpdateNode(), c)
|
||||
or
|
||||
exists(AssignmentExprCfgNode assignment, IndexExprCfgNode index |
|
||||
c instanceof CollectionContent and
|
||||
c instanceof ElementContent and
|
||||
assignment.getLhs() = index and
|
||||
node1.asExpr() = assignment.getRhs() and
|
||||
node2.(PostUpdateNode).getPreUpdateNode().asExpr() = index.getBase()
|
||||
@@ -1566,7 +1566,7 @@ private module Cached {
|
||||
TVariantFieldContent(VariantCanonicalPath v, string field) {
|
||||
field = v.getVariant().getFieldList().(RecordFieldList).getAField().getName().getText()
|
||||
} or
|
||||
TArrayElement() or
|
||||
TElementContent() or
|
||||
TTuplePositionContent(int pos) {
|
||||
pos in [0 .. max([
|
||||
any(TuplePat pat).getNumberOfFields(),
|
||||
|
||||
@@ -79,8 +79,8 @@ module Input implements InputSig<Location, RustDataFlow> {
|
||||
arg = s.getExtendedCanonicalPath() + "::" + field
|
||||
)
|
||||
or
|
||||
result = "ArrayElement" and
|
||||
c = TArrayElement() and
|
||||
result = "Element" and
|
||||
c = TElementContent() and
|
||||
arg = ""
|
||||
or
|
||||
exists(int pos |
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* - `Parameter[n]`: the `n`-th parameter of a callback. May be a range of form `x..y` (inclusive)
|
||||
* and/or a comma-separated list.
|
||||
* - `ReturnValue`: the value returned by a function call.
|
||||
* - `ArrayElement`: an element of an array.
|
||||
* - `Element`: an element in a collection.
|
||||
* - `Variant[v::f]`: field `f` of the variant with canonical path `v`, for example
|
||||
* `Variant[crate::ihex::Record::Data::value]`.
|
||||
* - `Variant[v(i)]`: position `i` inside the variant with canonical path `v`, for example
|
||||
|
||||
@@ -44,7 +44,7 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> {
|
||||
// source is a collection.
|
||||
exists(SingletonContentSet cs |
|
||||
RustDataFlow::readStep(pred, cs, succ) and
|
||||
cs.getContent() instanceof CollectionContent
|
||||
cs.getContent() instanceof ElementContent
|
||||
)
|
||||
or
|
||||
exists(FormatArgsExprCfgNode format | succ.asExpr() = format |
|
||||
@@ -64,7 +64,7 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> {
|
||||
predicate defaultImplicitTaintRead(Node::Node node, ContentSet cs) {
|
||||
exists(node) and
|
||||
exists(Content c | c = cs.(SingletonContentSet).getContent() |
|
||||
c instanceof CollectionContent or
|
||||
c instanceof ElementContent or
|
||||
c instanceof ReferenceContent
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ models
|
||||
| 5 | Source: repo::test; crate::enum_source; test-source; ReturnValue.Variant[crate::MyFieldEnum::D::field_d] |
|
||||
| 6 | Source: repo::test; crate::simple_source; test-source; ReturnValue |
|
||||
| 7 | Summary: repo::test; crate::coerce; Argument[0]; ReturnValue; taint |
|
||||
| 8 | Summary: repo::test; crate::get_array_element; Argument[0].ArrayElement; ReturnValue; value |
|
||||
| 8 | Summary: repo::test; crate::get_array_element; Argument[0].Element; ReturnValue; value |
|
||||
| 9 | Summary: repo::test; crate::get_struct_field; Argument[0].Struct[crate::MyStruct::field1]; ReturnValue; value |
|
||||
| 10 | Summary: repo::test; crate::get_tuple_element; Argument[0].Tuple[0]; ReturnValue; value |
|
||||
| 11 | Summary: repo::test; crate::get_var_field; Argument[0].Variant[crate::MyFieldEnum::C::field_c]; ReturnValue; value |
|
||||
| 12 | Summary: repo::test; crate::get_var_pos; Argument[0].Variant[crate::MyPosEnum::A(0)]; ReturnValue; value |
|
||||
| 13 | Summary: repo::test; crate::set_array_element; Argument[0]; ReturnValue.ArrayElement; value |
|
||||
| 13 | Summary: repo::test; crate::set_array_element; Argument[0]; ReturnValue.Element; value |
|
||||
| 14 | Summary: repo::test; crate::set_tuple_element; Argument[0]; ReturnValue.Tuple[1]; value |
|
||||
| 15 | Summary: repo::test; crate::set_var_field; Argument[0]; ReturnValue.Variant[crate::MyFieldEnum::D::field_d]; value |
|
||||
| 16 | Summary: repo::test; crate::set_var_pos; Argument[0]; ReturnValue.Variant[crate::MyPosEnum::B(0)]; value |
|
||||
|
||||
@@ -24,7 +24,7 @@ extensions:
|
||||
- ["repo::test", "crate::set_var_field", "Argument[0]", "ReturnValue.Variant[crate::MyFieldEnum::D::field_d]", "value", "manual"]
|
||||
- ["repo::test", "crate::get_struct_field", "Argument[0].Struct[crate::MyStruct::field1]", "ReturnValue", "value", "manual"]
|
||||
- ["repo::test", "crate::set_struct_field", "Argument[0]", "ReturnValue.Struct[crate::MyStruct::field2]", "value", "manual"]
|
||||
- ["repo::test", "crate::get_array_element", "Argument[0].ArrayElement", "ReturnValue", "value", "manual"]
|
||||
- ["repo::test", "crate::set_array_element", "Argument[0]", "ReturnValue.ArrayElement", "value", "manual"]
|
||||
- ["repo::test", "crate::get_array_element", "Argument[0].Element", "ReturnValue", "value", "manual"]
|
||||
- ["repo::test", "crate::set_array_element", "Argument[0]", "ReturnValue.Element", "value", "manual"]
|
||||
- ["repo::test", "crate::get_tuple_element", "Argument[0].Tuple[0]", "ReturnValue", "value", "manual"]
|
||||
- ["repo::test", "crate::set_tuple_element", "Argument[0]", "ReturnValue.Tuple[1]", "value", "manual"]
|
||||
|
||||
Reference in New Issue
Block a user