Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clippy::unwrap_used lint #515

Merged
merged 1 commit into from
Aug 16, 2023
Merged

Add clippy::unwrap_used lint #515

merged 1 commit into from
Aug 16, 2023

Conversation

tony-iqlusion
Copy link
Member

Lints for usages of unwrap() in the yubikey crate (not CLI yet).

Replaces them with ? or expect() as the situation warrants.

Lints for usages of `unwrap()` in the `yubikey` crate (not CLI yet).

Replaces them with `?` or `expect()` as the situation warrants.
@@ -48,6 +48,7 @@ const OBJ_CAPABILITY: u32 = 0x005f_c107;
/// - 0xff == Manufacturer ID (dummy)
/// - 0x02 == Card type (javaCard)
/// - next 14 bytes: card ID
#[allow(dead_code)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out we don't actually use this

@@ -767,6 +767,7 @@ impl RsaKeyData {
/// Generates a new RSA key data set from two randomly generated, secret, primes.
///
/// Panics if `secret_p` or `secret_q` are invalid primes.
#[allow(clippy::unwrap_used)] // TODO(tarcieri): make fallible and handle errors
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there are a lot of situations where malformed/malchosen p/q will currently cause this code to crash

@@ -648,7 +647,11 @@ impl YubiKey {
return Err(Error::AuthenticationError);
}

Ok(response.data()[4..12].try_into().unwrap())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing actually checked response.data().len() here so this could've potentially panicked if the response were malformed

@tony-iqlusion tony-iqlusion merged commit 7831336 into main Aug 16, 2023
9 checks passed
@tony-iqlusion tony-iqlusion deleted the clippy/unwrap_used branch August 16, 2023 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant