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

How do you add a pattern that begins with '-'? #62

Open
bknowles opened this issue Jan 25, 2018 · 4 comments · May be fixed by #240
Open

How do you add a pattern that begins with '-'? #62

bknowles opened this issue Jan 25, 2018 · 4 comments · May be fixed by #240
Labels
aged Issues that have gone more than 365 days without a response from the requester.

Comments

@bknowles
Copy link

bknowles commented Jan 25, 2018

So, I'm trying to add a pattern that looks like this:

-----BEGIN RSA PRIVATE KEY-----

However, I keep getting the following error, regardless of the options I provide:

$ git secrets --add --literal --global '-----BEGIN RSA PRIVATE KEY-----'
error: unknown option `---BEGIN RSA PRIVATE KEY-----'
usage: git secrets --scan [-r|--recursive] [--cached] [--no-index] [--untracked] [<files>...]
   or: git secrets --scan-history
   or: git secrets --install [-f|--force] [<target-directory>]
   or: git secrets --list [--global]
   or: git secrets --add [-a|--allowed] [-l|--literal] [--global] <pattern>
   or: git secrets --add-provider [--global] <command> [arguments...]
   or: git secrets --register-aws [--global]
   or: git secrets --aws-provider [<credentials-file>]

    --scan                Scans <files> for prohibited patterns
    --scan-history        Scans repo for prohibited patterns
    --install             Installs git hooks for Git repository or Git template directory
    --list                Lists secret patterns
    --add                 Adds a prohibited or allowed pattern, ensuring to de-dupe with existing patterns
    --add-provider        Adds a secret provider that when called outputs secret patterns on new lines
    --aws-provider        Secret provider that outputs credentials found in an ini file
    --register-aws        Adds common AWS patterns to the git config and scans for ~/.aws/credentials
    -r, --recursive       --scan scans directories recursively
    --cached              --scan scans searches blobs registered in the index file
    --no-index            --scan searches files in the current directory that is not managed by Git
    --untracked           In addition to searching in the tracked files in the working tree, --scan also in untracked files
    -f, --force           --install overwrites hooks if the hook already exists
    -l, --literal         --add and --add-allowed patterns are escaped so that they are literal
    -a, --allowed         --add adds an allowed pattern instead of a prohibited pattern
    --global              Uses the --global git config
@bknowles
Copy link
Author

Any suggestions how we can add new prohibited patterns where the string begins with dashes?

@ghost
Copy link

ghost commented Feb 1, 2018

Tried prefixing your pattern with -- (dash dash space)? This will cause the grep to treat is as a pattern not an arg.

@Rob-Conan
Copy link

Rob-Conan commented Sep 12, 2018

I wasn't able to fix this issue directly but I added the following patterns to my ~/.gitconfig file which has achieved the desired result for me

patterns = BEGIN\\s*CERTIFICATE
patterns = BEGIN\\s*RSA\\s*PRIVATE\\s*KEY

@beekeep
Copy link

beekeep commented May 8, 2019

I was running into a similar issue and was able to use the following pattern:

git secrets --add --global '(-){5}(BEGIN RSA PRIVATE KEY)(-){5}'

@plygrnd plygrnd added the aged Issues that have gone more than 365 days without a response from the requester. label May 28, 2020
@sparr sparr linked a pull request Jun 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aged Issues that have gone more than 365 days without a response from the requester.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants