Skip to content

Commit b4cf101

Browse files
authored
Fix build warnings and lints (#184)
* build: Replace warnings for private_in_public with new warning groups * build: Fix security warning for dev package of rsa * build: Fix warnings about temporary security issue with rustls. We will be fixing this very shortly by upgrading opentelemetry-otlp * build: Fix lints that were breaking CI from passing * build: Update deny.toml to remove deprecated config options * build: Ignore RUSTSEC-2021-0145 as it only impacts windows machines * build: fix lints from improper formatting in comments * build: Define the tokio_unstable cfg to fix the build
1 parent bfcc47d commit b4cf101

File tree

18 files changed

+86
-70
lines changed

18 files changed

+86
-70
lines changed

Diff for: rust+wasm/deny.toml

+24-27
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,25 @@ db-path = "~/.cargo/advisory-db"
3636
# The url(s) of the advisory databases to use
3737
db-urls = ["https://github.com/rustsec/advisory-db"]
3838
# The lint level for security vulnerabilities
39-
vulnerability = "deny"
39+
# vulnerability = "deny"
4040
# The lint level for unmaintained crates
41-
unmaintained = "warn"
41+
# unmaintained = "warn"
4242
# The lint level for crates that have been yanked from their source registry
43-
yanked = "deny"
43+
# yanked = "deny"
4444
# The lint level for crates with security notices. Note that as of
4545
# 2019-12-17 there are no security notice advisories in
4646
# https://github.com/rustsec/advisory-db
47-
notice = "warn"
47+
# notice = "warn"
4848
# A list of advisory IDs to ignore. Note that ignored advisories will still
4949
# output a note when they are encountered.
5050
ignore = [
51-
"RUSTSEC-2020-0071" # time 0.1 w/ chrono
51+
"RUSTSEC-2021-0145", # atty on windows only
52+
"RUSTSEC-2023-0071", # Impacts rsa crate, which is only used in dev, see
53+
# https://github.com/RustCrypto/RSA/pull/394 for remediation
54+
"RUSTSEC-2024-0336", # Ignore a DOS issue w/ rustls-0.20.9. This will go
55+
# away when we update opentelemetry-otlp soon.
56+
{ id = "RUSTSEC-2020-0168", reason = "Not planning to force upgrade to mach2 yet" },
57+
{ id = "RUSTSEC-2024-0320", reason = "Not planning to force upgrade to rust-yaml2 yet" },
5258
]
5359
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
5460
# lower than the range specified will be ignored. Note that ignored advisories
@@ -65,7 +71,7 @@ ignore = [
6571
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
6672
[licenses]
6773
# The lint level for crates which do not have a detectable license
68-
unlicensed = "warn"
74+
# unlicensed = "warn"
6975
# List of explicitly allowed licenses
7076
# See https://spdx.org/licenses/ for list of possible licenses
7177
# [possible values: any SPDX 3.7 short identifier (+ optional exception)].
@@ -81,23 +87,23 @@ allow = [
8187
# List of explicitly disallowed licenses
8288
# See https://spdx.org/licenses/ for list of possible licenses
8389
# [possible values: any SPDX 3.7 short identifier (+ optional exception)].
84-
deny = [
90+
# deny = [
8591
#"Nokia",
86-
]
92+
# ]
8793
# Lint level for licenses considered copyleft
88-
copyleft = "deny"
94+
# copyleft = "deny"
8995
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
9096
# * both - The license will be approved if it is both OSI-approved *AND* FSF
9197
# * either - The license will be approved if it is either OSI-approved *OR* FSF
9298
# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF
9399
# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved
94100
# * neither - This predicate is ignored and the default lint level is used
95-
allow-osi-fsf-free = "neither"
101+
# allow-osi-fsf-free = "neither"
96102
# Lint level used when no other predicates are matched
97103
# 1. License isn't in the allow or deny lists
98104
# 2. License isn't copyleft
99105
# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither"
100-
default = "deny"
106+
# default = "deny"
101107
# The confidence threshold for detecting a license from license text.
102108
# The higher the value, the more closely the license text must be to the
103109
# canonical license text of a valid SPDX license file.
@@ -111,27 +117,18 @@ exceptions = [
111117
# included in the application. We do not distribute those data files so
112118
# this is not a problem for us. See https://github.com/dtolnay/unicode-ident/pull/9/files
113119
{ allow = ["Unicode-DFS-2016"], name = "unicode-ident", version = "*"},
120+
{ allow = ["OpenSSL"], name = "ring", version = "*" },
114121
]
115122

116123
# Some crates don't have (easily) machine readable licensing information,
117124
# adding a clarification entry for it allows you to manually specify the
118125
# licensing information
119-
#[[licenses.clarify]]
120-
# The name of the crate the clarification applies to
121-
#name = "ring"
122-
# The optional version constraint for the crate
123-
#version = "*"
124-
# The SPDX expression for the license requirements of the crate
125-
#expression = "MIT AND ISC AND OpenSSL"
126-
# One or more files in the crate's source used as the "source of truth" for
127-
# the license expression. If the contents match, the clarification will be used
128-
# when running the license check, otherwise the clarification will be ignored
129-
# and the crate will be checked normally, which may produce warnings or errors
130-
# depending on the rest of your configuration
131-
#license-files = [
132-
# Each entry is a crate relative path, and the (opaque) hash of its contents
133-
#{ path = "LICENSE", hash = 0xbd0eed23 }
134-
#]
126+
[[licenses.clarify]]
127+
name = "ring"
128+
expression = "MIT AND ISC AND OpenSSL"
129+
license-files = [
130+
{ path = "LICENSE", hash = 0xbd0eed23 }
131+
]
135132

136133
[licenses.private]
137134
# If true, ignores workspace crates that aren't published, or are only

Diff for: rust+wasm/{{project-name}}-wasm/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![cfg_attr(docsrs, feature(doc_cfg))]
22
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]
3-
#![deny(unreachable_pub, private_in_public)]
3+
#![deny(unreachable_pub)]
4+
#![deny(private_bounds)]
5+
#![deny(rustdoc::private_intra_doc_links)]
6+
#![deny(private_interfaces)]
47

58
//! {{project-name}}
69

Diff for: rust+wasm/{{project-name}}/Cargo.axum.toml

+3
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,6 @@ test_utils = ["proptest"]{% endif %}
109109
all-features = true
110110
# defines the configuration attribute `docsrs`
111111
rustdoc-args = ["--cfg", "docsrs"]
112+
113+
[lints.rust]
114+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }

Diff for: rust+wasm/{{project-name}}/src.axum/extract/json.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::error::AppError;
3030
/// - The request doesn't have a `Content-Type: application/json` (or similar) header.
3131
/// - The body doesn't contain syntactically valid JSON.
3232
/// - The body contains syntactically valid JSON but it couldn't be deserialized into the target
33-
/// type.
33+
/// type.
3434
/// - Buffering the request body fails.
3535
///
3636
/// See [AppError] for more details.

Diff for: rust+wasm/{{project-name}}/src.axum/headers/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ macro_rules! header {
5454

5555
/// Trait for returning header value directly for passing
5656
/// along to client calls.
57+
#[allow(unused)]
5758
pub(crate) trait HeaderValue {
5859
fn header_value(&self) -> String;
5960
}

Diff for: rust+wasm/{{project-name}}/src.axum/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![cfg_attr(docsrs, feature(doc_cfg))]
22
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]
3-
#![deny(unreachable_pub, private_in_public)]
3+
#![deny(unreachable_pub)]
4+
#![deny(private_bounds)]
5+
#![deny(rustdoc::private_intra_doc_links)]
6+
#![deny(private_interfaces)]
47

58
//! {{project-name}}
69

Diff for: rust+wasm/{{project-name}}/src.axum/middleware/logging.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ async fn log_reqwest_response(
279279
.headers_mut()
280280
.ok_or_else(|| anyhow!("failed to convert response headers"))?;
281281

282-
headers.extend(headers_iter.map(|(k, v)| (k, v)));
282+
headers.extend(headers_iter);
283283

284284
let res = builder.body(body)?;
285285
Ok(reqwest::Response::from(res))

Diff for: rust+wasm/{{project-name}}/src.axum/middleware/reqwest_retry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ static MAXIMUM_NUMBER_OF_RETRIES: u32 = 10;
5151
///
5252
/// Some workaround suggestions:
5353
/// * If you can fit the data in memory, you can instead build static request bodies e.g. with
54-
/// `Body`'s `From<String>` or `From<Bytes>` implementations.
54+
/// `Body`'s `From<String>` or `From<Bytes>` implementations.
5555
/// * You can wrap this middleware in a custom one which skips retries for streaming requests.
5656
/// * You can write a custom retry middleware that builds new streaming requests from the data
57-
/// source directly, avoiding the issue of streaming requests not being clonable.
57+
/// source directly, avoiding the issue of streaming requests not being clonable.
5858
#[derive(Debug)]
5959
pub struct RetryTransientMiddleware<T: RetryPolicy + Send + Sync + 'static> {
6060
client_name: String,

Diff for: rust+wasm/{{project-name}}/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![cfg_attr(docsrs, feature(doc_cfg))]
22
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]
3-
#![deny(unreachable_pub, private_in_public)]
3+
#![deny(unreachable_pub)]
4+
#![deny(private_bounds)]
5+
#![deny(rustdoc::private_intra_doc_links)]
6+
#![deny(private_interfaces)]
47

58
//! {{project-name}}
69
{% if bench %}

Diff for: rust/Cargo.axum.toml

+3
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,6 @@ rustdoc-args = ["--cfg", "docsrs"]
121121
# See https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#splitting-debug-information
122122
[profile.dev]
123123
split-debuginfo = "unpacked"
124+
125+
[lints.rust]
126+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }

Diff for: rust/deny.toml

+27-29
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,26 @@ db-path = "~/.cargo/advisory-db"
3636
# The url(s) of the advisory databases to use
3737
db-urls = ["https://github.com/rustsec/advisory-db"]
3838
# The lint level for security vulnerabilities
39-
vulnerability = "deny"
39+
# vulnerability = "deny"
4040
# The lint level for unmaintained crates
41-
unmaintained = "warn"
41+
# unmaintained = "warn"
4242
# The lint level for crates that have been yanked from their source registry
43-
yanked = "deny"
43+
# yanked = "deny"
4444
# The lint level for crates with security notices. Note that as of
4545
# 2019-12-17 there are no security notice advisories in
4646
# https://github.com/rustsec/advisory-db
47-
notice = "warn"
47+
# notice = "warn"
4848
# A list of advisory IDs to ignore. Note that ignored advisories will still
4949
# output a note when they are encountered.
50-
#ignore = [
51-
#]
50+
ignore = [
51+
"RUSTSEC-2021-0145", # atty on windows only
52+
"RUSTSEC-2023-0071", # Impacts rsa crate, which is only used in dev, see
53+
# https://github.com/RustCrypto/RSA/pull/394 for remediation
54+
"RUSTSEC-2024-0336", # Ignore a DOS issue w/ rustls-0.20.9. This will go
55+
# away when we update opentelemetry-otlp soon.
56+
{ id = "RUSTSEC-2020-0168", reason = "Not planning to force upgrade to mach2 yet" },
57+
{ id = "RUSTSEC-2024-0320", reason = "Not planning to force upgrade to rust-yaml2 yet" },
58+
]
5259
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
5360
# lower than the range specified will be ignored. Note that ignored advisories
5461
# will still output a note when they are encountered.
@@ -64,7 +71,7 @@ notice = "warn"
6471
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
6572
[licenses]
6673
# The lint level for crates which do not have a detectable license
67-
unlicensed = "warn"
74+
# unlicensed = "warn"
6875
# List of explicitly allowed licenses
6976
# See https://spdx.org/licenses/ for list of possible licenses
7077
# [possible values: any SPDX 3.7 short identifier (+ optional exception)].
@@ -80,23 +87,23 @@ allow = [
8087
# List of explicitly disallowed licenses
8188
# See https://spdx.org/licenses/ for list of possible licenses
8289
# [possible values: any SPDX 3.7 short identifier (+ optional exception)].
83-
deny = [
90+
# deny = [
8491
#"Nokia",
85-
]
92+
# ]
8693
# Lint level for licenses considered copyleft
87-
copyleft = "deny"
94+
# copyleft = "deny"
8895
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
8996
# * both - The license will be approved if it is both OSI-approved *AND* FSF
9097
# * either - The license will be approved if it is either OSI-approved *OR* FSF
9198
# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF
9299
# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved
93100
# * neither - This predicate is ignored and the default lint level is used
94-
allow-osi-fsf-free = "neither"
101+
# allow-osi-fsf-free = "neither"
95102
# Lint level used when no other predicates are matched
96103
# 1. License isn't in the allow or deny lists
97104
# 2. License isn't copyleft
98105
# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither"
99-
default = "deny"
106+
# default = "deny"
100107
# The confidence threshold for detecting a license from license text.
101108
# The higher the value, the more closely the license text must be to the
102109
# canonical license text of a valid SPDX license file.
@@ -110,32 +117,23 @@ exceptions = [
110117
# included in the application. We do not distribute those data files so
111118
# this is not a problem for us. See https://github.com/dtolnay/unicode-ident/pull/9/files
112119
{ allow = ["Unicode-DFS-2016"], name = "unicode-ident", version = "*"},
120+
{ allow = ["OpenSSL"], name = "ring", version = "*" },
113121
]
114122

115123
# Some crates don't have (easily) machine readable licensing information,
116124
# adding a clarification entry for it allows you to manually specify the
117125
# licensing information
118-
#[[licenses.clarify]]
119-
# The name of the crate the clarification applies to
120-
#name = "ring"
121-
# The optional version constraint for the crate
122-
#version = "*"
123-
# The SPDX expression for the license requirements of the crate
124-
#expression = "MIT AND ISC AND OpenSSL"
125-
# One or more files in the crate's source used as the "source of truth" for
126-
# the license expression. If the contents match, the clarification will be used
127-
# when running the license check, otherwise the clarification will be ignored
128-
# and the crate will be checked normally, which may produce warnings or errors
129-
# depending on the rest of your configuration
130-
#license-files = [
131-
# Each entry is a crate relative path, and the (opaque) hash of its contents
132-
#{ path = "LICENSE", hash = 0xbd0eed23 }
133-
#]
126+
[[licenses.clarify]]
127+
name = "ring"
128+
expression = "MIT AND ISC AND OpenSSL"
129+
license-files = [
130+
{ path = "LICENSE", hash = 0xbd0eed23 }
131+
]
134132

135133
[licenses.private]
136134
# If true, ignores workspace crates that aren't published, or are only
137135
# published to private registries
138-
ignore = false
136+
ignore = true
139137
# One or more private registries that you might publish crates to, if a crate
140138
# is only published to private registries, and ignore is true, the crate will
141139
# not have its license(s) checked

Diff for: rust/src.axum/extract/json.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::error::AppError;
3030
/// - The request doesn't have a `Content-Type: application/json` (or similar) header.
3131
/// - The body doesn't contain syntactically valid JSON.
3232
/// - The body contains syntactically valid JSON but it couldn't be deserialized into the target
33-
/// type.
33+
/// type.
3434
/// - Buffering the request body fails.
3535
///
3636
/// See [AppError] for more details.

Diff for: rust/src.axum/headers/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ macro_rules! header {
5454

5555
/// Trait for returning header value directly for passing
5656
/// along to client calls.
57+
#[allow(unused)]
5758
pub(crate) trait HeaderValue {
5859
fn header_value(&self) -> String;
5960
}

Diff for: rust/src.axum/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![cfg_attr(docsrs, feature(doc_cfg))]
22
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]
33
#![deny(unreachable_pub)]
4+
#![deny(private_bounds)]
5+
#![deny(rustdoc::private_intra_doc_links)]
6+
#![deny(private_interfaces)]
47

58
//! {{project-name}}
69

Diff for: rust/src.axum/main.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ use std::{
1212
};
1313
use tokio::signal;
1414
#[cfg(unix)]
15-
use tokio::signal::{
16-
unix::{signal, SignalKind},
17-
};
15+
use tokio::signal::unix::{signal, SignalKind};
1816
use tower::ServiceBuilder;
1917
use tower_http::{
2018
catch_panic::CatchPanicLayer, sensitive_headers::SetSensitiveHeadersLayer,

Diff for: rust/src.axum/middleware/logging.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ async fn log_reqwest_response(
279279
.headers_mut()
280280
.ok_or_else(|| anyhow!("failed to convert response headers"))?;
281281

282-
headers.extend(headers_iter.map(|(k, v)| (k, v)));
282+
headers.extend(headers_iter);
283283

284284
let res = builder.body(body)?;
285285
Ok(reqwest::Response::from(res))

Diff for: rust/src.axum/middleware/reqwest_retry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ static MAXIMUM_NUMBER_OF_RETRIES: u32 = 10;
5151
///
5252
/// Some workaround suggestions:
5353
/// * If you can fit the data in memory, you can instead build static request bodies e.g. with
54-
/// `Body`'s `From<String>` or `From<Bytes>` implementations.
54+
/// `Body`'s `From<String>` or `From<Bytes>` implementations.
5555
/// * You can wrap this middleware in a custom one which skips retries for streaming requests.
5656
/// * You can write a custom retry middleware that builds new streaming requests from the data
57-
/// source directly, avoiding the issue of streaming requests not being clonable.
57+
/// source directly, avoiding the issue of streaming requests not being clonable.
5858
#[derive(Debug)]
5959
pub struct RetryTransientMiddleware<T: RetryPolicy + Send + Sync + 'static> {
6060
client_name: String,

Diff for: rust/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![cfg_attr(docsrs, feature(doc_cfg))]
22
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]
33
#![deny(unreachable_pub)]
4+
#![deny(private_bounds)]
5+
#![deny(rustdoc::private_intra_doc_links)]
6+
#![deny(private_interfaces)]
47

58
//! {{project-name}}
69
{% if bench %}

0 commit comments

Comments
 (0)