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

feat: add support for .trivyignore.yaml #5070

Merged
merged 11 commits into from
Aug 31, 2023

Conversation

knqyf263
Copy link
Collaborator

@knqyf263 knqyf263 commented Aug 30, 2023

Description

Support the structured ignore file.

Example:

$ cat .trivyignore.yaml
vulnerabilities:
  - id: CVE-2023-30861
    paths:
      - "pkg/fanal/analyzer/language/python/poetry/testdata/happy/poetry.lock"
      - "pkg/fanal/analyzer/language/python/pip/testdata/requirements.txt"
    statement: Accept the risk
  - id: CVE-2023-37920
  - id: GHSA-5crp-9r3c-p9vr
     expired_at: 2023-09-01

misconfigurations:
  - id: AVD-DS-0002
  - id: AVD-DS-0003
     paths:
       - docs/Dockerfile
     statement: The container image is not deployed

It is still experimental since we're aware of more requirements around ignoring and possibly adding breaking changes. Thus, the file path must be explicitly specified as below so that it will not break compatibility.

$ trivy repo --ignorefile .trivyignore.yaml .

If the file extension is .yml or .yaml, Trivy tries to parse that in the YAML format. Otherwise, it is treated as the legacy .trivyignore.

TODOs

  • Support .trivyignore.yaml
  • Backward compatibility
  • Write tests
  • Write docs

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Sorry, something went wrong.

@knqyf263 knqyf263 self-assigned this Aug 30, 2023

Verified

This commit was signed with the committer’s verified signature.
migruiz4 Miguel Ruiz
Signed-off-by: knqyf263 <knqyf263@gmail.com>
@knqyf263 knqyf263 force-pushed the feat/trivyignore_yaml branch from dec7dbb to 588f426 Compare August 30, 2023 21:16

func (findings IgnoreFindings) Match(path, id string) bool {
for _, finding := range findings {
if len(finding.Paths) != 0 && !slices.Contains(finding.Paths, path) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we want to use wildcard for paths?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget: we need to update docs if we don't add wildcards.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added c624be4

knqyf263 and others added 8 commits August 31, 2023 09:38
Signed-off-by: knqyf263 <knqyf263@gmail.com>

Verified

This commit was signed with the committer’s verified signature.
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
@knqyf263 knqyf263 marked this pull request as ready for review August 31, 2023 10:14
@knqyf263 knqyf263 requested a review from simar7 as a code owner August 31, 2023 10:14
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@knqyf263 knqyf263 added this pull request to the merge queue Aug 31, 2023
Merged via the queue into aquasecurity:main with commit 9628b1c Aug 31, 2023
@knqyf263 knqyf263 deleted the feat/trivyignore_yaml branch August 31, 2023 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Report vulnerability filtering: support scoped ignores
2 participants