-
Notifications
You must be signed in to change notification settings - Fork 4
ROX-33217: Instrument inode tracking on directory being created path mkdir #465
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
Open
JoukoVirtanen
wants to merge
5
commits into
main
Choose a base branch
from
jv-ROX-33217-instrument-inode-tracking-on-directory-being-created-path_mkdir
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6e63d30
X-Smart-Branch-Parent: main
JoukoVirtanen 0682fb2
Added integration tests
JoukoVirtanen 7aecaa4
Instrument inode tracking on directory being created
JoukoVirtanen e01ccb1
Only tracking directories if the parent is monitored
JoukoVirtanen 9a7a03e
Removed some comments
JoukoVirtanen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
| from event import Event, EventType, Process | ||
|
|
||
|
|
||
| def test_mkdir_nested(monitored_dir, server): | ||
| """ | ||
| Tests that creating nested directories tracks all inodes correctly. | ||
|
|
||
| Args: | ||
| monitored_dir: Temporary directory path for creating the test directory. | ||
| server: The server instance to communicate with. | ||
| """ | ||
| process = Process.from_proc() | ||
|
|
||
| # Create nested directories | ||
| level1 = os.path.join(monitored_dir, 'level1') | ||
| level2 = os.path.join(level1, 'level2') | ||
| level3 = os.path.join(level2, 'level3') | ||
|
|
||
| os.mkdir(level1) | ||
| os.mkdir(level2) | ||
| os.mkdir(level3) | ||
|
|
||
| # Create a file in the deepest directory | ||
| test_file = os.path.join(level3, 'deep_file.txt') | ||
| with open(test_file, 'w') as f: | ||
| f.write('nested content') | ||
|
|
||
| events = [ | ||
| Event(process=process, event_type=EventType.CREATION, | ||
| file=level1, host_path=level1), | ||
| Event(process=process, event_type=EventType.CREATION, | ||
| file=level2, host_path=level2), | ||
| Event(process=process, event_type=EventType.CREATION, | ||
| file=level3, host_path=level3), | ||
| Event(process=process, event_type=EventType.CREATION, | ||
| file=test_file, host_path=test_file), | ||
| ] | ||
|
|
||
| server.wait_events(events) | ||
|
|
||
|
|
||
| def test_mkdir_ignored(monitored_dir, ignored_dir, server): | ||
| """ | ||
| Tests that directories created outside monitored paths are ignored. | ||
|
|
||
| Args: | ||
| monitored_dir: Temporary directory path that is monitored. | ||
| ignored_dir: Temporary directory path that is not monitored. | ||
| server: The server instance to communicate with. | ||
| """ | ||
| process = Process.from_proc() | ||
|
|
||
| # Create directory in ignored path - should not be tracked | ||
| ignored_subdir = os.path.join(ignored_dir, 'ignored_subdir') | ||
| os.mkdir(ignored_subdir) | ||
|
|
||
| # Create directory in monitored path - should be tracked | ||
| monitored_subdir = os.path.join(monitored_dir, 'monitored_subdir') | ||
| os.mkdir(monitored_subdir) | ||
|
|
||
| # Only the monitored directory should generate an event | ||
| e = Event(process=process, event_type=EventType.CREATION, | ||
| file=monitored_subdir, host_path=monitored_subdir) | ||
|
|
||
| server.wait_events([e]) |
Oops, something went wrong.
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.
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.
I originally had
However,
test_nonrecursive_wildcard::test_wildcard.pyfailed with that change. The reason was that was the inodes of all directories created in that test were tracked and subsequently all files in those directories were tracked regardless if they matched the wildcard pattern or not.