Skip to content

feat(forge): add target attestation safety policy#22

Merged
cwilson613 merged 1 commit into
mainfrom
feat/forge-target-attestation
May 30, 2026
Merged

feat(forge): add target attestation safety policy#22
cwilson613 merged 1 commit into
mainfrom
feat/forge-target-attestation

Conversation

@cwilson613

Copy link
Copy Markdown
Contributor

Summary

Adds an explicit target-attestation safety policy for destructive forge USB operations.

This supports external-first install flows where the operator must attest the target class before destructive writes, e.g. an external USB/Thunderbolt SSD is allowed while an internal Apple NVMe target is forbidden by default.

New safety fields:

requires_target_attestation
 target_attestation
allowed_targets
forbidden_targets

Supported attestations:

external-usb-ssd
external-thunderbolt-ssd
internal-apple-nvme

Behavior

For destructive USB install requests:

  • if requires_target_attestation = true and no attestation is present, planning is blocked with TARGET_ATTESTATION_REQUIRED
  • if an attestation is not listed in allowed_targets, planning is blocked with TARGET_ATTESTATION_NOT_ALLOWED
  • if an attestation is listed in forbidden_targets, planning is blocked with TARGET_ATTESTATION_FORBIDDEN
  • internal-apple-nvme is additionally blocked by default unless allow_internal_disk_selection = true

Why

This is the next safety primitive needed for external-first NixOS install flows on hardware like Intel Apple T2 MacBooks. It lets profile/materialization artifacts express:

allowed_targets = external-usb-ssd, external-thunderbolt-ssd
forbidden_targets = internal-apple-nvme
requires_target_attestation = true

without relying only on stringly disk names.

Tests

nix shell nixpkgs#cargo nixpkgs#rustc nixpkgs#rustfmt -c cargo fmt
nix shell nixpkgs#cargo nixpkgs#rustc -c cargo test target_attestation -- --nocapture
nix shell nixpkgs#cargo nixpkgs#rustc -c cargo test

Targeted tests cover:

  • missing required attestation blocks destructive flash
  • allowed external attestation permits the plan
  • internal Apple NVMe attestation is blocked by default
  • JSON/Pkl transport parsing for attestation fields

Comment thread src/forge.rs
}
}

fn parse_target_attestation(value: &str) -> Result<TargetAttestation> {
@cwilson613

Copy link
Copy Markdown
Contributor Author

Local review complete. Verified the PR only changes src/forge.rs and adds the target-attestation safety gate, Pkl/JSON normalization, and focused tests. Local validation passed: cargo fmt -- --check, cargo clippy --all-targets -- -D warnings, cargo test target_attestation -- --nocapture, and cargo test. GitHub checks are green. No blocking findings.\n\nNote: GitHub rejected an approve review because this is my own PR.

@cwilson613
cwilson613 merged commit 0ff00e7 into main May 30, 2026
3 checks passed
@cwilson613
cwilson613 deleted the feat/forge-target-attestation branch May 30, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants