pre-commit-terraform icon indicating copy to clipboard operation
pre-commit-terraform copied to clipboard

Failure of terrascan hook to use config file

Open snemetz opened this issue 2 years ago β€’ 1 comments

Describe the bug

Need to have terrascan use a config file.

Tried to use

  • id: terrascan args:
    • --args="-c .terrascan.toml"

Got error

2023-02-08T19:52:39.243-0800 error config/config-reader.go:62 config file: .terrascan.toml, doesn't exist 2023-02-08T19:52:39.244-0800 error cli/register.go:71 error while loading global config{error 26 0 config file not present}

Also, tried adding GIT_WORKING_DIR/ but that doesn't seem to be supported in this hook. Would be good if GIT_WORKING_DIR was supported in all hooks

No idea what directory terrascan is run from. But it is not the top of the git repo.

How can we reproduce it?

Create .terrascan.toml in the root of the git repo Add below to .pre-commit-config.yaml

repos:

  • repo: https://github.com/antonbabenko/pre-commit-terraform rev: v1.77.1 hooks:
    • id: terrascan args:
      • --args="-c .terrascan.toml"

Execute pre-commit

Environment information

  • OS: macOS 13.2

  • Tools availability and versions:

terrascan version: v1.18.0

snemetz avatar Feb 09 '23 04:02 snemetz

Hi It could be simply done by adding __GIT_WORKING_DIR__ support

Here is example

https://github.com/antonbabenko/pre-commit-terraform/pull/399

MaxymVlasov avatar Feb 09 '23 14:02 MaxymVlasov