Skip to content

robust username masking in print_config #6914

@wyli

Description

@wyli

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions