-
-
Notifications
You must be signed in to change notification settings - Fork 541
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
feat: Make checkov more flexible #329
feat: Make checkov more flexible #329
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks sensible to me, though I'll leave design appropriateness consideration and decision to @MaxymVlasov and @antonbabenko
declare -a -g FILES=() | ||
|
||
argv=("$@") | ||
pattern='^.*\.tf$' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The any_chars_from_beginning part of pattern makes no much sense and can be dropped
pattern='^.*\.tf$' | |
pattern='\.tf$' |
#290 + compatibility in args parsing by replacing/changing
Looks like you mean this code: pre-commit-terraform/hooks/_common.sh Lines 65 to 72 in 321fb16
This is a string with array:
That then passed as a string with array pre-commit-terraform/hooks/_common.sh Line 96 in 321fb16
and then - expanded to an array
So this argument is not vaild. |
This PR has been automatically marked as stale because it has been open 30 days |
This PR was automatically closed because of stale in 10 days |
Put an
x
into the box if that apply:Description of your changes
Currently, the checkov hook is hard-coded to run against the entire directory - no override is possible.
This change allows the hook to run in any of three modes - whole directory (the default), against all directories which contain a changed file, and against only changed files.
It should be noted that:
common::parse_cmdline
function would've forced the introduction of a breaking change (having to preface all arguments with--args
) and 2. Using thecommon::per_dir_hook
function would have removed the ability to pass multiple arguments to checkov, as the code block at line 70 assumes that only $1 is an argument and the rest are files.How can we test changes
pre-commit try-repo $path/to/clone
to confirm the default behaviour is still scanning the entire repositorycheckov.sh
from within that dummy directory to confirm that when passed--scan-change-directories
(and file names), the tool only scans directories that contain a change file, and while passed--scan-change-files
, the tool only scans files, as well as any other changes and logic deemed necessary.