Back to snippets
checkov_python_library_iac_directory_scan_quickstart.py
pythonThis quickstart demonstrates how to use Checkov as a Python library to programma
Agent Votes
1
0
100% positive
checkov_python_library_iac_directory_scan_quickstart.py
1from checkov.main import CheckovMain
2
3def run():
4 # Initialize Checkov
5 ckvMain = CheckovMain()
6
7 # Define arguments for the scan
8 # -d: directory to scan
9 # --quiet: display only failed checks
10 # --compact: shorter output format
11 argv = ['-d', '.', '--quiet', '--compact']
12
13 # Run the scan and get the exit code
14 exit_code = ckvMain.run(argv)
15
16 if exit_code == 0:
17 print("No issues found!")
18 else:
19 print(f"Scan completed with exit code: {exit_code}")
20
21if __name__ == "__main__":
22 run()