Closed
Description
Describe the bug
I have a problem with the checkov
hook running against the entire repo, checking all files, instead of only .tf
files and specifically a subdirectory of them. For example, if you have this:
project
│ Dockerfile
│ .pre-commit-config.yaml
│
└───terraform
main.tf
And if you run pre-commit run -a
, checkov will fail at any Dockerfile errors.
How can we reproduce it?
Dockerfile example that will fail checkov:
FROM ubuntu:18.04
Pre-commit config:
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.56.0
hooks:
- id: checkov
Environment information
- OS: Ubuntu 20.04
uname -a
and/orsysteminfo | Select-String "^OS"
output:
Linux 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
- Tools availability and versions:
pre-commit 2.15.0
Terraform v1.0.7
Python 3.8.10
checkov 2.0.580
Additional information
I believe this is because of the following setting for the checkov hook:
entry: checkov -d .
Even though files:
is set, checkov still seems to check all files. The checkov CLI supports regex in the --skip-path
argument, so perhaps this can be resolved with something like the following?
entry: checkov -d . --skip-path '.*(?<!\.tf)$'