mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 21:24:21 +01:00
Merge pull request #313 from zricethezav/bug/docker-update
adding docker push support again to Make and fixed a go vet nit
This commit is contained in:
3 files changed
+45
-40
No files matched your search
+2
-1
@@ -1,7 +1,8 @@
|
|||||||
FROM golang:1.13.4 AS build
|
FROM golang:1.13.4 AS build
|
||||||
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||||
|
ARG ldflags
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks *.go
|
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="${ldflags} *.go
|
||||||
|
|
||||||
FROM alpine:3.10
|
FROM alpine:3.10
|
||||||
RUN apk add --no-cache bash git openssh
|
RUN apk add --no-cache bash git openssh
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
||||||
PKG=github.com/zricethezav/gitleaks
|
PKG=github.com/zricethezav/gitleaks
|
||||||
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/version.Version=$(VERSION)"
|
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/version.Version=$(VERSION)"
|
||||||
|
_LDFLAGS="github.com/zricethezav/gitleaks/version.Version=$(VERSION)"
|
||||||
COVER=--cover --coverprofile=cover.out
|
COVER=--cover --coverprofile=cover.out
|
||||||
|
|
||||||
test-cover:
|
test-cover:
|
||||||
@@ -12,6 +13,7 @@ test-cover:
|
|||||||
test:
|
test:
|
||||||
go get golang.org/x/lint/golint
|
go get golang.org/x/lint/golint
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
|
go vet ./...
|
||||||
golint ./...
|
golint ./...
|
||||||
go test ./... --race $(PKG) -v
|
go test ./... --race $(PKG) -v
|
||||||
|
|
||||||
@@ -21,6 +23,7 @@ test-integration:
|
|||||||
build:
|
build:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
golint ./...
|
golint ./...
|
||||||
|
go vet ./...
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go build $(LDFLAGS)
|
go build $(LDFLAGS)
|
||||||
|
|
||||||
@@ -37,6 +40,6 @@ release-builds:
|
|||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
||||||
docker build -f Dockerfile -t $(REPO):$(TAG) .
|
docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
|
||||||
echo "Pushing $(REPO):$(COMMIT) $(REPO):$(TAG)"
|
echo "Pushing zricethezav/gitleaks:$(VERSION) and zricethezav/gitleaks:latest"
|
||||||
docker push $(REPO)
|
docker push zricethezav/gitleaks
|
||||||
+37
-36
@@ -79,7 +79,7 @@ type RegexTime struct {
|
|||||||
|
|
||||||
// Metadata is a struct used to communicate metadata about an audit like timings and total commit counts.
|
// Metadata is a struct used to communicate metadata about an audit like timings and total commit counts.
|
||||||
type Metadata struct {
|
type Metadata struct {
|
||||||
mux sync.Mutex
|
mux *sync.Mutex
|
||||||
data map[string]interface{}
|
data map[string]interface{}
|
||||||
|
|
||||||
timings chan interface{}
|
timings chan interface{}
|
||||||
@@ -103,6 +103,42 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewManager accepts options and returns a manager struct. The manager is a container for gitleaks configurations,
|
||||||
|
// options and channel receivers.
|
||||||
|
func NewManager(opts options.Options, cfg config.Config) (*Manager, error) {
|
||||||
|
cloneOpts, err := opts.CloneOptions()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := &Manager{
|
||||||
|
Opts: opts,
|
||||||
|
Config: cfg,
|
||||||
|
CloneOptions: cloneOpts,
|
||||||
|
|
||||||
|
stopChan: make(chan os.Signal, 1),
|
||||||
|
leakChan: make(chan Leak),
|
||||||
|
leakWG: &sync.WaitGroup{},
|
||||||
|
leakCache: make(map[string]bool),
|
||||||
|
metaWG: &sync.WaitGroup{},
|
||||||
|
metadata: Metadata{
|
||||||
|
RegexTime: make(map[string]int64),
|
||||||
|
timings: make(chan interface{}),
|
||||||
|
data: make(map[string]interface{}),
|
||||||
|
mux: new(sync.Mutex),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
signal.Notify(m.stopChan, os.Interrupt)
|
||||||
|
|
||||||
|
// start receiving leaks and metadata
|
||||||
|
go m.receiveLeaks()
|
||||||
|
go m.receiveMetadata()
|
||||||
|
go m.receiveInterrupt()
|
||||||
|
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetLeaks returns all available leaks
|
// GetLeaks returns all available leaks
|
||||||
func (manager *Manager) GetLeaks() []Leak {
|
func (manager *Manager) GetLeaks() []Leak {
|
||||||
// need to wait for any straggling leaks
|
// need to wait for any straggling leaks
|
||||||
@@ -195,41 +231,6 @@ func (manager *Manager) RecordTime(t interface{}) {
|
|||||||
manager.metadata.timings <- t
|
manager.metadata.timings <- t
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewManager accepts options and returns a manager struct. The manager is a container for gitleaks configurations,
|
|
||||||
// options and channel receivers.
|
|
||||||
func NewManager(opts options.Options, cfg config.Config) (*Manager, error) {
|
|
||||||
cloneOpts, err := opts.CloneOptions()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
m := &Manager{
|
|
||||||
Opts: opts,
|
|
||||||
Config: cfg,
|
|
||||||
CloneOptions: cloneOpts,
|
|
||||||
|
|
||||||
stopChan: make(chan os.Signal, 1),
|
|
||||||
leakChan: make(chan Leak),
|
|
||||||
leakWG: &sync.WaitGroup{},
|
|
||||||
leakCache: make(map[string]bool),
|
|
||||||
metaWG: &sync.WaitGroup{},
|
|
||||||
metadata: Metadata{
|
|
||||||
RegexTime: make(map[string]int64),
|
|
||||||
timings: make(chan interface{}),
|
|
||||||
data: make(map[string]interface{}),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
signal.Notify(m.stopChan, os.Interrupt)
|
|
||||||
|
|
||||||
// start receiving leaks and metadata
|
|
||||||
go m.receiveLeaks()
|
|
||||||
go m.receiveMetadata()
|
|
||||||
go m.receiveInterrupt()
|
|
||||||
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DebugOutput logs metadata and other messages that occurred during a gitleaks audit
|
// DebugOutput logs metadata and other messages that occurred during a gitleaks audit
|
||||||
func (manager *Manager) DebugOutput() {
|
func (manager *Manager) DebugOutput() {
|
||||||
log.Debugf("-------------------------\n")
|
log.Debugf("-------------------------\n")
|
||||||
|
|||||||
Reference in new issue
Block a user