Skip to content

test(gates): reach the id-masking gate's rules from this repository's policy - #300

Open
stxkxs wants to merge 1 commit into
mainfrom
claude/gates-vendored-coverage
Open

stxkxs wants to merge 1 commit into
mainfrom
claude/gates-vendored-coverage

Conversation

@stxkxs

@stxkxs stxkxs commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

The vendored id-masking gate and mask core are tested by their own self-tests, which test_workflow_id_masking.py runs in the suite's own process. There they reached 98% of the gate's lines and 97% of its branches, and 99% and 98% of the core's. Three things were left unreached:

  • rules this repository's policy planted no case for;
  • the core's main() entry, which CI's mask-aws-ids.sh --self-test goes through;
  • the gate's refusal to run without tomllib or PyYAML. Its self-test proves that only in a child process, which the coverage run does not see.

This change plants the missing cases and runs both entries in the suite's process. It then holds each file to what that reaches: the core at 100/100, and the gate at (99.9, 99.6).

What changed

scripts/workflow-id-masking.toml plants six more cases the gate must reject. Each is rejected at its mutated line, by its rule:

Case The rule it plants
every variable value through an object filter, join(vars.*, ',') a filter over the vars context is refused
a variable read in a job granted write-all a job that can hold AWS credentials reads no variable
a role ARN assembled around an account id secret an id-named key takes a secret only whole
an id-named key in the workflow-level env at workflow level, only the guard form
an environment id whose needs share a job, none refusing the inherited name the refuse-inherited-config rule, followed through transitive needs
a guard written with a double-quoted string an expression the gate cannot read is refused

It also adds this repository's first [[accepted]] edits. Each is a change the gate must pass with no finding anywhere:

  • a comment above the mask command;
  • AWS's documentation account id, 123456789012, in a message;
  • a secret named outside the id rule, read in a job that can hold AWS credentials;
  • an id-named key fed from an output of the mask step.

scripts/tests/test_workflow_id_masking.py:

  • runs the core's self-test through main(["--self-test"]), the way CI reaches it;
  • loads the gate first with tomllib unavailable, then with PyYAML unavailable, and requires exit 2 and the refusal each time.

scripts/tests/run.py:

  • holds mask-aws-ids.py at 100/100, among the security-critical files;
  • holds the gate to the tenth just under what it reaches, so one more line or branch left unreached fails the run. A whole-number floor could not catch that, because one of the gate's 1229 lines is 0.08%.
  • PER_GATE_FLOORS accepts tenths. The per-file loop names its floor separately from the totals' loop, so mypy reads both as float.

What the gate still leaves unreached: line 1018, and the branches 1014→1018 and 1588→1587. Only a tree with no scripts/vendored.json, whose policy vendors nothing, takes them. That is landing-zone's own tree, and never a copy's. The self-test vendored here, from 517a99d, plants no such tree. landing-zone's own self-test has planted one since 564461b (#319). The re-vendor after this PR brings that case here, and the gate is then held at 100.

Checks run on this branch

All local, at this head (41f6a1f, on 27f1230), under Python 3.15.2 with the lock installed --require-hashes:

  • scripts/check-workflow-id-masking.py --self-test passes. It rejects 59 mutations (the policy's 58 and the gate's own quoting case) and accepts the 4 permitted edits. Each new case is decided by the rule it names.
  • scripts/check-workflow-id-masking.py passes the tree, and scripts/mask-aws-ids.sh --self-test passes its 31 cases.
  • COVERAGE_REQUIRED=1 coverage run --rcfile=.coveragerc scripts/tests/run.py: 1593 tests across 44 modules pass, and all 25 per-file floors hold. The gate reaches 1228 of 1229 lines and 514 of 516 branches; the core reaches 184 of 184 and 74 of 74.
  • scripts/tests/controls.py: 25 controls each complete a proof, the id-masking gate's among them.
  • scripts/tests/empty-corpus.py: all 36 probed gates refuse an empty corpus.
  • scripts/tests/reverify-tests.sh: pass=300 fail=0, main's 300. This change adds no probe and changes none: the vendored files carry none, since an edit to either fails its record first.
  • ruff, ruff format, mypy over scripts/, and shellcheck all pass.

The rebase onto 27f1230 met two conflicts in run.py. In the first, the float type now sits beside the fork-safety gate's floor, which main had added. In the second, this change's two vendored files come right after verdicts.py, ahead of #299's catalog.py floor and #302's raised control-exempt floors. Both sides are kept in each.

@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.

…d both vendored files to it

The vendored id-masking gate and mask core are tested by their own
self-tests, run in this process. Here those reached 98% of the gate's
lines and 97% of its branches, and 99% and 98% of the core's. Three
things were left unreached: rules this repository's policy planted no
case for; the core's main() entry, which CI's `mask-aws-ids.sh
--self-test` goes through; and the gate's refusal to run without
tomllib or PyYAML, which its self-test proves only in a child process
the coverage run does not see.

- scripts/workflow-id-masking.toml plants six more cases the gate must
  reject: every variable through an object filter, a variable read in a
  job granted write-all, a role ARN assembled around an account id
  secret, an id-named key in the workflow-level env, an environment id
  whose needs share a job, and a guard written with a double-quoted
  string. It also lists the first [[accepted]] edits, four changes the
  gate must pass: a comment above the mask command, AWS's documentation
  account id in a message, a secret named outside the id rule read in a
  job that can hold AWS credentials, and an id-named key fed from an
  output of the mask step.
- test_workflow_id_masking.py runs the core's self-test through
  main(["--self-test"]), and loads the gate with tomllib, then PyYAML,
  unavailable, requiring exit 2 and the refusal each time.
- run.py holds mask-aws-ids.py at 100/100 among the security-critical
  files. It holds the gate to the tenth just under what it reaches,
  (99.9, 99.6), so any further line or branch left unreached fails. Its
  one line and two branches left are reached only by a tree with no
  scripts/vendored.json, which is landing-zone's own and never a copy's.
  The floors accept tenths, and the per-file loop names its floor apart
  from the totals' so mypy reads both as float.

Co-authored-by: stxkxsbot <275011021+stxkxsbot@users.noreply.github.com>
@stxkxs
stxkxs force-pushed the claude/gates-vendored-coverage branch from bb16c19 to 41f6a1f Compare November 29, 2026 07:59
@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.

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