How do you add a pattern that begins with '-'?
- Dominant language
- Shell
- Stars
- 13.4k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
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] [...]
or: git secrets --scan-history
or: git secrets --install [-f|--force] []
or: git secrets --list [--global]
or: git secrets --add [-a|--allowed] [-l|--literal] [--global]
or: git secrets --add-provider [--global] [arguments...]
or: git secrets --register-aws [--global]
or: git secrets --aws-provider []
--scan Scans 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
```
Contributor guide
Research direction
Start at the `git secrets --add` command and trace how its pattern argument is passed to option parsing. Reproduce the command with the literal RSA-key pattern, then verify that a pattern beginning with `-` is accepted and appears correctly in `git secrets --list`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- cli, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100