Skip to content

fix(gates): run every program a gate calls under a bound - #297

Merged
stxkxs merged 2 commits into
mainfrom
claude/gates-bounded-calls
Nov 27, 2026
Merged

stxkxs merged 2 commits into
mainfrom
claude/gates-bounded-calls

Conversation

@stxkxs

@stxkxs stxkxs commented Nov 27, 2026

Copy link
Copy Markdown
Member

When a gate lets subprocess.TimeoutExpired escape, it ends through the traceback with status 1, the status every gate gives a finding. So a slow renderer or a stalled clone read as a defect in this repository. Two calls had no bound at all: the kustomize builds in check-alert-severity-routes.py and check-burn-rate-budgets.py. This PR puts every program a gate runs under a bound, makes a bound that runs out read as could-not-run, and adds a test that keeps it that way.

What changed

gatelib.run. It runs a program under a timeout. When the program runs its bound out, or cannot start, it exits CANNOT_RUN, naming the call and its bound.

  • Every gate now runs programs through it: 13 call sites across 12 scripts.
  • check-image-verification.py and check-image-vulnerabilities.py keep their own calls, which already handle the expiry.

validate-dashboards.py exits CANNOT_RUN rather than 1 when grafana.com stays unreachable after every retry. It does this through an entry() a test reaches.

scripts/tests/test_gatelib.py covers the helper's outcomes and reads every script's syntax tree. It fails:

  • a subprocess call with no timeout;
  • one outside a try that catches the expiry;
  • a urlopen with no timeout.

A handler counts if it names TimeoutExpired, a class that derives it (SubprocessError, Exception), or no class at all. A handler for anything else doesn't count.

The vendored files are left to landing-zone. The files scripts/vendored.json records are landing-zone's bytes, and the gate reading the record fails a copy that differs. So the reader reads the exemption from that record.

  • Four calls in their self-tests still let an expiry escape: check-workflow-id-masking.py lines 2002, 2449 and 2457, and mask-aws-ids.py line 357.
  • Those get fixed in landing-zone and re-vendored here.
  • The vendored gate's own git ls-files is already bounded and handled upstream. This branch's earlier edit to that file is dropped, and its bytes are landing-zone's.

Checks run on this branch

At this head (c25b124, rebased onto 68320f3), under Python 3.15.2 with the lock installed --require-hashes:

  • COVERAGE_REQUIRED=1 coverage run --rcfile=.coveragerc scripts/tests/run.py: 1497 tests across 42 modules pass, and all 23 per-file floors hold.
  • scripts/tests/controls.py: 25 controls complete a proof.
  • scripts/tests/empty-corpus.py: all 36 probed gates refuse an empty corpus.
  • check-workflow-id-masking.py on this tree: OK. Its three vendored files are the bytes their record names.
  • ruff, ruff format, mypy and shellcheck: pass.

I didn't re-run the reverify harness at this head; CI runs it.


Generated by Claude Code

@github-actions

Copy link
Copy Markdown

CI Results

Check Status
Zero-placeholder gate ✅ success
Pinned chart archives ✅ success
YAML Lint ✅ success
Dashboard gate (live grafana.com ids + AMG-saveable) ✅ success
Kyverno policy tests (+ verify-images contract) ✅ success
Admission pins a verified tag to its digest (kind) ✅ success
Fork-safety gate (no hardcoded org, blocking) ✅ success
Account ids read as secrets and masked first ✅ success
Helm-render (every addon × every env) ✅ success
Rendered images carry no unacknowledged CRITICAL ✅ success
Policy-admission (Enforce-tier Kyverno vs the fleet) ✅ success
ApplicationSet schema + sync waves ✅ success
Appset render (ApplicationSet template strings) ✅ success
Secret scan (gitleaks) ✅ success
Render + assert + schema + misconfig (all environments) ✅ success
Renovate manager coverage ✅ success
Loki volume warns before cutoff ✅ success
Falco loads every rule set it installs ✅ success
Gate scripts pass lint, typecheck and shellcheck ✅ success
Policy validity (kustomize + kyverno) ✅ success
The gates themselves are tested ✅ success
Pods name ServiceAccounts that exist ✅ success
Catalog CRs admissible against the operator chart ✅ success
Catalog source reads its revision ✅ success

All checks passed.

@stxkxs
stxkxs force-pushed the claude/gates-bounded-calls branch from c25b124 to 33a217b Compare November 27, 2026 09:20
stxkxs and others added 2 commits November 27, 2026 09:34
A gate that lets subprocess.TimeoutExpired escape ends through the
traceback with status 1, the status every gate gives a finding, so a slow
renderer or a stalled clone read as a defect in this repository. Three
calls had no bound at all: the kustomize builds in
check-alert-severity-routes and check-burn-rate-budgets, and git ls-files
in check-workflow-id-masking.

