Skip to content

Commit 30f419f

Browse files
chore: add clippy rule for reqwest::Client::builder
1 parent 4524712 commit 30f419f

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

clippy.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
disallowed-methods = [
2+
{ path = "reqwest::Client::builder", reason = "prefer the FIPS-compatible adapter", replacement = "datadog_serverless_fips::reqwest_adapter::create_reqwest_client_builder" },
3+
]
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1-
# Datadog Serverless FIPS
1+
# Datadog FIPS for Serverless
22

3-
A package to support FIPS builds for serverless tools. Currently tested with the datadog-lambda-extension, but it may be useful in other environments.
3+
A package to support FIPS builds for serverless tools. Currently tested with
4+
the datadog-lambda-extension, but it may be useful in other environments.
5+
6+
Please add the following to your `clippy.toml`:
7+
8+
```
9+
disallowed-methods = [
10+
{ path = "reqwest::Client::builder", reason = "prefer the FIPS-compatible adapter", replacement = "datadog_serverless_fips::reqwest_adapter::create_reqwest_client_builder" },
11+
]
12+
```

crates/datadog-serverless-fips/src/reqwest_adapter.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use tracing::debug;
88
/// Otherwise, it uses reqwest's default rustls TLS implementation.
99
#[cfg(not(feature = "fips"))]
1010
pub fn create_reqwest_client_builder() -> Result<ClientBuilder, Box<dyn Error>> {
11-
// Just return the default builder with rustls TLS
11+
// Just return the default builder with rustls TLS. This is the one place we should be okay
12+
// to call reqwest::Client::builder().
13+
#[allow(clippy::disallowed_methods)]
1214
Ok(reqwest::Client::builder().use_rustls_tls())
1315
}
1416

@@ -55,5 +57,7 @@ pub fn create_reqwest_client_builder() -> Result<ClientBuilder, Box<dyn Error>>
5557
}
5658
debug!("Client builder is configured with FIPS.");
5759

60+
// This is the one place that it is okay to call reqwest::Client::builder().
61+
#[allow(clippy::disallowed_methods)]
5862
Ok(reqwest::Client::builder().use_preconfigured_tls(config))
5963
}

0 commit comments

Comments
 (0)