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

fix(db): fix case when 2 trivy-db were copied at the same time #8452

Merged
merged 4 commits into from
Feb 28, 2025

Conversation

DmitriyLewen
Copy link
Contributor

@DmitriyLewen DmitriyLewen commented Feb 27, 2025

Description

Fix case when Trivy uses empty trivy-db.
See more in #8454

Changes:

  • bump trivy-db to return error for these cases.
  • update trivy-db if trivy.db file doesn't exist

Related Issues

Related PRs

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).

@knqyf263
Copy link
Collaborator

knqyf263 commented Feb 27, 2025

I will add some context for future reference.
If the database is downloaded by multiple processes, it may become corrupted. In such cases, Trivy detects the corruption and deletes the database file; however, metadata.json may remain.
The current implementation skips the download if this metadata.json contains a new update date even if the database doesn't exist locally. To prevent this, we will check for the existence of the database in addition to metadata.json.

@DmitriyLewen DmitriyLewen changed the title fix(db): update trivy-db if DB file doesn't exist fix(db): fix case when 2 trivy-db were copied at the same time Feb 27, 2025
@DmitriyLewen DmitriyLewen self-assigned this Feb 27, 2025
@DmitriyLewen DmitriyLewen marked this pull request as ready for review February 27, 2025 07:36
@DmitriyLewen
Copy link
Contributor Author

@knqyf263 I bumped trivy-db version. You can review this PR.

@knqyf263 knqyf263 added this pull request to the merge queue Feb 28, 2025
Merged via the queue into aquasecurity:main with commit bb3cca6 Feb 28, 2025
12 checks passed
@DmitriyLewen DmitriyLewen deleted the fix/no-db-file branch March 5, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants