Skip to content

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

Closed
eyalatox wants to merge 2 commits intobridgecrewio:mainfrom
eyalatox:main
Closed

kubernetes fix: do not fail where metadata.name is missing#7055
eyalatox wants to merge 2 commits intobridgecrewio:mainfrom
eyalatox:main

Conversation

@eyalatox
Copy link
Copy Markdown

@eyalatox eyalatox commented Mar 17, 2025

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).

@tsmithv11
Copy link
Copy Markdown
Contributor

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

@AdamDev
Copy link
Copy Markdown
Contributor

AdamDev commented Aug 5, 2025

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

@maxamel
Copy link
Copy Markdown
Contributor

maxamel commented Oct 12, 2025

Closing due to inactivity

@maxamel maxamel closed this Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants