forked from mboot-github/WhoisDomain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
194 lines (155 loc) · 5.13 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# ==========================================================
# ==========================================================
# https://docs.secure.software/cli
SHELL := /bin/bash -l
RLSECURE := ~/tmp/rl-secure/rl-secure
RLSTORE := ~/
WHAT := whoisdomain
DOCKER_WHO := mbootgithub
SIMPLEDOMAINS = $(shell ls testdata)
# PHONY targets: make will run its recipe regardless of whether a file with that name exists or what its last modification time is.
.PHONY: TestSimple TestSimple2 TestAll clean
first: reformat mypy
./test1.py # now tests with python 3.9
# ./testCache.py
second: first test2
# ==========================================================
# run a test sequence local only, no docker ,no upload to pypi
LocalTestSimple: reformat mypy test2
# ==========================================================
LocalTestWhl: build
./bin/testLocalWhl.sh 2>tmp/$@-2 | tee tmp/$@-1
# this step creates or updates the toml file
build:
./bin/build.sh
# ==========================================================
# scan the most recent build and fail if the status fails
rlsecure: rlsecure-scan rlsecure-list rlsecure-status rlsecure-report rlsecure-version
rlsecure-scan:
@export VERSION=$(shell cat work/version) && \
$(RLSECURE) scan \
--rl-store $(RLSTORE) \
--purl mboot-github/$(WHAT)@$${VERSION} \
--file-path dist/$(WHAT)-$${VERSION}*.whl \
--replace \
--no-tracking
rlsecure-list:
@export VERSION=$(shell cat work/version) && \
$(RLSECURE) list \
--rl-store $(RLSTORE) \
--show-all \
--purl mboot-github/$(WHAT)@$${VERSION} \
--no-color | tee rlsecure/list-$${VERSION}.txt
rlsecure-status:
@export VERSION=$(shell cat work/version) && \
$(RLSECURE) status \
--rl-store $(RLSTORE) \
--purl mboot-github/$(WHAT)@$${VERSION} \
--show-all \
--return-status \
--no-color | tee rlsecure/status-$${VERSION}.txt
rlsecure-report:
@export VERSION=$(shell cat work/version) && \
$(RLSECURE) report \
--rl-store $(RLSTORE) \
--purl mboot-github/$(WHAT)@$${VERSION} \
--format=all \
--bundle=report-$(WHAT)-$${VERSION}.zip \
--output-path ./rlsecure
rlsecure-version:
@$(RLSECURE) --version
# ==========================================================
# build a docker images with the latest python and run a test -a
dockerTests: docker dockerRunLocal dockerTestdata
testdocker:
export VERSION=$(shell cat work/version) && \
docker build \
--build-arg VERSION \
--tag $(DOCKER_WHO)/$(WHAT)-test \
--tag $(DOCKER_WHO)/$(WHAT)-$${VERSION}-test \
--tag $(WHAT)-$${VERSION}-test \
--tag $(WHAT)-test \
-f Dockerfile-test .
testdockerTestdata:
@export VERSION=$(shell cat work/version) && \
docker run \
-v ./testdata:/testdata \
$(WHAT)-$${VERSION}-test \
-f /testdata/DOMAINS.txt 2>tmp/$@-2 | \
tee tmp/$@-1
docker:
export VERSION=$(shell cat work/version) && \
docker build \
--build-arg VERSION \
--tag $(DOCKER_WHO)/$(WHAT) \
--tag $(DOCKER_WHO)/$(WHAT)-$${VERSION} \
--tag $(WHAT)-$${VERSION} \
--tag $(WHAT) \
-f Dockerfile .
dockerRunLocal:
export VERSION=$(shell cat work/version) && \
docker run \
-v ./testdata:/testdata \
$(WHAT)-$${VERSION} \
-d google.com -j | jq -r .
dockerTestdata:
@export VERSION=$(shell cat work/version) && \
docker run \
-v ./testdata:/testdata \
$(WHAT)-$${VERSION} \
-f /testdata/DOMAINS.txt 2>tmp/$@-2 | \
tee tmp/$@-1
dockerPush:
export VERSION=$(shell cat work/version) && \
docker image push \
--all-tags $(DOCKER_WHO)/$(WHAT)
# ====================================================
# uploading to pypi an pypiTestUpload
# build a test-mypi and download the image in a venv ane run a test
pypiTest: pypiTestUpload testTestPypi
# this is only the upload now for pypi builders
pypiTestUpload:
./bin/upload_to_pypiTest.sh
testTestPypi:
./bin/testTestPyPiUpload.sh 2>tmp/$@-2 | tee tmp/$@-1
releaseTest: build rlsecure pypiTestUpload testTestPypi
# this is for pypi owners after all tests have finished
pypi: rlsecure
./bin/upload_to_pypi.sh
release: build rlsecure pypi
# ====================================================
# full test runs with all supported tld's
# test2 has the data type in the output
test2: reformat mypy
./test2.py -f testdata/DOMAINS.txt 2> tmp/$@-2 | tee tmp/$@-1
# test3 simulates the whoisdomain command and has no data type in the output
test3: reformat mypy
./test3.py -f testdata/DOMAINS.txt 2> tmp/$@-2 | tee tmp/$@-1
# ====================================================
# update the sqlite db with the latest tld info and psl info and suggest missing tld's we can add with a simple fix
suggest:
( cd analizer; ./analizeIanaTld.py )
( cd analizer; ./investigateTld.py ) | tee out
# black pylama and mypy on the source directory
format:
./bin/reformat-code.sh
# black pylama and mypy on the source directory
reformat:
./bin/reformat-code.sh
# only verify --strict all python code
mypy:
mypy --strict *.py bin/*.py $(WHAT)
pylint:
python -m pylint --max-line-length=160 whoisdomain/ | \
awk '/missing/ && /docstring/ { next } \
/C0103/ { next } \
/too-many-lines/ { next } \
{ print}'
clean:
rm -rf tmp/*
rm -f ./rl-secure-list-*.txt
rm -f ./rl-secure-status-*.txt
docker image prune --all --force
cleanDist:
rm -rf dist/*
# rm -f work/version