Skip to content

Commit e56519d

Browse files
committed
Rust: Add a dataflow sources test for the Actix web fraemework.
1 parent 310c02f commit e56519d

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

rust/ql/test/library-tests/dataflow/sources/options.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ qltest_dependencies:
99
- futures = { version = "0.3" }
1010
- poem = { version = "3.1.10" }
1111
- serde = { version = "1.0.219" }
12+
- actix-web = { version = "4.10.2" }

rust/ql/test/library-tests/dataflow/sources/web_frameworks.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,50 @@ mod poem_test {
7979
// ...
8080
}
8181
}
82+
83+
mod actix_test {
84+
use actix_web::{get, web, App, HttpServer};
85+
use crate::web_frameworks::sink;
86+
87+
async fn my_actix_handler_1(path: web::Path<String>) -> String { // $ MISSING: Alert[rust/summary/taint-sources]
88+
let a = path.into_inner();
89+
sink(a.as_str()); // $ MISSING: hasTaintFlow
90+
sink(a.as_bytes()); // $ MISSING: hasTaintFlow
91+
sink(a); // $ MISSING: hasTaintFlow
92+
93+
"".to_string()
94+
}
95+
96+
async fn my_actix_handler_2(path: web::Path<(String, String)>) -> String { // $ MISSING: Alert[rust/summary/taint-sources]
97+
let (a, b) = path.into_inner();
98+
99+
sink(a); // $ MISSING: hasTaintFlow
100+
sink(b); // $ MISSING: hasTaintFlow
101+
102+
"".to_string()
103+
}
104+
105+
async fn my_actix_handler_3(web::Query(a): web::Query<String>) -> String { // $ MISSING: Alert[rust/summary/taint-sources]
106+
sink(a); // $ MISSING: hasTaintFlow
107+
108+
"".to_string()
109+
}
110+
111+
#[get("/4/{a}")]
112+
async fn my_actix_handler_4(path: web::Path<String>) -> String { // $ MISSING: Alert[rust/summary/taint-sources]
113+
let a = path.into_inner();
114+
sink(a); // $ MISSING: hasTaintFlow
115+
116+
"".to_string()
117+
}
118+
119+
async fn test_actix() {
120+
let app = App::new()
121+
.route("/1/{a}", web::get().to(my_actix_handler_1))
122+
.route("/2/{a}/{b}", web::get().to(my_actix_handler_2))
123+
.route("/3/{a}", web::get().to(my_actix_handler_3))
124+
.service(my_actix_handler_4);
125+
126+
// ...
127+
}
128+
}

0 commit comments

Comments
 (0)