Skip to content

Commit de9d102

Browse files
committed
Rust: Add Warp test to request forgery query tests
1 parent def1bcf commit de9d102

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

rust/ql/test/query-tests/security/CWE-918/Cargo.lock

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/test/query-tests/security/CWE-918/options.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ qltest_dependencies:
33
- reqwest = { version = "0.12.23", features = ["blocking", "json"] }
44
- tokio = { version = "1.0", features = ["full"] }
55
- poem = { version = "3.1.12", features = ["server"] }
6+
- warp = { version = "0.4.2", features = ["server"] }

rust/ql/test/query-tests/security/CWE-918/request_forgery_tests.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,26 @@ mod poem_server {
5454
}
5555
}
5656

57+
mod warp_test {
58+
use warp::Filter;
59+
60+
#[tokio::main]
61+
#[rustfmt::skip]
62+
async fn test_warp() {
63+
// A route with parameter and `and_then`
64+
let map_route =
65+
warp::path::param().and_then(async |a: String| // $ MISSING: Source=a
66+
{
67+
68+
let response = reqwest::get(&a).await; // $ MISSING: Alert[rust/request-forgery]=a
69+
match response {
70+
Ok(resp) => Ok(resp.text().await.unwrap_or_default()),
71+
Err(_err) => Err(warp::reject::not_found()),
72+
}
73+
});
74+
}
75+
}
76+
5777
/// Start the Poem web application
5878
pub fn start() {
5979
tokio::runtime::Runtime::new()

0 commit comments

Comments
 (0)