mirror of
https://github.com/projectdiscovery/nuclei-templates.git
synced 2026-01-31 15:53:33 +08:00
47 lines
1.7 KiB
YAML
47 lines
1.7 KiB
YAML
id: k8s-memory-limits-not-set
|
|
|
|
info:
|
|
name: Memory limits not set in Deployments
|
|
author: princechaddha
|
|
severity: medium
|
|
description: Checks for missing memory limits in Kubernetes Deployments, which can lead to resource contention and instability
|
|
impact: |
|
|
Missing memory limits in Kubernetes Deployments can cause resource contention and potential application instability.
|
|
remediation: Set memory limits for all containers in Kubernetes Deployments to ensure resource management and application stability
|
|
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.limits && container.resources.limits.memory)) {
|
|
let result = (`Deployment '${deployment.metadata.name}' in namespace '${deployment.metadata.namespace}' lacks memory limits.`);
|
|
Export(result);
|
|
}
|
|
|
|
extractors:
|
|
- type: dsl
|
|
dsl:
|
|
- response
|
|
# digest: 4a0a0047304502203a66813cc15b12b1260c6862926c6748694a84bc66c9ca24dff7052f998b5aaf022100ef69cce9aba0cb47d58dd0bc916ee54f02a32632a4749e98e7a22e3b92da0e8d:366f2a24c8eb519f6968bd8801c08ebe |