liggitt/audit2rbac
liggitt/audit2rbac has 1,111 GitHub stars and 84 forks. GitHot measured 0 in 7 days. Last checked 2026-11-11 00:09 UTC. Last push 2023-02-11.
Autogenerate RBAC policies based on Kubernetes audit logs
Measured star growth
- in 24h
- Update delayed
- in 7 days
- 0
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originalaudit2rbac
Overview
audit2rbac takes a Kubernetes audit log and username as input, and generates RBAC role and binding objects that cover all the API requests made by that user.
Demo Video
User Instructions
Obtain a Kubernetes audit log containing all the API requests you expect your user to perform:
- The log must be in JSON format. This requires running an API server with an
--audit-policy-filedefined. See documentation for more details. audit.k8s.io/v1,audit.k8s.io/v1beta1andaudit.k8s.io/v1alpha1events are supported.- The
Metadatalog level works best to minimize log size. - To exercise all API calls, it is sometimes necessary to grant broad access to a user or application to avoid short-circuiting code paths on failed API requests. This should be done cautiously, ideally in a development environment.
- A sample audit policy and a sample audit log containing requests from
alice,bob, and the service accountns1:sa1is available.
- The log must be in JSON format. This requires running an API server with an
Identify a specific user you want to scan for audit events for and generate roles and role bindings for:
- Specify a normal user with
--user <username> - Specify a service account with
--serviceaccount <namespace>:<name>
- Specify a normal user with
Run
audit2rbac, capturing the output:audit2rbac -f https://git.io/v51iG --user alice > alice-roles.yaml audit2rbac -f https://git.io/v51iG --user bob > bob-roles.yaml audit2rbac -f https://git.io/v51iG --serviceaccount ns1:sa1 > sa1-roles.yamlInspect the output to verify the generated roles/bindings:
more alice-roles.yamlapiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: labels: audit2rbac.liggitt.net/generated: "true" audit2rbac.liggitt.net/user: alice name: audit2rbac:alice namespace: ns1 rules: - apiGroups: - "" resources: - configmaps - pods - secrets verbs: - get - list - watch --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: labels: audit2rbac.liggitt.net/generated: "true" audit2rbac.liggitt.net/user: alice name: audit2rbac:alice namespace: ns1 roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: audit2rbac:alice subjects: - apiGroup: rbac.authorization.k8s.io kind: User name: aliceLoad the generated roles/bindings:
kubectl create -f roles.yaml role "audit2rbac:alice" created rolebinding "audit2rbac:alice" created
Developer Instructions
Requirements:
- Go 1.17+
To build and install from source:
go get -d github.com/liggitt/audit2rbac
cd $GOPATH/src/github.com/liggitt/audit2rbac
git fetch --tags
make install-deps
make install
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
561,650 starspublic-apis/public-apis
A collective list of free APIs
498,029 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
450,586 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,312 stars