checkov icon indicating copy to clipboard operation
checkov copied to clipboard

kubernetes fix: do not fail where metadata.name is missing

Open eyalatox opened this issue 8 months ago • 1 comments

User description

Description

in cases the name field in not present in the metadata section an exception is thrown

Fixes # (issue)

fix case of uncaught exception, passing the policy instead

Checklist:

  • I have performed a self-review of my own code

Generated description

Below is a concise technical summary of the changes proposed in this PR: Modifies the DefaultNamespace check in the kubernetes_security_checks module to handle cases where the metadata.name field is missing. Improves the robustness of the security validation process for Kubernetes resources.

TopicDetails
Code refactoring Refactors how the 'name' field is accessed and used in conditional statements
Modified files (1)
  • checkov/kubernetes/checks/resource/k8s/DefaultNamespace.py
Latest Contributors(2)
UserCommitDate
gruebelchore-fix-flake8-issue...October 11, 2022
YaaraVernerRun-k8s-graph-from-run...December 05, 2021
Exception handling Adds a check for the existence of the 'name' field in metadata to prevent exceptions
Modified files (1)
  • checkov/kubernetes/checks/resource/k8s/DefaultNamespace.py
Latest Contributors(2)
UserCommitDate
gruebelchore-fix-flake8-issue...October 11, 2022
YaaraVernerRun-k8s-graph-from-run...December 05, 2021
This pull request is reviewed by Baz. Join @eyalatox and the rest of your team on (Baz).

eyalatox avatar Mar 17 '25 06:03 eyalatox

@eyalatox please add a test that would have previous to your fix thrown an error

tsmithv11 avatar Apr 04 '25 16:04 tsmithv11

Hi @eyalatox, Could you please merge the latest changes from main into this branch?

AdamDev avatar Aug 05 '25 12:08 AdamDev

Closing due to inactivity

maxamel avatar Oct 12 '25 17:10 maxamel