Compare commits

...
Author SHA1 Message Date
Meta Vens
ac7824b482 Land R-I25: version the artifact digest, and the frozen-source digest too
Self's finding: R-I20 changed digest_artifact's bare-file shape, but three
stored values are compared against a fresh recompute forever after they are
sealed -- expected.artifact_sha256 (IdunnExpectedIncarnationRecord),
ArtifactReceipt::sha256 (SealedRelease, in host.rs's verify_artifacts), and
HostWorkloadObservation::executable_sha256. The first Idunn upgrade past
R-I20 would have refused every already-installed and already-running
workload sealed before it.

The ruling asked for an explicit version tag recorded with the stored
value. That channel does not exist here: expected.artifact_sha256 and
ArtifactReceipt::sha256 are both validated to a bare `sha256-<64 lower hex>`
shape with no room for one -- IdunnExpectedIncarnationRecord's validator
lives in the pinned cultnet-rs git dependency, a separate repo this
worktree has no authority to widen, and ArtifactReceipt::sha256's own local
validator enforces the identical shape. There has only ever been one prior
shape (raw_sha256 of the file's bytes alone, nothing else), so
verify_artifact_digest recomputes under the current algorithm first and
falls back to that exact legacy shape -- the same effect as reading an
implicit version, without a tag this worktree cannot add. New seals always
call digest_artifact directly, so they always use the current shape;
nothing here ever rewrites a stored value to match.

host.rs's start(), observe() and verify_artifacts() now go through
verify_artifact_digest instead of comparing digest_artifact's output to the
stored string directly. start() carries expected.artifact_sha256 forward
into the returned observation rather than a fresh recompute, so a
legacy-shaped receipt is echoed, not silently upgraded to a value it was
never sealed against.

Checked whether frozen_source_sha256 (the frozen-source digest,
observe_frozen's stored-value comparison against FrozenSourceReceipt) has
the same exposure: yes. Its algorithm changed twice before this batch
touched anything -- R-I9 added mode and gid, R-I18 added xattrs -- and a
FrozenSourceReceipt is persisted in DeploymentTransaction.frozen_source
between the freeze() step and the step that calls observe_frozen, each a
separate advance_sealing call that can cross a restart. The window is
narrower than the artifact side (one in-flight Sealing-phase transaction,
not every installed workload), but this cut's own batches 6 through 8
already crossed it twice. verify_frozen_source_digest applies the same
answer against both prior shapes, which are reproduced verbatim in
frozen_source_sha256_legacy from git history (f873b54^ and f873b54).

Tests: verify_artifact_digest_accepts_a_receipt_sealed_under_the_pre_r_i20_shape
and verify_frozen_source_digest_accepts_both_shapes_that_predate_this_cuts_sixth_batch
construct a stored value the old code would have produced and confirm the
new code still accepts it, confirm the current-algorithm-only comparison
they replace would have refused it, and confirm a real content tamper is
still caught. verify_artifacts_accepts_a_receipt_sealed_under_the_pre_r_i20_shape
exercises the same thing through host.rs's own verify_artifacts. Manually
mutated (fallback removed, then restored) on Yggdrasil; see the verification
report.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 05:48:48 +02:00
Meta Vens
1f68cff9a5 Fix R-I26: turn host_actuator.rs's never_loop into a real if, restore --all-targets
The answerer thread's `while let Some(frame) = client.receive_once()? { ...;
return Ok(()); }` always returns on its first (and only reachable) iteration,
so clippy::never_loop was right that it never loops -- the outer `for` is
what actually retries across polls. Rewritten as `if let`.

With that gone, cargo clippy --all-targets has nothing left to scope the
lint workflow around, so .github/workflows/lint.yml runs it again. Test
code is exactly where a disallowed_methods bypass would hide, and it was
the one place the workflow's own lint couldn't reach.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 05:48:07 +02:00
Meta Vens
75153b09b1 Drop --all-targets from the lint workflow: it fails on pre-existing,
unrelated code

Measured on Yggdrasil against both this batch and its parent, a46b997:
`cargo clippy --all-targets` already fails on `clippy::never_loop` in
host_actuator.rs's own test code, which this batch never touched and is
not chartered to fix. `cargo clippy` without --all-targets still analyzes
the library crate, which is where frozen_symlink_port and every other
disallowed-method call site actually live, so R-I23's coverage is
unaffected; only test-only code outside the lib goes unchecked by this
job.

Also verified directly on Yggdrasil: with this scoping, `cargo clippy
--all-features -- -D clippy::disallowed_methods` passes clean on
c667171, and fails as intended when Soul's exact bypass spellings are
reintroduced (`candidate.canonicalize()?` and `fs::canonicalize(&candidate)?`
at drivers.rs:6219, and `fs::read_link(symlink_path)?` in
open_frozen_symlink_frame) -- each one reported as
"use of a disallowed method" pointing at the port, not silently passing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 05:21:43 +02:00
Meta Vens
c66717136f Fix two fixture bugs in the R-I21 xattr coverage tests, found by running
them for real

Measured on Yggdrasil against a2b8057, both real container-level facts,
not code-under-test bugs:

- digest_artifact_differs_when_only_a_directorys_extended_attribute_differs
  set the xattr on the artifact root itself. digest_tree(root, root, ...)
  never hashes the root's own metadata, only entries it reads out of some
  directory's read_dir (the same fact the pre-existing directory-mode/gid
  tests already build around), so the two digests were identical. Moved
  the xattr onto a child directory, matching those tests' own shape.
- digest_artifact_differs_when_only_a_symlinks_extended_attribute_differs
  used the `user` namespace. `lsetxattr(..., "user.*", ...)` on a symlink
  fails EPERM even as root: the kernel restricts `user` to regular files
  and directories regardless of privilege. Switched to
  `security.capability`, the same setuid-equivalent value the
  frozen-source xattr tests already use, which has no such restriction.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 05:16:50 +02:00
Meta Vens
a2b8057a00 Land R-I20 through R-I22 of Cut 1's eighth fix batch: close the artifact
digest's xattr and single-file blind spots

Soul pass 8 found the artifact digest's single-file branch
(digest_artifact) was a content-only sha256 -- no mode, gid or xattr --
and it is the branch host.rs actually takes for an installed executable,
immediately before launch and while the process is running. All three
existing digest_artifact tests wrapped the file in a directory so
digest_tree ran instead, which is exactly why the fast path's own
blindness survived three fix batches untested.

- R-I20: extract digest_file_entry, the one place a file entry is hashed
  for the artifact digest, and delegate both digest_tree's file arm and
  digest_artifact's bare-file branch to it. Rewrite the three wrapped-file
  tests to call digest_artifact on a bare file, matching the shape
  production uses.
- R-I21: give the artifact digest an xattr term on all three arms
  (dir/file/link), matching hash_frozen_source_tree's own coverage --
  the asymmetry ran the wrong way, since the artifact is the binary that
  gets exec'd and re-verified before every launch, unlike the frozen
  source's 0555 root-owned tree nothing executes. Shared the framing
  writer (hash_xattr_list) between hash_frozen_source_xattrs and the new
  digest_tree_xattrs so the two terms can't drift apart; the artifact
  side reads xattrs through a platform-conditional reader since artifact
  digesting (unlike frozen-source digesting) runs on every target
  platform this daemon ships for. Add fixture tests for the dir, file and
  symlink arms.
- R-I22: hash_xattr_list's framing was pinned by nothing -- all 193 tests
  stayed green while dropping the value length prefix, the count prefix,
  the name NUL terminator, folding names to lowercase, or hashing names
  only and dropping values entirely. Add five tests that call
  hash_xattr_list directly with hand-constructed attribute lists chosen
  so each specific framing removed is exactly what makes two different
  lists collide, not just assertions that some digest changed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 05:14:49 +02:00
Meta Vens
43dc318f12 Land R-I23 of Cut 1's eighth fix batch: make the resolver's bypass a
compile error

Soul pass 8 proved the FrozenSymlinkFs port (R-I14) was an honour system
one level up from the counter it replaced: restoring the S5-1 cubic bug
as `candidate.canonicalize()?` in resolve_frozen_source_symlink's Normal
arm left all 193 tests green, and open_frozen_symlink_frame was still
calling fs::read_link directly, proving the convention leaks.

- Add `read_link` to FrozenSymlinkFs and route open_frozen_symlink_frame
  and validate_frozen_source_symlink's root resolution through it.
- Move every function the resolver can reach into a `frozen_symlink_port`
  submodule with `#![deny(clippy::disallowed_methods)]`; drivers.rs
  blanket-allows the lint at the top of the file since most of the crate
  has legitimate, unrelated reasons to call these methods (host.rs and
  provisioning.rs get the same blanket allow). Everything the module
  exports is re-exported so every existing caller and test keeps its
  bare name.
- Add clippy.toml listing Path::canonicalize, fs::canonicalize,
  fs::symlink_metadata and fs::read_link as disallowed, each with a
  reason pointing at the port.
- Add .github/workflows/lint.yml: this repo had no CI surface at all
  before this batch, so "denied in CI" had nowhere to attach.
- Update validate_frozen_source_symlinks_resolves_a_long_component_chain_
  with_a_linear_call_count's formula and doc: read_link and the
  now-ported root canonicalize add two calls per resolution
  (components + 4, not + 2), and the doc no longer claims the count
  can't catch its own regression -- R-I23 is what catches it now (R-I24).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 05:14:32 +02:00
Meta Vens
a46b9976cd Fix R-I14: update the last direct resolve_frozen_source_symlink call site
validate_frozen_source_symlink_accepts_a_legitimate_in_root_parent_reference
still called resolve_frozen_source_symlink with the pre-port two-argument
signature. Missed in the R-I14 commit; the crate did not compile.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 04:34:33 +02:00
Meta Vens
67d0f9355d Land R-I15 through R-I19 of Cut 1's seventh fix batch
R-I15 (F2): delete digest_artifact_differs_across_a_symlink_target_boundary_shift
rather than repair it. Soul pass 7 confirmed it cannot fail: the link name is
already NUL-terminated before the target in digest_tree, so two entries whose
(name, target) pairs differ always diverge there regardless of the (missing)
trailing terminator the test claimed to be pinning. The collision class is
real in principle and unreachable in practice -- a NUL cannot appear in a real
symlink target or filename. Left a note in its place and corrected the
production comment that pointed at it.

R-I16 (F4): digest_tree (the artifact digest, re-derived against the sealed
receipt immediately before launch) hashed only an executable-bit boolean for
files and nothing at all for directories. Widened to the full mode & 0o7777
plus the owning gid, for directories as well as files, matching
hash_frozen_source_tree's own R-I9 treatment. Added digest_tree_mode/
digest_tree_gid (replacing digest_tree_is_executable) and one test per new
term: file setuid, file gid, directory mode (setgid), directory gid.

R-I17 (F5): the validator's mode mask was pinned only for setuid-on-a-file.
Added validate_frozen_source_refuses_a_{setgid,sticky}_file and
_a_{setuid,setgid,sticky}_directory so narrowing either mask (0o7777 ->
0o5777 file, 0o7777 -> 0o3777 directory) cannot pass with a green suite.

R-I18 (F3): a real security.capability grant (cap_setuid=ep) on a root-owned
0555 tree validated ACCEPT and re-hashed unchanged -- a grant with no setuid
bit for the mode term to see. hash_frozen_source_tree now hashes every
extended attribute (name and value, sorted by name) on every entry via a new
read_sorted_xattrs helper built on listxattr/getxattr directly (libc is
already a normal dependency). This is detection, not prevention:
no-new-privileges on Idunn's own deployment path is what prevents a file
capability from being exercised; this digest term is what makes
observe_frozen's "this is the tree we froze" verdict correct for xattrs.
Pinned with a general user.-namespace test and a direct reproduction of
Soul's security.capability finding, both noting the root precondition.

R-I19 (F6): nix_group_or_skip never skipped -- it returned Ok(1)
unconditionally, and chown(2) never consults /etc/group, so its own
reasoning was already moot. Renamed to second_gid_for_chown_fixture, since
the documented "bail loudly, don't silently skip" behaviour is the one
actually wanted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 04:30:28 +02:00
Meta Vens
1edc49ab38 Land R-I14 of Cut 1's seventh fix batch
Soul pass 7 (F1) restored the S5-1 bug -- a per-component canonicalize() --
without instrumenting it, and the call-count pin measured no regression at
all. record_frozen_symlink_probe_call() was an honour system: it only fired
where a call site remembered to invoke it by hand.

Put canonicalize() and symlink_metadata() behind a narrow FrozenSymlinkFs
port. The one production implementation (StdFrozenSymlinkFs) charges the
counter inside the same method that makes the syscall, so a reintroduced
call written the way the surrounding code is now written cannot bypass the
count. resolve_frozen_source_symlink and open_frozen_symlink_frame are
generic over the port instead of calling Path::canonicalize/
fs::symlink_metadata directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 04:30:07 +02:00
Meta Vens
9e572bdb4d Land R-I13 of Cut 1's sixth fix batch
Soul pass 6 (F6) found two gaps outside the fifth batch's own diff:
digest_tree -- the artifact digest, separate from the frozen-source
digest R-I3 fixed -- still had exactly the same blindness (no
executable-bit term, no terminator after a symlink target), and
observe_frozen, the tamper check itself, had no test of its own at all.

- digest_tree now hashes an executable-bit boolean for files (mirroring
  R-I3/S5-4's fix to hash_frozen_source_tree) and a trailing terminator
  after a symlink target. The executable-bit term is pinned by a test
  that goes red when it is removed (verified by hand mutation). The
  terminator is deliberately NOT pinned by a test: constructing a real
  encoding collision requires a NUL byte embedded inside a symlink
  target, to reproduce the NUL that is always partway through the next
  entry's own "dir\0"/"file\0"/"link\0" tag, and no legitimate fixture
  can produce that -- std::os::unix::fs::symlink rejects an interior NUL
  (CString::new fails), and symlink(2) itself takes a NUL-terminated C
  string. A two-name "boundary shift" fixture (link "a"->"bc" vs link
  "ab"->"c") does not collide either, since the relative-name field
  already carries its own terminator, unaffected by this fix -- tried,
  confirmed not to go red under the term's removal, and removed rather
  than kept as a test that doesn't test what it claims. The fix is kept
  anyway: it costs nothing and matches the file arm's already
  self-delimiting shape.

- observe_frozen gets an end-to-end test against a real receipt, per
  Soul's note that building a CompiledDeploymentPlan was out of its own
  budget. It goes through GitSourceDriver::freeze_exact for a real frozen
  tree and compile_deployment_plan (the same constructor production code
  uses) for a minimal but real TargetDeclaration/OperatorBinding TOML
  pair -- no runtime state, dependency graph, or route, since
  observe_frozen never reads past plan.source and plan.recipe_blob once
  receipt.validate_against accepts the plan. Confirms observe_frozen both
  accepts an intact receipt and refuses one tampered with after freezing.
  The tampered file is a second file in the tree, not the recipe itself:
  tampering the recipe file is independently caught by observe_frozen's
  own recipe-bytes-equality check, which would have kept this test green
  even with the digest re-check deleted -- confirmed by hand mutation
  before correcting the fixture.

183 passed / 0 failed / 2 ignored (180 after the prior commit in this
batch, +3 new tests here). Every new/changed test run under its own hand
mutation on the final code; each that is pinned went red, and the one
deliberately unpinned case (the symlink terminator) is explained above
and in the code.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 23:37:43 +02:00
Meta Vens
f873b54941 Land R-I8 through R-I12 of Cut 1's sixth fix batch
Soul pass 6 confirmed the containment argument and five of seven rulings,
but found R-I1's timing pin measured a clamp artifact (33x, not the real
1.63x) and R-I3's digest coverage stopped short of setuid/setgid/sticky
and gid. This lands the deterministic replacement and the privilege fix,
plus two smaller corrections pass 6 asked for.

- R-I8: replace the wall-clock ratio pin on the long-component-chain
  resolver test with a deterministic call count. A test-only thread-local
  counter (zero cost outside cfg(test)) counts every canonicalize()/
  symlink_metadata() call the resolver makes; the test now asserts an
  exact formula (components + 2) instead of a clock reading that measured
  198.9ms for a clean revision under three concurrent Yggdrasil suites,
  and a 1.63x true separation that Hands' original 11ms/359ms pair
  misreported as 33x by straddling the test's own clamp boundary.

- R-I9: validate_frozen_source_tree widens its mode mask from 0o777 to
  0o7777, so a root-owned setuid/setgid/sticky file or directory is
  refused outright instead of masked down to a legal 0o444/0o555. The
  frozen-source digest (hash_frozen_source_tree) now hashes each entry's
  full mode and owning gid, for directories as well as files, replacing
  the executable-bit-only boolean the tamper check relied on. New tests:
  a direct validator refusal test, plus one digest test per newly-covered
  term (file setuid, file gid, directory mode, directory gid).

- R-I10: the two-link-cycle fixture now asserts on the traversal budget's
  own ceiling message, not merely is_err(), so a refusal from some other
  guard cannot pass for the budget doing its job.

- R-I11: softens the claim that the symlink-target length guard "refuses
  exactly what the kernel refuses" to what is actually true -- it bounds
  the buffer at PATH_MAX, and a filesystem may refuse less (an ext4 slow
  symlink is bounded by block size). Doc only.

- R-I12: records at the loop-tail containment check, by hand-mutation,
  that it is the one that must survive -- deleting it alone turns the
  bare-parent-reference test red, while the Normal arm's own check can be
  deleted with the full suite and a 20-shape escape sweep still green.
  Also records the two mutants Soul found genuinely equivalent. No
  deletion.

R-I9's third part -- add nosuid to the bind mount -- is not implemented.
Verified by hand against a real Docker CLI: `--mount type=bind,...,nosuid`
is rejected ("invalid field 'nosuid'") and so is `-v host:dst:nosuid`
("invalid mode: nosuid"). Docker exposes no bind-mount-level nosuid flag
through either the modern or legacy CLI syntax. The container already
carries `--security-opt no-new-privileges`, which is the standard Docker
mitigation for exactly this class of finding and is arguably stronger
(process-wide, not per-mount) than the requested mount flag would have
been. Flagged for Self.

175 passed / 0 failed / 2 ignored baseline; 180 passed / 0 failed / 2
ignored after this commit (+5 new tests). Every new/changed test run
under its own hand mutation on the final code; each went red. See the
batch report for the full list.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 23:35:49 +02:00
Meta Vens
87daa06c86 Fix R-I6 rig: lowercase the .GIT fixture's binding target
OperatorBinding's target field only allows lowercase ASCII (require_id),
and the ".GIT" hostile-fixture label was going in uppercase. Caught by
actually running the new HTTPS rig test on Yggdrasil.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 22:28:03 +02:00
Meta Vens
0b2ac95e03 Land R-I6: commit Soul's HTTPS resolve() rig
SourcePort::resolve has one production caller and, before this, zero
tests: every existing fixture in this suite approximates it with a
file:// origin or a hand-copied fetch invocation. This stands up a real
TLS git-http-backend origin instead -- a self-signed certificate the
driver's own Git identity trusts through $HOME/.gitconfig's
http.sslCAInfo, a minimal CGI-over-HTTPS Python bridge (no web server in
eureka-verify-rust speaks smart HTTP directly), and a validated
OperatorBinding whose origin is a real https://127.0.0.1:<port>/
origin.git. A clean revision resolves; moving refs/heads/main onto either
hostile tree this suite already builds for freeze_exact (duplicate-named
trees, a .GIT look-alike) is refused by resolve()'s own
transfer.fsckObjects=true fetch.

Soul's original pass-5 rig (soul-idunn05-notes.md, probe5_https2.rs,
s5-https-run.sh) lived in a session scratchpad that did not survive past
that session -- the same "green history, empty repository" failure
SKILL.md already documents from the QUIC cut. No matching session, no
leftover Yggdrasil work directory, and no local scratch trace were found,
so this rebuilds the rig from the map's description rather than reusing
Soul's files.

Also drops open_frozen_symlink_frame's now-dead canonical_root parameter,
left unused by the previous commit's containment-check deletions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 22:26:45 +02:00
Meta Vens
f52cefc4e0 Land R-I1 through R-I5 and R-I7 of Cut 1's fifth fix batch
Soul's fifth pass on Cut 1 could not falsify the fourth batch's mechanism;
what it left was a bill of seven rulings. This lands six of them (R-I6,
the HTTPS resolve() rig, follows separately):

R-I1: delete the dead per-component canonicalize() in
open_frozen_symlink_frame's Normal-step match (frame.resolved is already
canonical there), and pin the O(k^3) term can't come back with a
component-count timing test.

R-I2: two hand-checked fixtures for the traversal budget, the resolver's
only termination guarantee -- a two-link cycle and 41 distinct links, both
must refuse.

R-I3: digest coverage tests for the symlink target and the executable bit,
the two terms hash_frozen_source_tree already hashes but nothing had
pinned.

R-I4: fix materialize_tree_raw's symlink-target guard off-by-one (<=
PATH_MAX admitted a 4096-byte target the kernel's own symlink() refuses
with ENAMETOOLONG; now < PATH_MAX, refusing exactly what the kernel
refuses) and pin it against a real kernel boundary.

R-I5: declare the 40-traversal ceiling (matches the kernel's own ELOOP
limit) and name the link and count reached in its error, a deliberate
narrow departure from "keep S6's behaviour exactly".

R-I7: drop FrozenSymlinkFrame's symlink_path Option (only ever
constructed Some) and its backwards doc comment; delete two of the three
"redundant" containment checks Soul proved redundant by deletion. The
third -- the unconditional check at the bottom of the resolver's loop --
turns out load-bearing once the other two are gone: a symlink whose whole
target is ".." at the root has no later Normal step to trip that arm's
own check, so nothing else catches the escape. Traced by hand, pinned
with a new test, and kept rather than deleted as a documented deviation
from the map's "delete all three" reading. Also deletes the 189-line
resolve_style_fetch_then_freeze_exact_refuses_hostile_trees test (its
lone assertion sits in an Ok(_) arm pass 4 showed is never taken, and
freeze_exact_refuses_already_local_hostile_objects_via_its_own_fsck
already runs the same fixtures plus four more through a harder path),
and collapses the hash_object/literal_tree/dotgit_lookalike/git_owned/
chown_to_source_identity boilerplate the three surviving hostile-tree
fixture tests duplicated into module-level test helpers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 22:10:49 +02:00
6 changed files with 3080 additions and 527 deletions

29
.github/workflows/lint.yml vendored Normal file
View 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
View 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" },
]

File diff suppressed because it is too large Load diff

View file

@ -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() {

View file

@ -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);

View file

@ -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,