Open n0ts opened 8 years ago
The tests for git-secrets works both on my mac and on Travis, so I haven't run into this issue.
Can you give an example of a regex that doesn't work on both?
@mtdowling Thanks. Sorry for late reply. Hmm, I tried more times, I also working...
@mtdowling I use gnu grep 2.25 via homebrew (brew install --with-default-names grep).
$ grep --version
grep (GNU grep) 2.25
Packaged by Homebrew
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
My gitconfig grep and secret is below.
[pager]
grep = false
[secrets]
providers = git secrets --aws-provider
patterns = [A-Z0-9]{20}
patterns = (\"|')?(AWS|aws|Aws)?_?(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)(\"|')?\\s*(:|=>|=)\\s*(\"|')?[A-Za-z0-9/\\+=]{40}(\"|')?
patterns = (\"|')?(AWS|aws|Aws)?_?(ACCOUNT|account|Account)_?(ID|id|Id)?(\"|')?\\s*(:|=>|=)\\s*(\"|')?[0-9]{4}\\-?[0-9]{4}\\-?[0-9]{4}(\"|')?
allowed = AKIAIOSFODNN7EXAMPLE
allowed = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
So I create new files into the git repository. When I commit new files got a below error.
$ git init .
$ touch hoge_{1..10}
$ git add hoge_*
$ git commit -m "test" .
fatal: ambiguous argument 'hoge_1 hoge_10 hoge_2 hoge_3 hoge_4 hoge_5 hoge_6 hoge_7 hoge_8 hoge_9': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
I think that git-secret regular patterns is not compatible gnu grep.
$ git grep -nwHEI --cached "[A-Z0-9]{20}|("|')?(AWS|aws|Aws)?_?(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)("|')?\s*(:|=>|=)\s*("|')?[A-Za-z0-9/\+=]{40}("|')?|("|')?(AWS|aws|Aws)?_?(ACCOUNT|account|Account)_?(ID|id|Id)?("|')?\s*(:|=>|=)\s*("|')?[0-9]{4}\-?[0-9]{4}\-?[0-9]{4}("|')?|AKIAJYEVZ2UZKEDU3B2A|6U4Iwm/0u9aNPyIFA\+KYRkPZi42LDQMhAw9zlPNn" hoge_1 hoge_10 hoge_2 hoge_3 hoge_4 hoge_5 hoge_6 hoge_7 hoge_8 hoge_9
bash: syntax error near unexpected token `)'
@mtdowling What is status this issue? Thanks.
What version of git-secrets are you using? Can you try updating to the latest version? The ambiguous argument error looks unrelated to the regular expression that's being used.
As for the second, bash syntax error, that looks to be caused by not escaping the regex properly.
I use git-scretes 1.2.1.
I've been unable to reproduce this so far. What version of git are you using?
Thanks, Now I use git 2.10.1,
any progress on this? Also having same issue.
Steps to reproduce...
Dockerfile
:FROM ubuntu:17.04
# Ubuntu 16.10 (git 2.9.3 & grep 2.25) : OK
# Ubuntu 17.04 (git 2.11.0 & grep 2.27) : NG
RUN apt-get update \
&& apt-get install -y git
RUN apt-get install -y curl
RUN curl -L -o /tmp/git-secrets \
https://raw.githubusercontent.com/awslabs/git-secrets/1.2.1/git-secrets
RUN install /tmp/git-secrets /usr/local/bin/
RUN git config --global user.email "you@example.com" \
&& git config --global user.name "Your Name"
RUN mkdir /app
WORKDIR /app
RUN git --version ; grep --version | grep '^grep'
RUN git init
RUN git secrets --install && git secrets --register-aws
RUN touch a b c
RUN git add .
RUN git commit -m "Initial commit"
docker build .
I am also seeing this problem.
Note that I can commit one file at a time. But if I try to commit several files, I get an error message like
fatal: ambiguous argument 'file1 file2': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
macOS 10.12.6 git-secrets 1.2.1 git 2.15.1
Aktifkan
macOS's grep (BSD grep 2.5.1-FreeBSD) is not compatible gnu grep. So, commit-msg hook is always ERROR.