Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac7824b482 | ||
|
|
1f68cff9a5 | ||
|
|
75153b09b1 | ||
|
|
c66717136f | ||
|
|
a2b8057a00 | ||
|
|
43dc318f12 | ||
|
|
a46b9976cd | ||
|
|
67d0f9355d | ||
|
|
1edc49ab38 | ||
|
|
9e572bdb4d | ||
|
|
f873b54941 | ||
|
|
87daa06c86 | ||
|
|
0b2ac95e03 | ||
|
|
f52cefc4e0 |
6 changed files with 3080 additions and 527 deletions
29
.github/workflows/lint.yml
vendored
Normal file
29
.github/workflows/lint.yml
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
name: lint
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
clippy:
|
||||
# R-I23 (Self's ruling, Cut 1's eighth fix batch, F1): this repo had no
|
||||
# CI surface at all before this batch, so "denied in CI" had nowhere to
|
||||
# attach. This is that surface: `clippy.toml`'s `disallowed-methods`
|
||||
# list only stops a bypass of the frozen-symlink resolver's
|
||||
# `FrozenSymlinkFs` port (see `src/drivers.rs`, `frozen_symlink_port`)
|
||||
# if something actually runs clippy with the lint promoted to an error.
|
||||
#
|
||||
# R-I26 (Self's ruling, migration-hazard follow-up): the pre-existing
|
||||
# `clippy::never_loop` this batch's parent scoped the workflow around is
|
||||
# fixed (`host_actuator.rs`'s answerer thread used a `while let` whose
|
||||
# every path returned; it is an `if let` now, since the outer `for` was
|
||||
# already what retried across polls). Test code is exactly where a
|
||||
# `disallowed_methods` bypass would hide, so `--all-targets` is back:
|
||||
# this job now reaches it too, not just the library crate.
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: clippy
|
||||
- run: cargo clippy --all-targets --all-features -- -D clippy::disallowed_methods
|
||||
25
clippy.toml
Normal file
25
clippy.toml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# R-I23 (Self's ruling, Cut 1's eighth fix batch, F1): these four methods are
|
||||
# how the frozen-symlink resolver's authority leaks. Soul pass 8 proved it by
|
||||
# existence -- `open_frozen_symlink_frame` called `fs::read_link` directly
|
||||
# while everything else in the resolver went through `FrozenSymlinkFs`, and
|
||||
# restoring the pass-7 cubic bug as `candidate.canonicalize()?` (or
|
||||
# `fs::canonicalize(&candidate)?`) at `resolve_frozen_source_symlink`'s
|
||||
# `Normal` arm passed all 193 tests green, because nothing stopped the
|
||||
# resolver from reaching past the port.
|
||||
#
|
||||
# This list is crate-wide because `disallowed-methods` has no per-module
|
||||
# scope of its own. `src/drivers.rs` blanket-allows the lint at the top of
|
||||
# the file (most of the crate has a legitimate reason to call these methods
|
||||
# directly -- deployment staging, host executable-identity checks, artifact
|
||||
# digesting, and so on are not part of frozen-symlink resolution) and the
|
||||
# `frozen_symlink_port` submodule inside it re-denies the lint for its own
|
||||
# scope, which is the only place these calls must not appear outside the
|
||||
# port. A future edit that adds a bypass inside that module fails
|
||||
# `cargo clippy` with this list's reason text; a call anywhere else in the
|
||||
# crate is unaffected, exactly as before this batch.
|
||||
disallowed-methods = [
|
||||
{ path = "std::path::Path::canonicalize", reason = "frozen-symlink resolution must go through FrozenSymlinkFs::canonicalize (src/drivers.rs, frozen_symlink_port); this method is blanket-allowed outside that module" },
|
||||
{ path = "std::fs::canonicalize", reason = "frozen-symlink resolution must go through FrozenSymlinkFs::canonicalize (src/drivers.rs, frozen_symlink_port); this function is blanket-allowed outside that module" },
|
||||
{ path = "std::fs::symlink_metadata", reason = "frozen-symlink resolution must go through FrozenSymlinkFs::symlink_metadata (src/drivers.rs, frozen_symlink_port); this function is blanket-allowed outside that module" },
|
||||
{ path = "std::fs::read_link", reason = "frozen-symlink resolution must go through FrozenSymlinkFs::read_link (src/drivers.rs, frozen_symlink_port); this function is blanket-allowed outside that module" },
|
||||
]
|
||||
3451
src/drivers.rs
3451
src/drivers.rs
File diff suppressed because it is too large
Load diff
72
src/host.rs
72
src/host.rs
|
|
@ -11,6 +11,16 @@
|
|||
//! Only the process layer is Windows-specific and it is confined to
|
||||
//! `platform`. Everything else is the same code Idunn runs on yggdrasil.
|
||||
|
||||
// R-I23 (Self's ruling, Cut 1's eighth fix batch, F1): `clippy.toml`'s
|
||||
// `disallowed-methods` list (`Path::canonicalize`, `fs::canonicalize`,
|
||||
// `fs::symlink_metadata`, `fs::read_link`) exists to keep the frozen-symlink
|
||||
// resolver in `drivers.rs` from bypassing its `FrozenSymlinkFs` port; it has
|
||||
// no per-module scope of its own, so it applies to this file too even
|
||||
// though this file's own executable-identity comparisons have nothing to do
|
||||
// with that resolver. See `drivers.rs`'s matching attribute for the full
|
||||
// rationale.
|
||||
#![allow(clippy::disallowed_methods)]
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
|
|
@ -36,7 +46,8 @@ use crate::deployment::{
|
|||
use crate::deployment_plan::{ArtifactReceipt, CompiledDeploymentPlan, SealedRelease};
|
||||
use crate::drivers::{
|
||||
HostWorkloadObservation, InstalledReleaseObservation, copy_artifact, copy_tree,
|
||||
digest_artifact, release_artifact, remove_tree_inside, sha256_id, write_runtime_bundle_records,
|
||||
digest_artifact, release_artifact, remove_tree_inside, sha256_id, verify_artifact_digest,
|
||||
write_runtime_bundle_records,
|
||||
};
|
||||
use crate::host_actuator::{
|
||||
HOST_ACTUATOR_CHANNEL, HOST_ACTUATOR_CONNECTION_ID, HOST_ACTUATOR_PING_MS,
|
||||
|
|
@ -679,12 +690,17 @@ impl Actuator {
|
|||
);
|
||||
let (executable, arguments) =
|
||||
Self::launch_command(&declaration, workload, &installed.root)?;
|
||||
let (executable_sha256, _) = digest_artifact(&executable)?;
|
||||
let executable_sha256 = format!("sha256-{executable_sha256}");
|
||||
// R-I25: recomputes under whichever shape (current or the one
|
||||
// R-I20 replaced) actually matches `expected.artifact_sha256`, so a
|
||||
// receipt sealed before that change still verifies. The value
|
||||
// carried forward is `expected.artifact_sha256` itself, not a fresh
|
||||
// recompute, so a legacy-shaped receipt is echoed rather than
|
||||
// silently upgraded to a value it was never sealed against.
|
||||
ensure!(
|
||||
executable_sha256 == expected.artifact_sha256,
|
||||
verify_artifact_digest(&executable, &expected.artifact_sha256)?,
|
||||
"installed executable differs from Expected"
|
||||
);
|
||||
let executable_sha256 = expected.artifact_sha256.clone();
|
||||
let environment = self.launch_environment(workload, &bundle)?;
|
||||
if let Some(mut previous) = self.spawned.remove(&activation.runtime_instance_id) {
|
||||
if previous.try_wait()?.is_none() {
|
||||
|
|
@ -800,9 +816,10 @@ impl Actuator {
|
|||
facts.image_path,
|
||||
prior.executable
|
||||
);
|
||||
let (executable_sha256, _) = digest_artifact(Path::new(&prior.executable))?;
|
||||
// R-I25: `prior.executable_sha256` carries whichever shape was
|
||||
// recorded at `start()`, current or legacy; verify against that.
|
||||
ensure!(
|
||||
format!("sha256-{executable_sha256}") == prior.executable_sha256,
|
||||
verify_artifact_digest(Path::new(&prior.executable), &prior.executable_sha256)?,
|
||||
"the installed executable changed under the running process"
|
||||
);
|
||||
}
|
||||
|
|
@ -897,9 +914,12 @@ fn verify_artifacts(root: &Path, release: &SealedRelease) -> Result<()> {
|
|||
for artifact in &release.artifacts {
|
||||
let path = root.join(&artifact.destination);
|
||||
ensure!(path.exists(), "artifact {} is absent", artifact.artifact_id);
|
||||
let (sha256, size_bytes) = digest_artifact(&path)?;
|
||||
// R-I25: the byte length an artifact seals is independent of which
|
||||
// `digest_artifact` shape computed its digest, so it is checked
|
||||
// directly rather than through the version fallback below.
|
||||
let size_bytes = fs::metadata(&path)?.len();
|
||||
ensure!(
|
||||
format!("sha256-{sha256}") == artifact.sha256 && size_bytes == artifact.size_bytes,
|
||||
verify_artifact_digest(&path, &artifact.sha256)? && size_bytes == artifact.size_bytes,
|
||||
"artifact {} differs from its sealed digest",
|
||||
artifact.artifact_id
|
||||
);
|
||||
|
|
@ -1302,6 +1322,42 @@ mod platform {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::deployment_plan::ExternalInputMaterializationReceipt;
|
||||
use crate::drivers::raw_sha256;
|
||||
|
||||
/// R-I25 (Self's ruling: the digest format change is a migration
|
||||
/// hazard). `verify_artifacts` is exactly `host.rs`'s own stored-value
|
||||
/// path R-I20 exposed: a receipt sealed by the pre-R-I20
|
||||
/// `digest_artifact` (bare content, no mode/gid/xattr term) must still
|
||||
/// verify under the current code, with no re-seal.
|
||||
#[test]
|
||||
fn verify_artifacts_accepts_a_receipt_sealed_under_the_pre_r_i20_shape() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let root = temp.path().to_path_buf();
|
||||
let destination = PathBuf::from("bin/service");
|
||||
let content = b"same content\n";
|
||||
fs::create_dir_all(root.join("bin"))?;
|
||||
fs::write(root.join(&destination), content)?;
|
||||
let legacy_sha256 = format!("sha256-{}", raw_sha256(content));
|
||||
|
||||
let release = SealedRelease {
|
||||
schema: "gamecult.idunn.sealed_release.v1".into(),
|
||||
sealed_release_id: format!("sha256-{}", "0".repeat(64)),
|
||||
plan_id: "plan-1".into(),
|
||||
artifacts: vec![ArtifactReceipt {
|
||||
artifact_id: "service".into(),
|
||||
destination: destination.clone(),
|
||||
sha256: legacy_sha256,
|
||||
size_bytes: content.len() as u64,
|
||||
executable: true,
|
||||
}],
|
||||
external_inputs: Vec::<ExternalInputMaterializationReceipt>::new(),
|
||||
sealed_at_unix_millis: 1,
|
||||
};
|
||||
|
||||
verify_artifacts(&root, &release)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_is_strict_and_absolute() {
|
||||
|
|
|
|||
|
|
@ -1108,7 +1108,11 @@ mod tests {
|
|||
let answerer = thread::spawn(move || -> Result<()> {
|
||||
for _ in 0..500 {
|
||||
client.poll_resends()?;
|
||||
while let Some(frame) = client.receive_once()? {
|
||||
// A plain `if let`, not `while`: every path through this body
|
||||
// returns, so a loop here would never run a second iteration
|
||||
// (`clippy::never_loop`) -- the outer `for` is what retries
|
||||
// across polls.
|
||||
if let Some(frame) = client.receive_once()? {
|
||||
let envelope = HostActuatorEnvelope::decode(&frame.payload)?;
|
||||
let request = envelope.open_request("raven", &idunn_anchor)?;
|
||||
assert_eq!(envelope.session_nonce, nonce);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
// R-I23 (Self's ruling, Cut 1's eighth fix batch, F1): see the matching
|
||||
// attribute in `drivers.rs` -- `clippy.toml`'s `disallowed-methods` list has
|
||||
// no per-module scope, so it reaches this file's unrelated `.canonicalize()`
|
||||
// call too unless blanket-allowed here.
|
||||
#![allow(clippy::disallowed_methods)]
|
||||
|
||||
use anyhow::{Context, Result, anyhow, bail};
|
||||
use cultcache_rs::{
|
||||
CultCacheEnvelope, CultCacheExpectedEnvelope, DatabaseEntry, SingleFileMessagePackBackingStore,
|
||||
|
|
|
|||
Loading…
Reference in a new issue