-
Notifications
You must be signed in to change notification settings - Fork 9
/
GNUmakefile
129 lines (106 loc) · 3.63 KB
/
GNUmakefile
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.PHONY: \
all \
build \
install \
lint \
golangci \
vet \
fmt \
fmtcheck \
pretest \
test \
cov \
clean \
build-integration \
clean-integration \
fetch-rdb \
fetch-redis \
diff-cves \
diff-edbs \
diff-server-rdb \
diff-server-redis \
diff-server-rdb-redis
SRCS = $(shell git ls-files '*.go')
PKGS = $(shell go list ./...)
VERSION := $(shell git describe --tags --abbrev=0)
REVISION := $(shell git rev-parse --short HEAD)
BUILDTIME := $(shell date "+%Y%m%d_%H%M%S")
LDFLAGS := -X 'github.com/vulsio/go-msfdb/config.Version=$(VERSION)' \
-X 'github.com/vulsio/go-msfdb/config.Revision=$(REVISION)'
GO := CGO_ENABLED=0 go
all: build test
build: main.go
$(GO) build -ldflags "$(LDFLAGS)" -o go-msfdb $<
install: main.go
$(GO) install -ldflags "$(LDFLAGS)"
lint:
go install github.com/mgechev/revive@latest
revive -config ./.revive.toml -formatter plain $(PKGS)
golangci:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run
vet:
echo $(PKGS) | xargs env $(GO) vet || exit;
fmt:
gofmt -w $(SRCS)
fmtcheck:
$(foreach file,$(SRCS),gofmt -d $(file);)
pretest: lint vet fmtcheck
test: pretest
$(GO) test -cover -v ./... || exit;
cov:
@ go get -v github.com/axw/gocov/gocov
@ go get golang.org/x/tools/cmd/cover
gocov test | gocov report
clean:
$(foreach pkg,$(PKGS),go clean $(pkg) || exit;)
BRANCH := $(shell git symbolic-ref --short HEAD)
build-integration:
@ git stash save
$(GO) build -ldflags "$(LDFLAGS)" -o integration/go-msfdb.new
git checkout $(shell git describe --tags --abbrev=0)
@git reset --hard
$(GO) build -ldflags "$(LDFLAGS)" -o integration/go-msfdb.old
git checkout $(BRANCH)
-@ git stash apply stash@{0} && git stash drop stash@{0}
clean-integration:
-pkill go-msfdb.old
-pkill go-msfdb.new
-rm integration/go-msfdb.old integration/go-msfdb.new integration/go-msfdb.old.sqlite3 integration/go-msfdb.new.sqlite3
-rm -rf integration/diff
-docker kill redis-old redis-new
-docker rm redis-old redis-new
fetch-rdb:
integration/go-msfdb.old fetch msfdb --dbpath=integration/go-msfdb.old.sqlite3
integration/go-msfdb.new fetch msfdb --dbpath=integration/go-msfdb.new.sqlite3
fetch-redis:
docker run --name redis-old -d -p 127.0.0.1:6379:6379 redis
docker run --name redis-new -d -p 127.0.0.1:6380:6379 redis
integration/go-msfdb.old fetch msfdb --dbtype redis --dbpath "redis://127.0.0.1:6379/0"
integration/go-msfdb.new fetch msfdb --dbtype redis --dbpath "redis://127.0.0.1:6380/0"
diff-cves:
@ python integration/diff_server_mode.py cves --sample_rate 0.01
@ python integration/diff_server_mode.py multi-cves --sample_rate 0.01
diff-edbs:
@ python integration/diff_server_mode.py edbs --sample_rate 0.01
@ python integration/diff_server_mode.py multi-edbs --sample_rate 0.01
diff-server-rdb:
integration/go-msfdb.old server --dbpath=integration/go-msfdb.old.sqlite3 --port 1325 > /dev/null 2>&1 &
integration/go-msfdb.new server --dbpath=integration/go-msfdb.new.sqlite3 --port 1326 > /dev/null 2>&1 &
make diff-cves
make diff-edbs
pkill go-msfdb.old
pkill go-msfdb.new
diff-server-redis:
integration/go-msfdb.old server --dbtype redis --dbpath "redis://127.0.0.1:6379/0" --port 1325 > /dev/null 2>&1 &
integration/go-msfdb.new server --dbtype redis --dbpath "redis://127.0.0.1:6380/0" --port 1326 > /dev/null 2>&1 &
make diff-cves
make diff-edbs
pkill go-msfdb.old
pkill go-msfdb.new
diff-server-rdb-redis:
integration/go-msfdb.new server --dbpath=integration/go-msfdb.new.sqlite3 --port 1325 > /dev/null 2>&1 &
integration/go-msfdb.new server --dbtype redis --dbpath "redis://127.0.0.1:6380/0" --port 1326 > /dev/null 2>&1 &
make diff-cves
make diff-edbs
pkill go-msfdb.new