gatelib.run runs a program under a timeout and exits CANNOT_RUN, naming
the call and its bound, when the program runs it out or cannot start.
Every gate now runs programs through it: 13 call sites across 12 gates.
check-image-verification and check-image-vulnerabilities keep their own
calls, which already handle the expiry.

validate-dashboards exits CANNOT_RUN rather than 1 when grafana.com stays
unreachable after every retry, through an entry() a test reaches.

test_gatelib covers the helper's outcomes and reads every script's syntax
tree: a subprocess call outside a try that handles TimeoutExpired, or one
with no timeout, fails it, as does a urlopen with no timeout.

Co-authored-by: stxkxsbot <275011021+stxkxsbot@users.noreply.github.com>
…red code to its source

The reader in test_gatelib took a subprocess call as bounded only inside
a try whose handler names TimeoutExpired. A handler naming a class it
derives from catches it too, SubprocessError, Exception or everything,
and the vendored masking gate's git ls-files is bounded in exactly that
way. The reader now accepts those, and refuses a handler for anything
else.

The files scripts/vendored.json records are landing-zone's bytes, and
the gate reading the record fails a copy that differs from it. Four
calls in their self-tests still let an expiry escape:
check-workflow-id-masking.py lines 2002, 2449 and 2457, and
mask-aws-ids.py line 357. Those are fixed in landing-zone and
re-vendored, so the reader holds the files this repository writes and
reads the exemption from the record itself.

Co-authored-by: stxkxsbot <275011021+stxkxsbot@users.noreply.github.com>
@stxkxs
stxkxs force-pushed the claude/gates-bounded-calls branch from 33a217b to d678139 Compare November 27, 2026 09:35
@github-actions

Copy link
Copy Markdown

CI Results

Check Status
Zero-placeholder gate ✅ success
Pinned chart archives ✅ success
YAML Lint ✅ success
Dashboard gate (live grafana.com ids + AMG-saveable) ✅ success
Kyverno policy tests (+ verify-images contract) ✅ success
Admission pins a verified tag to its digest (kind) ✅ success
Fork-safety gate (no hardcoded org, blocking) ✅ success
Account ids read as secrets and masked first ✅ success
Helm-render (every addon × every env) ✅ success
Rendered images carry no unacknowledged CRITICAL ✅ success
Policy-admission (Enforce-tier Kyverno vs the fleet) ✅ success
ApplicationSet schema + sync waves ✅ success
Appset render (ApplicationSet template strings) ✅ success
Secret scan (gitleaks) ✅ success
Render + assert + schema + misconfig (all environments) ✅ success
Renovate manager coverage ✅ success
Loki volume warns before cutoff ✅ success
Falco loads every rule set it installs ✅ success
Gate scripts pass lint, typecheck and shellcheck ✅ success
Policy validity (kustomize + kyverno) ✅ success
The gates themselves are tested ✅ success
Pods name ServiceAccounts that exist ✅ success
Catalog CRs admissible against the operator chart ✅ success
Catalog source reads its revision ✅ success

All checks passed.

1 similar comment
@github-actions

Copy link
Copy Markdown

CI Results

Check Status
Zero-placeholder gate ✅ success
Pinned chart archives ✅ success
YAML Lint ✅ success
Dashboard gate (live grafana.com ids + AMG-saveable) ✅ success
Kyverno policy tests (+ verify-images contract) ✅ success
Admission pins a verified tag to its digest (kind) ✅ success
Fork-safety gate (no hardcoded org, blocking) ✅ success
Account ids read as secrets and masked first ✅ success
Helm-render (every addon × every env) ✅ success
Rendered images carry no unacknowledged CRITICAL ✅ success
Policy-admission (Enforce-tier Kyverno vs the fleet) ✅ success
ApplicationSet schema + sync waves ✅ success
Appset render (ApplicationSet template strings) ✅ success
Secret scan (gitleaks) ✅ success
Render + assert + schema + misconfig (all environments) ✅ success
Renovate manager coverage ✅ success
Loki volume warns before cutoff ✅ success
Falco loads every rule set it installs ✅ success
Gate scripts pass lint, typecheck and shellcheck ✅ success
Policy validity (kustomize + kyverno) ✅ success
The gates themselves are tested ✅ success
Pods name ServiceAccounts that exist ✅ success
Catalog CRs admissible against the operator chart ✅ success
Catalog source reads its revision ✅ success

All checks passed.

@stxkxs
stxkxs merged commit 6e9fdb2 into main Nov 27, 2026
34 checks passed
@stxkxs
stxkxs deleted the claude/gates-bounded-calls branch November 27, 2026 21:21
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