-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
policy to detect a service without selector (#931)
- Loading branch information
1 parent
29201a7
commit c299d50
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
pkg/policies/opa/rego/k8s/kubernetes_service/AC_K8S_0114.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "ensureServiceWithSelector", | ||
"file": "ensureServiceWithSelector.rego", | ||
"policy_type": "k8s", | ||
"resource_type": "kubernetes_service", | ||
"template_args": { | ||
"name": "ensureServiceWithSelector", | ||
"prefix": "", | ||
"suffix": "" | ||
}, | ||
"severity": "LOW", | ||
"description": "Ensure the use of selector is enforced for Kubernetes Ingress or LoadBalancer service", | ||
"reference_id": "AC_K8S_0114", | ||
"category": "Infrastructure Security", | ||
"version": 1, | ||
"id": "AC_K8S_0114" | ||
} |
8 changes: 8 additions & 0 deletions
8
pkg/policies/opa/rego/k8s/kubernetes_service/ensureServiceWithSelector.rego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package accurics | ||
|
||
{{.prefix}}{{.name}}{{.suffix}}[service.id] { | ||
service := input.kubernetes_service[_] | ||
service_config := service.config | ||
service_config.spec.type == ["LoadBalancer", "Ingress"][_] | ||
object.get(service_config, "selector", "undefined") == "undefined" | ||
} |