Parcourir la source

Merge branch 'master' of https://github.com/zricethezav/gitleaks into develop

zricethezav il y a 8 ans
Parent
commit
4b4fa00b69
2 fichiers modifiés avec 17 ajouts et 7 suppressions
  1. 15 6
      Dockerfile
  2. 2 1
      main.go

+ 15 - 6
Dockerfile

@@ -1,17 +1,26 @@
-FROM golang:1.10.0-alpine3.7
+FROM golang:1.10.0 AS build
+
+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
 
 
 WORKDIR /app
 WORKDIR /app
 
 
 RUN apk update && apk upgrade && apk add --no-cache bash git openssh
 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"]
 ENTRYPOINT ["gitleaks"]
 
 
-
 # How to use me :
 # How to use me :
 
 
 # docker build -t gitleaks .
 # docker build -t gitleaks .

+ 2 - 1
main.go

@@ -50,14 +50,15 @@ func init() {
 		"Info", "INFO", "env", "Env", "ENV", "environment", "Environment", "ENVIRONMENT"}
 		"Info", "INFO", "env", "Env", "ENV", "environment", "Environment", "ENVIRONMENT"}
 
 
 	regexes = map[string]*regexp.Regexp{
 	regexes = map[string]*regexp.Regexp{
+		"PKCS8":    regexp.MustCompile("-----BEGIN PRIVATE KEY-----"),
 		"RSA":      regexp.MustCompile("-----BEGIN RSA PRIVATE KEY-----"),
 		"RSA":      regexp.MustCompile("-----BEGIN RSA PRIVATE KEY-----"),
 		"SSH":      regexp.MustCompile("-----BEGIN OPENSSH PRIVATE KEY-----"),
 		"SSH":      regexp.MustCompile("-----BEGIN OPENSSH PRIVATE KEY-----"),
 		"Facebook": regexp.MustCompile("(?i)facebook.*['|\"][0-9a-f]{32}['|\"]"),
 		"Facebook": regexp.MustCompile("(?i)facebook.*['|\"][0-9a-f]{32}['|\"]"),
 		"Twitter":  regexp.MustCompile("(?i)twitter.*['|\"][0-9a-zA-Z]{35,44}['|\"]"),
 		"Twitter":  regexp.MustCompile("(?i)twitter.*['|\"][0-9a-zA-Z]{35,44}['|\"]"),
 		"Github":   regexp.MustCompile("(?i)github.*[['|\"]0-9a-zA-Z]{35,40}['|\"]"),
 		"Github":   regexp.MustCompile("(?i)github.*[['|\"]0-9a-zA-Z]{35,40}['|\"]"),
+		"AWS":      regexp.MustCompile("AKIA[0-9A-Z]{16}"),
 		"Reddit":   regexp.MustCompile("(?i)reddit.*['|\"][0-9a-zA-Z]{14}['|\"]"),
 		"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}"),
 		"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}"),
-		"AWS":      regexp.MustCompile("AKIA[0-9A-Z]{16}"),
 		// "Custom": regexp.MustCompile(".*")
 		// "Custom": regexp.MustCompile(".*")
 	}
 	}
 	assignRegex = regexp.MustCompile(`(=|:|:=|<-)`)
 	assignRegex = regexp.MustCompile(`(=|:|:=|<-)`)