Sub topic 10
Filtering by severity and unfixed vulnerabilities
A default Trivy scan of a general-purpose image can print hundreds of rows. Most are low-impact, and many have no patch yet. This chapter shows how to cut that output down to findings you can act on.
This chapter assumes you know what a CVE is, how severity ratings work, and how to run trivy image on an image. These topics were covered in earlier chapters.
Why filter at all
A scanner reports every known vulnerability that matches a package in the image. A list that long hides the findings that matter. Two filters do most of the work:
- Severity keeps findings at or above a level you care about.
- Fix status hides findings where the vendor has not published a patched version.
The second filter needs care. A finding with no fix is still a real finding. You hide it because you cannot act on it today, not because it is safe.
Filtering by severity
Trivy labels each finding as UNKNOWN, LOW, MEDIUM, HIGH, or CRITICAL. The --severity flag takes a comma-separated list of the levels to keep.
trivy image --severity HIGH,CRITICAL python:3.12-slimTrivy does not treat the list as a threshold. If you write --severity CRITICAL, you see only critical findings, not "critical and above" or "critical and below". Name every level you want.
Hiding unfixed vulnerabilities
Distribution maintainers often leave a vulnerability unpatched for a long time. Some mark it "will not fix". The --ignore-unfixed flag removes any finding that has no fixed version.
trivy image --severity HIGH,CRITICAL --ignore-unfixed python:3.12-slimEvery row left in the report now has a value in the Fixed Version column. You can act on each one by upgrading that package or rebuilding on a newer base image.
The same filter in Docker Scout
Docker Scout offers a similar severity filter. It uses --only-severity.
docker scout cves --only-severity critical,high nginx:latestScout also has a fix-status filter. Run docker scout cves --help to check the exact flag names in your version, because options change between releases.
Comparing the two tools
| Goal | Trivy | Docker Scout |
|---|---|---|
| Keep chosen severities | `--severity HIGH,CRITICAL` | `--only-severity critical,high` |
| Hide unfixed findings | `--ignore-unfixed` | Check `docker scout cves --help` |
| Case of severity names | Upper case | Lower case |
Common errors
- Reading a short report as a clean image. After
--ignore-unfixed, the report only shows fixable findings. Run the scan once without the flag so you know what you are hiding. - Expecting a threshold.
--severity HIGHdoes not includeCRITICAL. - Forgetting
UNKNOWN. Findings that the database has not rated carry theUNKNOWNlabel. Filtering toHIGH,CRITICALdrops them. Review them occasionally. - Mixing up case. Trivy accepts upper-case severities in its documentation examples. Docker Scout examples use lower case.
Exercise
You run trivy image --severity CRITICAL --ignore-unfixed myapp:1.0 and get an empty report. Can you conclude the image has no serious vulnerabilities? Give two reasons for your answer.
Show answer
No. First, --severity CRITICAL hides HIGH findings, which are still serious. Second, --ignore-unfixed hides critical findings that have no patch yet. Run the scan without the filters, or with --severity HIGH,CRITICAL alone, to see what was hidden.