Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kubernetes): ensure seccompProfile is set to RuntimeDefault for all containers in deployments and similar resources #6459

Merged
merged 8 commits into from
Jun 23, 2024

Conversation

rutiNalenger
Copy link
Contributor

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Description

This change addresses issue #5796 where Checkov was incorrectly throwing CKV_K8S_31 even when the seccomp RuntimeDefault profile was added under the container securityContext. The fix ensures that the check correctly validates seccompProfile settings for each container within a Pod and not just at the Deployment level. This involves updating the logic to account for the seccompProfile setting in the securityContext of individual containers. There are no additional dependencies required for this change.
Fixes # (issue)

Checkov scan was incorrectly throwing CKV_K8S_31 even when seccomp runtimedefault was added under container securityContext. The issue was due to the check not accounting for settings at the container level properly. This fix ensures that the check correctly validates seccompProfile settings for each container within a Pod and not just at the Deployment level.

Description

CKV_K8S_31 checks if seccomp profile type is set to RuntimeDefault for containers. The violation occurs when this is not set, leading to potential security risks.

Fix

Updated the check to ensure that the seccompProfile type is set to RuntimeDefault within the securityContext of each container in the spec of Deployments, StatefulSets, DaemonSets, Jobs, and ReplicaSets. This involves iterating through each container, validating the seccompProfile type, and ensuring all containers have the correct RuntimeDefault setting. The check will pass only if all containers meet this requirement.

Checklist:

  • [v] My code follows the style guidelines of this project
  • [v] I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • [v] I have added tests that prove my feature, policy, or fix is effective and works
  • [v] New and existing tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor

@ChanochShayner ChanochShayner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very Nice!
Please fix your failing job.

@tsmithv11 tsmithv11 merged commit fb6a613 into bridgecrewio:main Jun 23, 2024
37 of 38 checks passed
boring-repos bot pushed a commit to harryzcy/checkov that referenced this pull request Jun 24, 2024
…ll containers in deployments and similar resources (bridgecrewio#6459)

* Fixed issue bridgecrewio#5796

* Error Correction

* Error Correction

* Deleting unnecessary files

* removed unnecessary files

* Error Correction dogfood-tests

* Error Correction

---------

Co-authored-by: Taylor <28880387+tsmithv11@users.noreply.github.com>
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.

3 participants