1313# permissions and limitations under the License.
1414
1515NONGIT_OK=1 OPTIONS_SPEC=" \
16- git secrets --scan [-r|--recursive] [--cached] [--no-index] [--untracked] [<files>...]
16+ git secrets --scan [-r|--recursive] [--cached] [-q|--quiet] [- -no-index] [--untracked] [<files>...]
1717git secrets --scan-history
1818git secrets --install [-f|--force] [<target-directory>]
1919git secrets --list [--global]
@@ -33,6 +33,7 @@ aws-provider Secret provider that outputs credentials found in an ini file
3333register-aws Adds common AWS patterns to the git config and scans for ~/.aws/credentials
3434r,recursive --scan scans directories recursively
3535cached --scan scans searches blobs registered in the index file
36+ q,quiet --scan shows results but removes error message from output
3637no-index --scan searches files in the current directory that is not managed by Git
3738untracked In addition to searching in the tracked files in the working tree, --scan also in untracked files
3839f,force --install overwrites hooks if the hook already exists
@@ -153,16 +154,18 @@ process_output() {
153154scan_with_fn_or_die () {
154155 local fn=" $1 " ; shift
155156 $fn " $@ " && exit 0
156- echo >&2
157- echo " [ERROR] Matched one or more prohibited patterns" >&2
158- echo >&2
159- echo " Possible mitigations:" >&2
160- echo " - Mark false positives as allowed using: git config --add secrets.allowed ..." >&2
161- echo " - Mark false positives as allowed by adding regular expressions to .gitallowed at repository's root directory" >&2
162- echo " - List your configured patterns: git config --get-all secrets.patterns" >&2
163- echo " - List your configured allowed patterns: git config --get-all secrets.allowed" >&2
164- echo " - List your configured allowed patterns in .gitallowed at repository's root directory" >&2
165- echo " - Use --no-verify if this is a one-time false positive" >&2
157+ if [ ${QUIET} -ne 1 ]; then
158+ echo >&2
159+ echo " [ERROR] Matched one or more prohibited patterns" >&2
160+ echo >&2
161+ echo " Possible mitigations:" >&2
162+ echo " - Mark false positives as allowed using: git config --add secrets.allowed ..." >&2
163+ echo " - Mark false positives as allowed by adding regular expressions to .gitallowed at repository's root directory" >&2
164+ echo " - List your configured patterns: git config --get-all secrets.patterns" >&2
165+ echo " - List your configured allowed patterns: git config --get-all secrets.allowed" >&2
166+ echo " - List your configured allowed patterns in .gitallowed at repository's root directory" >&2
167+ echo " - Use --no-verify if this is a one-time false positive" >&2
168+ fi
166169 exit 1
167170}
168171
@@ -294,7 +297,7 @@ assert_option_for_command() {
294297 fi
295298}
296299
297- declare COMMAND=" $1 " FORCE=0 RECURSIVE=0 LITERAL=0 GLOBAL=0 ALLOWED=0
300+ declare COMMAND=" $1 " FORCE=0 RECURSIVE=0 QUIET=0 LITERAL=0 GLOBAL=0 ALLOWED=0
298301declare SCAN_CACHED=0 SCAN_NO_INDEX=0 SCAN_UNTRACKED=0
299302
300303# Shift off the command name
@@ -309,6 +312,10 @@ while [ "$#" -ne 0 ]; do
309312 assert_option_for_command " --scan" " -r|--recursive"
310313 RECURSIVE=1
311314 ;;
315+ -q)
316+ assert_option_for_command " --scan" " -q|--quiet"
317+ QUIET=1
318+ ;;
312319 -a)
313320 assert_option_for_command " --add" " -a|--allowed"
314321 ALLOWED=1
0 commit comments