Skip to content

enroll: R15 — || die on mktemp, sed -i, write_enroll_nix, katello-setup#187

Merged
mdheller merged 1 commit into
mainfrom
fix/enroll-fifteenth-audit
Jun 16, 2026
Merged

enroll: R15 — || die on mktemp, sed -i, write_enroll_nix, katello-setup#187
mdheller merged 1 commit into
mainfrom
fix/enroll-fifteenth-audit

Conversation

@mdheller

Copy link
Copy Markdown
Member

Round 15 audit — all LOW

# Severity Location Finding
1 LOW mktemp × 3 (lines 403, 407, 723) No || die — full /tmp or SOURCEOS_DIR fires set -e silently
2 LOW sed -i × 2 (lines 294-295) Post-grep checks catch silent substitution but not sed's own non-zero exit
3 LOW write_enroll_nix (heredoc + mv) cat > .tmp <<NIX and mv both unguarded inside the function
4 LOW bash katello-sourceos-setup.sh No existence check; no || die on bash invocation
5 LOW _KATELLO_RUNNING docker ps pipeline Docker daemon death between up -d and count check fires set -e silently
6 LOW _KATELLO_FINAL docker ps pipeline Same pattern
7 LOW printf ... > "${PLAINTEXT}" No || die on plaintext secrets write

Changes

  • mktemp ... || die on all three mktemp calls
  • sed -i ... || die on both in-place edits
  • { cat > .tmp <<NIX ... NIX } || die + mv ... || die inside write_enroll_nix
  • [[ -f katello-sourceos-setup.sh ]] || die + bash ... || die in step 5
  • ... | wc -l | tr -d ' ' || echo 0 on both docker ps count pipelines
  • printf ... > "${PLAINTEXT}" || die in step 6 sops block

Test plan

  • bash -n scripts/enroll.sh passes (verified)
  • All changes are in branches already guarded by existence/idempotency checks

Seven LOW findings:

- mktemp (x3 at lines 403, 407, 723): || die if /tmp or SOURCEOS_DIR is full.

- sed -i (x2): || die on the sed command itself. The existing post-grep checks
  only catch "sed exited 0 but changed nothing"; a non-zero sed exit (e.g. disk
  full during in-place temp file write) would previously fire set -e silently.

- write_enroll_nix: wrap heredoc in { } || die and add || die to mv. Call site
  already had no guard because the function had no internal die calls.

- katello-sourceos-setup.sh: add existence check (|| die) before invoking it
  and || die on the bash call itself so API failures surface a clear message.

- _KATELLO_RUNNING / _KATELLO_FINAL docker ps pipelines: append || echo 0 so
  that a Docker daemon crash between `up -d` and the count check does not fire
  set -e silently; the count falls to 0 and the existing die guard triggers.

- printf > PLAINTEXT: || die on the write to the sops plaintext temp file.
@mdheller mdheller merged commit 1eb1d7e into main Jun 16, 2026
@mdheller mdheller deleted the fix/enroll-fifteenth-audit branch June 16, 2026 20:32
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.

1 participant