Expose running build verification in toolkit CLI
next-build / candidate (push) Canceled after 0s

This commit is contained in:
2026-10-17 10:03:34 -06:00
parent 3acb927e7e
commit 7d0b86afb8
2 changed files with 35 additions and 2 deletions
+1
View File
@@ -7,3 +7,4 @@ license.workspace = true
[dependencies]
alkane-core = { path = "../alkane-core" }
alkane-artifacts = { path = "../alkane-artifacts" }
alkane-access = { path = "../alkane-access" }
+34 -2
View File
@@ -1,14 +1,22 @@
// SPDX-License-Identifier: MIT
//! Headless entry point for read-only artifact verification.
use alkane_access::{parse_build_marker, verify_build_marker, Probe, SshTarget};
use alkane_artifacts::{seed_manifest, verify_file};
use std::io;
use std::net::IpAddr;
use std::path::Path;
fn run() -> Result<(), Box<dyn std::error::Error>> {
let args: Vec<_> = std::env::args().collect();
if args.len() != 4 || args[1] != "verify-artifact" {
return Err("usage: alkane-cli verify-artifact <manifest-path> <local-file>".into());
match args.get(1).map(String::as_str) {
Some("verify-artifact") if args.len() == 4 => verify_artifact(&args),
Some("verify-running-build") if args.len() == 8 => verify_running_build(&args),
_ => Err("usage: alkane-cli verify-artifact <manifest-path> <local-file>\n alkane-cli verify-running-build <ip> <user> <known-hosts> <board> <sdk-sha> <os-sha>".into()),
}
}
fn verify_artifact(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
let record = seed_manifest()?
.into_iter()
.find(|item| item.path == Path::new(&args[2]))
@@ -23,6 +31,30 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
fn verify_running_build(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
let address: IpAddr = args[2].parse()?;
let expected_text = format!(
"board={}\nsdk_revision={}\nos_revision={}\n",
args[5], args[6], args[7]
);
let expected = parse_build_marker(expected_text.as_bytes())
.map_err(|error| io::Error::other(format!("invalid expected build: {error:?}")))?;
let target = SshTarget::new(address, 22, &args[3], Path::new(&args[4]))
.map_err(|error| io::Error::other(format!("SSH target: {error:?}")))?;
let raw = target
.probe(Probe::AlkaneBuildMarker)
.map_err(|error| io::Error::other(format!("running build read: {error:?}")))?;
let observed = parse_build_marker(&raw)
.map_err(|error| io::Error::other(format!("running build marker: {error:?}")))?;
verify_build_marker(&observed, &expected)
.map_err(|error| io::Error::other(format!("build comparison: {error:?}")))?;
println!(
"verified running build {} {} {}",
observed.board, observed.sdk_revision, observed.os_revision
);
Ok(())
}
fn main() {
if let Err(error) = run() {
eprintln!("artifact verification failed: {error}");