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

platform(general): rationalize policy metadata error handling behavior #3795

Merged
merged 2 commits into from
Nov 7, 2022

Conversation

mikeurbanski1
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 causes checkov to fail if the user uses a platform API key, but the connection itself fails (e.g. SSL or auth error), and they don't use --include-all-checkov-checks.

Today, the behavior is that the policy metadata download will fail with an error, but then the run will proceed. However, Checkov thinks all the policies are local policies, and does not run any of them (by design when using an API key). The result is blank output (minus the connection error message in the logs). This causes issues primarily in the IDEs, where there is no error message popup from the failed run, so it just looks like nothing happened.

This change will cause the run to actually fail if no policies are going to get evaluated.

It also handles some general conflicting logic with the use of --skip-download, which causes similar behavior (but without an error).

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 (I tested all the cases locally)
  • New and existing tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@gruebel gruebel changed the title rationalize policy metadata error handling behavior fix(platform): rationalize policy metadata error handling behavior Nov 7, 2022
@gruebel gruebel changed the title fix(platform): rationalize policy metadata error handling behavior platform(general): rationalize policy metadata error handling behavior Nov 7, 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.

looks good 🥇

checkov/main.py Outdated Show resolved Hide resolved
@gruebel gruebel merged commit d206212 into master Nov 7, 2022
@gruebel gruebel deleted the fix-failed-policy-metadata-flow branch November 7, 2022 13:41
pull bot pushed a commit to Mu-L/checkov that referenced this pull request Nov 7, 2022
bridgecrewio#3795)

* rationalize policy metadata error handling behavior

* remove unused variable

Co-authored-by: Anton Grübel <[email protected]>
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