mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-06 07:03:45 +09:00
A Credential is a view over a CredentialTemplate's status, so a list or a get never reads a Secret. A mint builds the whole account Secret from the template and writes it under the Secret resourceVersion the template's status mirrors, so a concurrent mint or a seed in between fails with a conflict instead of silently replacing a password someone just received, and returns the plaintext once. A revoke stores a random password and discards it. A dry-run writes nothing. Each mint and revoke records an Event on the application naming the account and the caller, never the value, which needs create on events. The API review gate now captures a subresource registration such as credentials/mint as a resource of its own rather than dropping it. Co-authored-by: Timofei Larkin <lllamnyp@gmail.com> Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
105 lines
4.0 KiB
YAML
105 lines
4.0 KiB
YAML
suite: cozystack-api ClusterRole grants Option provider sources
|
|
templates:
|
|
- templates/rbac.yaml
|
|
|
|
release:
|
|
name: cozystack-api
|
|
namespace: cozy-system
|
|
|
|
# The Option (dropdown) providers run with the cozystack-api ServiceAccount's
|
|
# privileged client, so every GVR a provider lists must be granted on this
|
|
# ClusterRole. The plan/backup providers list namespaced plans/backups in the
|
|
# backups.cozystack.io group; without read access there the apiserver returns
|
|
# forbidden and List silently drops those dropdowns (Get returns 500). The
|
|
# bare cozystack.io grant does NOT cover backups.cozystack.io — RBAC matches
|
|
# the API group string exactly.
|
|
#
|
|
# The last two tests bound the role from two directions, and neither covers the
|
|
# other. The count bound pins the list at exactly twenty-two: templates/rbac.yaml
|
|
# carries no template directives, so anything appended makes rules[22] exist and
|
|
# anything dropped takes rules[21] away, whatever the rule is called. It says
|
|
# nothing about a grant swapped in for an existing one, because the count does
|
|
# not move under a swap. The spelling assert catches that case for the one rule
|
|
# it names, and misses every other wording of it, because helm-unittest compares
|
|
# each field it is handed by value equality and `any: true` only selects which
|
|
# fields are compared. Changing the rule count on purpose means moving both
|
|
# indices below, which is the review this role should get.
|
|
|
|
tests:
|
|
- it: grants read on backups.cozystack.io plans and backups for the plan/backup providers
|
|
asserts:
|
|
- contains:
|
|
path: rules
|
|
content:
|
|
apiGroups: ["backups.cozystack.io"]
|
|
resources: ["backupclasses", "plans", "backups"]
|
|
verbs: ["get", "watch", "list"]
|
|
|
|
- it: grants full access on cilium.io ciliumnetworkpolicies for SecurityGroup storage
|
|
asserts:
|
|
- contains:
|
|
path: rules
|
|
content:
|
|
apiGroups: ["cilium.io"]
|
|
resources: ["ciliumnetworkpolicies"]
|
|
verbs: ["get", "watch", "list", "create", "update", "patch", "delete"]
|
|
|
|
# The marketplace tap flow: disconnecting a tap deletes its cluster-scoped
|
|
# PackageSource and the tap-managed registration Package that de-registers its
|
|
# apps, and the tap's Flux OCIRepository is read to report status. These grants
|
|
# live on this ClusterRole because the tap handler runs with the cozystack-api
|
|
# ServiceAccount's client.
|
|
- it: grants delete on cozystack.io packagesources and packages for tap disconnect
|
|
asserts:
|
|
- contains:
|
|
path: rules
|
|
content:
|
|
apiGroups: ["cozystack.io"]
|
|
resources: ["packagesources", "packages"]
|
|
verbs: ["delete"]
|
|
|
|
- it: grants read on source.toolkit.fluxcd.io ocirepositories for tap status
|
|
asserts:
|
|
- contains:
|
|
path: rules
|
|
content:
|
|
apiGroups: ["source.toolkit.fluxcd.io"]
|
|
resources: ["ocirepositories"]
|
|
verbs: ["get", "list", "watch"]
|
|
|
|
- it: grants read on cdi.kubevirt.io datavolumes for the image provider
|
|
asserts:
|
|
- contains:
|
|
path: rules
|
|
content:
|
|
apiGroups: ["cdi.kubevirt.io"]
|
|
resources: ["datavolumes"]
|
|
verbs: ["get", "watch", "list"]
|
|
|
|
- it: does not grant objectstorage.k8s.io bucketclasses (no provider reads it)
|
|
asserts:
|
|
- notContains:
|
|
path: rules
|
|
content:
|
|
apiGroups: ["objectstorage.k8s.io"]
|
|
resources: ["bucketclasses"]
|
|
verbs: ["get", "watch", "list"]
|
|
|
|
- it: grants create on events for the credential issued and revoked records
|
|
asserts:
|
|
- contains:
|
|
path: rules
|
|
content:
|
|
apiGroups: [""]
|
|
resources: ["events"]
|
|
verbs: ["create"]
|
|
|
|
- it: ships exactly the twenty-two rules this role is pinned to
|
|
asserts:
|
|
# Both directions. A dropped grant is the failure this suite is about:
|
|
# the apiserver returns forbidden and List silently drops the dropdown.
|
|
- exists:
|
|
path: rules[21]
|
|
- notExists:
|
|
path: rules[22]
|