Skip to content

Conversation

@knqyf263
Copy link
Collaborator

Description

This PR changes the default value of the --list-all-pkgs flag from false to true to better align with the growing focus on supply chain security and SBOM (Software Bill of Materials) generation.

Background

While Trivy has traditionally focused on vulnerability detection, the increasing emphasis on supply chain security has created a stronger need for comprehensive package listings and SBOM generation. Users increasingly want to see all packages in their scans, not just those with vulnerabilities.

Problems with Current Behavior

The current default (--list-all-pkgs=false) creates several UX issues:

  • To use trivy convert, users must explicitly specify --format json --list-all-pkgs
  • This is unintuitive and adds friction to common workflows
  • Many users expect package lists to be complete by default

Solution

By changing the default to true:

  • The behavior becomes more intuitive for modern use cases
  • Users get comprehensive package information by default
  • Those who want the old behavior can still use --list-all-pkgs=false

Before and After Examples

Before (current behavior)

# Must explicitly specify --list-all-pkgs for complete package lists
$ trivy image --format json --list-all-pkgs -o result.json debian:11
$ trivy convert --format cyclonedx --output result.cdx result.json

# Without --list-all-pkgs, JSON output only includes packages with vulnerabilities
$ trivy image --format json -o result.json debian:11  # Incomplete package list

After (with this PR)

# All packages included by default
$ trivy image --format json -o result.json debian:11
$ trivy convert --format cyclonedx --output result.cdx result.json

# Can still exclude packages without vulnerabilities if needed
$ trivy image --format json --list-all-pkgs=false -o result.json debian:11

Warning Behavior

The warning for using --list-all-pkgs with non-JSON formats now only appears when explicitly set by the user:

Before: Warning shown when explicitly using --list-all-pkgs

$ trivy image debian:11  # No warning (default was false)
$ trivy image --list-all-pkgs debian:11  # Shows warning about --list-all-pkgs being ignored

After: Warning only when explicitly set (even though default is now true)

$ trivy image debian:11  # No warning (using default true, but not explicitly set)
$ trivy image --list-all-pkgs=true debian:11  # Shows warning (explicitly set)

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

Changes the default value of --list-all-pkgs flag from false to true,
making Trivy include all packages in JSON reports by default. This improves
SBOM generation and provides more comprehensive output by default.

- Update flag default value to true
- Update documentation to reflect the new default
- Update integration tests to explicitly pass --list-all-pkgs=false when needed
- Fix warning logic to only show when user explicitly sets the flag
- Update vulnerability scanner docs to avoid mentioning --list-all-pkgs
@knqyf263 knqyf263 self-assigned this Sep 22, 2025
@knqyf263 knqyf263 requested a review from Copilot September 22, 2025 20:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR changes the default value of the --list-all-pkgs flag from false to true to align with modern supply chain security practices and improve the user experience for SBOM generation workflows.

  • Changes the default behavior to include all packages in JSON reports by default
  • Updates warning logic to only show when the flag is explicitly set by users
  • Modifies test cases and documentation to reflect the new default behavior

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

File Description
pkg/flag/report_flags.go Sets default value to true and updates warning logic to check if flag was explicitly set
pkg/commands/app.go Removes --list-all-pkgs from convert command example
integration/*.go Updates test helper functions to use --list-all-pkgs=false when needed
docs/**/*.md Updates CLI documentation and examples to reflect new default value

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Since the default value of --list-all-pkgs has changed to true,
integration tests need to explicitly set it to false to maintain
existing test behavior and avoid golden file mismatches.
- Add --list-all-pkgs=false to VM tests
- Add --list-all-pkgs=false to SBOM tests
- Remove overrideUID from config_test.go as it was causing issues
@knqyf263 knqyf263 marked this pull request as ready for review September 24, 2025 04:19
@knqyf263 knqyf263 changed the title feat: change --list-all-pkgs default to true feat(cli): change --list-all-pkgs default to true Sep 24, 2025
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.

For the latest packages that I added, I tried to use the --list-all-pkgs flag so that we can verify both package detection and vulnerabilities (when available).
But for other packages, this flag is usually disabled.
I think we should update the test data, and leave only a few examples with --list-all-pkgs=false.
But this should be done in a separate PR.

@knqyf263
Copy link
Collaborator Author

I think we should update the test data, and leave only a few examples with --list-all-pkgs=false.

Currently, tests such as the package list are covered by fanal's integration tests. If we want to run tests on the Trivy side with --list-all-pkgs enabled, integration with fanal will likely be necessary. Otherwise, the tests will be duplicated. We can discuss it later.

@knqyf263 knqyf263 added this pull request to the merge queue Sep 24, 2025
Merged via the queue into aquasecurity:main with commit 7b663d8 Sep 24, 2025
19 checks passed
@knqyf263 knqyf263 deleted the feature/list-all-pkgs-default-true branch September 24, 2025 10:26
alexlebens pushed a commit to alexlebens/infrastructure that referenced this pull request Sep 30, 2025
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [mirror.gcr.io/aquasec/trivy](https://www.aquasec.com/products/trivy/) ([source](https://github.com/aquasecurity/trivy)) | minor | `0.66.0` -> `0.67.0` |

---

### Release Notes

<details>
<summary>aquasecurity/trivy (mirror.gcr.io/aquasec/trivy)</summary>

### [`v0.67.0`](https://github.com/aquasecurity/trivy/blob/HEAD/CHANGELOG.md#0670-2025-09-30)

[Compare Source](aquasecurity/trivy@v0.66.0...v0.67.0)

##### Features

- add documentation URL for database lock errors ([#&#8203;9531](aquasecurity/trivy#9531)) ([eba48af](aquasecurity/trivy@eba48af))
- **cli:** change --list-all-pkgs default to true ([#&#8203;9510](aquasecurity/trivy#9510)) ([7b663d8](aquasecurity/trivy@7b663d8))
- **cloudformation:** support default values and list results in Fn::FindInMap ([#&#8203;9515](aquasecurity/trivy#9515)) ([42b3bf3](aquasecurity/trivy@42b3bf3))
- **cyclonedx:** preserve SBOM structure when scanning SBOM files with vulnerability updates ([#&#8203;9439](aquasecurity/trivy#9439)) ([aff03eb](aquasecurity/trivy@aff03eb))
- **redhat:** add os-release detection for RHEL-based images ([#&#8203;9458](aquasecurity/trivy#9458)) ([cb25a07](aquasecurity/trivy@cb25a07))
- **sbom:** added support for CoreOS ([#&#8203;9448](aquasecurity/trivy#9448)) ([6d562a3](aquasecurity/trivy@6d562a3))
- **seal:** add seal support ([#&#8203;9370](aquasecurity/trivy#9370)) ([e4af279](aquasecurity/trivy@e4af279))

##### Bug Fixes

- **aws:** use `BuildableClient` insead of `xhttp.Client` ([#&#8203;9436](aquasecurity/trivy#9436)) ([fa6f1bf](aquasecurity/trivy@fa6f1bf))
- close file descriptors and pipes on error paths ([#&#8203;9536](aquasecurity/trivy#9536)) ([a4cbd6a](aquasecurity/trivy@a4cbd6a))
- **db:** Dowload database when missing but metadata still exists ([#&#8203;9393](aquasecurity/trivy#9393)) ([92ebc7e](aquasecurity/trivy@92ebc7e))
- **k8s:** disable parallel traversal with fs cache for k8s images ([#&#8203;9534](aquasecurity/trivy#9534)) ([c0c7a6b](aquasecurity/trivy@c0c7a6b))
- **misconf:** handle tofu files in module detection ([#&#8203;9486](aquasecurity/trivy#9486)) ([bfd2f6b](aquasecurity/trivy@bfd2f6b))
- **misconf:** strip build metadata suffixes from image history ([#&#8203;9498](aquasecurity/trivy#9498)) ([c938806](aquasecurity/trivy@c938806))
- **misconf:** unmark cty values before access ([#&#8203;9495](aquasecurity/trivy#9495)) ([8e40d27](aquasecurity/trivy@8e40d27))
- **misconf:** wrap legacy ENV values in quotes to preserve spaces ([#&#8203;9497](aquasecurity/trivy#9497)) ([267a970](aquasecurity/trivy@267a970))
- **nodejs:** parse workspaces as objects for package-lock.json files ([#&#8203;9518](aquasecurity/trivy#9518)) ([404abb3](aquasecurity/trivy@404abb3))
- **nodejs:** use snapshot string as `Package.ID` for pnpm packages ([#&#8203;9330](aquasecurity/trivy#9330)) ([4517e8c](aquasecurity/trivy@4517e8c))
- **vex:** don't  suppress vulns for packages with infinity loop ([#&#8203;9465](aquasecurity/trivy#9465)) ([78f0d4a](aquasecurity/trivy@78f0d4a))
- **vuln:** compare `nuget` package names in lower case ([#&#8203;9456](aquasecurity/trivy#9456)) ([1ff9ac7](aquasecurity/trivy@1ff9ac7))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMTYuNiIsInVwZGF0ZWRJblZlciI6IjQxLjExNi42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJpbWFnZSJdfQ==-->

Reviewed-on: https://gitea.alexlebens.dev/alexlebens/infrastructure/pulls/1622
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
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.

2 participants