feat: fix clippy & update dependencies

This commit is contained in:
2024-04-21 11:15:14 +08:00
parent 68473e2f01
commit b3d8c791c4
4 changed files with 44 additions and 47 deletions

View File

@@ -36,7 +36,7 @@ impl SignFileRequest {
let tobe_signed_filename = SignFileTlv::Filename(self.filename.clone()).to_byes();
debugging!("Tobe signed filename: {} ({:?})", hex::encode(&tobe_signed_filename), &self.filename);
tobe_signed.extend_from_slice(&tobe_signed_filename);
let tobe_signed_timestamp = SignFileTlv::Timestamp(self.timestamp.clone()).to_byes();
let tobe_signed_timestamp = SignFileTlv::Timestamp(self.timestamp).to_byes();
debugging!("Tobe signed timestamp: {} ({})", hex::encode(&tobe_signed_timestamp), &self.timestamp);
tobe_signed.extend_from_slice(&tobe_signed_timestamp);
let tobe_signed_attributes = SignFileTlv::Attributes(self.attributes.clone()).to_byes();
@@ -196,8 +196,8 @@ impl Command for CommandImpl {
let filename_opt = match filename_opt {
Some(filename) => Some(filename),
None => sub_arg_matches.value_of("file").map(|f| {
if f.contains("/") {
f.split("/").last().unwrap().to_string()
if f.contains('/') {
f.split('/').last().unwrap().to_string()
} else {
f.to_string()
}
@@ -218,11 +218,11 @@ impl Command for CommandImpl {
let signed_data = opt_result!(sign_data(&mut yk, &tobe_signed_digest, algorithm_id, slot_id), "Sign PIV failed: {}");
let signature_bytes = signed_data.as_slice();
debugging!("Tobe signed signature: {}", hex::encode(&signature_bytes));
debugging!("Tobe signed signature: {}", hex::encode(signature_bytes));
let signature = SimpleSignFileSignature {
algorithm: SIGNATURE_ALGORITHM_SHA256_WITH_ECDSA.to_string(),
signature: format!("{}", base64_encode(&signature_bytes)),
signature: base64_encode(signature_bytes),
certificates,
};
let simple_sig = SimpleSignFile {
@@ -254,7 +254,7 @@ struct FetchCertificateResponse {
fn fetch_certificates(fingerprint: &str) -> XResult<Vec<String>> {
let url = format!("{}{}", CERTIFICATES_SEARCH_URL, fingerprint);
let certificates_response = opt_result!( reqwest::blocking::get(&url), "Fetch certificates failed: {}");
let certificates_response = opt_result!( reqwest::blocking::get(url), "Fetch certificates failed: {}");
let certificates_response_bytes = opt_result!(certificates_response.bytes(), "Fetch certificates failed: {}");
let response = opt_result!(
serde_json::from_slice::<FetchCertificateResponse>(certificates_response_bytes.as_bytes()),

View File

@@ -166,10 +166,7 @@ fn split_claim(claim: &str) -> Option<(String, Value)> {
let mut claim_chars = claim.chars().peekable();
let ty = if let Some('^') = claim_chars.peek() {
let _ = claim_chars.next();
match claim_chars.next() {
None => return None,
Some(t) => Some(t),
}
claim_chars.next()
} else {
None
};
@@ -192,7 +189,7 @@ fn split_claim(claim: &str) -> Option<(String, Value)> {
match ty {
None | Some('s') => Some((k, Value::String(v))),
Some('b') => Some((k, Value::Bool(vec!["true", "yes", "1"].contains(&v.as_str())))),
Some('b') => Some((k, Value::Bool(["true", "yes", "1"].contains(&v.as_str())))),
Some('i') | Some('n') => {
if let Ok(i) = v.parse::<i64>() {
return Some((k, Value::Number(Number::from(i))));