Have checkov be callable from Python
See original GitHub issueRight now
Currently if you want to call checkov from Python, I think I have to do subprocess.check_output
, which is hacky.
Right now in main.py, we call
which implicitly pulls args from sys.argv
The proposal
Change def main
to do something like:
def main(argv=sys.argv[1:]):
if len(sys.argv) == 1: # pragma: no cover
sys.argv.append('--help')
args = parse_args(argv)
would do the trick.
I’ve also written code like the following
def parse_args(argv)
...
return parser.parse_args(
argv or ['--help']
)
def main(argv=sys.argv[1:]):
args = parse_args(argv)
...
etc. See detect-secrets main.py as an example.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:14 (12 by maintainers)
Top Results From Across the Web
Developers - Have checkov be callable from Python - - Bountysource
Currently if you want to call checkov from Python, I think I have to do subprocess.check_output , which is hacky. Right now in...
Read more >Add baseline functionality #379 - bridgecrewio/checkov - GitHub
This makes it easy to implement 'from now on' security, and audit baselines asynchronously. It also easily allows seeing how loud the tool...
Read more >Create Custom Policy - Python - Attribute Check - checkov
Custom Policies created in code (in Python) support checking the state of a resource's attributes. A Python-based Custom Policy for Checkov consists of ......
Read more >Issues · bridgecrewio / checkov · GitLab
Feature request: Support checkov:skip in modules. Issue #777 · created 1 year ago by Matt Grouping: Provide more ... Have checkov be callable...
Read more >module has no attribute mypy
In Python Iterator[YieldType] over Checkov is a static code analysis tool ... Callable type; Callable[[int], str] is a function of (int) -> str....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Alrighty, can confirm this works now! 🥳 ⚡ 🍰
is a sample.
Thanks for playing everyone.
To add to the above, if anybody is running checkov more than once in a given python context, you’ll need to reload the
checkov.main
module before each run since it has some global state.e.g.