You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(KONFLUX-9093): Add tool for validating role RBAC
In KONFLUX-9093, there is a request to enable roles to be cerated in
namespaces via Argo. In order to allow this, we need to be able to
guarantee that the roles are not granting permissions that users would
normally not have (but which Argo would have). We can use k8s tooling to
ensure that permissions are not exceeding some reference roles.
Co-Authored-By: Claude <[email protected]>
Signed-off-by: arewm <[email protected]>
rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
Copy file name to clipboardExpand all lines: Containerfile
+14-1Lines changed: 14 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,24 @@
1
1
FROM quay.io/konflux-ci/yq@sha256:15d0238843d954ee78c9c190705eb8b36f6e52c31434183c37d99a80841a635a as yq
2
2
FROM registry.redhat.io/openshift4/ose-cli-artifacts-rhel9:v4.17.0-202504091537.p0.g0000b3e.assembly.stream.el9 as oc
3
3
4
+
# Build stage for RBAC validator
5
+
FROM registry.access.redhat.com/ubi9/go-toolset:1.24.4-1754467841@sha256:3f552f246b4bd5bdfb4da0812085d381d00d3625769baecaed58c2667d344e5c as go-builder
6
+
7
+
# Copy tools directory and build the binary
8
+
COPY --chown=default tools/ /workspace/tools/
9
+
WORKDIR /workspace/tools
10
+
RUN go mod download && \
11
+
go build -o rbac-validator rbac-validator.go
12
+
13
+
# Main stage
4
14
FROM registry.access.redhat.com/ubi9/ubi:latest@sha256:8851294389a8641bd6efcd60f615c69e54fb0e2216ec8259448b35e3d9a11b06
Copy file name to clipboardExpand all lines: README.md
+98-2Lines changed: 98 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,106 @@
1
1
# konflux-release-data-ci
2
-
Config for building CI worker image for konflux-release-data repo
2
+
3
+
Config for building CI worker image for konflux-release-data repo, including RBAC validation tools.
4
+
5
+
## Overview
6
+
7
+
This repository provides:
8
+
- CI worker image configuration for the konflux-release-data repository
9
+
- RBAC validation tools using Kubernetes' official validation library
10
+
- Development tooling for RBAC policy verification
11
+
12
+
## RBAC Validator Tool
13
+
14
+
The `tools/` directory contains a Go-based RBAC validator that uses Kubernetes' official validation logic to verify RBAC policy subsets.
15
+
16
+
### Purpose
17
+
18
+
The RBAC validator ensures that user-defined roles and permissions are proper subsets of reference roles, preventing privilege escalation in Konflux tenants. It validates that:
19
+
20
+
- User roles don't exceed the permissions granted by reference roles
21
+
- APIGroups, Resources, Verbs, and ResourceNames are properly constrained
22
+
- Multi-rule policies are comprehensively validated
23
+
24
+
### Components
25
+
26
+
#### `tools/rbac-validator.go`
27
+
Main Go binary that:
28
+
- Accepts JSON input with user rules and reference rules
29
+
- Uses `k8s.io/component-helpers/auth/rbac/validation.Covers()` for authoritative validation
30
+
- Returns JSON output indicating whether user rules are covered by reference rules
31
+
- Handles errors gracefully with structured error responses
32
+
33
+
#### `tools/rbac-validator_test.go`
34
+
Comprehensive test suite with:
35
+
-**Edge case validation**: APIGroups overlap, subresources, resourceNames constraints
36
+
-**Real-world Konflux scenarios**: contributor vs admin roles, release pipeline permissions
37
+
-**Binary integration tests**: End-to-end validation of JSON input/output
38
+
-**Error handling tests**: Invalid JSON and malformed input validation
39
+
40
+
#### `tools/Makefile`
41
+
Development workflow automation:
42
+
```bash
43
+
make build # Build the binary
44
+
make test# Run all tests
45
+
make fmt # Format Go code
46
+
make lint # Run golangci-lint
47
+
make check-fmt # Verify code formatting
48
+
make ci # Run full CI pipeline (format check, lint, test, build)
49
+
```
50
+
51
+
#### `tools/.golangci.yml`
52
+
Linting configuration with security and code quality checks.
53
+
54
+
### Integration
55
+
56
+
The validator is integrated into the CI container and used by tenant validation scripts:
57
+
58
+
1.**CI Container**: Binary is pre-built during container image creation
59
+
2.**Smart Discovery**: Python scripts automatically find the binary via:
60
+
- PATH lookup for CI environments
61
+
- Local repository build for development
62
+
- On-demand compilation as fallback
63
+
3.**Tenant Validation**: Used by `tenants-config/tests/` for validating production and staging tenant roles
64
+
65
+
### Development Workflow
66
+
67
+
#### Local Development
68
+
```bash
69
+
cd tools/
70
+
make install-tools # Install golangci-lint
71
+
make ci # Run full validation pipeline
72
+
```
73
+
74
+
#### Adding Test Cases
75
+
Test cases should cover:
76
+
- Real Konflux role scenarios from infra-deployments
0 commit comments