Skip to content

Commit

Permalink
chore: fix a bunch of clippy warnings
Browse files Browse the repository at this point in the history
Address clippy warnings

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
  • Loading branch information
flavio committed Oct 12, 2022
1 parent 5b1fae7 commit b337376
Show file tree
Hide file tree
Showing 35 changed files with 53 additions and 55 deletions.
2 changes: 1 addition & 1 deletion examples/cosign/verify/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async fn run_app(
let mut client_builder = sigstore::cosign::ClientBuilder::default();

if let Some(key) = frd.rekor_pub_key.as_ref() {
client_builder = client_builder.with_rekor_pub_key(&key);
client_builder = client_builder.with_rekor_pub_key(key);
}

if !frd.fulcio_certs.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion examples/openidflow/openidconnect/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() -> Result<(), anyhow::Error> {
open::that(url.0.to_string())?;
println!(
"Open this URL in a browser if it does not automatically open for you:\n{}\n",
url.0.to_string()
url.0
);
}
Err(e) => println!("{}", e),
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ OSWS1X9vPavpiQOoTTGC0xX57OojUadxF1cdQmrsiReWg2Wn4FneJfa8xw==
let public_key = private_key.public_key();

let ec_pub_key =
EcKey::from_public_key(&group, &public_key).expect("Cannot create ec pub key");
EcKey::from_public_key(&group, public_key).expect("Cannot create ec pub key");
let pkey = pkey::PKey::from_ec_key(ec_pub_key).expect("Cannot create pkey");

let mut x509_name_builder = X509NameBuilder::new()?;
Expand Down Expand Up @@ -369,7 +369,7 @@ OSWS1X9vPavpiQOoTTGC0xX57OojUadxF1cdQmrsiReWg2Wn4FneJfa8xw==
// set issuer
if let Some(issuer_data) = issuer {
let issuer_name = issuer_data.cert.subject_name();
x509_builder.set_issuer_name(&issuer_name)?;
x509_builder.set_issuer_name(issuer_name)?;
} else {
// self signed cert
x509_builder.set_issuer_name(&x509_name)?;
Expand Down
6 changes: 2 additions & 4 deletions src/crypto/signing_key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,8 @@ mod tests {
#[case(SigningScheme::ECDSA_P384_SHA384_ASN1)]
#[case(SigningScheme::ED25519)]
fn sigstore_signing(#[case] signing_scheme: SigningScheme) {
let signer = signing_scheme.create_signer().expect(&format!(
"create SigStoreSigner with {:?} failed",
signing_scheme
));
let signer = signing_scheme.create_signer().unwrap_or_else(|_| panic!("create SigStoreSigner with {:?} failed",
signing_scheme));
let key_pair = signer
.to_sigstore_keypair()
.expect("convert SigStoreSigner to SigStoreKeypair failed.");
Expand Down
10 changes: 5 additions & 5 deletions src/crypto/verification_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ mod tests {
.expect("Cannot create CosignVerificationKey");
let msg = r#"{"critical":{"identity":{"docker-reference":"registry-testing.svc.lan/busybox"},"image":{"docker-manifest-digest":"sha256:f3cfc9d0dbf931d3db4685ec659b7ac68e2a578219da4aae65427886e649b06b"},"type":"cosign container image signature"},"optional":null}"#;

let outcome = verification_key.verify_signature(signature, &msg.as_bytes());
let outcome = verification_key.verify_signature(signature, msg.as_bytes());
assert!(outcome.is_ok());
}

Expand All @@ -301,7 +301,7 @@ mod tests {
let msg = "hello world";

let err = verification_key
.verify_signature(signature, &msg.as_bytes())
.verify_signature(signature, msg.as_bytes())
.expect_err("Was expecting an error");
let found = match err {
SigstoreError::PublicKeyVerificationError => true,
Expand All @@ -319,7 +319,7 @@ mod tests {
let msg = r#"{"critical":{"identity":{"docker-reference":"registry-testing.svc.lan/busybox"},"image":{"docker-manifest-digest":"sha256:f3cfc9d0dbf931d3db4685ec659b7ac68e2a578219da4aae65427886e649b06b"},"type":"cosign container image signature"},"optional":null}"#;

let err = verification_key
.verify_signature(signature, &msg.as_bytes())
.verify_signature(signature, msg.as_bytes())
.expect_err("Was expecting an error");
let found = match err {
SigstoreError::Base64DecodeError(_) => true,
Expand All @@ -344,7 +344,7 @@ JsB89BPhZYch0U0hKANx5TY+ncrm0s8bfJxxHoenAEFhwhuXeb4PqIrtoQ==
let msg = r#"{"critical":{"identity":{"docker-reference":"registry-testing.svc.lan/busybox"},"image":{"docker-manifest-digest":"sha256:f3cfc9d0dbf931d3db4685ec659b7ac68e2a578219da4aae65427886e649b06b"},"type":"cosign container image signature"},"optional":null}"#;

let err = verification_key
.verify_signature(signature, &msg.as_bytes())
.verify_signature(signature, msg.as_bytes())
.expect_err("Was expecting an error");
let found = match err {
SigstoreError::PublicKeyVerificationError => true,
Expand Down Expand Up @@ -374,7 +374,7 @@ DwIDAQAB
let msg = r#"{"critical":{"identity":{"docker-reference":"registry.suse.com/suse/sle-micro/5.0/toolbox"},"image":{"docker-manifest-digest":"sha256:356631f7603526a0af827741f5fe005acf19b7ef7705a34241a91c2d47a6db5e"},"type":"cosign container image signature"},"optional":{"creator":"OBS"}}"#;

assert!(verification_key
.verify_signature(signature, &msg.as_bytes())
.verify_signature(signature, msg.as_bytes())
.is_ok());
}
}
2 changes: 1 addition & 1 deletion src/rekor/apis/entries_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub enum SearchLogQueryError {
UnknownValue(serde_json::Value),
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LogEntries {
entries: Vec<LogEntry>,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/alpine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use serde::{Deserialize, Serialize};

/// Alpine : Alpine package
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Alpine {
#[serde(rename = "kind")]
pub kind: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/alpine_all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct AlpineAllOf {
#[serde(rename = "apiVersion")]
pub api_version: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/consistency_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct ConsistencyProof {
/// The hash value stored at the root of the merkle tree at the time the proof was generated
#[serde(rename = "rootHash")]
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Error {
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
pub code: Option<i32>,
Expand Down
14 changes: 7 additions & 7 deletions src/rekor/models/hashedrekord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use url::Url;

/// Hashedrekord : Hashed Rekord object
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Hashedrekord {
#[serde(rename = "kind")]
pub kind: String,
Expand All @@ -35,7 +35,7 @@ impl Hashedrekord {
}

/// Stores the Signature and Data struct
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Spec {
signature: Signature,
Expand All @@ -50,7 +50,7 @@ impl Spec {
}

/// Stores the signature format, signature of the artifact and the PublicKey struct
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Signature {
format: String,
Expand All @@ -69,7 +69,7 @@ impl Signature {
}

/// Stores the public key used to sign the artifact
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PublicKey {
content: String,
Expand All @@ -81,7 +81,7 @@ impl PublicKey {
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Data {
hash: Hash,
Expand All @@ -94,15 +94,15 @@ impl Data {
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[allow(non_camel_case_types)]
pub enum AlgorithmKind {
sha256,
sha1,
}

/// Stores the algorithm used to hash the artifact and the value of the hash
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Hash {
algorithm: AlgorithmKind,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/hashedrekord_all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct HashedrekordAllOf {
#[serde(rename = "apiVersion")]
pub api_version: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/helm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};

/// Helm : Helm chart
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Helm {
#[serde(rename = "kind")]
pub kind: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/helm_all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct HelmAllOf {
#[serde(rename = "apiVersion")]
pub api_version: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/inactive_shard_log_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct InactiveShardLogInfo {
/// The current hash value stored at the root of the merkle tree
#[serde(rename = "rootHash")]
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/inclusion_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct InclusionProof {
/// The index of the entry in the transparency log
#[serde(rename = "logIndex")]
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/intoto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};

/// Intoto : Intoto object
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Intoto {
#[serde(rename = "kind")]
pub kind: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/intoto_all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct IntotoAllOf {
#[serde(rename = "apiVersion")]
pub api_version: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/jar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// Jar : Java Archive (JAR)
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Jar {
#[serde(rename = "kind")]
pub kind: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/jar_all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct JarAllOf {
#[serde(rename = "apiVersion")]
pub api_version: String,
Expand Down
8 changes: 4 additions & 4 deletions src/rekor/models/log_entry.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};

/// Stores the response returned by Rekor after making a new entry
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LogEntry {
uuid: String,
Expand All @@ -14,7 +14,7 @@ pub struct LogEntry {
verification: Verification,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Attestation {
// This field is just a place holder
Expand All @@ -24,7 +24,7 @@ pub struct Attestation {
}

/// Stores the signature over the artifact's logID, logIndex, body and integratedTime.
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Verification {
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -33,7 +33,7 @@ pub struct Verification {
}

/// Stores the signature over the artifact's logID, logIndex, body and integratedTime.
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InclusionProof {
hashes: Vec<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/log_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct LogInfo {
/// The current hash value stored at the root of the merkle tree
#[serde(rename = "rootHash")]
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/proposed_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(tag = "kind")]
pub enum ProposedEntry {
#[serde(rename = "alpine")]
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/rekord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// Rekord : Rekord object
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Rekord {
#[serde(rename = "kind")]
pub kind: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/rekord_all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct RekordAllOf {
#[serde(rename = "apiVersion")]
pub api_version: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/rfc3161.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// Rfc3161 : RFC3161 Timestamp
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Rfc3161 {
#[serde(rename = "kind")]
pub kind: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/rfc3161_all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Rfc3161AllOf {
#[serde(rename = "apiVersion")]
pub api_version: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/rpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};

/// Rpm : RPM package
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct Rpm {
#[serde(rename = "kind")]
pub kind: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/rpm_all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct RpmAllOf {
#[serde(rename = "apiVersion")]
pub api_version: String,
Expand Down
2 changes: 1 addition & 1 deletion src/rekor/models/search_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct SearchIndex {
#[serde(rename = "email", skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
Expand Down
Loading

0 comments on commit b337376

Please sign in to comment.