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

Use `--` when invoking `grep` during `add_config` #240

Open sparr opened 1 year ago

sparr commented 1 year ago

Issue #, if available: Fixes #62

Description of changes: add_config invokes grep in two places to check for an existing identical pattern. This PR adds -- before the pattern so that grep won't interpret a pattern like "--foo" as an option.

Also add a test for this functionality. Also improve the error propagation in add_config, so that grep errors can be detected by tests.

This change should probably also be applied to some (all?) other grep and git grep invocations, but those are more complex cases without an outstanding bug report so I'm leaving them for now.

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