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

     1  # METADATA
     2  # title: "If the kubelet config.yaml configuration file is being used validate permissions set to 600 or more restrictive"
     3  # description: "Ensure that if the kubelet refers to a configuration file with the --config argument, that 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: KCV0077
    11  #   avd_id: AVD-KCV-0077
    12  #   severity: HIGH
    13  #   short_code: ensure-kubelet-config.yaml--permissions-600-or-more-restrictive.
    14  #   recommended_action: "Change the kubelet config yaml permissions to 600 or more restrictive if exist"
    15  #   input:
    16  #     selector:
    17  #     - type: kubernetes
    18  package builtin.kubernetes.KCV0077
    19  
    20  import data.lib.kubernetes
    21  
    22  types := ["master", "worker"]
    23  
    24  validate_kubelet_config_yaml_permission(sp) := {"kubeletConfigYamlConfigurationFilePermission": violation} {
    25  	sp.kind == "NodeInfo"
    26  	sp.type == types[_]
    27  	count(sp.info.kubeletConfigYamlConfigurationFilePermission) > 0
    28  	violation := {permission | permission = sp.info.kubeletConfigYamlConfigurationFilePermission.values[_]; permission > 600}
    29  	count(violation) > 0
    30  }
    31  
    32  deny[res] {
    33  	output := validate_kubelet_config_yaml_permission(input)
    34  	msg := "Ensure that if the kubelet refers to a configuration file with the --config argument, that file has permissions of 600 or more restrictive."
    35  	res := result.new(msg, output)
    36  }