Skip to content
Merged
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
9 changes: 7 additions & 2 deletions src/backend/aqua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,12 @@ impl AquaBackend {
.get(&platform_key)
.is_none_or(|pi| pi.checksum.is_none());

let needs_cosign = !skip_cosign;
let needs_cosign = !skip_cosign
&& Settings::get().aqua.cosign
&& checksum
.cosign
.as_ref()
.is_some_and(|c| c.enabled != Some(false));
Comment on lines +1083 to +1088
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since this code is inside an if let Some(checksum) = &pkg.checksum block, you can simplify this condition by using the checksum variable directly instead of accessing pkg.checksum again. This makes the code more concise and avoids redundant access.

Suggested change
let needs_cosign = !skip_cosign
&& Settings::get().aqua.cosign
&& pkg
.checksum
.as_ref()
.and_then(|c| c.cosign.as_ref())
.is_some_and(|c| c.enabled != Some(false));
let needs_cosign = !skip_cosign
&& Settings::get().aqua.cosign
&& checksum.cosign.as_ref().is_some_and(|c| c.enabled != Some(false));

// Short-circuit cosign if a higher-priority mechanism already recorded provenance.
// Safe to cache: provenance is only modified by the single-threaded verification
// methods above (attestations, slsa, minisign), all of which have completed by now.
Expand All @@ -1107,7 +1112,7 @@ impl AquaBackend {
.await?;
}

if !skip_cosign && !cosign_already_verified && checksum_path.exists() {
if needs_cosign && !cosign_already_verified && checksum_path.exists() {
self.cosign_checksums(ctx, pkg, v, tv, &checksum_path, &download_path)
.await?;
}
Expand Down
Loading