data: consolidate the YAML embed convention into an embed_data! macro

This commit is contained in:
2026-09-18 13:22:13 +02:00
parent 6e5ecd2f45
commit ead97e1213
5 changed files with 84 additions and 20 deletions
+3 -9
View File
@@ -21,16 +21,14 @@ use std::path::{Path, PathBuf};
use std::time::Duration;
use indicatif::ProgressBar;
use lazy_static::lazy_static;
use log::debug;
use serde::Deserialize;
use sha2::{Digest, Sha256};
use ssh2::{CheckResult, HostKeyType, KnownHostFileKind, KnownHosts, Session};
use crate::data::embed_data;
use crate::ui::prompt;
const HOST_KEYS_YAML: &str = include_str!("../../data/host_keys.yml");
/// Pinned SSH host key fingerprints, loaded from the bundled
/// `host_keys.yml` data file (same pattern as `distro_info.yml`): data
/// rather than code, so trust anchors are updatable without touching the
@@ -42,12 +40,8 @@ struct PinnedHostKeys {
fingerprints: HashMap<String, Vec<String>>,
}
lazy_static! {
// The YAML is include_str!'d at compile time and statically valid; if it
// ever failed to parse it would be a build-time bug that cannot be
// recovered from at runtime, so panicking here is acceptable.
static ref PINNED_HOST_KEYS: PinnedHostKeys = serde_yaml::from_str(HOST_KEYS_YAML)
.expect("built-in host_keys.yml data is statically valid and must parse");
embed_data! {
static ref PINNED_HOST_KEYS: PinnedHostKeys = "../../data/host_keys.yml"
}
/// Whether `fingerprint` is one of the pinned (published) fingerprints of