fix(plugin): don't remove plugins when updating index.yaml file #9358
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes plugin directory removal during index updates by changing the download strategy for index.yaml files. Previously, the plugin manager would use downloader.Download() which could inadvertently remove the entire plugin directory
during index updates.
See the following code:
trivy/pkg/downloader/download.go
Lines 58 to 60 in 8f5b560
This change ensures that installed plugins are preserved when updating the plugin index.
The fix implements a safer approach by:
Examples:
Before:
➜ trivy plugin list Installed Plugins: Name: referrer Version: 0.3.1 ➜ trivy plugin update 2025-08-20T12:35:54+06:00 INFO [plugin] Updating the plugin index... url="https://aquasecurity.github.io/trivy-plugin-index/v1/index.yaml" ➜ trivy plugin list No Installed PluginsAfter:
➜ ./trivy plugin list Installed Plugins: Name: referrer Version: 0.3.1 ➜ ./trivy plugin update 2025-08-20T12:38:36+06:00 INFO [plugin] Updating the plugin index... url="https://aquasecurity.github.io/trivy-plugin-index/v1/index.yaml" ➜ ./trivy plugin list Installed Plugins: Name: referrer Version: 0.3.1Related issues
trivy plugin updatecommand removes installed plugins. #9357Checklist