forked from pawnu/secDevLabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (61 loc) · 1.87 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
.SILENT:
.DEFAULT_GOAL := help
GO ?= go
GOROOT ?= $(shell $(GO) env GOROOT)
GOPATH ?= $(shell $(GO) env GOPATH)
GOBIN ?= $(GOPATH)/bin
GODEP ?= $(GOBIN)/dep
GOLINT ?= $(GOBIN)/golint
GOSEC ?= $(GOBIN)/gosec
A5APIBIN ?= a5ecommerceapi
COLOR_RESET = \033[0m
COLOR_COMMAND = \033[36m
COLOR_YELLOW = \033[33m
COLOR_GREEN = \033[32m
COLOR_RED = \033[31m
PROJECT := A5 Vulnerable Ecommerce API
PORT := 10005
SLEEPUNTILAPPSTARTS := 10
## Installs a development environment
install: generate-passwords compose msg
## Gets all go test dependencies
get-deps:
$(GO) get -u github.com/golang/dep/cmd/dep
$(GO) get -u golang.org/x/lint/golint
$(GO) get -u github.com/securego/gosec/cmd/gosec
## Checks depencies of the project
check-deps:
$(GODEP) ensure -v
## Runs a security static analysis using Gosec
check-sec:
$(GOSEC) ./... 2>/dev/null
## Perfoms all make tests
test: get-deps lint security-check
## Runs lint
lint:
$(GOLINT) $(shell $(GO) list ./...)
## Runs project using docker-compose
compose:
docker-compose -f deployments/docker-compose.yml down -v --remove-orphans
docker-compose -f deployments/docker-compose.yml up -d --build --force-recreate
## Generates passwords and set them as environment variables
generate-passwords:
chmod +x app/scripts/generate-passwords.sh
./app/scripts/generate-passwords.sh
## Prints initialization message after compose phase
msg:
chmod +x deployments/check-init.sh
./deployments/check-init.sh
## Prints help message
help:
printf "\n${COLOR_YELLOW}${PROJECT}\n------\n${COLOR_RESET}"
awk '/^[a-zA-Z\-\_0-9\.%]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf "${COLOR_COMMAND}$$ make %s${COLOR_RESET} %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST) | sort
printf "\n"