Repository navigation
Conversation
Test_calculateNextIssuanceTime checked a single hand-computed example of the 2/3-lifetime rule. The property in manager_hegel_test.go draws validity periods from 1970 to 2100 with lifetimes up to a century and recomputes the expected next issuance time independently of the PEM / X.509 parsing pipeline. It also checks that only the first PEM block governs the result. This adds the hegel.dev/go/hegel test dependency and gitignores its .hegel example database. The property's doc comment records a latent panic found while writing it: calculateNextIssuanceTime dereferences the nil block returned by pem.Decode when the chain contains no PEM block. csi-driver-spiffe copied this code and inherited the same flaw. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Richard Wall <[email protected]>
The nine rows of Test_fsGroupForMetadata were hand-picked instances of one rule: the volume attribute named by FSGroupVolumeAttributeKey takes precedence over VolumeMountGroup, an empty effective value means no ownership change, and anything else must parse as a decimal integer in [1, 4294967295]. The property recomputes that rule from drawn parts, with group strings drawn as wide-ranging integers (crossing both range boundaries and int64 overflow) or arbitrary Unicode text. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Richard Wall <[email protected]>
Test_restConfigForMetadataTokenRequestEmptyAud's five rows were instances of one rule: the getter succeeds iff the kubelet token-request volume context key carries a non-empty token for the empty audience, and on success the rest config is exactly the seed's Host, TLSClientConfig, UserAgent and Timeout plus that token as the bearer token. The property draws kubelet-style audience/token maps (empty audience present or not, empty or non-empty tokens, extra audiences) and recomputes the rule. It also pins that the seed config's own BearerToken never leaks into the per-volume config. A second property feeds arbitrary Unicode text as the volume context value: EmptyAudienceTokenFromMetadata must error, never panic and never return an empty token without an error. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Richard Wall <[email protected]>
HashIdentifier turns arbitrary node and volume IDs into CertificateRequest label values but had no tests. The property checks that for any input — including empty strings and arbitrary Unicode — the output is a valid Kubernetes label value (using the apimachinery validator the API server itself uses) and is deterministic. Metadata.MarshalLog redacts the kubelet-injected ServiceAccount token from log output. The example-based tests pin the formatted-output security property; the new property checks the redaction rule over arbitrary volume contexts: the token entry (if present) becomes exactly "[REDACTED]", every other entry is preserved unchanged, and the original Metadata is never mutated. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Richard Wall <[email protected]>
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Not for merge as-is — this is the csi-lib instalment of the property-based-testing trial previously run on cert-manager (cert-manager/cert-manager#9149, which describes how candidates are chosen), approver-policy (cert-manager/approver-policy#989), trust-manager (cert-manager/trust-manager#1064), istio-csr (cert-manager/istio-csr#891) and csi-driver-spiffe (cert-manager/csi-driver-spiffe#586). If maintainers want any of it, it should be split per package, and the new test-only dependency (hegel-go, a Hypothesis-style property-testing library with a native shrinking engine, pulled in via
hegel.dev/go/hegel+purego) needs discussing first.What's here
Four commits, each putting properties in separate
*_hegel_test.gofiles so the diff reads as deleted tables and new properties. Tables are replaced only where their rows merely instantiate a recomputable rule; tests that pin end-to-end flows, external bytes or exact output are kept.managercalculateNextIssuanceTime— the single-exampleTest_calculateNextIssuanceTimebecomes a property: for any leaf certificate (validity drawn 1970–2100, lifetimes up to a century) the next issuance time is exactly 2/3 through the certificate's lifetime, recomputed independently of the PEM/X.509 pipeline, and only the first PEM block governs.storagefsGroupForMetadata— the nine-row table becomes a property recomputing the precedence and range rule: theFSGroupVolumeAttributeKeyvolume attribute overridesVolumeMountGroup; empty means no ownership change; anything else must parse as a decimal integer in [1, 4294967295]. Group strings are drawn as wide-ranging integers (crossing both boundaries and int64 overflow) or arbitrary Unicode text.manager/utiltoken request — the five-rowTest_restConfigForMetadataTokenRequestEmptyAudtable becomes a property over kubelet-style audience→token maps: the getter succeeds iff a non-empty empty-audience ("") token is present, and on success the rest config is exactly the seed's Host/TLS/UserAgent/Timeout plus that token — pinning that the seed's ownBearerTokennever leaks into the per-volume config. A second property feeds arbitrary text as the volume-context value: error, never panic.internal/api/util.HashIdentifier(no tests at all; for any input the output must be a valid Kubernetes label value, checked with the apimachinery validator, and deterministic) andmetadata.Metadata.MarshalLog(over arbitrary volume contexts: the SA token entry becomes exactly[REDACTED], every other entry is preserved, the original is never mutated — alongside the example-based pins from the token-redaction fix, which are kept).Kept as-is: all the manager issuance/backoff/cleanup tests, the filesystem read/list tests, the metrics exact-output tests, the driver redaction pins and the integration tests.
What it found
No production behaviour bugs, but two long-standing flaws worth one-line follow-ups:
calculateNextIssuanceTimepanic found in csi-driver-spiffe originates here. manager.go line 983 atb7fffdeignorespem.Decode's nil return: a certificate chain with no PEM block dereferences a nil pointer instead of returning an error. The chain comes from the issuedCertificateRequest's status, so it takes a misbehaving issuer or someone with status-write access to trigger. csi-driver-spiffe copied this function and inherited the flaw (written up in Trial hegel-go property-based tests on the SPIFFE approver and driver csi-driver-spiffe#586); fixing it here and there are both one-line nil checks. Documented in the property's doc comment; not fixed here since the trial is test-only.fsGroupForMetadata's range error message is off by one. filesystem.go line 352 atb7fffdesays the gid "must be greater than 0 and less than 4294967295", but the check on line 351 (and the comment above it) accepts exactly 4294967295. The property pins the code's actual behaviour (inclusive upper bound).Coverage (
mainat b7fffde → branch,go test -coverprofile, unit packages)internal/api/utilmanagermanager/utilmetadatastorage¹ Block-level diff shows the only "lost" block (
issue()'s ReadMetadata error branch) flickers run-to-run on identical code — it is covered nondeterministically by the concurrent manager tests, not by anything this branch removed. No other blocks lost; the flat percentages reflect that the replaced tables already touched every line — the properties add adversarial input coverage, not line coverage.with claude fable-5