-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Support Inline Filtering #2961
Comments
This issue is stale because it has been labeled with inactivity. |
I am interested in support for this feature as well. |
@Kurt-von-Laven @jmreicha Are you talking about misconfiguration as below?
https://aquasecurity.github.io/tfsec/v0.61.3/getting-started/configuration/ignores/ |
Thank you for reaching out, but that link is to the documentation from an outdated release of tfsec, which is a Terraform linter. This issue is on the Trivy repository, which is a general purpose security scanner. For example, we can't find a way to disable AVD-DS-0002 but only for this file, so we are forced to disable the rule entirely. |
I just asked because Trivy has several capabilities like vulnerabilities, misconfigurations and secrets, and I was not sure which one you are talking about. I showed TFsec as an example as Trivy share the engine with TFsec. If you need this feature in Trivy as well, I believe we can make it easily. |
Oh, gotcha; thanks for educating me. Yeah, I believe this feature would be helpful to many people on the basis that it seems to make its way into most popular linters eventually. |
@knqyf263 is the plan to support the same tfsec ignore capabilities across all misconfiguration scanners? |
We should have the same ignore capabilities for Terraform first. As for other languages, I think we can start with file level ignore like @Kurt-von-Laven showed. |
if we're braking the implementation into multiple steps (first file, then line,block,args etc) then should we create a specific issue for allow ignoring check at the file level? or this issue will be closed when the PR is complete? currently the ignore annotation starts with |
adding a relevant proposal from openssf, not saying we should follow it now, just for future reference: https://docs.google.com/document/d/1811qanC8h9egv3Iszn_rrXGtAoSCz0YJGzp9vACjjH8 |
This issue could have large scope. File level, resource level, line level, etc. Also, it depends on configuration language. For example, JSON files cannot have comments. So, I'd hear the requirement from @Kurt-von-Laven. If @Kurt-von-Laven just needs file level ignore for Dockerfile, we will update this issue to narrow the scope.
I think we should keep both, |
Yes, our current needs will be met by support for file level ignore for Dockerfile alone, and I am all for incremental progress, so I agree with decomposing the issue. |
Interested in this as well, its the lack of inline ignores that is keeping us on tfsec and we may use another tool since they have support for similar functionality (wiz for example) |
@tinder-tder I think that tfsec:ignore already works through trivy terraform scanning as well (@simar7 @giorod3 please confirm?). we are currently working on generalizing it to work across trivy misconfiguration scanning as trivy:ignore. |
This is definitely a bit of a regression for us migrating from I have tried a mix of |
Hi @jof can you tell me which version of trivy you are using. I can confirm that Here is an example of how I verified it was working as expected: this also works with |
@giorod3 -- thank you for a quality example. I was just testing before/after switching to Trivy and finding some used-to-be-ignored findings. I am doing all my testing with Trivy After some more testing, I found that this does work, but has a couple of small changes I needed to apply to my files:
With these new findings, it seems like this functionality (inline ignore comments) does work, but users switching from |
I'm also running into some similar challenges with Dockerfiles in my repo. Since there are so many possible ways (or non-ways; e.g. JSON) to add inline comments, maybe a more flexible approach for trickier formats could be scoping the ignores by path inside of the config? For example, I could fantasize about a ---
ignores:
- CVE-123
- CVE-456
path_ignores:
"some/sub/directory/Dockerfile":
- AVD-DS-0002 Or something flat like:
I'm not sure how to nicely, uniquely refer to resources inside of config-scan files from a one-size-fits-all ignore config, though. |
that's a reasonable suggestion, but probably off-topic for this current issue. we can discuss this feature suggestion in a separate issue if needed |
Is this issue exclusively about misconfiguration? I'm looking for (an example of) how to selectively ignore CVEs when running If this is not the right issue, is there a more appropriate one yet? |
I am not affiliated with Trivy, but my understanding is that this issue has come to regard support for a special comment syntax to ignore Trivy rules in specific files (or on specific lines, but that has already been added). |
Note: the top hit on Google goes to an old version of Trivy which makes it look like Trivy still can't do this, whereas if you update the version at the top of the page and then go to the filtering section it mentions Here is a direct link: https://aquasecurity.github.io/trivy/v0.41/docs/configuration/filtering/#by-inline-comments |
Thanks for the note @HariSekhon , I've opened #4352 to discuss this |
Related discussion: #4573 and a broader one here: #3620 As far as more granular ignoring is concerned, I think it might be easier to support that within the
Thoughts? |
Filtering out by inline-comments for vulnerabilities (not just misconfigurations: https://aquasecurity.github.io/trivy/v0.44/docs/configuration/filtering/#by-inline-comments) would be a very helpful feature. Whether that's in the file itself (preferred) or in the My specific use-case is a helm chart, no terraform like others above are using. |
@simar7 would that go into the .trivyignore or the trivy.yaml file? |
Having hit this a couple of times last week while migrating from tfsec, there are two things which would have helped save me a couple of CI cycles:
|
thanks for the excellent feedback @acdha . |
thanks @acdha - I've created a couple of issues (docs and experience related) to improve this. Appreciate the feedback. |
Looks good, thanks! |
Trivy already supports globally disabling a rule via
.trivyignore
, which is very valuable, but causes users to accept false negatives in order to eliminate false positives. To address this, most linters support disabling a specific rule in a specific file (or even on a specific line if applicable), making false positives far less likely.The text was updated successfully, but these errors were encountered: