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

robust username masking in print_config #6914

Closed
wyli opened this issue Aug 30, 2023 · 1 comment · Fixed by #6922
Closed

robust username masking in print_config #6914

wyli opened this issue Aug 30, 2023 · 1 comment · Fixed by #6922

Comments

@wyli
Copy link
Contributor

wyli commented Aug 30, 2023

masked_file_path = re.sub(
r"/home/\w+/",
"/home/<username>/",
re.sub(
r"/Users/\w+/",
"/Users/<username>/",
re.sub(r"C:\\Users\\\w+\\", r"C:\\Users\\<username>\\", monai.__file__),
),

if home directories are in other locations, eg. networked directories, the regex patterns won't match. I'd suggest a more thorough approach is to get the username with getpass.getuser() or os.path.basename(os.path.expanduser("~")) then replace all instances of that string in the output with "". This will catch more places but will miss paths that might contain other identifying names, but these should be very rare.

Originally posted by @ericspod in #6913 (comment)

@anishrajan25
Copy link
Contributor

@wyli I would like to pick this up.

wyli pushed a commit that referenced this issue Aug 31, 2023
Fixes #6914.


### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: anishrajan25 <anishrajan2708@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants