bridgecrewio / checkov

Prevent cloud misconfigurations and find vulnerabilities during build-time in infrastructure as code, container images and open source packages with Checkov by Bridgecrew.
https://www.checkov.io/
Apache License 2.0
7.16k stars 1.12k forks source link

feat(general): Update range includes to handle range values #6867

Open tsmithv11 opened 3 days ago

tsmithv11 commented 3 days ago

User description

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

[//]: # "

PR Title

We use the title to create changelog automatically and therefore only allow specific prefixes
- break:    to indicate a breaking change, this supersedes any of the other types
- feat:     to indicate new features or checks
- fix:      to indicate a bugfix or handling of edge cases of existing checks
- docs:     to indicate an update to our documentation
- chore:    to indicate adjustments to workflow files or dependency updates
- platform: to indicate a change needed for the platform
Each prefix should be accompanied by a scope that specifies the targeted framework. If uncertain, use 'general'.
#    
Allowed prefixs:
ansible|argo|arm|azure|bicep|bitbucket|circleci|cloudformation|dockerfile|github|gha|gitlab|helm|kubernetes|kustomize|openapi|sast|sca|secrets|serverless|terraform|general|graph|terraform_plan|terraform_json
#
ex.
feat(terraform): add CKV_AWS_123 to ensure that VPC Endpoint Service is configured for Manual Acceptance

"

Description

range_includes can handle ranges in the value like [4,10-20]

Checklist:


Generated description

Below is a concise technical summary of the changes proposed in this PR:

Enhance the RangeIncludesAttributeSolver class to support range values in the value parameter, allowing for more flexible attribute checks. This update processes range strings (e.g., "10-20") by converting them into a list of integers, thus enabling the solver to handle both single values and ranges effectively. Additionally, new test cases have been added to validate this functionality, ensuring that both range_includes and range_not_includes operations work correctly with the updated logic.

<table><tr><th>Topic</th><th>Details</th><tr><td><a href=https://baz.co/changes/bridgecrewio/checkov/6867?tool=ast&topic=Testing+Enhancements>Testing Enhancements</a>
    </td><td>Add test cases to validate the new range handling logic in <code>RangeIncludesAttributeSolver</code>, ensuring both <code>range_includes</code> and <code>range_not_includes</code> operations work correctly.<details><summary>Modified files (6)</summary><ul><li>tests/terraform/graph/checks_infra/attribute_solvers/range_not_includes_solver/test_solver.py</li>
  • tests/terraform/graph/checks_infra/attribute_solvers/range_includes_solver/test_solver.py
  • tests/terraform/graph/checks_infra/attribute_solvers/range_includes_solver/JsonPathRangeIncludesListWRange.yaml
  • tests/terraform/graph/checks_infra/attribute_solvers/range_not_includes_solver/RangeNotIncludesListWRange.yaml
  • tests/terraform/graph/checks_infra/attribute_solvers/range_includes_solver/RangeIncludesListWRange.yaml
  • tests/terraform/graph/checks_infra/attribute_solvers/range_not_includes_solver/JsonPathRangeNotIncludesListWRange.yaml
  • Latest Contributors(2)
    UserCommitDate
    tsmithv11feat-general-Update-ra...April 22, 2024
    lirshindalmanfeat-general-Add-image...September 28, 2023
    Range Handling Enhance the RangeIncludesAttributeSolver to support range values in the value parameter, allowing for more flexible attribute checks.
    Modified files (1)
    • checkov/common/checks_infra/solvers/attribute_solvers/range_includes_attribute_solver.py
    Latest Contributors(2)
    UserCommitDate
    tsmithv11feat-general-Update-ra...April 22, 2024
    tronxd@users.noreply.g...feat-general-igraph-li...January 25, 2023
    This pull request is reviewed by Baz. Join @tsmithv11 and the rest of your team on (Baz).