From 5f6bb25e6d12c9cf9971cf1d18073993dc01c599 Mon Sep 17 00:00:00 2001 From: Lindsay Stewart Date: Mon, 30 Sep 2024 14:47:57 -0700 Subject: [PATCH] ci: run clippy on all features (#4809) --- .github/workflows/ci_rust.yml | 1 + bindings/rust/s2n-tls/src/client_hello.rs | 8 ++++---- bindings/rust/s2n-tls/src/fingerprint.rs | 6 +++--- bindings/rust/s2n-tls/src/renegotiate.rs | 12 ++++++------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci_rust.yml b/.github/workflows/ci_rust.yml index cfaf30318ba..e768fce9c7d 100644 --- a/.github/workflows/ci_rust.yml +++ b/.github/workflows/ci_rust.yml @@ -254,6 +254,7 @@ jobs: - name: Run cargo clippy run: | cargo clippy --manifest-path ${{env.ROOT_PATH}}/Cargo.toml --all-targets -- -D warnings + cargo clippy --manifest-path ${{env.ROOT_PATH}}/Cargo.toml --all-targets --all-features -- -D warnings msrv: runs-on: ubuntu-latest diff --git a/bindings/rust/s2n-tls/src/client_hello.rs b/bindings/rust/s2n-tls/src/client_hello.rs index 590e0d241f6..fb6f6fcc55f 100644 --- a/bindings/rust/s2n-tls/src/client_hello.rs +++ b/bindings/rust/s2n-tls/src/client_hello.rs @@ -138,6 +138,10 @@ impl fmt::Debug for ClientHello { } } +// Leftover from when fingerprinting was implemented in this module +#[cfg(feature = "unstable-fingerprint")] +pub use crate::fingerprint::FingerprintType; + #[cfg(test)] mod tests { use crate::client_hello::ClientHello; @@ -177,7 +181,3 @@ mod tests { assert_eq!("incoming.telemetry.mozilla.org".as_bytes(), server_name); } } - -// Leftover from when fingerprinting was implemented in this module -#[cfg(feature = "unstable-fingerprint")] -pub use crate::fingerprint::FingerprintType; diff --git a/bindings/rust/s2n-tls/src/fingerprint.rs b/bindings/rust/s2n-tls/src/fingerprint.rs index 0b83371ab4c..8b4e7153f99 100644 --- a/bindings/rust/s2n-tls/src/fingerprint.rs +++ b/bindings/rust/s2n-tls/src/fingerprint.rs @@ -362,7 +362,7 @@ mod tests { }; use std::{collections::HashSet, error::Error}; - const CLIENT_HELLO_BYTES: &'static [u8] = &[ + const CLIENT_HELLO_BYTES: &[u8] = &[ 0x01, 0x00, 0x00, 0xEC, 0x03, 0x03, 0x90, 0xe8, 0xcc, 0xee, 0xe5, 0x70, 0xa2, 0xa1, 0x2f, 0x6b, 0x69, 0xd2, 0x66, 0x96, 0x0f, 0xcf, 0x20, 0xd5, 0x32, 0x6e, 0xc4, 0xb2, 0x8c, 0xc7, 0xbd, 0x0a, 0x06, 0xc2, 0xa5, 0x14, 0xfc, 0x34, 0x20, 0xaf, 0x72, 0xbf, 0x39, 0x99, 0xfb, @@ -398,7 +398,7 @@ mod tests { let client_hello = pair.server.client_hello()?; let mut builder = Fingerprint::builder(FingerprintType::JA3)?; - let mut fingerprint = builder.build(&client_hello)?; + let mut fingerprint = builder.build(client_hello)?; let hash_size = fingerprint.hash_size()?; let hash = fingerprint.hash()?; @@ -498,7 +498,7 @@ mod tests { pair.handshake()?; let client_hello = pair.server.client_hello()?; - let mut fingerprint = builder.build(&client_hello)?; + let mut fingerprint = builder.build(client_hello)?; let hash = fingerprint.hash()?; hex::decode(hash)?; diff --git a/bindings/rust/s2n-tls/src/renegotiate.rs b/bindings/rust/s2n-tls/src/renegotiate.rs index ba382f174a4..78deec920f4 100644 --- a/bindings/rust/s2n-tls/src/renegotiate.rs +++ b/bindings/rust/s2n-tls/src/renegotiate.rs @@ -121,7 +121,7 @@ impl config::Builder { return CallbackResult::Success.into(); } } - return CallbackResult::Failure.into(); + CallbackResult::Failure.into() }) } @@ -311,7 +311,7 @@ mod tests { // Like s2n-tls, a call to send / write is required. let to_send = [0; 1]; self.server - .write(&to_send) + .write_all(&to_send) .expect("Failed to write hello request"); // s2n-tls needs to attempt to read data to receive the message @@ -328,7 +328,7 @@ mod tests { self.server.write_all(&to_send)?; unwrap_poll(self.client.poll_recv(&mut recv_buffer))?; unwrap_poll(self.client.poll_send(&to_send))?; - self.server.read(&mut recv_buffer)?; + self.server.read_exact(&mut recv_buffer)?; Ok(()) } @@ -447,7 +447,7 @@ mod tests { let to_write = "hello world"; let mut buf = [0; 100]; pair.server - .write(to_write.as_bytes()) + .write_all(to_write.as_bytes()) .expect("Application data during renegotiate"); let (result, n) = pair.client.poll_renegotiate(&mut buf); assert!(result.is_pending()); @@ -489,7 +489,7 @@ mod tests { if this.count > 1 { // Repeatedly block the handshake in order to verify // that renegotiate can handle Pending callbacks. - this.count = this.count - 1; + this.count -= 1; Pending } else { // Perform the pkey operation with the selected cert / key pair. @@ -568,7 +568,7 @@ mod tests { if this.count > 1 { // Repeatedly block the handshake in order to verify // that renegotiate can handle Pending callbacks. - this.count = this.count - 1; + this.count -= 1; Pending } else { conn.set_server_name(&this.server_name)?;