Skip to content
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

tfsec deprecated, replaced by Trivy. Create a new hook for Trivy #550

Closed
bodgit opened this issue Aug 1, 2023 · 10 comments · Fixed by #606
Closed

tfsec deprecated, replaced by Trivy. Create a new hook for Trivy #550

bodgit opened this issue Aug 1, 2023 · 10 comments · Fixed by #606
Labels
documentation Improvements or additions to documentation estimate/1h Need 1 hour to be done feature New feature or request good first issue Good for newcomers hook/terraform_tfsec Bash hook hook/terraform_trivy Bash hook

Comments

@bodgit
Copy link

bodgit commented Aug 1, 2023

What problem are you facing?

tfsec is deprecated and it's recommended to migrate to use Trivy instead.

How could pre-commit-terraform help solve your problem?

A new hook that runs trivy config ... in some form would therefore be useful. Trivy seems to currently honour existing tfsec:ignore:* comment blocks so you can switch hooks without needing to rewrite existing comments.

@bodgit bodgit added the feature New feature or request label Aug 1, 2023
@MaxymVlasov MaxymVlasov changed the title Support running Trivy instead/as well as tfsec tfsec deprecated, replaced by Trivy. Create a new hook for Trivy Aug 14, 2023
@MaxymVlasov MaxymVlasov added good first issue Good for newcomers estimate/1day Need 1 work day to be done labels Aug 14, 2023
@pdecat
Copy link

pdecat commented Sep 22, 2023

As trivy is not only for terraform, maybe it makes sense to use https://github.com/mxab/pre-commit-trivy

It was added to docs here: aquasecurity/trivy#3203

@MaxymVlasov
Copy link
Collaborator

Nice, let's them just add to docs info about tfsec deprecation and info where can be found trivy hook (which maintenance will be not our problem 🎉 )

@MaxymVlasov MaxymVlasov added documentation Improvements or additions to documentation estimate/1h Need 1 hour to be done and removed estimate/1day Need 1 work day to be done labels Sep 22, 2023
@MaxymVlasov
Copy link
Collaborator

MaxymVlasov commented Sep 22, 2023

Of course, if the repo author adds a LICENCE (mxab/pre-commit-trivy#12), otherwise his hooks are not usable

@bodgit
Copy link
Author

bodgit commented Sep 25, 2023

I'd actually rather not use that hook as it requires Docker and is pinned to the version of trivy specified in the hook configuration, which means I'm reliant on the author to keep updating the hook.

Given trivy is a single binary, I can (and do) install that by other means, so a hook that just tries to run trivy and assume it's somewhere in $PATH would be more flexible.

@pdecat
Copy link

pdecat commented Sep 25, 2023

Maybe that's something the author of https://github.com/mxab/pre-commit-trivy/ would accept to implement, especially easy to add without breaking anything IMO as the current hooks are suffixed by -docker.

@pdecat
Copy link

pdecat commented Sep 25, 2023

On the other hand, I see that pre-commit-terraform already supports checkov which is also not only terraform.

@MaxymVlasov
Copy link
Collaborator

MaxymVlasov commented Sep 25, 2023

Well, then you can just copy-paste tfsec hook, change tfsec execution command, and that mostly all from hook logic addition prospective

There is a full doc on how to add docs and so on - https://github.com/antonbabenko/pre-commit-terraform/blob/master/.github/CONTRIBUTING.md#add-new-hook

Also, we will need a deprecation notice to tfsec both in README and in hook itself

The hook notice can be just

common::colorify "yellow" "tfsec tool was deprecated, and replaced by trivy. You can check trivy hook here:"
common::colorify "yellow" "https://github.com/antonbabenko/pre-commit-terraform/tree/master#terraform_trivy"

at the end of main function (of right before common::per_dir_hook execution - not sure that it will shown after)

In any case, notice will show only when something will go wrong (hook found issues and failed). That's planned

@umbertix
Copy link

umbertix commented Dec 7, 2023

Wondering if someone has picked up this in any meaninful way. I'm very keen on this feature and not sure at what point this is standing. Is this waiting for someone to actually come with the PR for the mentioned changes?

@MaxymVlasov
Copy link
Collaborator

MaxymVlasov commented Dec 11, 2023

Is this waiting for someone to actually come with the PR for the mentioned changes?

Exactly. And it can be you :)

@antonbabenko
Copy link
Owner

This issue has been resolved in version 1.85.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation estimate/1h Need 1 hour to be done feature New feature or request good first issue Good for newcomers hook/terraform_tfsec Bash hook hook/terraform_trivy Bash hook
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants