awslabs / git-secrets

Prevents you from committing secrets and credentials into git repositories
Apache License 2.0
12.36k stars 1.17k forks source link

Only break patterns by linebreak in the function load_combined_patterns #121

Closed ChristopherGAndrews closed 4 years ago

ChristopherGAndrews commented 5 years ago

Issue #120 Regexes with spaces and \s cause issues with different versions of git and grep

Description of changes:

The load_combined_patterns function was configured to only split the patterns variable by line breaks. This allows you to have spaces in your pattern, like:

password = [^ ]+

The \s pattern group is not properly recognized in all version of grep and git grep. Also, space is a valid character that you can build a pattern around.

Additionally, two tests were added:

  1. Verify that a pattern with a space in it like WHITE SPACE is not split into WHITE|SPACE
  2. Verify that a pattern with a space in it like WHITE SPACE will properly match

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

ChristopherGAndrews commented 5 years ago

Just checking to see if I am missing a step to get this PR approved or declined?

madchap commented 4 years ago

@mtdowling any chance to merge? (there seems to be a couple PRs ready for you to just push a button that would benefit quite a few people). Thanks.

ChristopherGAndrews commented 4 years ago

This code was merged to master in #137 .