Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
brew install protobuf
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.81
toolchain: 1.86
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
sudo apt-get install -y protobuf-compiler
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.81
toolchain: 1.86
override: true
- name: Add target
run: rustup target add ${{ matrix.target }}
Expand All @@ -86,7 +86,7 @@ jobs:
sudo apt-get install -y protobuf-compiler
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.81
toolchain: 1.86
override: true
- name: cargo check
uses: actions-rs/cargo@v1
Expand All @@ -95,7 +95,7 @@ jobs:
args: --tests --examples --benches --all-features

clippy:
name: Clippy (1.81)
name: Clippy (1.86)
runs-on: ubuntu-latest

steps:
Expand All @@ -106,13 +106,13 @@ jobs:
sudo apt-get install -y protobuf-compiler
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.81
toolchain: 1.86
components: clippy
override: true
- name: Clippy check
uses: actions-rs/clippy-check@v1
with:
name: Clippy (1.81)
name: Clippy (1.86)
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings

Expand All @@ -128,7 +128,7 @@ jobs:
sudo apt-get install -y protobuf-compiler
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.81
toolchain: 1.86
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
Expand All @@ -151,7 +151,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.81
toolchain: 1.86
components: rustfmt
override: true
- name: Check formatting
Expand Down
88 changes: 42 additions & 46 deletions plexi_cli/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ impl fmt::Display for VerificationStatus {
let s = match self {
VerificationStatus::Success => "success".to_string(),
VerificationStatus::Disabled => "-".to_string(),
VerificationStatus::Failed(err) => format!("failed - {}", err),
VerificationStatus::Failed(err) => format!("failed - {err}"),
};
write!(f, "{}", s)
write!(f, "{s}")
}
}

Expand All @@ -138,7 +138,7 @@ fn format_audit_response(
time::OffsetDateTime::from_unix_timestamp((signature.timestamp() / 1000) as i64)?
.format(&format)?;

return Ok([
Ok([
"Namespace",
format!(
" {: <22}: {namespace}",
Expand All @@ -152,7 +152,7 @@ fn format_audit_response(
version = format_ciphersuite(signature.version())
)
.as_str(),
format!("\nSignature ({timestamp})", timestamp = formatted_timestamp).as_str(),
format!("\nSignature ({formatted_timestamp})").as_str(),
format!(
" {: <22}: {epoch}",
"Epoch height".bold(),
Expand Down Expand Up @@ -184,7 +184,7 @@ fn format_audit_response(
)
.as_str(),
]
.join("\n"));
.join("\n"))
}

pub async fn audit(
Expand All @@ -196,16 +196,15 @@ pub async fn audit(
epoch: Option<&Epoch>,
) -> Result<String> {
let client = PlexiClient::new(Url::parse(remote_url)?, None, Some(APP_USER_AGENT))?;
let epoch = match epoch {
Some(epoch) => epoch,
None => {
let Some(last_verified_epoch) = client.last_verified_epoch(namespace).await? else {
return Err(anyhow!(
"namespace {namespace} does not have a latest epoch. Please specify one"
));
};
&last_verified_epoch.epoch()
}
let epoch = if let Some(epoch) = epoch {
epoch
} else {
let Some(last_verified_epoch) = client.last_verified_epoch(namespace).await? else {
return Err(anyhow!(
"namespace {namespace} does not have a latest epoch. Please specify one"
));
};
&last_verified_epoch.epoch()
};
let Some(signature) = client.signature(namespace, epoch).await? else {
return Err(anyhow!(
Expand All @@ -225,36 +224,33 @@ pub async fn audit(

// verify the signature against the log signature
let config = client.auditor_config().await?;
let verifying_key = match verifying_key {
Some(key) => key,
None => {
let Some(key_id) = signature.key_id() else {
return format_audit_response(
long,
&signature,
&VerificationStatus::Failed(
"don't want to implement random key validation".to_string(),
),
&VerificationStatus::Disabled,
);
};
let Some(key) = config
.keys()
.iter()
.find(|key_info| key_info.key_id() == key_id)
else {
return format_audit_response(
long,
&signature,
&VerificationStatus::Failed(
"auditor does not have key with key_id".to_string(),
),
&VerificationStatus::Disabled,
);
};

key.public_key().as_str()
}
let verifying_key = if let Some(key) = verifying_key {
key
} else {
let Some(key_id) = signature.key_id() else {
return format_audit_response(
long,
&signature,
&VerificationStatus::Failed(
"don't want to implement random key validation".to_string(),
),
&VerificationStatus::Disabled,
);
};
let Some(key) = config
.keys()
.iter()
.find(|key_info| key_info.key_id() == key_id)
else {
return format_audit_response(
long,
&signature,
&VerificationStatus::Failed("auditor does not have key with key_id".to_string()),
&VerificationStatus::Disabled,
);
};

key.public_key().as_str()
};

let Ok(verifying_key) = hex::decode(verifying_key) else {
Expand Down Expand Up @@ -315,7 +311,7 @@ pub async fn audit(

// First check if the epoch is the root or before root
let (root_epoch, root_digest) = {
let root_parts: Vec<&str> = root.split("/").collect();
let root_parts: Vec<&str> = root.split('/').collect();
if root_parts.len() != 2 {
return format_audit_response(
long,
Expand Down
2 changes: 1 addition & 1 deletion plexi_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub async fn main() -> anyhow::Result<()> {
match output {
Ok(result) => {
if !result.is_empty() {
println!("{result}")
println!("{result}");
}
}
Err(err) => {
Expand Down
2 changes: 1 addition & 1 deletion plexi_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl fmt::Display for Ciphersuite {
Self::BincodeEd25519 => "0x0002",
Self::Unknown(_u) => "unknown",
};
write!(f, "{}", s)
write!(f, "{s}")
}
}

Expand Down
2 changes: 1 addition & 1 deletion plexi_core/src/namespaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,6 @@ impl fmt::Display for NamespaceStatus {
Self::Initialization => "Initialization",
Self::Online => "Online",
};
write!(f, "{}", s)
write!(f, "{s}")
}
}
Loading