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(fs): use same walker for slow and fast modes #5667

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lebauce
Copy link
Contributor

@lebauce lebauce commented Nov 27, 2023

Description

filepath.WalkDir doesn't follow symlink which makes it impossible to use it to walk through /proc/12345/root This PR changes the current walker to:

  • handle top directory symlink
  • use same walker for both slow and fast paths for consistency

PR's were push upstream but the project (https://github.com/saracen/walker) seems dead.

Other options would be to import the code (into pkg/utils/fsutils ?) or have the fork under the aqua org.

Related issues

  • Close #XXX

Related PRs

  • #XXX
  • #YYY

Remove this section if you don't have related PRs.

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@lebauce lebauce changed the title feat(walker): use same walker for slow and fast modes feat(fs): use same walker for slow and fast modes Nov 27, 2023
@lebauce lebauce marked this pull request as draft November 27, 2023 23:00
@lebauce lebauce marked this pull request as ready for review November 28, 2023 18:55
@lebauce
Copy link
Contributor Author

lebauce commented Dec 20, 2023

@knqyf263 Sorry, I know that you are pretty busy but if you or someone else from the team could have a look at this one, that would be very much appreciated. Thanks !

filepath.WalkDir doesn't follow symlink which makes it
impossible to use it to walk through /proc/<pid>/root
This PR changes the current walker to:
- handle top directory symlink
- use same walker for both slow and fast paths for consistency
@knqyf263
Copy link
Collaborator

knqyf263 commented Jan 6, 2024

I'm sorry for the late reply. We already have a PR. Does it meet your requirements?

@lebauce
Copy link
Contributor Author

lebauce commented Jan 10, 2024

I'm sorry for the late reply

No problem !

Does it meet your requirements?

Unfortunately no :-/
My use case is the following one : being able to scan the filesystem of a container through /proc/1234/root , which is a "somehow magic" symlink and therefore not supported by the Golang walker who ignores all the symlink including the top one.
One approach would be to handle the root directory "manually" and use the walker only for the subdirectories of this root directory. I can try to add a PR on top of yours.

Copy link

This PR is stale because it has been labeled with inactivity.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and will be auto-closed. label Apr 29, 2024
@knqyf263
Copy link
Collaborator

We've finally merged #5180. If your use-case benefits the community, we'd accept it. If not, the walker is now an interface, and you can overwrite it on your end.
https://github.com/knqyf263/trivy/blob/e8190608d6f0f29c873ba8d43c529968f1149843/pkg/fanal/artifact/local/fs.go#L36-L38

@github-actions github-actions bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and will be auto-closed. label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants