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): use schema version as tag only for trivy-db and trivy-java-db registries by default #6219

Conversation

DmitriyLewen
Copy link
Contributor

@DmitriyLewen DmitriyLewen commented Feb 28, 2024

Description

We add schema version as tag only for all registries (both default and external).
To avoid limiting users, we only need to do this for the default registries (ghcr.io/aquasecurity/trivy-db and ghcr.io/aquasecurity/trivy-java-db).

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

@DmitriyLewen DmitriyLewen self-assigned this Feb 28, 2024
@DmitriyLewen DmitriyLewen marked this pull request as ready for review February 28, 2024 11:37
Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

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

If I understand correctly, the current change will be breaking compatibility. Those who specify --db-repository myregistry will see an error after this PR since their repository is now myregistry:2, but Trivy accesses myregistry. Am I correct?
What if adding a tag only when a tag not specified?

  • --db-repository ghcr.io/aquasecurity/trivy-db => Access ghcr.io/aquasecurity/trivy-db:2
  • --db-repository ghcr.io/aquasecurity/trivy-db:2 => Access ghcr.io/aquasecurity/trivy-db:2
  • --db-repository myregistry => Access myregistry:2
  • --db-repository myregistry:2 => Access myregistry:2
  • --db-repository myregistry:3 => Access myregistry:3

@DmitriyLewen DmitriyLewen force-pushed the fix/dont-add-schema-version-for-external-repos branch from e44a3d4 to d8a0c03 Compare March 6, 2024 03:22
@DmitriyLewen
Copy link
Contributor Author

@knqyf263 I updated this PR using your solution
Take a look, when you have time, please.

@knqyf263
Copy link
Collaborator

knqyf263 commented Mar 8, 2024

And the default value should be ghcr.io/aquasecurity/trivy-db:2 now.

@DmitriyLewen
Copy link
Contributor Author

You are right.
Changed in f4048b7

Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

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

I left small comments, but LGTM basically.

@@ -78,6 +79,11 @@ func NewClient(cacheDir string, quiet bool, opts ...Option) *Client {
opt(o)
}

// Add the schema version as a tag if the tag doesn't exist.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment this is for backward compatibility? We want to remove it after a while.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment in 91bcb0a

@@ -82,8 +83,12 @@ func (u *Updater) Update() error {
}

func Init(cacheDir, javaDBRepository string, skip, quiet bool, registryOption ftypes.RegistryOptions) {
// Add the schema version as a tag if the tag doesn't exist.
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment in 91bcb0a

@knqyf263 knqyf263 added this pull request to the merge queue Mar 11, 2024
Merged via the queue into aquasecurity:main with commit 96bd7ac Mar 11, 2024
17 checks passed
romulets added a commit to romulets/cloudbeat that referenced this pull request Aug 13, 2024
- Fix registry version aquasecurity/trivy#6219; \n- Fix replace zap with slog aquasecurity/trivy#6466; \n  - The fix with slog used a zap to slog bridge (official from zap, but exp). It didn't have a license file, so I hardcoded a commit version that had; \n- Adopt opts.Align() to validate options object;
romulets added a commit to romulets/cloudbeat that referenced this pull request Aug 13, 2024
- Fix registry version aquasecurity/trivy#6219; \n- Fix replace zap with slog aquasecurity/trivy#6466; \n  - The fix with slog used a zap to slog bridge (official from zap, but exp). It didn't have a license file, so I hardcoded a commit version that had; \n- Adopt opts.Align() to validate options object;
romulets added a commit to elastic/cloudbeat that referenced this pull request Aug 13, 2024
* Bump trivy to v0.49.1

* Bump trivy to v0.51.4
    - Fix registry version aquasecurity/trivy#6219; 
    - Fix replace zap with slog aquasecurity/trivy#6466;
        - The fix with slog used a zap to slog bridge (official from zap, but exp). It didn't have a license file, so I hardcoded a commit version that had; 
  - Adopt opts.Align() to validate options object;

* Bump trivy to v0.52.2

* Temp change the workflow trigger to test changes

* Free up space on runner

* Bump trivy to v0.53.0
  - Fix go clear cache aquasecurity/trivy#7010

* Bump trivy to v0.54.1
  - Fix --vuln-type flag renamed into --pkg-types aquasecurity/trivy#7104; 
  - Adopt package relationships aquasecurity/trivy#7237

* Rollback CI run on target

* Clean 'scan cache clean' code and add timeout to it
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.

Trivy image with flag --java-db-repository is adding ":1" to the URL of container repo
2 participants