Repository navigation
Description
This issue tracks a trial of property-based testing across the cert-manager projects, and collects the findings so they don't get lost in the individual draft PRs.
The method, applied identically in each repository: replace example tables whose rows merely instantiate a recomputable rule with properties that recompute the rule over generated inputs; keep tables that pin external bytes (OpenSSL/Java interop fixtures), policy choices or specific regressions; hunt for bugs at trust boundaries with adversarial inputs; and require a block-level coverage diff against the base commit with zero blocks lost. The library is hegel-go, a Hypothesis-style property-testing library with a native shrinking engine — failing cases shrink automatically to minimal counterexamples. #9149 describes candidate selection in detail.
Trial PRs (all draft, not for merge as-is)
| project | PR | outcome |
|---|---|---|
| cert-manager | #9149 | pkg/util/pki, ingress-shim, policies, solverpicker, internal/cron; produced the four issues and two issue comments below |
| approver-policy | cert-manager/approver-policy#989 | no production bugs — recent hardening held; predicate coverage 71.2% → 80.3% |
| trust-manager | cert-manager/trust-manager#1064 | CertPool, JKS/PKCS#12 truststore encoders, condition helpers; util coverage 81.1% → 90.5% |
| istio-csr | cert-manager/istio-csr#891 | CSR extension validation, identity matching, istiodcert options; extensions coverage 81.2% → 93.8% |
| csi-driver-spiffe | cert-manager/csi-driver-spiffe#586 | approver evaluator, identity validation, issuance-time; evaluator coverage 76.7% → 92.2% |
| csi-lib | cert-manager/csi-lib#279 | issuance-time, fsGroup parsing, token request, HashIdentifier, MarshalLog redaction; internal/api/util 0% → 100% |
| issuer-lib | cert-manager/issuer-lib#497 | condition setters, controller predicates; zero coverage blocks lost, one gained |
Findings
Checked items were addressed by the trial PRs themselves; unchecked items are open follow-ups.
cert-manager
- ingress-shim accepts annotation values that the API server rejects, so the Certificate is never created #9145 — ingress-shim accepts annotation values that the API server rejects, so the Certificate is never created
- Renewal windows that can never be satisfied pass admission; the Certificate is left permanently Ready=False and renewed outside its windows #9146 — renewal windows that can never be satisfied pass admission; the Certificate is left permanently Ready=False and renewed outside its windows
- JoinWithEscapeCSV/SplitWithEscapeCSV cannot round-trip a single empty value, and silently corrupt values containing CRLF #9147 —
JoinWithEscapeCSV/SplitWithEscapeCSVcannot round-trip a single empty value, and silently corrupt values containing CRLF - internal/cron returns the zero time for leap-day schedules when the next occurrence is more than 5 years away #9148 — internal/cron returns the zero time for leap-day schedules when the next occurrence is more than 5 years away
- Controller panic (nil pointer) at checks.go:316 when a renewal window errors, e.g. windowDuration: 0s #9100 — the reported panic reproduces and shrinks to
windowDuration: 0s(commented there); extend the crash property to coverspec.renewalonce fixed - Bundles containing cross-signed certificates are deterministically rejected as "malformed or broken" in every order and subset (also noted on Support cross-signed intermediate CAs issued with Vault #7645); root-cause fix open in Accept bundles containing cross-signed certificates in ParseSingleCertificateChain #9150
-
findBeforeDesired's comments claim it can return windows earlier than the desired time, but its filters mean it only ever returns the desired time (renewaltime.go#L244) -
MarshalSANsaccepts unwrapped otherName values and emits an extension thatUnmarshalSANsthen rejects (sans.go#L204) -
TestPrivateKeyEncodingshad a duplicate row — the "empty key encoding" row actually set PKCS1, so the default encoding path was never tested; replaced by a property in Experiment: property-based tests with hegel-go #9149
approver-policy
- No production bugs found. The wildcard matcher (checked against an anchored-regexp oracle), the allowed and constraints evaluators, and the predicates all held under adversarial inputs — the recent RawSubject and fail-closed SAN-parsing hardening checked out.
trust-manager
- Stale doc comment on
AddCertsFromPEMclaims an error is returned when the input bundle contains no non-expired certificates; that behaviour was removed by CertPool should not error when input adds no certificates trust-manager#624 but the comment stayed (cert_pool.go#L118). One-line doc fix.
istio-csr
-
TestValidateExtendedKeyUsageExtensionhad been vacuous since Intoduce more in-depth CSR extension validation istio-csr#37 (2021): the test built its extension with the plain KU OID, so every case failed at the ID guard and the forbidden-EKU branch was never exercised. Replaced by properties in Trial: property-based tests with hegel-go istio-csr#891. -
istiodcert.Options.Validatedrops the invalid DNS name from its error: the%qmeant for the name is given the joined validation errors instead, and the message ends with a dangling ": " (options.go#L111, since Add ability to dynamically configure istiod cert istio-csr#359). One-line fix.
csi-driver-spiffe
- The same vacuous EKU test, inherited from istio-csr via the initial import (Initial code csi-driver-spiffe#1). Replaced in Trial hegel-go property-based tests on the SPIFFE approver and driver csi-driver-spiffe#586.
- Latent nil-pointer panic in
calculateNextIssuanceTime: thepem.Decoderesult is used without a nil check, so a corrupt stored certificate panics the driver (util.go#L81-L83). Fix together with the csi-lib original below. - The extension-rejection message prints
csr.Extensionsrather than the offendingcsr.ExtraExtensions(extensions.go#L65).
csi-lib
- The origin of the nil-pointer panic above (manager.go#L983-L984). One-line fix in both repositories.
- The fsGroup error message says "less than 4294967295" but the bound is inclusive (filesystem.go#L352).
issuer-lib
-
CertificateRequestPredicate's doc comment oversells: it says a reconcile is triggered when "a status condition was added or removed", but Ready conditions are skipped and the fast path only compares counts, so replacing a Ready condition with one of a different type does not trigger (predicates.go#L37). Doc fix. -
LinkedIssuerPredicate's wrong-type branch had never been tested — now covered by the property in Property-based-testing trial with hegel-go issuer-lib#497, the one coverage block gained there.
Decisions needed
- Dependency: adopting any of this means accepting a new test-only dependency,
hegel.dev/go/hegel(plus an indirectpurego; the shrinking engine ships as an embedded shared library). That needs a maintainer decision before any trial PR is split up for merging. - The showcase PRs are deliberately monolithic to make the before/after comparison easy; if maintainers want the changes, they should be split per package.
- Whether to write the selection rule of thumb into the contributing docs: replace tables whose rows instantiate a recomputable rule; keep tables that pin external bytes, policy choices or regressions.
with claude fable-5
Activity