From c4738ef26fe46d84dddd1a138aacae326b05736e Mon Sep 17 00:00:00 2001 From: zcong1993 <1005997919@qq.com> Date: Fri, 23 Feb 2018 11:52:41 +0800 Subject: [PATCH 1/4] reduce docker image size --- Dockerfile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7a9cba68..63c3aee9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,24 @@ -FROM golang:1.10.0-alpine3.7 +FROM golang:1.10.0 AS build -WORKDIR /app +ENV PROJECT /go/src/github.com/zricethezav/gitleaks + +RUN mkdir -p $PROJECT + +WORKDIR ${PROJECT} + +RUN git clone https://github.com/zricethezav/gitleaks.git . \ + && CGO_ENABLED=0 go build -o bin/gitleaks *.go + +FROM alpine:3.7 + +ENV PROJECT /go/src/github.com/zricethezav/gitleaks RUN apk update && apk upgrade && apk add --no-cache bash git openssh -COPY . ./ - -RUN go get -u github.com/zricethezav/gitleaks -RUN go build +COPY --from=build $PROJECT/bin/* /usr/bin/ ENTRYPOINT ["gitleaks"] - # How to use me : # docker build -t gitleaks . From 780123c5be07c66d65dd610c76514d4a2f3976a1 Mon Sep 17 00:00:00 2001 From: zcong1993 <1005997919@qq.com> Date: Fri, 23 Feb 2018 12:08:52 +0800 Subject: [PATCH 2/4] add docker WORKDIR --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 63c3aee9..20cef68e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,8 @@ FROM alpine:3.7 ENV PROJECT /go/src/github.com/zricethezav/gitleaks +WORKDIR /app + RUN apk update && apk upgrade && apk add --no-cache bash git openssh COPY --from=build $PROJECT/bin/* /usr/bin/ From 224ba4196840281af5b04485898bb40a762ebf92 Mon Sep 17 00:00:00 2001 From: Shawn Smith Date: Sat, 24 Feb 2018 17:02:59 -0500 Subject: [PATCH 3/4] Case insensitive regex matching This changes the current regexs to ones that aren't case sensitive. --- main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 30747703..cf84031a 100644 --- a/main.go +++ b/main.go @@ -43,12 +43,12 @@ func init() { regexes = map[string]*regexp.Regexp{ "RSA": regexp.MustCompile("-----BEGIN RSA PRIVATE KEY-----"), "SSH": regexp.MustCompile("-----BEGIN OPENSSH PRIVATE KEY-----"), - "Facebook": regexp.MustCompile("[f|F][a|A][c|C][e|E][b|B][o|O][o|O][k|K].*['|\"][0-9a-f]{32}['|\"]"), - "Twitter": regexp.MustCompile("[t|T][w|W][i|I][t|T][t|T][e|E][r|R].*['|\"][0-9a-zA-Z]{35,44}['|\"]"), - "Github": regexp.MustCompile("[g|G][i|I][t|T][h|H][u|U][b|B].*[['|\"]0-9a-zA-Z]{35,40}['|\"]"), + "Facebook": regexp.MustCompile("(?i)facebook.*['|\"][0-9a-f]{32}['|\"]"), + "Twitter": regexp.MustCompile("(?i)twitter.*['|\"][0-9a-zA-Z]{35,44}['|\"]"), + "Github": regexp.MustCompile("(?i)github.*[['|\"]0-9a-zA-Z]{35,40}['|\"]"), "AWS": regexp.MustCompile("AKIA[0-9A-Z]{16}"), - "Reddit": regexp.MustCompile("[r|R][e|E][d|D][d|D][i|I][t|T].*['|\"][0-9a-zA-Z]{14}['|\"]"), - "Heroku": regexp.MustCompile("[h|H][e|E][r|R][o|O][k|K][u|U].*[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}"), + "Reddit": regexp.MustCompile("(?i)reddit.*['|\"][0-9a-zA-Z]{14}['|\"]"), + "Heroku": regexp.MustCompile("(?i)heroku.*[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}"), // "Custom": regexp.MustCompile(".*") } assignRegex = regexp.MustCompile(`(=|:|:=|<-)`) From bc0dab1c567f6692c5a86822aca4851a2954f35a Mon Sep 17 00:00:00 2001 From: Alex Pliutau Date: Sun, 25 Feb 2018 20:10:57 +0700 Subject: [PATCH 4/4] #35 Add GCP service account key check: PKCS8 --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index cf84031a..3b0b2ba6 100644 --- a/main.go +++ b/main.go @@ -41,6 +41,7 @@ func init() { "Info", "INFO", "env", "Env", "ENV", "environment", "Environment", "ENVIRONMENT"} regexes = map[string]*regexp.Regexp{ + "PKCS8": regexp.MustCompile("-----BEGIN PRIVATE KEY-----"), "RSA": regexp.MustCompile("-----BEGIN RSA PRIVATE KEY-----"), "SSH": regexp.MustCompile("-----BEGIN OPENSSH PRIVATE KEY-----"), "Facebook": regexp.MustCompile("(?i)facebook.*['|\"][0-9a-f]{32}['|\"]"),