github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/kubernetes/policies/cisbenchmarks/controllermamager/controller_manager_conf_permission.rego (about)

     1  # METADATA
     2  # title: "Ensure that the controller-manager config file permissions are set to 600 or more restrictive"
     3  # description: "Ensure that the controller-manager config file has permissions of 600 or more restrictive."
     4  # scope: package
     5  # schemas:
     6  # - input: schema["kubernetes"]
     7  # related_resources:
     8  # - https://www.cisecurity.org/benchmark/kubernetes
     9  # custom:
    10  #   id: KCV0064
    11  #   avd_id: AVD-KCV-0064
    12  #   severity: HIGH
    13  #   short_code: ensure-controller-manager-config-file-permissions-set-600-or-more-restrictive
    14  #   recommended_action: "Change the controller manager config file /etc/kubernetes/controller-manager.conf permissions of 600 or more restrictive "
    15  #   input:
    16  #     selector:
    17  #     - type: kubernetes
    18  package builtin.kubernetes.KCV0064
    19  
    20  import data.lib.kubernetes
    21  
    22  validate_conf_permission(sp) := {"controllerManagerConfFilePermissions": violation} {
    23  	sp.kind == "NodeInfo"
    24  	sp.type == "master"
    25  	violation := {permission | permission = sp.info.controllerManagerConfFilePermissions.values[_]; permission > 600}
    26  	count(violation) > 0
    27  }
    28  
    29  deny[res] {
    30  	output := validate_conf_permission(input)
    31  	msg := "Ensure that the controller-manager config file permissions is set to 600 or more restrictive"
    32  	res := result.new(msg, output)
    33  }