-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Improve file traversal performance and correctness #8704
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
Conversation
217c5ae to
590ad28
Compare
590ad28 to
654c5ee
Compare
zwass
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this! I'm going to need to take some more time to review and test, but I did kick off the CI and see that the formatting checks fail: https://github.com/osquery/osquery/actions/runs/18953561159/job/54706407760?pr=8704#step:7:11. Those should be pretty easy to fix. You can test locally, see https://osquery.readthedocs.io/en/stable/development/building/#formatting-the-code
|
Thanks for your time and for testing! I fixed the formatting. |
zwass
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Krechals we are continuing to see format issues. I'd love to get this merged for the next osquery release.
654c5ee to
2da143f
Compare
Signed-off-by: Krechals <topala.andrei@gmail.com>
2da143f to
2134ef0
Compare
|
@zwass, the test should pass now |
zwass
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Krechals I'm still seeing failures. Thank you for your persistence.
57: [ RUN ] FilesystemTests.test_wildcard_double_folders
57: /__w/osquery/osquery/workspace/padding-required-by-rpm-packages/src/osquery/filesystem/tests/filesystem.cpp:437: Failure
57: Expected equality of these values:
57: results.size()
57: Which is: 3
57: 10U
57: Which is: 10
57:
57: /__w/osquery/osquery/workspace/padding-required-by-rpm-packages/src/osquery/filesystem/tests/filesystem.cpp:441: Failure
57: Value of: contains(results, fs::path(fake_directory_ / "deep11/deep2/deep3/") .make_preferred() .string())
57: Actual: false
57: Expected: true
|
I updated to fix the failing test which seemed to be an issue with recursive directory handling. Will see if CI is good now. |
|
My changes caused some tables (and associated tests) to break because there was an undocumented assumption that directories are returned with no trailing separators in A few places with this assumption: |
zwass
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good with me, assuming tests pass. I've pushed changes so I don't think my review allows merging.
This PR fixes #7291
Another issue with the current osquery implementation is that hidden directories don't get traversed.
Currently, recursive traversals terminate early when a cycle is detected.
For example, given the following query:
and the directory structure:
osquery currently returns:
The fix updates the traversal logic to continue expanding ** recursively until no new folders or files remain to explore.
With this change, osquery now returns:
The implementation now calls
platformGlobonly initially, with directory expansion handled through directory traversal.A rough benchmark shows this change makes the traversal 2x faster than the current implementation.
Before:
After: