Recently been trying my hand at fixing some issues on checkov. As I've been trying
to pick up some of the more complicated issues, I've found the need to run checkov in order to debug it. Being a relative
noob with python and VS Codde, I thought it might be useful to note how I got this working.
Follow the Contributing steps to get your environment set
up. The main program that runs checkov is checkov/main.py - funny that.
So steps to run it are:
- In VS Code open
main.py - Select `Run -> Add Configuration
- Select
Pythonfrom the dropdown - Select
Python File - This will open a
launch.jsonlooking like
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]
}- Add the following entries to the files
"env": { "PYTHONPATH": "${workspaceRoot}"},
"args": [ "-d", "<directory>", "--framework", "terraform"]The env solves the issue with Module not found
The args are, well, the args you'd normally pass on the command line
7. Give your launch profile a more useful name
"name": "Checkov Debug"
- Set the
main.pyas the program to launch
"program": "${workspaceRoot}/checkov/main.py"
- You can now start
checkov, by going to theRun and Debugview ->Ctrl + Shift + D F5to start debugging or press the green play button to the left of theCheckov Debugat the top left of the view
Final launch.json should look like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Checkov Debug",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/checkov/main.py",
"console": "integratedTerminal",
"justMyCode": true,
"env": { "PYTHONPATH": "${workspaceRoot}"},
"args": [ "-d", "<directory>", "--framework", "terraform"]
}
]
}