Skip to content

feat(cli): Add available version checking#8553

Merged
knqyf263 merged 17 commits intomainfrom
feat/add-update-checking
May 28, 2025
Merged

feat(cli): Add available version checking#8553
knqyf263 merged 17 commits intomainfrom
feat/add-update-checking

Conversation

@owenrumney
Copy link
Copy Markdown
Contributor

@owenrumney owenrumney commented Mar 14, 2025

Description

Adds a background check to https://api.trivy.cloud/check to see if there is new version or any relevant notices available.

The check will be suppressed if the user uses the --no-notices or --quiet envvars or flags. The docs have been updated with the new notices flag

Example output

image

Although the image shows dummy versions, the api has been updated to reflect the correct information and has no announcements at this time... just the latest version (0.60.0)

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

@owenrumney owenrumney self-assigned this Mar 14, 2025
@owenrumney owenrumney marked this pull request as ready for review March 14, 2025 11:44
@owenrumney owenrumney requested a review from knqyf263 as a code owner March 14, 2025 11:44
@knqyf263 knqyf263 requested a review from DmitriyLewen March 17, 2025 02:44
Copy link
Copy Markdown
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.

@owenrumney left comments.
Take a look, please.

Also I think update is not a very good name for this logic.
Maybe something like notification?

UPD:
and I would also think about how we can inform users about the ---no-notises flag

Comment thread pkg/commands/app.go Outdated
Comment thread docs/docs/references/configuration/cli/trivy_clean.md Outdated
Comment thread pkg/update/check.go Outdated
Comment thread pkg/update/check.go Outdated
Comment thread pkg/update/check.go Outdated
@owenrumney owenrumney marked this pull request as draft March 17, 2025 11:54
@owenrumney owenrumney force-pushed the feat/add-update-checking branch 2 times, most recently from 4a269dd to be383c3 Compare March 17, 2025 13:46
Comment thread pkg/commands/artifact/run.go Outdated
@owenrumney owenrumney marked this pull request as ready for review April 14, 2025 11:26
Copy link
Copy Markdown
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.

LGTM. I left small comments.

Comment thread pkg/notification/notice.go Outdated
Comment thread pkg/commands/artifact/run.go Outdated
@owenrumney owenrumney force-pushed the feat/add-update-checking branch 2 times, most recently from 9c714fb to f21196a Compare April 16, 2025 18:23
Copy link
Copy Markdown
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 think we also need to create a new page for privacy. @itaysk should know some examples from other OSS projects.

Comment thread pkg/notification/notice.go Outdated
Comment thread pkg/notification/notice.go Outdated
Comment thread pkg/notification/notice.go Outdated
Comment thread pkg/notification/notice.go Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where is this used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's actually only used in the test at the moment to know when the process is completed

Comment thread pkg/notification/notice.go Outdated
@owenrumney owenrumney force-pushed the feat/add-update-checking branch from 67acb5e to 5152ff5 Compare April 17, 2025 18:41
@itaysk
Copy link
Copy Markdown
Contributor

itaysk commented Apr 18, 2025

I think we also need to create a new page for privacy. @itaysk should know some examples from other OSS projects.

yes I already have a draft for a dedicated doc, wasn't sure if we want it in the same PR or not. actually I'll try to add it to this one. (ps i don't think the doc should include referenences from other products)

Comment thread pkg/flag/scan_flags.go Outdated
Copy link
Copy Markdown
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.

LGTM!

I'm fine with updating the documentation either in this PR or in a separate one, as long as it gets updated before the next release—so I'll approve this PR.

Comment thread pkg/notification/option.go Outdated
Copy link
Copy Markdown
Contributor

@nikpivkin nikpivkin left a comment

Choose a reason for hiding this comment

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

LGTM. Left a small comment

@itaysk
Copy link
Copy Markdown
Contributor

itaysk commented Apr 19, 2025

I may have some more comment after writing the doc, so don't merge it yet please

@owenrumney owenrumney requested a review from afdesk as a code owner April 22, 2025 08:02
Comment thread helm/trivy/Chart.yaml Outdated
@owenrumney owenrumney force-pushed the feat/add-update-checking branch from 929742f to bd1feb4 Compare May 5, 2025 18:58
Copy link
Copy Markdown
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
left small comments

Comment thread pkg/notification/notice.go Outdated
Comment thread pkg/notification/notice.go Outdated
Copy link
Copy Markdown
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
left small comments

Owen Rumney added 2 commits May 12, 2025 06:15
- Update the preRun and postRun to check and print the latest version
  - Run in a go routine so as not to interfere or slow the normal flow
  - Provide new `--no-notices` flag to prevent notice checking, same if
    they `-q/--quiet` flag is used
- Add tests for the identifier and the check logic
- change no-notices flag to `skip-version-check` and add
  `disable-metrics` flag
- create VersionChecker type and add to runner
- if the flag conditions are met, create a new checker and trigger check
- handle logic of flags for disabling metrics
- update the tests
Owen Rumney and others added 12 commits May 12, 2025 06:15
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
Remove the -x prefix as per RFC6648. While headers are case-insensitve,  making custom headers title case as per general
convention.

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
- update the URL to check.trivy.cloud/updates
- change the flag to disable-telemetry
- update tests

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
offline scan isn't to be included at the moment, this will be tackled
as a different piece of work.

tidied up the notices option to be more consistent with the flag it
reflects

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
…ents

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
- add support for different formats of date time from the service

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
@owenrumney owenrumney force-pushed the feat/add-update-checking branch from 52162e0 to c6f5d66 Compare May 12, 2025 05:48
Comment thread docs/docs/advanced/telemetry.md Outdated
Comment thread docs/docs/advanced/telemetry.md Outdated
Copy link
Copy Markdown
Member

@simar7 simar7 left a comment

Choose a reason for hiding this comment

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

lgtm, left a small comment.

Co-authored-by: simar7 <1254783+simar7@users.noreply.github.com>
Copy link
Copy Markdown
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
Copy link
Copy Markdown
Collaborator

@itaysk Can we merge this PR?

@knqyf263 knqyf263 added this pull request to the merge queue May 28, 2025
Merged via the queue into main with commit 5a0bf9e May 28, 2025
21 checks passed
@knqyf263 knqyf263 deleted the feat/add-update-checking branch May 28, 2025 08:31
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.

feat(cli): Capture some basic information during the update check feat(cli): Add new version checking

6 participants