nuclei-templates/cloud/kubernetes/deployments/k8s-memory-requests-not-set...

47 lines
1.8 KiB
YAML

id: k8s-memory-requests-not-set
info:
name: Memory requests not set in Deployments
author: princechaddha
severity: medium
description: Checks for missing memory requests in Kubernetes Deployments, which can lead to inefficient scheduling and potential node resource exhaustion.
impact: |
Missing memory requests in Kubernetes Deployments can lead to inefficient pod scheduling, causing potential resource exhaustion on nodes.
remediation: Set memory requests for all containers in Kubernetes Deployments to ensure efficient pod scheduling and node resource utilization.
reference:
- https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/
tags: cloud,devops,kubernetes,k8s,devsecops,deployments,k8s-cluster-security
flow: |
code(1);
for (let deployment of template.items) {
set("deployment",deployment)
javascript(1);
}
self-contained: true
code:
- engine:
- sh
- bash
source: kubectl get deployments --all-namespaces --output=json
extractors:
- type: json
name: items
internal: true
json:
- '.items[]'
javascript:
- code: |
deployment = JSON.parse(template.deployment);
if (!deployment.spec.template.spec.containers.some(container => container.resources && container.resources.requests && container.resources.requests.memory)) {
let result = (`Deployment '${deployment.metadata.name}' in namespace '${deployment.metadata.namespace}' lacks memory requests.`);
Export(result);
}
extractors:
- type: dsl
dsl:
- response
# digest: 4b0a00483046022100ae7c1c49b3e8f2afdad758ffeaea087dd5d811cf1b8183d2e4ee53b0dabdc51f0221009e2889066edaae078f4fdf8a31f77e108530839cdab907fa37589501d461773c:922c64590222798bb761d5b6d8e72950