Skip to content

Commit 06b769b

Browse files
committed
run cargo fmt, fix merge issues
Signed-off-by: Wolf Vollprecht <[email protected]>
1 parent a21dc96 commit 06b769b

File tree

9 files changed

+60
-50
lines changed

9 files changed

+60
-50
lines changed

src/cosign/bundle.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ impl Bundle {
8888
rekor_pub_keys: &BTreeMap<String, CosignVerificationKey>,
8989
) -> Result<()> {
9090
let mut encoded = Vec::new();
91-
let mut ser = serde_json::Serializer::with_formatter(&mut encoded, CanonicalFormatter::new());
91+
let mut ser =
92+
serde_json::Serializer::with_formatter(&mut encoded, CanonicalFormatter::new());
9293
bundle.payload.serialize(&mut ser).map_err(|e| {
9394
SigstoreError::UnexpectedError(format!("Cannot serialize bundle payload: {e:?}"))
9495
})?;

src/crypto/merkle/proof_verification.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::rfc6962::Rfc6269HasherTrait;
2+
use MerkleProofError::*;
23
use digest::{Digest, Output};
34
use hex::ToHex;
45
use std::cmp::Ordering;
56
use std::fmt::Debug;
6-
use MerkleProofError::*;
77

88
#[derive(Debug)]
99
pub enum MerkleProofError {
@@ -101,17 +101,17 @@ where
101101
return Self::verify_match(old_root, new_root).map_err(|_| MismatchedRoot {
102102
got: new_root.encode_hex(),
103103
expected: old_root.encode_hex(),
104-
})
104+
});
105105
}
106106

107107
// the proof cannot be empty if the sizes are equal or the previous size was zero
108108
(Ordering::Equal, _, false) | (Ordering::Less, true, false) => {
109-
return Err(UnexpectedNonEmptyProof)
109+
return Err(UnexpectedNonEmptyProof);
110110
}
111111
// any proof is accepted if old_size == 0 and the hash is the expected empty hash
112112
(Ordering::Less, true, true) => {
113113
return Self::verify_match(old_root, &Self::empty_root())
114-
.map_err(|_| WrongEmptyTreeHash)
114+
.map_err(|_| WrongEmptyTreeHash);
115115
}
116116
(Ordering::Less, false, true) => return Err(UnexpectedEmptyProof),
117117
(Ordering::Less, false, false) => {}

src/crypto/merkle/rfc6962.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ pub(crate) type Rfc6269Default = Sha256;
4747
/// These tests were taken from the [transparency-dev Merkle implementation](https://github.com/transparency-dev/merkle/blob/036047b5d2f7faf3b1ee643d391e60fe5b1defcf/rfc6962/rfc6962_test.go).
4848
#[cfg(test)]
4949
mod test_rfc6962 {
50-
use crate::crypto::merkle::rfc6962::Rfc6269HasherTrait;
5150
use crate::crypto::merkle::Rfc6269Default;
51+
use crate::crypto::merkle::rfc6962::Rfc6269HasherTrait;
5252
use hex_literal::hex;
5353

5454
#[derive(Debug, PartialEq)]

src/crypto/merkle/testdata_tests.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
use super::proof_verification::MerkleProofVerifier;
2121
use super::rfc6962::Rfc6269Default;
22-
use base64::{engine::general_purpose::STANDARD as base64, Engine as _};
22+
use base64::{Engine as _, engine::general_purpose::STANDARD as base64};
2323
use digest::Output;
2424
use rstest::rstest;
2525
use serde::Deserialize;
@@ -69,13 +69,11 @@ fn decode_base64_hash(s: &str) -> Result<Output<Rfc6269Default>, String> {
6969
}
7070

7171
#[rstest]
72-
fn test_inclusion_proof(
73-
#[files("tests/data/merkle/testdata/inclusion/**/*.json")] path: PathBuf,
74-
) {
75-
let content = fs::read_to_string(&path)
76-
.unwrap_or_else(|_| panic!("Failed to read file: {:?}", path));
77-
let vector: InclusionProofTestVector =
78-
serde_json::from_str(&content).unwrap_or_else(|e| panic!("Failed to parse {:?}: {}", path, e));
72+
fn test_inclusion_proof(#[files("tests/data/merkle/testdata/inclusion/**/*.json")] path: PathBuf) {
73+
let content =
74+
fs::read_to_string(&path).unwrap_or_else(|_| panic!("Failed to read file: {:?}", path));
75+
let vector: InclusionProofTestVector = serde_json::from_str(&content)
76+
.unwrap_or_else(|e| panic!("Failed to parse {:?}: {}", path, e));
7977

8078
// Try to decode - if any decoding fails and we expect an error, accept it
8179
let root_result = decode_base64_hash(&vector.root);
@@ -120,10 +118,10 @@ fn test_inclusion_proof(
120118
fn test_consistency_proof(
121119
#[files("tests/data/merkle/testdata/consistency/**/*.json")] path: PathBuf,
122120
) {
123-
let content = fs::read_to_string(&path)
124-
.unwrap_or_else(|_| panic!("Failed to read file: {:?}", path));
125-
let vector: ConsistencyProofTestVector =
126-
serde_json::from_str(&content).unwrap_or_else(|e| panic!("Failed to parse {:?}: {}", path, e));
121+
let content =
122+
fs::read_to_string(&path).unwrap_or_else(|_| panic!("Failed to read file: {:?}", path));
123+
let vector: ConsistencyProofTestVector = serde_json::from_str(&content)
124+
.unwrap_or_else(|e| panic!("Failed to parse {:?}: {}", path, e));
127125

128126
// Try to decode - if any decoding fails and we expect an error, accept it
129127
let root1_result = decode_base64_hash(&vector.root1);
@@ -134,8 +132,7 @@ fn test_consistency_proof(
134132
.map(|p| p.iter().map(|h| decode_base64_hash(h)).collect())
135133
.unwrap_or(Ok(Vec::new()));
136134

137-
if (root1_result.is_err() || root2_result.is_err() || proof_result.is_err())
138-
&& vector.want_err
135+
if (root1_result.is_err() || root2_result.is_err() || proof_result.is_err()) && vector.want_err
139136
{
140137
// Expected error due to invalid input
141138
return;

src/registry/oci_caching_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ async fn pull_manifest_cached(
245245
impl ClientCapabilitiesDeps for OciCachingClient {}
246246

247247
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
248-
#[cfg_attr(target_arch = "wasm32", async_trait(? Send))]
248+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
249249
impl ClientCapabilities for OciCachingClient {
250250
async fn fetch_manifest_digest(
251251
&mut self,

src/rekor/models/checkpoint.rs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::crypto::{CosignVerificationKey, Signature};
33
use crate::errors::SigstoreError;
44
use crate::errors::SigstoreError::ConsistencyProofError;
55
use crate::rekor::models::checkpoint::ParseCheckpointError::*;
6-
use base64::prelude::BASE64_STANDARD;
76
use base64::Engine;
7+
use base64::prelude::BASE64_STANDARD;
88
use digest::Output;
99
use serde::{Deserialize, Deserializer, Serialize, Serializer};
1010
use std::fmt::Write;
@@ -239,7 +239,8 @@ mod test {
239239
9944,
240240
[1; 32],
241241
vec![],
242-
"Banana Checkpoint v5\n9944\nAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=\n", ),
242+
"Banana Checkpoint v5\n9944\nAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=\n",
243+
),
243244
(
244245
"Banana Checkpoint v7",
245246
9943,
@@ -280,7 +281,8 @@ mod test {
280281
9944,
281282
[1; 32],
282283
vec![],
283-
"Banana Checkpoint v5\n9944\nAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=\n", ),
284+
"Banana Checkpoint v5\n9944\nAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=\n",
285+
),
284286
(
285287
"valid with multiple trailing data lines",
286288
"Banana Checkpoint v7",
@@ -294,7 +296,10 @@ mod test {
294296
"Banana Checkpoint v7",
295297
9943,
296298
[2; 32],
297-
vec![KeyValue("Timestamp".to_string(), "1689748607742585419".to_string())],
299+
vec![KeyValue(
300+
"Timestamp".to_string(),
301+
"1689748607742585419".to_string(),
302+
)],
298303
"Banana Checkpoint v7\n9943\nAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=\nTimestamp: 1689748607742585419\n",
299304
),
300305
(
@@ -322,22 +327,24 @@ mod test {
322327

323328
#[test]
324329
fn test_unmarshal_invalid() {
325-
let test_cases = [(
326-
"invalid - insufficient lines",
327-
"Head\n9944\n",
328-
), (
329-
"invalid - empty header",
330-
"\n9944\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n",
331-
), (
332-
"invalid - missing newline on roothash",
333-
"Log Checkpoint v0\n123\nYmFuYW5hcw==",
334-
), (
335-
"invalid size - not a number",
336-
"Log Checkpoint v0\nbananas\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n",
337-
), (
338-
"invalid size - negative",
339-
"Log Checkpoint v0\n-34\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n",
340-
),
330+
let test_cases = [
331+
("invalid - insufficient lines", "Head\n9944\n"),
332+
(
333+
"invalid - empty header",
334+
"\n9944\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n",
335+
),
336+
(
337+
"invalid - missing newline on roothash",
338+
"Log Checkpoint v0\n123\nYmFuYW5hcw==",
339+
),
340+
(
341+
"invalid size - not a number",
342+
"Log Checkpoint v0\nbananas\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n",
343+
),
344+
(
345+
"invalid size - negative",
346+
"Log Checkpoint v0\n-34\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n",
347+
),
341348
(
342349
"invalid size - too large",
343350
"Log Checkpoint v0\n3438945738945739845734895735\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n",

src/rekor/models/inclusion_proof.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
* Generated by: https://openapi-generator.tech
99
*/
1010

11+
use crate::crypto::CosignVerificationKey;
1112
use crate::crypto::merkle::{
12-
hex_to_hash_output, MerkleProofVerifier, Rfc6269Default, Rfc6269HasherTrait,
13+
MerkleProofVerifier, Rfc6269Default, Rfc6269HasherTrait, hex_to_hash_output,
1314
};
14-
use crate::crypto::CosignVerificationKey;
1515
use crate::errors::SigstoreError;
1616
use crate::errors::SigstoreError::{InclusionProofError, UnexpectedError};
17-
use crate::rekor::models::checkpoint::Checkpoint;
1817
use crate::rekor::TreeSize;
18+
use crate::rekor::models::checkpoint::Checkpoint;
1919
use serde::{Deserialize, Serialize};
2020

2121
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]

src/rekor/models/log_entry.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use base64::{Engine as _, engine::general_purpose::STANDARD as BASE64_STD_ENGINE
1919

2020
use crate::crypto::CosignVerificationKey;
2121
use crate::errors::SigstoreError::UnexpectedError;
22-
use crate::rekor::models::checkpoint::Checkpoint;
2322
use crate::rekor::models::InclusionProof as InclusionProof2;
23+
use crate::rekor::models::checkpoint::Checkpoint;
2424
use olpc_cjson::CanonicalFormatter;
2525
use serde::{Deserialize, Serialize};
2626
use serde_json::{Error, Value, json};
@@ -161,9 +161,14 @@ impl LogEntry {
161161
.and_then(|proof| {
162162
// encode as canonical JSON
163163
let mut encoded_entry = Vec::new();
164-
let mut ser = serde_json::Serializer::with_formatter(&mut encoded_entry, CanonicalFormatter::new());
164+
let mut ser = serde_json::Serializer::with_formatter(
165+
&mut encoded_entry,
166+
CanonicalFormatter::new(),
167+
);
165168
self.body.serialize(&mut ser).map_err(|e| {
166-
SigstoreError::UnexpectedError(format!("Cannot serialize log entry body: {e:?}"))
169+
SigstoreError::UnexpectedError(format!(
170+
"Cannot serialize log entry body: {e:?}"
171+
))
167172
})?;
168173
proof.verify(&encoded_entry, rekor_key)
169174
})

src/rekor/models/log_info.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
* Generated by: https://openapi-generator.tech
99
*/
1010

11-
use crate::crypto::merkle::hex_to_hash_output;
1211
use crate::crypto::CosignVerificationKey;
12+
use crate::crypto::merkle::hex_to_hash_output;
1313
use crate::errors::SigstoreError;
14-
use crate::rekor::models::checkpoint::Checkpoint;
15-
use crate::rekor::models::ConsistencyProof;
1614
use crate::rekor::TreeSize;
15+
use crate::rekor::models::ConsistencyProof;
16+
use crate::rekor::models::checkpoint::Checkpoint;
1717
use serde::{Deserialize, Serialize};
1818

1919
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]

0 commit comments

Comments
 (0)