What does trivy fs do?

BeginnerHands-onTrivy
Answer

Short answer

trivy fs scans a local folder — usually the repo in CI — before any image is built. It reads dependency lockfiles and manifests (package-lock.json, pom.xml, requirements.txt, go.sum, Gemfile.lock…) for vulnerable libraries, and can also find secrets and misconfigurations in the same pass.

Examples

trivy fs .                                                   # vulnerabilities + secrets (default scanners)
trivy fs --scanners vuln,secret,misconfig .
trivy fs --severity HIGH,CRITICAL --exit-code 1 .
trivy fs --scanners license --severity HIGH .                # licence issues

Why scan the filesystem and the image?

trivy fs trivy image
When Early (every PR, before build) After build
Sees App dependencies, IaC, secrets in repo OS packages + what actually ended up in the image
Fast feedback ✅ Slower

Both are useful: fs gives developers fast feedback; image catches base-image CVEs and anything added during the build.

What to say in the interview

"trivy fs scans the repository's lockfiles for vulnerable dependencies plus secrets and IaC misconfigs, giving fast PR feedback before an image exists. trivy image later covers OS packages and the final contents."

All Security Tools questions Roadmap: Trivy — image, file system & IaC scanning

More on Trivy