Skip to content

Commit 5b91b1d

Browse files
authored
Add basic TUF repo check after generation (#8722)
There are an extended number of tests designed to catch issues with TUF repos. Despite this, it is still possible (though unlikely) to generate a TUF repo that fails one or more checks. Nobody likes broken builds so add an extra last check to verify that we can do "something" with the TUF repo.
1 parent d073586 commit 5b91b1d

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev-tools/releng/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ tokio = { workspace = true, features = ["full"] }
3131
toml.workspace = true
3232
tufaceous-artifact.workspace = true
3333
tufaceous-lib.workspace = true
34+
update-common.workspace = true
3435

3536
[lints]
3637
workspace = true

dev-tools/releng/src/tuf.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use sha2::Digest;
1818
use sha2::Sha256;
1919
use slog::Logger;
2020
use tokio::io::AsyncReadExt;
21+
use tufaceous_artifact::ArtifactHash;
2122
use tufaceous_artifact::ArtifactVersion;
2223
use tufaceous_artifact::KnownArtifactKind;
2324
use tufaceous_lib::Key;
@@ -27,6 +28,9 @@ use tufaceous_lib::assemble::DeserializedArtifactSource;
2728
use tufaceous_lib::assemble::DeserializedControlPlaneZoneSource;
2829
use tufaceous_lib::assemble::DeserializedManifest;
2930
use tufaceous_lib::assemble::OmicronRepoAssembler;
31+
use update_common::artifacts::{
32+
ArtifactsWithPlan, ControlPlaneZonesMode, VerificationMode,
33+
};
3034

3135
pub(crate) async fn build_tuf_repo(
3236
logger: Logger,
@@ -160,5 +164,38 @@ pub(crate) async fn build_tuf_repo(
160164
)
161165
.await?;
162166

167+
// Check that we haven't stepped on any rakes by attempting to generate a
168+
// plan from the zip
169+
let zip_bytes = std::fs::File::open(&output_dir.join("repo.zip"))
170+
.context("error opening archive.zip")?;
171+
let repo_hash = ArtifactHash([0u8; 32]);
172+
let _ = ArtifactsWithPlan::from_zip(
173+
zip_bytes,
174+
None,
175+
repo_hash,
176+
ControlPlaneZonesMode::Split,
177+
VerificationMode::BlindlyTrustAnything,
178+
&logger,
179+
)
180+
.await
181+
.with_context(|| {
182+
"error reading generated TUF repo (split control plane)".to_string()
183+
})?;
184+
185+
let zip_bytes = std::fs::File::open(&output_dir.join("repo.zip"))
186+
.context("error opening archive.zip")?;
187+
let _ = ArtifactsWithPlan::from_zip(
188+
zip_bytes,
189+
None,
190+
repo_hash,
191+
ControlPlaneZonesMode::Composite,
192+
VerificationMode::BlindlyTrustAnything,
193+
&logger,
194+
)
195+
.await
196+
.with_context(|| {
197+
"error reading generated TUF repo (composite control plane)".to_string()
198+
})?;
199+
163200
Ok(())
164201
}

0 commit comments

Comments
 (0)