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

Hook currently fails to interpret filenames with spaces #470

Merged
merged 1 commit into from
Aug 1, 2021

Conversation

psedge
Copy link
Contributor

@psedge psedge commented Jul 16, 2021

I noticed that detect-secrets-hook -v --baseline .secrets.baseline $(git ls-files) interprets filenames containing spaces as separate arguments, preventing them from being scanned. It seems like with the current README.md command it is possible to evade secrets detection by naming files in this way.

To prevent that, it would be better to use the -z argument for git diff and git ls-files, splitting by NUL instead, and passing the arglist to detect-secrets-hook via xargs -0.

I'm not sure if the change needs to be made elsewhere as well, possibly in the .pre-commit hook?

Thanks!

Copy link
Collaborator

@KevinHock KevinHock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

git ls-files --help
....
-z
           \0 line termination on output and do not quote filenames. See OUTPUT below for more information.

and

man xargs
....
     -0      Change xargs to expect NUL (``\0'') characters as separators, instead of spaces and newlines.  This is expected to be
             used in concert with the -print0 function in find(1).

Thanks @psedge!

@KevinHock KevinHock merged commit c0a37d2 into Yelp:master Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants