Repository navigation
Walk aborts the whole fs/rootfs scan when a file disappears between the directory read and lstat #11670
Closed
burak-bayir
started this conversation in
Bugs
Replies: 2 comments
|
Say a nightly Trivy scan is running on a CI runner when a Go build finishes. Go cleans up its temporary files under For the regression test, I’d put a |
0 replies
|
Thanks for the detailed report and the reproduction. This is tracked in #11679, so I'm closing this discussion. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Description
trivy fsandtrivy rootfsend the whole scan when a regular file disappears between the directory read and thelstatthatd.Info()makes inWalkDirFunc(pkg/fanal/walker/fs.go). On a busy machine, build output, package manager caches and temp files come and go during a walk, so a scan of/fails now and then and produces no report at all. Over 3 weeks, 4 of 36 nightlytrivy rootfs --scanners vulnscans of busy build machines ended this way.onErrorin the same file already skips permission errors. A file that no longer exists has nothing left to scan, so it could be skipped the same way, for example with anerrors.Is(err, fs.ErrNotExist)case next toos.IsPermission(err).errors.Issees through thexerrors.Errorf("file info error: %w", err)wrap.mainhas the sameonErrortoday.#7554 hits the same error on
/procentries when the host is scanned from a container. This report shows it on ordinary files, with no container involved.Desired Behavior
The walk skips a file that vanished after its directory was read, maybe with a debug log line, and scans the rest of the tree.
Actual Behavior
The scan exits 1 with
walk dir error: unknown error with <file>: file info error: lstat <file>: no such file or directory, and no report is written.Reproduction Steps
Runs 1 and 2 exited 0, and run 3 exited 1 with the error below.
--format cyclonedxkeeps the repro free of the vulnerability DB, andtrivy rootfs --scanners vuln --format jsonon/fails the same way.Target
Filesystem
Scanner
Vulnerability
Output Format
JSON
Mode
Standalone
Debug Output
- fs scan error: github.com/aquasecurity/trivy/pkg/commands/artifact.run /home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:452 - scan error: github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).scanArtifact /home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:304 - scan failed: github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).scan /home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:712 - failed analysis: github.com/aquasecurity/trivy/pkg/scan.Service.ScanArtifact /home/runner/work/trivy/trivy/pkg/scan/service.go:54 - analyze with traversal: github.com/aquasecurity/trivy/pkg/fanal/artifact/local.Artifact.Inspect /home/runner/work/trivy/trivy/pkg/fanal/artifact/local/fs.go:226 - walk dir error: github.com/aquasecurity/trivy/pkg/fanal/walker.(*FS).Walk /home/runner/work/trivy/trivy/pkg/fanal/walker/fs.go:35 - unknown error with <dir>/scan/churn/c151.tmp: github.com/aquasecurity/trivy/pkg/fanal/walker.(*FS).onError.func1 /home/runner/work/trivy/trivy/pkg/fanal/walker/fs.go:92 - file info error: github.com/aquasecurity/trivy/pkg/fanal/walker.(*FS).WalkDirFunc.func1 /home/runner/work/trivy/trivy/pkg/fanal/walker/fs.go:69 - lstat <dir>/scan/churn/c151.tmp: no such file or directoryOperating System
Ubuntu 26.04.1 LTS, amd64
Version
Checklist
trivy clean --all. Each run here used a fresh, empty--cache-dirinstead.All reactions