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

feat: add --severity-src flag to customize vulnerability severity selection #8180

Open
knqyf263 opened this issue Dec 26, 2024 · 0 comments
Open
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@knqyf263
Copy link
Collaborator

Description

Currently, Trivy automatically selects the "best" severity among multiple data sources (NVD, GHSA, etc.) based on its internal logic. While this works well for most cases, some users have specific needs for severity selection:

  • Some users prefer to prioritize NVD severities
  • Others might want to avoid GHSA severities if they consider them problematic
  • Different organizations might have different preferences for severity sources

To address these needs, I propose adding a new --severity-src flag that allows users to specify their preferred severity sources in order of priority.

Proposed Implementation

The flag would work as follows:

  1. Accept multiple values in comma-separated format or repeated flags
    Example: --severity-src nvd --severity-src ghsa

  2. Process severity sources in the specified order

    • If the first source has a severity, use it
    • If not, try the next source
    • If no sources have severity:
      • Return "unknown" as severity
      • Output a warning message: "No severity found in specified sources: [source1,source2]"
  3. Define current behavior as auto

  4. Allow fallback to auto mode
    Example: --severity-src nvd,auto

    • This would first check NVD, then fall back to the current automatic selection logic

Usage Examples

# Use NVD severity, fallback to GHSA
$ trivy image --severity-src nvd,ghsa myimage

# Use NVD severity, fallback to automatic selection
$ trivy image --severity-src nvd,auto myimage

# Use current automatic selection (default)
$ trivy image --severity-src auto alpine:latest

# Example of warning message when no severity found
$ trivy image --severity-src nvd,ghsa alpine:latest
WARN No severity found in specified sources: [nvd,ghsa]

Benefits

  • Provides flexibility for organizations with specific severity source preferences
  • Maintains backward compatibility with current behavior
@knqyf263 knqyf263 added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 26, 2024
@knqyf263 knqyf263 added this to the v0.60.0 milestone Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
Status: No status
Development

No branches or pull requests

2 participants