Skip to content

Commit abf0a01

Browse files
committed
Rust: Generate more sinks and update query description
1 parent 0086e2d commit abf0a01

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

rust/ql/lib/codeql/rust/frameworks/reqwest.model.yml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ extensions:
99
pack: codeql/rust-all
1010
extensible: sinkModel
1111
data:
12-
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "crate::blocking::get", "Argument[0]", "transmission", "manual"]
1312
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::async_impl::client::Client>::request", "Argument[1]", "transmission", "manual"]
1413
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::blocking::client::Client>::request", "Argument[1]", "transmission", "manual"]
1514
- addsTo:

rust/ql/lib/ext/generated/reqwest/repo-https-github.com-seanmonstar-reqwest-reqwest.model.yml

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ extensions:
1010
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::async_impl::client::Client>::patch", "Argument[0]", "transmission", "df-generated"]
1111
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::async_impl::client::Client>::post", "Argument[0]", "transmission", "df-generated"]
1212
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::async_impl::client::Client>::put", "Argument[0]", "transmission", "df-generated"]
13+
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::blocking::client::Client>::delete", "Argument[0]", "transmission", "df-generated"]
14+
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::blocking::client::Client>::get", "Argument[0]", "transmission", "df-generated"]
15+
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::blocking::client::Client>::head", "Argument[0]", "transmission", "df-generated"]
16+
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::blocking::client::Client>::patch", "Argument[0]", "transmission", "df-generated"]
17+
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::blocking::client::Client>::post", "Argument[0]", "transmission", "df-generated"]
18+
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::blocking::client::Client>::put", "Argument[0]", "transmission", "df-generated"]
1319
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::connect::Connector as crate::Service>::call", "Argument[0]", "log-injection", "df-generated"]
1420
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "<crate::connect::ConnectorService as crate::Service>::call", "Argument[0]", "log-injection", "df-generated"]
21+
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "crate::blocking::get", "Argument[0]", "transmission", "df-generated"]
22+
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "crate::blocking::wait::timeout", "Argument[1]", "log-injection", "df-generated"]
1523
- ["repo:https://github.com/seanmonstar/reqwest:reqwest", "crate::get", "Argument[0]", "transmission", "df-generated"]

rust/ql/src/queries/security/CWE-311/CleartextTransmission.qhelp

+9-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ sensitive information when it is not necessary to.
2222

2323
<p>
2424
The following example shows three cases of transmitting information. In the
25-
'BAD' case, the data transmitted is sensitive (a password) and is not encrypted
26-
as it occurs as a URL parameter. In the 'GOOD' cases, the data is either not
27-
sensitive, or is protected with encryption. When encryption is used, take care
28-
to select a secure modern encryption algorithm, and put suitable key management
29-
practices into place.
25+
'BAD' case, the transmitted data is sensitive (a credit card number) and is
26+
included as cleartext in the URL. URLs are often logged or otherwise visible in
27+
cleartext, and should not contain sensitive information.
28+
</p>
29+
30+
<p>
31+
In the 'GOOD' cases, the data is either not sensitive, or is protected with
32+
encryption. When encryption is used, take care to select a secure modern
33+
encryption algorithm, and put suitable key management practices into place.
3034
</p>
3135

3236
<sample src="CleartextTransmission.rs" />

rust/ql/src/queries/security/CWE-311/CleartextTransmission.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ func getData() {
22
// ...
33

44
// GOOD: not sensitive information
5-
let body = reqwest::get("https://example.com/data").await?.text().await?;
5+
let body = reqwest::get("https://example.com/song/{faveSong}").await?.text().await?;
66

7-
// BAD: sensitive information sent in cleartext
8-
let body = reqwest::get(format!("https://example.com/data?password={password}")).await?.text().await?;
7+
// BAD: sensitive information sent in cleartext in the URL
8+
let body = reqwest::get(format!("https://example.com/card/{creditCardNo}")).await?.text().await?;
99

10-
// GOOD: encrypted sensitive information sent
10+
// GOOD: encrypted sensitive information sent in the URL
1111
let encryptedPassword = encrypt(password, encryptionKey);
12-
let body = reqwest::get(format!("https://example.com/data?password={encryptedPassword}")).await?.text().await?;
12+
let body = reqwest::get(format!("https://example.com/card/{creditCardNo}")).await?.text().await?;
1313

1414
// ...
1515
}

0 commit comments

Comments
 (0)