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

feat(terraform): include pods of kubernetes_deployment in kubernetes_pod checks (1/4) #3691

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

ugrave
Copy link
Contributor

@ugrave ugrave commented Oct 18, 2022

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

Description

This PR includes pods defined via kubernetes_deployment in pod checks . PR 1 of 4.

Fixes #3690

New/Edited policies (Delete if not relevant)

  • CKV_K8S_20
    Add resource: kubernetes_deployment, kubernetes_deployment_v1
  • CKV_K8S_25
    Add resource: kubernetes_deployment, kubernetes_deployment_v1
  • CKV_K8S_39
    Add resource: kubernetes_deployment, kubernetes_deployment_v1
  • CKV_K8S_11
    Add resource: kubernetes_deployment, kubernetes_deployment_v1
  • CKV_K8S_10
    Add resource: kubernetes_deployment, kubernetes_deployment_v1
  • CKV_K8S_30
    Add resource: kubernetes_deployment, kubernetes_deployment_v1

Checklist:

  • My code follows the style guidelines of this project
  • 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
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@ugrave ugrave force-pushed the deployment_pod_checks_1 branch 2 times, most recently from 1c62bcf to d233a08 Compare October 19, 2022 07:43
@ugrave ugrave changed the title feat(terraform) include pods of kubernetes_deployment in kubernetes_pod checks (1/2) feat(terraform) include pods of kubernetes_deployment in kubernetes_pod checks (1/4) Oct 19, 2022
@ugrave ugrave force-pushed the deployment_pod_checks_1 branch 2 times, most recently from 1a5d768 to cc144bf Compare October 20, 2022 06:03
@ugrave ugrave changed the title feat(terraform) include pods of kubernetes_deployment in kubernetes_pod checks (1/4) feat(terraform): include pods of kubernetes_deployment in kubernetes_pod checks (1/4) Oct 25, 2022
Copy link
Contributor

@gruebel gruebel left a comment

Choose a reason for hiding this comment

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

great work again. I have specific change suggestion, which you probably need to add to all the adjusted checks, also in the other PRs.

Copy link
Contributor

@gruebel gruebel left a comment

Choose a reason for hiding this comment

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

nice, thanks 🍹

evaluated_keys_path = "spec"

template = spec.get("template")
if template and isinstance(template, list):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if template and isinstance(template, list):
if template and isinstance(template, list) and len(template) == 1:

if template and isinstance(template, list):
template = template[0]
template_spec = template.get("spec")
if template_spec and isinstance(template_spec, list):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if template_spec and isinstance(template_spec, list):
if template_spec and isinstance(template_spec, list) and len(template_spec) == 1:

evaluated_keys_path = "spec"

template = spec.get("template")
if template and isinstance(template, list):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if template and isinstance(template, list):
if template and isinstance(template, list) and len(template) == 1:

if template and isinstance(template, list):
template = template[0]
template_spec = template.get("spec")
if template_spec and isinstance(template_spec, list):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if template_spec and isinstance(template_spec, list):
if template_spec and isinstance(template_spec, list) and len(template_spec) == 1:

evaluated_keys_path = "spec"

template = spec.get("template")
if template and isinstance(template, list):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if template and isinstance(template, list):
if template and isinstance(template, list) and len(template) == 1:

if template and isinstance(template, list):
template = template[0]
template_spec = template.get("spec")
if template_spec and isinstance(template_spec, list):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if template_spec and isinstance(template_spec, list):
if template_spec and isinstance(template_spec, list) and len(template_spec) == 1:

evaluated_keys_path = "spec"

template = spec.get("template")
if template and isinstance(template, list):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if template and isinstance(template, list):
if template and isinstance(template, list) and len(template) == 1:

if template and isinstance(template, list):
template = template[0]
template_spec = template.get("spec")
if template_spec and isinstance(template_spec, list):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if template_spec and isinstance(template_spec, list):
if template_spec and isinstance(template_spec, list) and and len(template_spec) == 1:

@gruebel gruebel merged commit 6eaaa5e into bridgecrewio:master Nov 7, 2022
This pull request was closed.
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.

Include Pods specefied via kubernetes_deployments in kubernetes_pod checks
3 participants