Skip to content

Property-based testing across the cert-manager projects: trial results and findings #9155

Open

Description

@wallrj

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

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

istio-csr

csi-driver-spiffe

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 indirect purego; 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions