-
-
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: Add terraform_checkov
, that run per folder. Deprecate checkov
hook
#290
feat: Add terraform_checkov
, that run per folder. Deprecate checkov
hook
#290
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.
checkov
used in 176 OSS projects.
So we can't merge this PR as is before 2.0.0
version.
I suggest adding a new Checkov hook, like checkov_2
, and marking checkov
as deprecated with the note "Will be removed in 2.0.0. Please, use checkov_2
" (and in 2.0.0 rename checkov_2
to checkov
)
@antonbabenko what do you think?
Can we achieve backward compatibility with both checkov versions 1 and 2? From what I see, it is possible. It is rather a bad idea to ask people to update anything unless it is absolutely necessary when we bump to version 2 of this repo. |
@MaxymVlasov Do I get it right that the backward incompatible thing with the new hook would be the UPD: especially having that people should know that major version is something to pay a very close attention to. |
On my test infra repo: took 14s repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.60.0
hooks:
- id: checkov took 4m 20s repos:
- repo: [email protected]:bmbferreira/pre-commit-terraform.git
rev: 9885aaf # latest commit in this PR
hooks:
- id: checkov Something wrong with the hook implementation in this PR. It shouldn't take so much time. |
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.
Performance issue detected.
To fix it, you need to find an error in logic. It is based on how the checkov
works
Great finding mate. This means we can introduce such a backward incompatible change and even create issues in those projects to let the folks know they need to update their configs, right? |
GH doesn't count private repos, which means that it only helps to understand ~% repos that use 16/176 ~= 9% repos will be affected. And no, we shouldn't go to folks and open issues about any changes. |
Test results5 runs '
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 6307376 kB
MemAvailable: 8895252 kB
Buffers: 356464 kB
Cached: 2229868 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.007
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: 5 runs '
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 6285132 kB
MemAvailable: 8874268 kB
Buffers: 357716 kB
Cached: 2229876 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.007
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: 5 runs '
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 6318444 kB
MemAvailable: 8910328 kB
Buffers: 358448 kB
Cached: 2229980 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.007
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: 5 runs '
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 6270784 kB
MemAvailable: 8862552 kB
Buffers: 359112 kB
Cached: 2229980 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.007
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: 5 runs '
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 6116244 kB
MemAvailable: 8744184 kB
Buffers: 366044 kB
Cached: 2257108 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.007
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: 5 runs '
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 6027688 kB
MemAvailable: 8657460 kB
Buffers: 367748 kB
Cached: 2257132 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.007
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: |
checkov
to run per folder
This PR has been automatically marked as stale because it has been open 30 days |
fa75ebc
to
c83c55a
Compare
performance issue for Tests results:5 runs 'v1.63.0 `pre-commit run`'
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 4908188 kB
MemAvailable: 8161860 kB
Buffers: 300264 kB
Cached: 2923732 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.008
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: 2 runs 'v1.63.0
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 4906488 kB
MemAvailable: 8160928 kB
Buffers: 300568 kB
Cached: 2923872 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.008
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: 5 runs '290
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 4879912 kB
MemAvailable: 8134636 kB
Buffers: 301016 kB
Cached: 2924104 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.008
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: 2 runs '290
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 4908756 kB
MemAvailable: 8163916 kB
Buffers: 301620 kB
Cached: 2924188 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.008
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: 2 runs '290
Run details
Memory info ( MemTotal: 12765352 kB
MemFree: 4798432 kB
MemAvailable: 8062356 kB
Buffers: 308048 kB
Cached: 2925804 kB
SwapCached: 0 kB CPU info: Real procs: 6
Virtual (hyper-threading) procs: 12
processor : 11
vendor_id : GenuineIntel
cpu family : 6
model : 165
model name : Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
stepping : 2
microcode : 0xffffffff
cpu MHz : 2712.008
cache size : 12288 KB
physical id : 0
siblings : 12
core id : 5
cpu cores : 6
apicid : 11
initial apicid : 11
fpu : yes
fpu_exception : yes
cpuid level : 21
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips : 5424.01
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management: |
@MaxymVlasov Looks like this is ready to be merged, isn't it? I can test if there is more testing needed. Thanks! |
b82d5a7
to
044baac
Compare
checkov
to run per folderterraform_checkov
, that run per folder. Deprecate checkov
hook
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.
Let's keep the existing hook but customize its behavior to support both recursive and non-recursive runs (or what else this PR adds).
It is pretty bad to have two hooks doing very similar things.
No way. @antonbabenko
So the old one will be removed in 2.0.0
This PR makes the hook customizable as all other hooks, which allows us to introduce custom settings for hook etc., and support it at all. |
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.
We need to make it a bit clear that checkov
hook is deprecated in favor of terraform_checkov
hook.
Update name
in .pre-commit-hooks.yaml
(line 96) with (deprecated, use "terraform_checkov")
.
@antonbabenko merge, please |
# [1.67.0](v1.66.0...v1.67.0) (2022-04-15) ### Features * Added `terraform_checkov` (run per folder), deprecated `checkov` hook ([#290](#290)) ([e3a9834](e3a9834))
This PR is included in version 1.67.0 🎉 |
Thank you very much @MaxymVlasov ! |
Put an
x
into the box if that apply:Description of your changes
This change applies the same logic to
checkov
that is already being used for other tools, such astflint
. If we have a monorepo with multiple modules such asmodule1
andmodule2
and we run for examplepre-commit run --files module1/istio/*
, it would runcheckov
for all the modules buttflint
would just run formodule1
, which is inconsistent with the argument that was passed topre-commit
.How has this code been tested
In a monorepo with multiple modules, before if you ran
pre-commit run --files module1/istio/*
,checkov
would execute for all the modules because of the-d .
while other tools such astflint
would just execute for the paths passed as argument topre-commit
. With this change,checkov
will start having the same behaviour as other tools, improving the consistency between the different tools.