-
Notifications
You must be signed in to change notification settings - Fork 455
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
Convert baseline file to match local filesystem path #573
Conversation
Hey there, requesting any feedback on this PR |
Hi @eddiez9, thank you for opening this PR. Looks like tests are failing. I'd appreciate if you could take a look and get them all passing. |
…re/support-windows-linux-paths
….path.join substitutions in tests
I've had to change the unit tests as they make assumptions about UNIX pathing wrt. assertions. To summarize all the changes: util/path.py tests/audit/audit_test.py tests/pre_commit_hook_test.py tests/core/baselien_test.py |
Problem
Currently, detect-secrets doesn't support multi OS environments very well.
If a Windows developer generates a baseline file, Linux developers will always be alerted on new secrets and vice versa.
This is because baseline files have OS specific paths
Windows:
"filename": "src\blah\appsettings
Linux:
"filename": "src/blah/appsettings
When performing new_secrets = secrets - args.baseline you will always get new secrets because the filenames dont match.
Solution
The best solution would probably be to generate baseline files/read files in a consistent manner to always use Unix paths with something like os.path.normpath Doing this however will mean people will need to update their baseline files.
The solution implemented in the PR instead will using os.sep to determine if we are on UNIX or Windows, then replace slashes in filenames for the loaded baseline file (without changing the baseline file). The comparison will then work regardless of if you are on Linux comparing against a windows generated baseline file and vice versa.