-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
315 lines (269 loc) · 5.78 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
USES := ldns libglog libidn2 opendkim openssl libseccomp
CXXFLAGS += -IPEGTL/include -Ijson/include
LDLIBS += \
-lboost_filesystem \
-lboost_iostreams \
-lboost_system \
-lcdb \
-lfmt \
-lgflags \
-lmagic \
-lopenarc \
-lopendmarc \
-lpsl \
-lresolv \
-lspf2 \
-lunistring
PROGRAMS := dns_tool smtp msg sasl snd socks5
arcsign_STEMS := arcsign \
message Domain IP IP4 IP6 Mailbox OpenARC OpenDKIM OpenDMARC Pill Reply osutil esc
arcverify_STEMS := arcverify \
message Domain IP IP4 IP6 Mailbox OpenARC OpenDKIM OpenDMARC Pill Reply osutil esc
DNS := DNS DNS-rrs DNS-fcrdns DNS-message
dns_tool_STEMS := dns_tool \
$(DNS) \
Domain \
IP \
IP4 \
IP6 \
POSIX \
SPF \
Sock \
SockBuffer \
TLS-OpenSSL \
esc \
osutil
msg_STEMS := msg \
CDB \
$(DNS) \
Domain \
IP \
IP4 \
IP6 \
Mailbox \
OpenDKIM \
OpenDMARC \
POSIX \
SPF \
Sock \
SockBuffer \
TLS-OpenSSL \
esc \
osutil
sasl_STEMS := sasl \
Base64 \
Domain \
IP \
IP4 \
IP6 \
POSIX \
Sock \
SockBuffer \
TLS-OpenSSL \
esc \
osutil
smtp_STEMS := smtp \
CDB \
$(DNS) \
Domain \
IP \
IP4 \
IP6 \
Mailbox \
MessageStore \
OpenARC \
OpenDKIM \
OpenDMARC \
POSIX \
Pill \
SPF \
Session \
Sock \
SockBuffer \
TLS-OpenSSL \
esc \
osutil
snd_STEMS := snd \
Base64 \
$(DNS) \
Domain \
IP \
IP4 \
IP6 \
Magic \
Mailbox \
MessageStore \
OpenDKIM \
OpenDMARC \
POSIX \
Pill \
SPF \
Sock \
SockBuffer \
TLS-OpenSSL \
esc \
osutil
socks5_STEMS := socks5 \
$(DNS) \
Domain \
IP \
IP4 \
IP6 \
POSIX \
Pill \
Sock \
SockBuffer \
TLS-OpenSSL \
esc \
osutil
TESTS := \
Base64-test \
CDB-test \
DNS-test \
Domain-test \
IP4-test \
IP6-test \
Magic-test \
Mailbox-test \
MessageStore-test \
Now-test \
OpenDKIM-test \
POSIX-test \
Pill-test \
SPF-test \
Session-test \
Sock-test \
SockBuffer-test \
TLD-test \
TLS-OpenSSL-test \
default_init_allocator-test \
esc-test \
iequal-test \
iobuffer-test \
is_ascii-test \
osutil-test
Base64-test_STEMS := Base64
CDB-test_STEMS := CDB osutil
DNS-test_STEMS := $(DNS) DNS-ldns Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
Domain-test_STEMS := Domain IP IP4 IP6
IP4-test_STEMS := Domain IP IP4 IP6
IP6-test_STEMS := Domain IP IP4 IP6
Magic-test_STEMS := Magic
Mailbox-test_STEMS := Mailbox Domain IP IP4 IP6 osutil
MessageStore-test_STEMS := $(DNS) Domain IP IP4 IP6 MessageStore Pill POSIX Sock SockBuffer TLS-OpenSSL esc osutil
OpenDKIM-test_STEMS := OpenDKIM
POSIX-test_STEMS := POSIX
Pill-test_STEMS := Pill
SPF-test_STEMS := $(DNS) Domain IP IP4 IP6 SPF POSIX Sock SockBuffer TLS-OpenSSL esc osutil
osutil-test_STEMS := osutil
Session-test_STEMS := \
CDB \
$(DNS) \
Domain \
IP \
IP4 \
IP6 \
Mailbox \
MessageStore \
OpenARC \
OpenDKIM \
OpenDMARC \
POSIX \
Pill \
SPF \
Session \
Sock \
SockBuffer \
TLS-OpenSSL \
esc \
osutil
Sock-test_STEMS := Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
SockBuffer-test_STEMS := Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
TLS-OpenSSL-test_STEMS := Domain IP IP4 IP6 POSIX TLS-OpenSSL osutil
esc-test_STEMS := esc
databases := \
accept_domains.cdb \
allow.cdb \
bad_recipients.cdb \
bad_recipients_data.cdb \
bad_senders.cdb \
block.cdb \
forward.cdb \
ip-block.cdb \
temp_fail.cdb
all:: $(databases) public_suffix_list.dat
TMPDIR ?= /tmp
export TEST_MAILDIR=$(TMPDIR)/Maildir
export MAILDIR=$(TEST_MAILDIR)
export ASAN_OPTIONS=detect_leaks=0
export GHSMTP_SERVER_ID=digilicious.com
export LLVM_PROFILE_FILE=smtp.profraw
$(TEST_MAILDIR):
mkdir -p $@
#smtp.cpp: smtp.rl
# ragel -o smtp.cpp smtp.rl
clean-test::
rm -f smtp.profraw
rm -f smtp.profdata
rm -rf $(TEST_MAILDIR)/*
%.cdb : % cdb-gen
./cdb-gen < $< | cdb -c $@
clean::
rm -f accept_domains.cdb
rm -f block.cdb
rm -f cdb-gen
rm -f forward.cdb
rm -f ip-block.cdb
rm -f allow.cdb
accept_domains.cdb: accept_domains cdb-gen
allow.cdb: allow cdb-gen
block.cdb: block cdb-gen
ip-block.cdb: ip-block cdb-gen
three-level-tlds.cdb: three-level-tlds cdb-gen
forward.cdb: forward
cat $< | cdb -c $@
public_suffix_list.dat:
wget --timestamping https://publicsuffix.org/list/public_suffix_list.dat
opt_flags := -Og
# safty_flags := # nada
# visibility_flags := # nada
lto_flags := # nada
include MKUltra/rules
regression:: $(programs) $(TEST_MAILDIR)
@for f in testcase_dir/* ; do \
echo -n test `basename $$f` ""; \
tmp_out=`mktemp`; \
valgrind ./smtp < $$f > $$tmp_out; \
diff testout_dir/`basename $$f` $$tmp_out && echo ...pass; \
rm $$tmp_out; \
done
check::
@for f in testcase_dir/* ; do \
echo -n test `basename $$f` ""; \
tmp_out=`mktemp`; \
./smtp < $$f > $$tmp_out; \
diff testout_dir/`basename $$f` $$tmp_out && echo ...pass; \
if [ -e smtp.profraw ] ; then mv smtp.profraw /tmp/smtp-profile/`basename $$f`; fi; \
rm $$tmp_out; \
done
net-check::
@for f in testcase_dir/* ; do \
echo -n test `basename $$f` ""; \
tmp_out=`mktemp`; \
ncat localhost 225 < $$f > $$tmp_out; \
diff testout_dir/`basename $$f` $$tmp_out && echo ...pass; \
if [ -e smtp.profraw ] ; then mv smtp.profraw /tmp/smtp-profile/`basename $$f`; fi; \
rm $$tmp_out; \
done
check:: msg snd
./msg --selftest
GHSMTP_CLIENT_ID=digilicious.com ./snd --selftest
show::
llvm-profdata merge -sparse /tmp/smtp-profile/* -o smtp.profdata
llvm-cov show ./smtp -instr-profile=smtp.profdata
init::
touch accept_domains bad_recipients bad_recipients_data bad_senders block ip-block temp_fail
sudo dnf install boost-devel file-devel fmt-devel glog-devel ldns-devel libidn2-devel tinycdb-devel libunistring-devel
.PHONY:: list
list:
@LC_ALL=C $(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | uniq | grep -E -v -e '^[^[:alnum:]]' -e '^$@$$'