fix(fs): skip unreadable files and directories during filesystem walk#10938
Open
kevglynn wants to merge 1 commit into
Open
fix(fs): skip unreadable files and directories during filesystem walk#10938kevglynn wants to merge 1 commit into
kevglynn wants to merge 1 commit into
Conversation
Unreadable files and directories (e.g. "lstat: input/output error" on special files when scanning a mounted Windows filesystem) currently abort the whole scan. Skip them with a debug log instead, as they cannot be analyzed anyway. Errors with the root directory itself are still returned as the scan cannot continue without it. Close aquasecurity#3259 Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When
trivy fswalks a filesystem and hits a file or directory that cannot be read (e.g.lstat: input/output erroron special files when scanning a Windows filesystem mounted on Linux, or paths exceedingPATH_MAX), the whole scan is aborted withunknown error with <path>.These entries cannot be analyzed anyway, so this PR skips them with a debug log instead of halting the traversal:
WalkDirFuncfor a non-root path (failedlstat/ReadDir) now skips that entry.d.Info()call now skips that file.Before
(The scan dies and produces no results, even though readable lockfiles exist elsewhere in the tree. The same happens with
lstat ...: input/output errorfrom the original issue.)After
With
--debug:Related issues
Checklist
Made with Cursor