File tree 6 files changed +524
-470
lines changed
test/library-tests/dataflow
shared/dataflow/codeql/dataflow/test
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 1
1
import codeql.rust.dataflow.DataFlow
2
2
import codeql.rust.dataflow.internal.DataFlowImpl
3
+ import utils.test.TranslateModels
3
4
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
+ }
5
17
6
18
query predicate storeStep = RustDataFlow:: storeStep / 3 ;
7
19
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 |
4
5
| main.rs:4:5:4:8 | 1000 | main.rs:4:5:4:12 | ... + ... | |
5
6
| main.rs:4:12:4:12 | i | main.rs:4:5:4:12 | ... + ... | |
6
7
| main.rs:8:20:8:20 | s | main.rs:8:14:8:20 | FormatArgsExpr | |
17
18
| main.rs:64:24:64:24 | s | main.rs:64:24:64:27 | s[1] | |
18
19
| main.rs:64:24:64:27 | s[1] | main.rs:64:18:64:27 | FormatArgsExpr | |
19
20
| 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 1
1
import codeql.rust.dataflow.DataFlow
2
2
import codeql.rust.dataflow.internal.TaintTrackingImpl
3
+ import utils.test.TranslateModels
3
4
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 {
16
16
17
17
private signature predicate provenanceSig ( string model ) ;
18
18
19
- private module TranslateModels<
19
+ /** Translates models-as-data provenance information into a format that can be used in tests. */
20
+ module TranslateModels<
20
21
interpretModelForTestSig / 2 interpretModelForTest0, provenanceSig / 1 provenance>
21
22
{
22
23
private predicate madIds ( string madId ) {
@@ -79,6 +80,7 @@ private module TranslateModels<
79
80
)
80
81
}
81
82
83
+ /** Holds if the model `model1` should be translated to `model2`. */
82
84
predicate translateModels ( string model1 , string model2 ) {
83
85
exists ( int i |
84
86
translateModelsPart ( model1 , model2 , i ) and
You can’t perform that action at this time.
0 commit comments