2018-03-12 22:57:10 +00:00
|
|
|
GIT_TAG?= $(shell git describe --always --tags)
|
2018-07-19 17:42:25 +01:00
|
|
|
BIN = gosec
|
2018-03-12 22:57:10 +00:00
|
|
|
FMT_CMD = $(gofmt -s -l -w $(find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr)
|
2018-08-19 01:28:17 +01:00
|
|
|
IMAGE_REPO = securego
|
2019-04-25 11:48:22 +01:00
|
|
|
BUILDFLAGS := '-w -s'
|
2018-08-15 08:53:33 +01:00
|
|
|
CGO_ENABLED = 0
|
2019-05-02 08:19:18 +01:00
|
|
|
GO := GO111MODULE=on go
|
|
|
|
GO_NOMOD :=GO111MODULE=off go
|
2020-01-06 08:47:28 +00:00
|
|
|
GOPATH ?= $(shell $(GO) env GOPATH)
|
|
|
|
GOBIN ?= $(GOPATH)/bin
|
|
|
|
GOLINT ?= $(GOBIN)/golint
|
|
|
|
GOSEC ?= $(GOBIN)/gosec
|
|
|
|
GINKGO ?= $(GOBIN)/ginkgo
|
2018-03-12 22:57:10 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
$(MAKE) build
|
|
|
|
|
2020-03-26 21:43:52 +00:00
|
|
|
install-test-deps:
|
2019-05-02 08:19:18 +01:00
|
|
|
$(GO_NOMOD) get -u github.com/onsi/ginkgo/ginkgo
|
2020-03-26 21:43:52 +00:00
|
|
|
$(GO_NOMOD) get -u golang.org/x/crypto/ssh
|
|
|
|
$(GO_NOMOD) get -u github.com/lib/pq
|
|
|
|
|
|
|
|
test: install-test-deps build fmt lint sec
|
2020-01-06 08:47:28 +00:00
|
|
|
$(GINKGO) -r -v
|
2018-07-27 13:41:45 +01:00
|
|
|
|
2019-05-02 08:19:18 +01:00
|
|
|
fmt:
|
|
|
|
@echo "FORMATTING"
|
|
|
|
@FORMATTED=`$(GO) fmt ./...`
|
|
|
|
@([[ ! -z "$(FORMATTED)" ]] && printf "Fixed unformatted files:\n$(FORMATTED)") || true
|
|
|
|
|
2020-01-06 08:47:28 +00:00
|
|
|
lint:
|
2019-05-02 08:19:18 +01:00
|
|
|
@echo "LINTING"
|
|
|
|
$(GO_NOMOD) get -u golang.org/x/lint/golint
|
2020-01-06 08:47:28 +00:00
|
|
|
$(GOLINT) -set_exit_status ./...
|
2019-05-02 08:19:18 +01:00
|
|
|
@echo "VETTING"
|
2020-01-06 08:47:28 +00:00
|
|
|
$(GO) vet ./...
|
2019-05-02 08:19:18 +01:00
|
|
|
|
2020-01-06 08:47:28 +00:00
|
|
|
sec:
|
2019-05-02 08:19:18 +01:00
|
|
|
@echo "SECURITY SCANNING"
|
|
|
|
./$(BIN) ./...
|
|
|
|
|
2020-03-26 21:43:52 +00:00
|
|
|
test-coverage: install-test-deps
|
2018-12-11 16:08:31 +00:00
|
|
|
go test -race -coverprofile=coverage.txt -covermode=atomic
|
|
|
|
|
2018-03-12 22:57:10 +00:00
|
|
|
build:
|
2018-07-19 17:42:25 +01:00
|
|
|
go build -o $(BIN) ./cmd/gosec/
|
2018-07-27 13:41:45 +01:00
|
|
|
|
2018-03-12 22:57:10 +00:00
|
|
|
clean:
|
2020-03-26 21:43:52 +00:00
|
|
|
rm -rf build vendor dist coverage.txt
|
2019-04-25 08:31:00 +01:00
|
|
|
rm -f release image $(BIN)
|
2018-07-27 13:41:45 +01:00
|
|
|
|
2020-01-06 08:47:28 +00:00
|
|
|
release:
|
2018-07-27 13:41:45 +01:00
|
|
|
@echo "Releasing the gosec binary..."
|
|
|
|
goreleaser release
|
2020-01-06 08:47:28 +00:00
|
|
|
|
2018-08-15 08:53:33 +01:00
|
|
|
build-linux:
|
|
|
|
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 go build -ldflags $(BUILDFLAGS) -o $(BIN) ./cmd/gosec/
|
2018-03-12 22:57:10 +00:00
|
|
|
|
2018-09-26 06:09:20 +01:00
|
|
|
image:
|
2018-03-12 22:57:10 +00:00
|
|
|
@echo "Building the Docker image..."
|
2018-07-27 13:41:45 +01:00
|
|
|
docker build -t $(IMAGE_REPO)/$(BIN):$(GIT_TAG) .
|
|
|
|
docker tag $(IMAGE_REPO)/$(BIN):$(GIT_TAG) $(IMAGE_REPO)/$(BIN):latest
|
2018-03-12 22:57:10 +00:00
|
|
|
touch image
|
|
|
|
|
|
|
|
image-push: image
|
|
|
|
@echo "Pushing the Docker image..."
|
2018-08-19 01:28:17 +01:00
|
|
|
docker push $(IMAGE_REPO)/$(BIN):$(GIT_TAG)
|
2018-03-12 22:57:10 +00:00
|
|
|
docker push $(IMAGE_REPO)/$(BIN):latest
|
|
|
|
|
2018-07-27 13:41:45 +01:00
|
|
|
.PHONY: test build clean release image image-push
|