File tree Expand file tree Collapse file tree 6 files changed +524
-470
lines changed
test/library-tests/dataflow
shared/dataflow/codeql/dataflow/test Expand file tree Collapse file tree 6 files changed +524
-470
lines changed Original file line number Diff line number Diff line change 1+ private import codeql.dataflow.test.ProvenancePathGraph as Graph
2+ private import codeql.rust.dataflow.internal.ModelsAsData as MaD
3+
4+ private signature predicate provenanceSig ( string model ) ;
5+
6+ /** Translates models-as-data provenance information into a format that can be used in tests. */
7+ module TranslateModels< provenanceSig / 1 provenance> {
8+ import Graph:: TranslateModels< MaD:: interpretModelForTest / 2 , provenance / 1 >
9+ }
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 11import codeql.rust.dataflow.DataFlow
22import codeql.rust.dataflow.internal.DataFlowImpl
3+ import utils.test.TranslateModels
34
4- query predicate localStep = DataFlow:: localFlowStep / 2 ;
5+ private predicate provenance ( string model ) { RustDataFlow:: simpleLocalFlowStep ( _, _, model ) }
6+
7+ private module Tm = TranslateModels< provenance / 1 > ;
8+
9+ query predicate models = Tm:: models / 2 ;
10+
11+ query predicate localStep ( Node nodeFrom , Node nodeTo , string model ) {
12+ exists ( string madId |
13+ RustDataFlow:: simpleLocalFlowStep ( nodeFrom , nodeTo , madId ) and
14+ Tm:: translateModels ( madId , model )
15+ )
16+ }
517
618query predicate storeStep = RustDataFlow:: storeStep / 3 ;
719
Original file line number Diff line number Diff line change 1- | file://:0:0:0:0 | [summary param] 0 in lang:alloc::_::crate::fmt::format | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:alloc::_::crate::fmt::format | MaD:35 |
2- | file://:0:0:0:0 | [summary param] self in lang:alloc::_::<crate::string::String>::as_str | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:alloc::_::<crate::string::String>::as_str | MaD:33 |
3- | file://:0:0:0:0 | [summary param] self in repo:https://github.com/seanmonstar/reqwest:reqwest::_::<crate::blocking::response::Response>::text | file://:0:0:0:0 | [summary] to write: ReturnValue.Variant[crate::result::Result::Ok(0)] in repo:https://github.com/seanmonstar/reqwest:reqwest::_::<crate::blocking::response::Response>::text | MaD:12 |
1+ additionalTaintStep
2+ | file://:0:0:0:0 | [summary param] 0 in lang:alloc::_::crate::fmt::format | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:alloc::_::crate::fmt::format | MaD:2 |
3+ | file://:0:0:0:0 | [summary param] self in lang:alloc::_::<crate::string::String>::as_str | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:alloc::_::<crate::string::String>::as_str | MaD:1 |
4+ | file://:0:0:0:0 | [summary param] self in repo:https://github.com/seanmonstar/reqwest:reqwest::_::<crate::blocking::response::Response>::text | file://:0:0:0:0 | [summary] to write: ReturnValue.Variant[crate::result::Result::Ok(0)] in repo:https://github.com/seanmonstar/reqwest:reqwest::_::<crate::blocking::response::Response>::text | MaD:3 |
45| main.rs:4:5:4:8 | 1000 | main.rs:4:5:4:12 | ... + ... | |
56| main.rs:4:12:4:12 | i | main.rs:4:5:4:12 | ... + ... | |
67| main.rs:8:20:8:20 | s | main.rs:8:14:8:20 | FormatArgsExpr | |
1718| main.rs:64:24:64:24 | s | main.rs:64:24:64:27 | s[1] | |
1819| main.rs:64:24:64:27 | s[1] | main.rs:64:18:64:27 | FormatArgsExpr | |
1920| main.rs:69:9:69:12 | arr2 | main.rs:69:9:69:15 | arr2[1] | |
21+ models
22+ | 1 | Summary: lang:alloc; <crate::string::String>::as_str; Argument[self]; ReturnValue; taint |
23+ | 2 | Summary: lang:alloc; crate::fmt::format; Argument[0]; ReturnValue; taint |
24+ | 3 | Summary: repo:https://github.com/seanmonstar/reqwest:reqwest; <crate::blocking::response::Response>::text; Argument[self]; ReturnValue.Variant[crate::result::Result::Ok(0)]; taint |
Original file line number Diff line number Diff line change 11import codeql.rust.dataflow.DataFlow
22import codeql.rust.dataflow.internal.TaintTrackingImpl
3+ import utils.test.TranslateModels
34
4- query predicate additionalTaintStep = RustTaintTracking:: defaultAdditionalTaintStep / 3 ;
5+ private predicate provenance ( string model ) {
6+ RustTaintTracking:: defaultAdditionalTaintStep ( _, _, model )
7+ }
8+
9+ private module Tm = TranslateModels< provenance / 1 > ;
10+
11+ query predicate models = Tm:: models / 2 ;
12+
13+ query predicate additionalTaintStep ( DataFlow:: Node pred , DataFlow:: Node succ , string model ) {
14+ exists ( string madId |
15+ RustTaintTracking:: defaultAdditionalTaintStep ( pred , succ , madId ) and
16+ Tm:: translateModels ( madId , model )
17+ )
18+ }
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ signature class PathNodeSig {
1616
1717private signature predicate provenanceSig ( string model ) ;
1818
19- private module TranslateModels<
19+ /** Translates models-as-data provenance information into a format that can be used in tests. */
20+ module TranslateModels<
2021 interpretModelForTestSig / 2 interpretModelForTest0, provenanceSig / 1 provenance>
2122{
2223 private predicate madIds ( string madId ) {
@@ -79,6 +80,7 @@ private module TranslateModels<
7980 )
8081 }
8182
83+ /** Holds if the model `model1` should be translated to `model2`. */
8284 predicate translateModels ( string model1 , string model2 ) {
8385 exists ( int i |
8486 translateModelsPart ( model1 , model2 , i ) and
You can’t perform that action at this time.
0 commit comments