fix: fourth audit — nix build log, signing key validation, idempotent publish, hw-config cleanup#176
Merged
Merged
Conversation
… publish, hw-config tmp cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fourth audit findings
H1 — Step 10:
nix build 2>/dev/nullhides all build errorsWhen
nix buildfails, the die message told the operator to re-run with--show-trace— but they had no idea what failed because stderr was suppressed. Replaced2>/dev/nullwith2>"${BUILD_LOG}", whereBUILD_LOGis a timestamped path in/tmp. The die message now includes the log path so the operator can read the error immediately without re-running.H2 — Step 8: Empty/corrupt minisign public key not caught before writing enroll.nix
SIGNING_PUBKEY=$(grep -v '^untrusted comment' "${MINISIGN_PUB}" | head -1)returns an empty string if the pub file exists but is malformed (e.g. interrupted write from a previous run). Without validation,write_enroll_nix ""silently writessigningPublicKey = ""to enroll.nix. Pass-2 nixos-rebuild then fails with a Nix type error that has no obvious connection to the signing key. Added[[ -n "${SIGNING_PUBKEY}" ]]guard with a clear remediation instruction.H3 —
katello-sourceos-setup.sh:content-view publishnot idempotentEvery call to
katello-sourceos-setup.sh(invoked unconditionally by enroll.sh step 5) published a new content view version regardless of whether any version already existed. Publishing is a slow operation (1–2 min Katello sync) and creates spurious versions (v1.0, v2.0, v3.0...) that clutter the CV history. The CV_VERSION selection at the end (sorted by ID, take last) still worked correctly, but the extra round-trip on every re-run is wasteful and incorrect.Fix: check
content-view version listcount before publishing; skip if any version already exists.M1 — Step 1: Stale
hardware-configuration.nix.tmpfrom previous interrupted runsThe atomic write pattern (
> .tmp→mv .tmp final) leaves a.tmpon disk if step 1 is interrupted afternixos-generate-configbut beforemv. On re-run, the.tmpis silently overwritten anyway (the idempotent check looks forHW_CONFIG, not.tmp), but the stale file is confusing. Addedrm -f "${HW_CONFIG}.tmp"at the top of step 1.