test: harden the CEL guard and name the Job generation in its pin #172
Loading…
Reference in a new issue
No description provided.
Delete branch "test/vap-cel-balance-hardening"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
An adversarial review of #168 (three independent reviewers, each finding verified by a refuter against cel-go v0.26.0 / k8s.io/apiserver v0.36.0, the parser the apiserver runs) found holes in
tests/vap-cel-balance.sh. The guard was fail-closed on today's tree, but it could miss the class it was written for and it could go red on valid CEL. Every hole is now a fixture the self-test must catch before the guard judges the repository.Lexer (false negatives first)
'…',"…"orr'…'string. cel-go excludes\n/\rfrom single-quoted strings; only the triple-quoted forms span lines. The lexer accepted it. Reachable today: the>-style every policy underkyverno-policies/uses puts a line break inside the string as soon as a continuation line is more-indented. Verified: rewrapping onemessageExpressioninbinjovi-image-digest-pinnedthat way was green before and isstring opened with " has a line break in itnow.//comments. They are CEL (COMMENT : '//' (~'\n')* -> channel(HIDDEN)). Un-skipped, a)in a comment masked a missing)(verified in the incident's own variable,publisherCredential: comment added, one real)removed, guard green; now red with1 unclosed: (), and an apostrophe in a comment went red on a valid policy (now green).br'…'/bR"…"raw bytes literals were read as escaped strings.Discovery and extraction
kind: Listwas discovered by grep and dropped by yq, so it was never judged; kustomize flattens a List, so its items are applied.extractnow opens Lists..ymlfile escaped the grep. Loosened to what yq'sselectaccepts.ok: 64 …and then the bracket advice (pipefail made the pipeline red after judge had already spoken). yq now runs to completion into a file first and is named as the failure:FAIL: yq could not read an admission policy file named above; repair that YAML first.variables:crashed the judge with aTypeErrortraceback instead of a FAIL line.Self-test
The broken fixture now carries eight defects (short bracket, open string, crossed brackets, split string, comment-masked bracket, messageExpression, auditAnnotations, a List-wrapped MutatingAdmissionPolicy) and the whole fixture twelve valid expressions across a VAP and a MutatingAdmissionPolicy (nested, escaped, raw, raw bytes, triple-quoted over two lines,
//comment with a quote and a bracket in it, map/list literals, auditAnnotations, applyConfiguration and jsonPatch). The judge must also refuse the whole fixture at a minimum of 13. Ten lexer/extractor mutants each turn the self-test red (no comment handling, no line-break check, no bytes prefix, auditAnnotations/mutations/matchConditions/messageExpression branch dropped, minimum ignored, List not opened, lexer always None).Pin (
tests/binjovi.sh)The review showed the fingerprint pin is bypassable in exactly the shape of
18db1c1f: change the template, keepv15, re-pin the new checksum. A snapshot test cannot see history, so the pin now carries the generation name with the checksum (binjovi-forgejo-integration-v15 1955159150 12636), refuses an empty template (a renamed kind used to fingerprint as4294967295 0), and its message says not to re-pin under the old name. The step still rests on the editor; the durable alternative iskustomize.toolkit.fluxcd.io/force: enabledon the Job, asbinjovi-release-cli-oauth-v2in the same component already carries — a design call for a Job withPGUSER=forgejopower, so not made here.Verified
ok: 64 CEL expressions in 6 admission policies close what they open, 1 s in the admission image;tests/binjovi.shgreen locally and in the image; fulltests/check.shgreen in the image.18db1c1fcredential guard, the split-string rewrap, the comment-masked bracket, a quoted/commented kind in a.yml, a List-wrapped policy, a tab-indented file, a map-shapedvariables:, a one-character template edit without a rename.https://claude.ai/code/session_01LeVatedQ4sCA1u6LHjo7B5