github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/kubernetes/policies/pss/baseline/1_host_pid.rego (about)

     1  # METADATA
     2  # title: "Access to host PID"
     3  # description: "Sharing the host’s PID namespace allows visibility on host processes, potentially leaking information such as environment variables and configuration."
     4  # scope: package
     5  # schemas:
     6  # - input: schema["kubernetes"]
     7  # related_resources:
     8  # - https://kubernetes.io/docs/concepts/security/pod-security-standards/#baseline
     9  # custom:
    10  #   id: KSV010
    11  #   avd_id: AVD-KSV-0010
    12  #   severity: HIGH
    13  #   short_code: no-host-pid
    14  #   recommended_action: "Do not set 'spec.template.spec.hostPID' to true."
    15  #   input:
    16  #     selector:
    17  #     - type: kubernetes
    18  package builtin.kubernetes.KSV010
    19  
    20  import data.lib.kubernetes
    21  
    22  default failHostPID = false
    23  
    24  # failHostPID is true if spec.hostPID is set to true (on all controllers)
    25  failHostPID {
    26  	kubernetes.host_pids[_] == true
    27  }
    28  
    29  deny[res] {
    30  	failHostPID
    31  	msg := kubernetes.format(sprintf("%s '%s' should not set 'spec.template.spec.hostPID' to true", [kubernetes.kind, kubernetes.name]))
    32  	res := result.new(msg, input.spec)
    33  }