Skip to content

fix(ci): close phase catalog self-test files - #988

Open
tfm4 wants to merge 1 commit into
mainfrom
fix/phase-catalog-self-test-file-handles
Open

tfm4 wants to merge 1 commit into
mainfrom
fix/phase-catalog-self-test-file-handles

Conversation

@tfm4

@tfm4 tfm4 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What

The phase-catalog guard's self-test helpers leave the catalog input and fixture read/write files without explicit closure. Use context managers at the three reported sites so files close before subsequent validation reads them, preserving catalog entries, table contents, and refusal behavior.

Tracking issue: #987. Addresses code-scanning alerts 333, 334, and 335.

Block-completion review (ADR 1015)

  • Non-block change — three file-resource fixes in existing self-test helpers.

Test plan

  • python3 ops/ci/check-phase-catalog.py --self-test — the unedited copy passes; a hand-edited table, missing required field, and nonexistent read path are refused; all 71 phases and generated tables match.
  • python3 ops/ci/check-phase-catalog.py — passes on the current repository.
  • The probe below fails on base commit 9ba6fada with 10 unclosed-file warnings from the three reported sites, and passes on this branch with zero.
  • bash ops/ci/check-no-identity-spillage.sh ops/ci/check-phase-catalog.py — passes.
  • bash ops/ci/check-no-live-secret.sh ops/ci/check-phase-catalog.py — passes with live values loaded.
  • git diff --check and local signature verification — pass.
python3 - <<'PYTHON'
import gc
import runpy
import warnings

guard = runpy.run_path("ops/ci/check-phase-catalog.py")
with warnings.catch_warnings(record=True) as captured:
    warnings.simplefilter("always", ResourceWarning)
    assert guard["self_test"](".") == 0
    gc.collect()
leaks = [str(w.message) for w in captured
         if issubclass(w.category, ResourceWarning) and "unclosed file" in str(w.message)]
assert not leaks, leaks
print("No unclosed-file warnings")
PYTHON

Both hosted Python CodeQL analyses passed. The broader Python/Ansible job was cancelled after about 30 minutes; a targeted rerun has been requested. Full CI validation remains pending. No scanner alerts have been manually dismissed; closure on main awaits merge and a successful main-branch scan.

Cross-repo coordination

Documentation

  • No architectural change. Only self-test file lifetime changes.

Checklist

  • Commit is signed and verified locally, with a matching DCO sign-off.
  • PR title follows Conventional Commits.
  • Used git commit <path> form for the single changed file.
  • Hosted CI is green — pending.
  • Reviewer routing and approvals — pending; no approvals claimed.

Security-sensitive?

  • Not security-sensitive — ordinary file-resource maintenance in self-test helpers. The public handling assessment was completed before implementation.

Notes for reviewers

Keep tracking issue #987 open until its acceptance criteria, including merge and scanner-confirmed closure on main, are satisfied. This PR uses a non-closing issue reference so that merge alone does not claim that the alerts have been rescanned.

Refs #987

Signed-off-by: tfm4 <310161029+tfm4@users.noreply.github.com>
@tfm4 tfm4 added bug Something is broken hardening Security or reliability hardening that is not a reported vulnerability area/release CI, images, releases, supply chain labels Nov 16, 2026
@tfm4 tfm4 self-assigned this Nov 16, 2026
@tfm4 tfm4 moved this to In Progress in GOAT Roadmap Nov 16, 2026
@tfm4
tfm4 marked this pull request as ready for review November 16, 2026 15:37
@tfm4
tfm4 requested a review from a team as a code owner November 16, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/release CI, images, releases, supply chain bug Something is broken hardening Security or reliability hardening that is not a reported vulnerability

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant