Repository navigation
Add provenance-validated snapshot overlay loading #2117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ee7e544
4cec72d
3bee09c
0e42457
1a3ac97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,7 +163,7 @@ impl CpuVendor { | |
|
|
||
| /// Top-level Hyperlight snapshot config JSON. Lives at | ||
| /// `blobs/sha256/<config-digest>` with media type | ||
| /// `application/vnd.hyperlight.snapshot.config.v6+json`. | ||
| /// `application/vnd.hyperlight.snapshot.config.v7+json`, with defaults for v6. | ||
| /// | ||
| /// In OCI terms this is the "image config" blob that the manifest's | ||
| /// `config` descriptor points to. It describes the accompanying | ||
|
|
@@ -213,6 +213,10 @@ pub(super) struct OciSnapshotConfig { | |
| /// `SCRATCH_TOP_SNAPSHOT_GENERATION_OFFSET` is continuous across | ||
| /// save/load. | ||
| pub(super) snapshot_generation: u64, | ||
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub(super) snapshot_id: Option<String>, | ||
| #[serde(default, skip_serializing_if = "Vec::is_empty")] | ||
| pub(super) bases: Vec<String>, | ||
|
Comment on lines
+216
to
+219
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These fields should probably carry comments |
||
| /// Application-owned metadata keyed by namespace. | ||
| #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||
| pub(super) metadata: BTreeMap<String, serde_json::Value>, | ||
|
|
@@ -430,6 +434,20 @@ impl OciSnapshotConfig { | |
| } | ||
|
|
||
| pub(super) fn validate_for_load(&self) -> crate::Result<()> { | ||
| if self.snapshot_id.is_none() && !self.bases.is_empty() { | ||
| return Err(crate::new_error!("snapshot bases require a snapshot ID")); | ||
| } | ||
| let mut ids = std::collections::HashSet::new(); | ||
| for id in self.snapshot_id.iter().chain(&self.bases) { | ||
| let id = uuid::Uuid::parse_str(id) | ||
| .map_err(|e| crate::new_error!("invalid snapshot provenance ID: {}", e))?; | ||
| if id.is_nil() { | ||
| return Err(crate::new_error!("snapshot provenance ID must not be nil")); | ||
| } | ||
| if !ids.insert(id) { | ||
| return Err(crate::new_error!("duplicate snapshot provenance ID")); | ||
| } | ||
|
Comment on lines
+444
to
+449
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessarily in scope for this PR, but it sure would be nice if we had an |
||
| } | ||
| if self.arch != Arch::current() { | ||
| return Err(crate::new_error!( | ||
| "snapshot architecture mismatch: file is {:?}, current host is {:?} \ | ||
|
|
@@ -808,6 +826,8 @@ mod tests { | |
| /// gating checks under test short-circuit before reading it. | ||
| fn gating_config() -> OciSnapshotConfig { | ||
| OciSnapshotConfig { | ||
| snapshot_id: None, | ||
| bases: Vec::new(), | ||
| hyperlight_version: "test".to_string(), | ||
| arch: Arch::current(), | ||
| abi_version: SNAPSHOT_ABI_VERSION, | ||
|
|
@@ -1110,7 +1130,9 @@ mod schema_pin { | |
| "return_type": "void" | ||
| } | ||
| ], | ||
| "snapshot_generation": 42 | ||
| "snapshot_generation": 42, | ||
| "snapshot_id": "00000000-0000-0000-0000-000000000001", | ||
| "bases": ["00000000-0000-0000-0000-000000000002"] | ||
| }"#; | ||
|
|
||
| #[cfg(target_arch = "aarch64")] | ||
|
|
@@ -1160,7 +1182,9 @@ mod schema_pin { | |
| "return_type": "void" | ||
| } | ||
| ], | ||
| "snapshot_generation": 42 | ||
| "snapshot_generation": 42, | ||
| "snapshot_id": "00000000-0000-0000-0000-000000000001", | ||
| "bases": ["00000000-0000-0000-0000-000000000002"] | ||
| }"#; | ||
|
|
||
| const PINNED_ARCH: &str = r#"[ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.