Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use container as cause in KSV104 check #304

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,17 @@ container_seccomp_from_annotations(container) := profile {

# containers_with_unconfined_seccomp_profile_type returns all containers which have a seccomp
# profile set and is profile set to "Unconfined"
containers_with_unconfined_seccomp_profile_type[name] {
containers_with_unconfined_seccomp_profile_type[seccomp.container] {
seccomp := container_seccomp[_]
lower(seccomp.type) == "unconfined"
name := seccomp.container.name
}

# containers_with_unconfined_seccomp_profile_type returns all containers that do not have
# a seccomp profile type specified, since the default is unconfined
# https://kubernetes.io/docs/tutorials/security/seccomp/#enable-the-use-of-runtimedefault-as-the-default-seccomp-profile-for-all-workloads
containers_with_unconfined_seccomp_profile_type[name] {
containers_with_unconfined_seccomp_profile_type[seccomp.container] {
seccomp := container_seccomp[_]
seccomp.type == ""
name := seccomp.container.name
}

container_seccomp[{"container": container, "type": type}] {
Expand All @@ -78,7 +76,7 @@ container_seccomp[{"container": container, "type": type}] {
}

deny[res] {
cause := containers_with_unconfined_seccomp_profile_type[_]
msg := kubernetes.format(sprintf("container %q of %s %q in %q namespace should specify a seccomp profile", [cause, lower(kubernetes.kind), kubernetes.name, kubernetes.namespace]))
res := result.new(msg, cause)
container := containers_with_unconfined_seccomp_profile_type[_]
msg := kubernetes.format(sprintf("container %q of %s %q in %q namespace should specify a seccomp profile", [container.name, lower(kubernetes.kind), kubernetes.name, kubernetes.namespace]))
res := result.new(msg, container)
}
Loading