-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(conftest): associate Rego policies with K8s resources (#752)
Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
- Loading branch information
1 parent
fa00227
commit 7ef9060
Showing
14 changed files
with
412 additions
and
231 deletions.
There are no files selected for viewing
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
38 changes: 19 additions & 19 deletions
38
itest/starboard-operator/configauditreport/conftest/testdata/run_as_root.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 |
---|---|---|
@@ -1,31 +1,31 @@ | ||
package main | ||
package kubernetes.configaudit.run_as_root | ||
|
||
deny[res] { | ||
input.kind == "ReplicaSet" | ||
not input.spec.template.spec.securityContext.runAsNonRoot | ||
input.kind == "ReplicaSet" | ||
not input.spec.template.spec.securityContext.runAsNonRoot | ||
|
||
res := { | ||
"msg": "Containers must not run as root", | ||
"title": "Run as root" | ||
} | ||
res := { | ||
"msg": "Containers must not run as root", | ||
"title": "Run as root", | ||
} | ||
} | ||
|
||
deny[res] { | ||
input.kind == "Pod" | ||
not input.spec.securityContext.runAsNonRoot | ||
input.kind == "Pod" | ||
not input.spec.securityContext.runAsNonRoot | ||
|
||
res := { | ||
"msg": "Containers must not run as root", | ||
"title": "Run as root" | ||
} | ||
res := { | ||
"msg": "Containers must not run as root", | ||
"title": "Run as root", | ||
} | ||
} | ||
|
||
deny[res] { | ||
input.kind == "CronJob" | ||
not input.spec.jobTemplate.spec.template.spec.securityContext.runAsNonRoot | ||
input.kind == "CronJob" | ||
not input.spec.jobTemplate.spec.template.spec.securityContext.runAsNonRoot | ||
|
||
res := { | ||
"msg": "Containers must not run as root", | ||
"title": "Run as root" | ||
} | ||
res := { | ||
"msg": "Containers must not run as root", | ||
"title": "Run as root", | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
itest/starboard-operator/configauditreport/conftest/testdata/service_with_external_ip.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,10 @@ | ||
package kubernetes.configaudit.service_with_external_ip | ||
|
||
deny[res] { | ||
input.kind == "Service" | ||
count(input.spec.externalIPs) > 0 | ||
res := { | ||
"msg": "Service with external IP", | ||
"title": "Service with external IP", | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.