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

🎉 Have checkov be callable from Python #774

Merged

Conversation

KevinHock
Copy link
Contributor

Solves #530

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

checkov/main.py Outdated
parser = argparse.ArgumentParser(description='Infrastructure as code static analysis')
add_parser_args(parser)
args = parser.parse_args()
args = parser.parse_args(argv or ['--help'])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we want the or ['--help'] I normally find it useful, but up to you

cc @schosterbarak

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, Haven't worked that way in the past.
@KevinHock Can you elaborate on what it means?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change this back to what it was

It turns out calling checkov with no args gives the following, which we wouldn't want to override with --help:

% checkov       

       _               _              
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V / 
  \___|_| |_|\___|\___|_|\_\___/ \_/  
                                      
By bridgecrew.io | version: 1.0.695 
Visualize and collaborate on security issues with Bridgecrew! 
Bridgecrew's dashboard allows automation of future checks, Pull Request scanning and auto-comments, automatic remidiation PR's and more! 
 Plus it's free for 100 cloud resources and a great way to visualize and collaborate on Checkov results. For more information on dashboard integration, see: http://bridge.dev/checkov-dashboard 
 
 To instantly see future Checkov scans in the platform, Press y! 

Visualize results? (y/n): y

Email Address? 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pip install -e .d the version I have now and got the following, which we could override with --help automatically if we wanted to:

% checkov


       _               _              
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V / 
  \___|_| |_|\___|\___|_|\_\___/ \_/  
                                      
By bridgecrew.io | version: 1.0.693 
Update available 1.0.693 → 1.0.695
Run pip3 install -U checkov to update 

No argument given. Try ` --help` for further information

Copy link
Contributor

Choose a reason for hiding this comment

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

@KevinHock we should keep the current behaviour of when no args are given (prompt to integrate into bridgecrew platform).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I've removed, sgtm, thanks!

@KevinHock
Copy link
Contributor Author

removed the --help

Copy link
Contributor

@metahertz metahertz left a comment

Choose a reason for hiding this comment

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

Tested in local environments, looks good to me keeping zero default args, thanks @KevinHock 👍

@schosterbarak schosterbarak merged commit 6e88fde into bridgecrewio:master Jan 13, 2021
@schosterbarak
Copy link
Contributor

Thank you @KevinHock @metahertz

github-actions bot pushed a commit that referenced this pull request Jan 13, 2021
github-actions bot pushed a commit that referenced this pull request Jan 13, 2021
schosterbarak pushed a commit that referenced this pull request Feb 10, 2021
* Functioning --quiet for -o json. Needs tests,
looking at #774 for callable unit test and passing in cli params

* added integration test for -o json --quiet
github-actions bot pushed a commit that referenced this pull request Feb 10, 2021
* Functioning --quiet for -o json. Needs tests,
looking at #774 for callable unit test and passing in cli params

* added integration test for -o json --quiet
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