File tree Expand file tree Collapse file tree 4 files changed +73
-7
lines changed
components/repository-validator Expand file tree Collapse file tree 4 files changed +73
-7
lines changed Original file line number Diff line number Diff line change 1+ apiVersion : kustomize.config.k8s.io/v1beta1
2+ kind : Kustomization
3+ resources :
4+ - validating-admission-policy.yaml
5+ - validating-admission-policy-binding.yaml
Original file line number Diff line number Diff line change 1+ apiVersion : admissionregistration.k8s.io/v1
2+ kind : ValidatingAdmissionPolicyBinding
3+ metadata :
4+ name : repository-url-validator-binding
5+ spec :
6+ policyName : repository-url-validator
7+ validationActions : [Deny, Audit]
8+ paramRef :
9+ namespace : repository-validator
10+ parameterNotFoundAction : Deny
11+ selector :
12+ matchLabels :
13+ app.kubernetes.io/name : repository-validator
14+ # Apply to all namespaces except system namespaces
15+ matchResources :
16+ namespaceSelector :
17+ matchExpressions :
18+ - key : kubernetes.io/metadata.name
19+ operator : NotIn
20+ values :
21+ - kube-system
22+ - kube-public
23+ - kube-node-lease
24+ - repository-validator
Original file line number Diff line number Diff line change 1+ apiVersion : admissionregistration.k8s.io/v1
2+ kind : ValidatingAdmissionPolicy
3+ metadata :
4+ name : repository-url-validator
5+ spec :
6+ failurePolicy : Fail
7+ paramKind :
8+ apiVersion : v1
9+ kind : ConfigMap
10+ matchConstraints :
11+ resourceRules :
12+ - apiGroups : ["pipelinesascode.tekton.dev"]
13+ apiVersions : ["v1alpha1"]
14+ operations : ["CREATE", "UPDATE"]
15+ resources : ["repositories"]
16+ variables :
17+ # Parse the JSON config from the ConfigMap
18+ - name : allowedPrefixes
19+ expression : |
20+ has(params.data) && has(params.data['config.json']) ?
21+ json.decode(params.data['config.json']) : []
22+ # Check if any prefix is empty (allow-all case)
23+ - name : allowAll
24+ expression : |
25+ size(variables.allowedPrefixes) == 1 &&
26+ variables.allowedPrefixes[0] == ""
27+ validations :
28+ - expression : |
29+ variables.allowAll ||
30+ variables.allowedPrefixes.exists(prefix,
31+ prefix != "" && object.spec.url.startsWith(prefix)
32+ )
33+ messageExpression: |
34+ 'Repository URL "' + object.spec.url +
35+ '" is not allowed on this cluster. Contact support.'
36+ reason: Forbidden
37+ auditAnnotations :
38+ - key : " repository-url-validation"
39+ valueExpression : |
40+ 'Repository URL: ' + object.spec.url +
41+ ', Allowed prefixes: ' + string(variables.allowedPrefixes)
Original file line number Diff line number Diff line change 11apiVersion : kustomize.config.k8s.io/v1beta1
22kind : Kustomization
33resources :
4- - https://github.com/konflux-ci/repository-validator/config/ocp?ref=1a1bd5856c7caf40ebf3d9a24fce209ba8a74bd9
5- - https://github.com/redhat-appstudio/internal-infra-deployments/components/repository-validator/staging?ref=da151a856b711f28e49a42658d6c17fec5d228dd
6- images :
7- - name : controller
8- newName : quay.io/redhat-user-workloads/konflux-infra-tenant/repository-validator/repository-validator
9- newTag : 1a1bd5856c7caf40ebf3d9a24fce209ba8a74bd9
10- namespace : repository-validator
4+ - https://github.com/redhat-appstudio/internal-infra-deployments/components/repository-validator/staging?ref=ae250b8d6062d019ee9e539c655eab91745b4fb0
5+ - ../base
6+
You can’t perform that action at this time.
0 commit comments