Haraka 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/.eslintrc.yaml +5 -9
  2. package/.prettierrc.yml +1 -0
  3. package/CONTRIBUTORS.md +11 -0
  4. package/Changes.md +1365 -1214
  5. package/Plugins.md +117 -105
  6. package/README.md +4 -13
  7. package/bin/haraka +197 -298
  8. package/config/auth_flat_file.ini +1 -0
  9. package/config/dhparams.pem +8 -0
  10. package/config/mail_from.is_resolvable.ini +4 -2
  11. package/config/me +1 -0
  12. package/config/outbound.ini +0 -2
  13. package/config/plugins +36 -35
  14. package/config/smtp.ini +0 -1
  15. package/config/smtp.json +17 -0
  16. package/config/tls_cert.pem +23 -0
  17. package/config/tls_key.pem +28 -0
  18. package/connection.js +46 -73
  19. package/contrib/bsd-rc.d/haraka +3 -1
  20. package/contrib/plugin2npm.sh +6 -36
  21. package/docs/CoreConfig.md +2 -2
  22. package/docs/Logging.md +7 -21
  23. package/docs/Outbound.md +104 -201
  24. package/docs/Plugins.md +2 -2
  25. package/docs/Transaction.md +59 -82
  26. package/docs/plugins/queue/smtp_proxy.md +5 -10
  27. package/docs/plugins/tls.md +29 -9
  28. package/endpoint.js +16 -13
  29. package/haraka.js +10 -14
  30. package/host_pool.js +5 -5
  31. package/line_socket.js +3 -4
  32. package/logger.js +44 -28
  33. package/outbound/client_pool.js +27 -23
  34. package/outbound/config.js +4 -6
  35. package/outbound/fsync_writestream.js +1 -1
  36. package/outbound/hmail.js +178 -218
  37. package/outbound/index.js +86 -99
  38. package/outbound/qfile.js +1 -1
  39. package/outbound/queue.js +51 -44
  40. package/outbound/timer_queue.js +3 -2
  41. package/outbound/tls.js +19 -7
  42. package/package.json +59 -48
  43. package/plugins/.eslintrc.yaml +0 -6
  44. package/plugins/auth/auth_base.js +4 -2
  45. package/plugins/auth/auth_proxy.js +14 -12
  46. package/plugins/auth/auth_vpopmaild.js +1 -1
  47. package/plugins/block_me.js +1 -1
  48. package/plugins/data.signatures.js +2 -4
  49. package/plugins/early_talker.js +2 -1
  50. package/plugins/mail_from.is_resolvable.js +65 -135
  51. package/plugins/queue/deliver.js +4 -5
  52. package/plugins/queue/lmtp.js +11 -14
  53. package/plugins/queue/qmail-queue.js +2 -2
  54. package/plugins/queue/quarantine.js +2 -2
  55. package/plugins/queue/rabbitmq.js +16 -17
  56. package/plugins/queue/smtp_forward.js +3 -3
  57. package/plugins/queue/smtp_proxy.js +10 -1
  58. package/plugins/queue/test.js +2 -2
  59. package/plugins/rcpt_to.host_list_base.js +5 -5
  60. package/plugins/rcpt_to.in_host_list.js +2 -2
  61. package/plugins/relay.js +6 -7
  62. package/plugins/reseed_rng.js +1 -1
  63. package/plugins/status.js +37 -33
  64. package/plugins/tls.js +2 -2
  65. package/plugins/xclient.js +3 -2
  66. package/plugins.js +50 -54
  67. package/run_tests +3 -30
  68. package/server.js +190 -190
  69. package/smtp_client.js +30 -23
  70. package/{tests → test}/config/plugins +0 -2
  71. package/{tests → test}/config/smtp.ini +1 -1
  72. package/test/config/tls/example.com/_.example.com.key +28 -0
  73. package/test/config/tls/example.com/example.com.crt +25 -0
  74. package/test/connection.js +302 -0
  75. package/test/endpoint.js +94 -0
  76. package/{tests → test}/fixtures/line_socket.js +1 -1
  77. package/{tests → test}/fixtures/util_hmailitem.js +19 -25
  78. package/{tests → test}/host_pool.js +42 -57
  79. package/test/logger.js +258 -0
  80. package/test/outbound/hmail.js +141 -0
  81. package/test/outbound/index.js +220 -0
  82. package/test/outbound/qfile.js +126 -0
  83. package/test/outbound_bounce_net_errors.js +142 -0
  84. package/{tests → test}/outbound_bounce_rfc3464.js +110 -122
  85. package/test/plugins/auth/auth_base.js +484 -0
  86. package/test/plugins/auth/auth_vpopmaild.js +83 -0
  87. package/test/plugins/early_talker.js +104 -0
  88. package/test/plugins/mail_from.is_resolvable.js +35 -0
  89. package/test/plugins/queue/smtp_forward.js +206 -0
  90. package/test/plugins/rcpt_to.host_list_base.js +122 -0
  91. package/test/plugins/rcpt_to.in_host_list.js +193 -0
  92. package/test/plugins/relay.js +303 -0
  93. package/test/plugins/status.js +130 -0
  94. package/test/plugins/tls.js +70 -0
  95. package/test/plugins.js +228 -0
  96. package/test/rfc1869.js +73 -0
  97. package/test/server.js +491 -0
  98. package/test/smtp_client.js +299 -0
  99. package/test/tls_socket.js +273 -0
  100. package/test/transaction.js +270 -0
  101. package/tls_socket.js +202 -252
  102. package/transaction.js +8 -23
  103. package/CONTRIBUTING.md +0 -1
  104. package/bin/dkimverify +0 -40
  105. package/config/access.domains +0 -13
  106. package/config/attachment.ctype.regex +0 -2
  107. package/config/attachment.filename.regex +0 -1
  108. package/config/avg.ini +0 -5
  109. package/config/bounce.ini +0 -15
  110. package/config/data.headers.ini +0 -61
  111. package/config/dkim/dkim_key_gen.sh +0 -78
  112. package/config/dkim_sign.ini +0 -4
  113. package/config/dkim_verify.ini +0 -7
  114. package/config/dnsbl.ini +0 -23
  115. package/config/greylist.ini +0 -43
  116. package/config/helo.checks.ini +0 -52
  117. package/config/messagesniffer.ini +0 -18
  118. package/config/spamassassin.ini +0 -56
  119. package/dkim.js +0 -614
  120. package/docs/plugins/avg.md +0 -35
  121. package/docs/plugins/bounce.md +0 -69
  122. package/docs/plugins/clamd.md +0 -147
  123. package/docs/plugins/esets.md +0 -8
  124. package/docs/plugins/greylist.md +0 -90
  125. package/docs/plugins/helo.checks.md +0 -135
  126. package/docs/plugins/messagesniffer.md +0 -163
  127. package/docs/plugins/spamassassin.md +0 -180
  128. package/outbound/mx_lookup.js +0 -70
  129. package/plugins/auth/auth_ldap.js +0 -3
  130. package/plugins/avg.js +0 -162
  131. package/plugins/backscatterer.js +0 -25
  132. package/plugins/bounce.js +0 -381
  133. package/plugins/clamd.js +0 -382
  134. package/plugins/data.uribl.js +0 -4
  135. package/plugins/dkim_sign.js +0 -395
  136. package/plugins/dkim_verify.js +0 -62
  137. package/plugins/dns_list_base.js +0 -221
  138. package/plugins/dnsbl.js +0 -146
  139. package/plugins/dnswl.js +0 -58
  140. package/plugins/esets.js +0 -71
  141. package/plugins/graph.js +0 -5
  142. package/plugins/greylist.js +0 -645
  143. package/plugins/helo.checks.js +0 -533
  144. package/plugins/messagesniffer.js +0 -381
  145. package/plugins/rcpt_to.ldap.js +0 -3
  146. package/plugins/rcpt_to.max_count.js +0 -24
  147. package/plugins/spamassassin.js +0 -384
  148. package/tests/config/dkim/example.com/dns +0 -29
  149. package/tests/config/dkim/example.com/private +0 -6
  150. package/tests/config/dkim/example.com/public +0 -4
  151. package/tests/config/dkim/example.com/selector +0 -1
  152. package/tests/config/dkim.private.key +0 -6
  153. package/tests/config/dkim_sign.ini +0 -4
  154. package/tests/config/helo.checks.ini +0 -52
  155. package/tests/connection.js +0 -327
  156. package/tests/endpoint.js +0 -128
  157. package/tests/fixtures/vm_harness.js +0 -59
  158. package/tests/logger.js +0 -327
  159. package/tests/outbound/hmail.js +0 -112
  160. package/tests/outbound/index.js +0 -324
  161. package/tests/outbound/qfile.js +0 -67
  162. package/tests/outbound_bounce_net_errors.js +0 -173
  163. package/tests/plugins/auth/auth_base.js +0 -463
  164. package/tests/plugins/auth/auth_vpopmaild.js +0 -91
  165. package/tests/plugins/bounce.js +0 -307
  166. package/tests/plugins/clamd.js +0 -224
  167. package/tests/plugins/deprecated/relay_acl.js +0 -140
  168. package/tests/plugins/deprecated/relay_all.js +0 -59
  169. package/tests/plugins/dkim_sign.js +0 -315
  170. package/tests/plugins/dkim_signer.js +0 -108
  171. package/tests/plugins/dns_list_base.js +0 -259
  172. package/tests/plugins/dnsbl.js +0 -101
  173. package/tests/plugins/early_talker.js +0 -115
  174. package/tests/plugins/greylist.js +0 -58
  175. package/tests/plugins/helo.checks.js +0 -525
  176. package/tests/plugins/mail_from.is_resolvable.js +0 -116
  177. package/tests/plugins/queue/smtp_forward.js +0 -221
  178. package/tests/plugins/rcpt_to.host_list_base.js +0 -132
  179. package/tests/plugins/rcpt_to.in_host_list.js +0 -218
  180. package/tests/plugins/relay.js +0 -339
  181. package/tests/plugins/spamassassin.js +0 -171
  182. package/tests/plugins/status.js +0 -138
  183. package/tests/plugins/tls.js +0 -84
  184. package/tests/plugins.js +0 -247
  185. package/tests/rfc1869.js +0 -61
  186. package/tests/server.js +0 -510
  187. package/tests/smtp_client/auth.js +0 -105
  188. package/tests/smtp_client/basic.js +0 -101
  189. package/tests/smtp_client.js +0 -80
  190. package/tests/tls_socket.js +0 -333
  191. package/tests/transaction.js +0 -284
  192. /package/docs/{plugins → deprecated}/dkim_sign.md +0 -0
  193. /package/docs/{plugins → deprecated}/dkim_verify.md +0 -0
  194. /package/docs/{plugins → deprecated}/dnsbl.md +0 -0
  195. /package/docs/{plugins → deprecated}/dnswl.md +0 -0
  196. /package/{tests → test}/.eslintrc.yaml +0 -0
  197. /package/{tests → test}/config/auth_flat_file.ini +0 -0
  198. /package/{tests → test}/config/dhparams.pem +0 -0
  199. /package/{tests → test}/config/host_list +0 -0
  200. /package/{tests → test}/config/outbound_tls_cert.pem +0 -0
  201. /package/{tests → test}/config/outbound_tls_key.pem +0 -0
  202. /package/{tests → test}/config/smtp_forward.ini +0 -0
  203. /package/{tests → test}/config/tls/ec.pem +0 -0
  204. /package/{tests → test}/config/tls/haraka.local.pem +0 -0
  205. /package/{tests → test}/config/tls/mismatched.pem +0 -0
  206. /package/{tests → test}/config/tls.ini +0 -0
  207. /package/{tests → test}/config/tls_cert.pem +0 -0
  208. /package/{tests → test}/config/tls_key.pem +0 -0
  209. /package/{tests → test}/fixtures/todo_qfile.txt +0 -0
  210. /package/{tests → test}/installation/config/test-plugin-flat +0 -0
  211. /package/{tests → test}/installation/config/test-plugin.ini +0 -0
  212. /package/{tests → test}/installation/config/tls.ini +0 -0
  213. /package/{tests → test}/installation/node_modules/load_first/index.js +0 -0
  214. /package/{tests → test}/installation/node_modules/load_first/package.json +0 -0
  215. /package/{tests → test}/installation/node_modules/test-plugin/config/test-plugin-flat +0 -0
  216. /package/{tests → test}/installation/node_modules/test-plugin/config/test-plugin.ini +0 -0
  217. /package/{tests → test}/installation/node_modules/test-plugin/package.json +0 -0
  218. /package/{tests → test}/installation/node_modules/test-plugin/test-plugin.js +0 -0
  219. /package/{tests → test}/installation/plugins/base_plugin.js +0 -0
  220. /package/{tests → test}/installation/plugins/folder_plugin/index.js +0 -0
  221. /package/{tests → test}/installation/plugins/folder_plugin/package.json +0 -0
  222. /package/{tests → test}/installation/plugins/inherits.js +0 -0
  223. /package/{tests → test}/installation/plugins/load_first.js +0 -0
  224. /package/{tests → test}/installation/plugins/plugin.js +0 -0
  225. /package/{tests → test}/installation/plugins/tls.js +0 -0
  226. /package/{tests → test}/loud/config/dhparams.pem +0 -0
  227. /package/{tests → test}/loud/config/tls/goobered.pem +0 -0
  228. /package/{tests → test}/loud/config/tls.ini +0 -0
  229. /package/{tests → test}/mail_specimen/base64-root-part.txt +0 -0
  230. /package/{tests → test}/mail_specimen/varied-fold-lengths-preserve-data.txt +0 -0
  231. /package/{tests → test}/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_fixed +0 -0
  232. /package/{tests → test}/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka +0 -0
  233. /package/{tests → test}/queue/1508269674999_1508269674999_0_34002_socVUF_1_haraka +0 -0
  234. /package/{tests → test}/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka +0 -0
  235. /package/{tests → test}/queue/multibyte +0 -0
  236. /package/{tests → test}/queue/plain +0 -0
  237. /package/{tests → test}/queue/zero-length +0 -0
  238. /package/{tests → test}/test-queue/delete-me +0 -0
@@ -1,307 +0,0 @@
1
- 'use strict';
2
-
3
- const Address = require('address-rfc2821');
4
- const fixtures = require('haraka-test-fixtures');
5
- const message = require('haraka-email-message')
6
-
7
- const Connection = fixtures.connection;
8
-
9
- function _set_up (done) {
10
-
11
- this.plugin = new fixtures.plugin('bounce');
12
- this.plugin.cfg = {
13
- main: { },
14
- check: {
15
- reject_all: false,
16
- single_recipient: true,
17
- empty_return_path: true,
18
- bad_rcpt: true,
19
- non_local_msgid: true,
20
- },
21
- reject: {
22
- single_recipient:true,
23
- empty_return_path:true,
24
- non_local_msgid:true,
25
- },
26
- invalid_addrs: { 'test@bad1.com': true, 'test@bad2.com': true },
27
- };
28
-
29
- this.connection = Connection.createConnection();
30
- this.connection.remote.ip = '8.8.8.8';
31
- this.connection.transaction = {
32
- header: new message.Header(),
33
- results: new fixtures.results(this.plugin),
34
- };
35
-
36
- done();
37
- }
38
-
39
- exports.load_configs = {
40
- setUp : _set_up,
41
- 'load_bounce_ini' (test) {
42
- test.expect(3);
43
- this.plugin.load_bounce_ini();
44
- test.ok(this.plugin.cfg.main);
45
- test.ok(this.plugin.cfg.check);
46
- test.ok(this.plugin.cfg.reject);
47
- test.done();
48
- },
49
- 'load_bounce_bad_rcpt' (test) {
50
- test.expect(3);
51
- this.plugin.load_bounce_bad_rcpt();
52
- test.ok(this.plugin.cfg.main);
53
- test.ok(this.plugin.cfg.check);
54
- test.ok(this.plugin.cfg.reject);
55
- test.done();
56
- },
57
- }
58
-
59
- exports.reject_all = {
60
- setUp : _set_up,
61
- 'disabled' (test) {
62
- test.expect(1);
63
- this.connection.transaction.mail_from= new Address.Address('<matt@example.com>');
64
- this.connection.transaction.rcpt_to= [ new Address.Address('test@any.com') ];
65
- const cb = function () {
66
- test.equal(undefined, arguments[0]);
67
- };
68
- this.plugin.cfg.check.reject_all=false;
69
- this.plugin.reject_all(cb, this.connection, new Address.Address('<matt@example.com>'));
70
- test.done();
71
- },
72
- 'not bounce ok' (test) {
73
- test.expect(1);
74
- this.connection.transaction.mail_from= new Address.Address('<matt@example.com>');
75
- this.connection.transaction.rcpt_to= [ new Address.Address('test@any.com') ];
76
- const cb = function () {
77
- test.equal(undefined, arguments[0]);
78
- };
79
- this.plugin.cfg.check.reject_all=true;
80
- this.plugin.reject_all(cb, this.connection, new Address.Address('<matt@example.com>'));
81
- test.done();
82
- },
83
- 'bounce rejected' (test) {
84
- test.expect(1);
85
- this.connection.transaction.mail_from= new Address.Address('<>');
86
- this.connection.transaction.rcpt_to= [ new Address.Address('test@any.com') ];
87
- const cb = function () {
88
- test.equal(DENY, arguments[0]);
89
- };
90
- this.plugin.cfg.check.reject_all=true;
91
- this.plugin.reject_all(cb, this.connection, new Address.Address('<>'));
92
- test.done();
93
- },
94
- }
95
-
96
- exports.empty_return_path = {
97
- setUp : _set_up,
98
- 'none' (test) {
99
- test.expect(1);
100
- this.connection.transaction.mail_from= new Address.Address('<>');
101
- this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
102
- const cb = function () {
103
- test.equal(undefined, arguments[0]);
104
- };
105
- this.plugin.empty_return_path(cb, this.connection);
106
- test.done();
107
- },
108
- 'has' (test) {
109
- test.expect(1);
110
- this.connection.transaction.mail_from= new Address.Address('<>');
111
- this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
112
- this.connection.transaction.header.add('Return-Path', "Content doesn't matter");
113
- const cb = function () {
114
- test.equal(DENY, arguments[0]);
115
- };
116
- this.plugin.empty_return_path(cb, this.connection);
117
- test.done();
118
- },
119
- }
120
-
121
- exports.non_local_msgid = {
122
- setUp: _set_up,
123
- 'no_msgid_in_headers' (test) {
124
- test.expect(1);
125
- this.connection.transaction.mail_from= new Address.Address('<>');
126
- this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
127
- this.connection.transaction.body = new message.Body();
128
- this.connection.transaction.body.bodytext = '';
129
- const cb = function () {
130
- test.equal(DENY, arguments[0]);
131
- }
132
- this.plugin.non_local_msgid(cb, this.connection);
133
- test.done();
134
- },
135
- 'no_domains_in_msgid' (test) {
136
- test.expect(1);
137
- this.connection.transaction.mail_from= new Address.Address('<>');
138
- this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
139
- this.connection.transaction.body = new message.Body();
140
- this.connection.transaction.body.bodytext = 'Message-ID:<blah>';
141
- const cb = function () {
142
- test.equal(DENY, arguments[0]);
143
- }
144
- this.plugin.non_local_msgid(cb, this.connection);
145
- test.done();
146
- },
147
- 'invalid_domain' (test) {
148
- test.expect(2);
149
- this.connection.transaction.mail_from= new Address.Address('<>');
150
- this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
151
- this.connection.transaction.body = new message.Body();
152
- this.connection.transaction.body.bodytext = 'Message-ID: <blah@foo.cooooooom>';
153
- const cb = function () {
154
- test.equal(DENY, arguments[0]);
155
- test.ok(/without valid domain/.test(arguments[1]));
156
- }
157
- this.plugin.non_local_msgid(cb, this.connection);
158
- test.done();
159
- },
160
- /* - commented out because the code looks bogus to me - see comment in plugins/bounce.js - @baudehlo
161
- 'non-local': function (test) {
162
- test.expect(2);
163
- this.connection.transaction.mail_from= new Address.Address('<>');
164
- this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
165
- this.connection.transaction.body = new message.Body();
166
- this.connection.transaction.body.bodytext = 'Message-ID: <blah@foo.com>';
167
- var cb = function () {
168
- test.equal(DENY, arguments[0]);
169
- test.ok(/non-local Message-ID/.test(arguments[1]));
170
- }
171
- this.plugin.non_local_msgid(cb, this.connection);
172
- test.done();
173
- },
174
- */
175
- }
176
-
177
- exports.single_recipient = {
178
- setUp : _set_up,
179
- 'valid' (test) {
180
- test.expect(1);
181
- this.connection.transaction.mail_from= new Address.Address('<>');
182
- this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
183
- const cb = function () {
184
- test.equal(undefined, arguments[0]);
185
- };
186
- this.plugin.single_recipient(cb, this.connection);
187
- test.done();
188
- },
189
- 'invalid' (test) {
190
- test.expect(1);
191
- this.connection.transaction.mail_from= new Address.Address('<>');
192
- this.connection.transaction.rcpt_to= [
193
- new Address.Address('test@good.com'),
194
- new Address.Address('test2@good.com')
195
- ];
196
- const cb = function () {
197
- console.log(arguments[0]);
198
- test.equal(DENY, arguments[0]);
199
- };
200
- this.plugin.single_recipient(cb, this.connection);
201
- test.done();
202
- },
203
- 'test@example.com' (test) {
204
- test.expect(1);
205
- this.connection.transaction.mail_from= new Address.Address('<>');
206
- this.connection.transaction.rcpt_to= [ new Address.Address('test@example.com') ];
207
- const cb = function () {
208
- test.equal(undefined, arguments[0]);
209
- };
210
- this.plugin.single_recipient(cb, this.connection);
211
- test.done();
212
- },
213
- 'test@example.com,test2@example.com' (test) {
214
- test.expect(1);
215
- this.connection.transaction.mail_from= new Address.Address('<>');
216
- this.connection.transaction.rcpt_to= [
217
- new Address.Address('test1@example.com'),
218
- new Address.Address('test2@example.com'),
219
- ];
220
- const cb = function () {
221
- test.equal(DENY, arguments[0]);
222
- };
223
- this.plugin.single_recipient(cb, this.connection);
224
- test.done();
225
- },
226
- }
227
-
228
- exports.bad_rcpt = {
229
- setUp : _set_up,
230
- 'test@good.com' (test) {
231
- test.expect(1);
232
- this.connection.transaction.mail_from= new Address.Address('<>');
233
- this.connection.transaction.rcpt_to= [ new Address.Address('test@good.com') ];
234
- function cb (rc) {
235
- test.equal(undefined, rc);
236
- }
237
- this.plugin.bad_rcpt(cb, this.connection);
238
- test.done();
239
- },
240
- 'test@bad1.com' (test) {
241
- test.expect(1);
242
- this.connection.transaction.mail_from= new Address.Address('<>');
243
- this.connection.transaction.rcpt_to= [ new Address.Address('test@bad1.com') ];
244
- function cb (rc) {
245
- test.equal(DENY, rc);
246
- }
247
- this.plugin.cfg.invalid_addrs = {'test@bad1.com': true, 'test@bad2.com': true };
248
- this.plugin.bad_rcpt(cb, this.connection);
249
- test.done();
250
- },
251
- 'test@bad1.com, test@bad2.com' (test) {
252
- test.expect(1);
253
- this.connection.transaction.mail_from= new Address.Address('<>');
254
- this.connection.transaction.rcpt_to= [
255
- new Address.Address('test@bad1.com'),
256
- new Address.Address('test@bad2.com')
257
- ];
258
- function cb (rc) {
259
- test.equal(DENY, rc);
260
- }
261
- this.plugin.cfg.invalid_addrs = {'test@bad1.com': true, 'test@bad2.com': true };
262
- this.plugin.bad_rcpt(cb, this.connection);
263
- test.done();
264
- },
265
- 'test@good.com, test@bad2.com' (test) {
266
- test.expect(1);
267
- this.connection.transaction.mail_from= new Address.Address('<>');
268
- this.connection.transaction.rcpt_to= [
269
- new Address.Address('test@good.com'),
270
- new Address.Address('test@bad2.com')
271
- ];
272
- function cb (rc) {
273
- test.equal(DENY, rc);
274
- }
275
- this.plugin.cfg.invalid_addrs = {'test@bad1.com': true, 'test@bad2.com': true };
276
- this.plugin.bad_rcpt(cb, this.connection);
277
- test.done();
278
- },
279
- }
280
-
281
- exports.has_null_sender = {
282
- setUp : _set_up,
283
- '<>' (test) {
284
- test.expect(1);
285
- this.connection.transaction.mail_from= new Address.Address('<>');
286
- test.equal(true, this.plugin.has_null_sender(this.connection));
287
- test.done();
288
- },
289
- ' ' (test) {
290
- test.expect(1);
291
- this.connection.transaction.mail_from= new Address.Address('');
292
- test.equal(true, this.plugin.has_null_sender(this.connection));
293
- test.done();
294
- },
295
- 'user@example' (test) {
296
- test.expect(1);
297
- this.connection.transaction.mail_from= new Address.Address('user@example');
298
- test.equal(false, this.plugin.has_null_sender(this.connection));
299
- test.done();
300
- },
301
- 'user@example.com' (test) {
302
- test.expect(1);
303
- this.connection.transaction.mail_from= new Address.Address('user@example.com');
304
- test.equal(false, this.plugin.has_null_sender(this.connection));
305
- test.done();
306
- },
307
- }
@@ -1,224 +0,0 @@
1
- 'use strict';
2
-
3
- const net = require('net');
4
- const fixtures = require('haraka-test-fixtures');
5
-
6
- const Connection = fixtures.connection;
7
-
8
- function _set_up (done) {
9
-
10
- this.plugin = new fixtures.plugin('clamd');
11
- this.plugin.register();
12
-
13
- this.connection = Connection.createConnection();
14
- this.connection.init_transaction();
15
-
16
- done();
17
- }
18
-
19
- exports.load_clamd_ini = {
20
- setUp : _set_up,
21
- 'none' (test) {
22
- test.expect(1);
23
- test.deepEqual([], this.plugin.skip_list);
24
- test.done();
25
- },
26
- 'defaults' (test) {
27
- test.expect(6);
28
- const cfg = this.plugin.cfg.main;
29
- test.equal('localhost:3310', cfg.clamd_socket);
30
- test.equal(30, cfg.timeout);
31
- test.equal(10, cfg.connect_timeout);
32
- test.equal(26214400, cfg.max_size);
33
- test.equal(false, cfg.only_with_attachments);
34
- test.equal(false, cfg.randomize_host_order);
35
- test.done();
36
- },
37
- 'reject opts' (test) {
38
- test.expect(14);
39
- test.equal(true, this.plugin.rejectRE.test('Encrypted.'));
40
- test.equal(true, this.plugin.rejectRE.test('Heuristics.Structured.'));
41
- test.equal(true, this.plugin.rejectRE.test(
42
- 'Heuristics.Structured.CreditCardNumber'));
43
- test.equal(true, this.plugin.rejectRE.test('Broken.Executable.'));
44
- test.equal(true, this.plugin.rejectRE.test('PUA.'));
45
- test.equal(true, this.plugin.rejectRE.test(
46
- 'Heuristics.OLE2.ContainsMacros'));
47
- test.equal(true, this.plugin.rejectRE.test('Heuristics.Safebrowsing.'));
48
- test.equal(true, this.plugin.rejectRE.test(
49
- 'Heuristics.Safebrowsing.Suspected-phishing_safebrowsing.clamav.net'));
50
- test.equal(true, this.plugin.rejectRE.test(
51
- 'Sanesecurity.Junk.50402.UNOFFICIAL'));
52
- test.equal(false, this.plugin.rejectRE.test(
53
- 'Sanesecurity.UNOFFICIAL.oops'));
54
- test.equal(false, this.plugin.rejectRE.test('Phishing'));
55
- test.equal(false, this.plugin.rejectRE.test(
56
- 'Heuristics.Phishing.Email.SpoofedDomain'));
57
- test.equal(false, this.plugin.rejectRE.test('Suspect.Executable'));
58
- test.equal(false, this.plugin.rejectRE.test('MattWuzHere'));
59
- test.done();
60
- },
61
- }
62
-
63
- exports.hook_data = {
64
- setUp : _set_up,
65
- 'only_with_attachments, false' (test) {
66
- test.expect(2);
67
- test.equal(false, this.plugin.cfg.main.only_with_attachments);
68
- const next = function () {
69
- test.equal(false, this.connection.transaction.parse_body);
70
- test.done();
71
- }.bind(this);
72
- this.plugin.hook_data(next, this.connection);
73
- },
74
- 'only_with_attachments, true' (test) {
75
- this.plugin.cfg.main.only_with_attachments=true;
76
- test.expect(2);
77
- this.connection.transaction.attachment_hooks = () => {};
78
- const next = function () {
79
- test.equal(true, this.plugin.cfg.main.only_with_attachments);
80
- test.equal(true, this.connection.transaction.parse_body);
81
- test.done();
82
- }.bind(this);
83
- this.plugin.hook_data(next, this.connection);
84
- },
85
- }
86
-
87
- exports.hook_data_post = {
88
- setUp : _set_up,
89
- 'skip attachment' (test) {
90
- this.connection.transaction.notes = { clamd_found_attachment: false };
91
- this.plugin.cfg.main.only_with_attachments=true;
92
- test.expect(1);
93
- const next = function () {
94
- test.ok(this.connection.transaction.results.get('clamd').skip.length > 0);
95
- test.done();
96
- }.bind(this);
97
- this.plugin.hook_data_post(next, this.connection);
98
- },
99
- 'skip authenticated' (test) {
100
- this.connection.notes.auth_user = 'user';
101
- this.plugin.cfg.check.authenticated = false;
102
- test.expect(1);
103
- const next = function () {
104
- test.ok(this.connection.transaction.results.get('clamd').skip.length > 0);
105
- test.done();
106
- }.bind(this);
107
- this.plugin.hook_data_post(next, this.connection);
108
- },
109
- 'checks local IP' (test) {
110
- this.connection.remote.is_local = true;
111
- this.plugin.cfg.check.local_ip = true;
112
-
113
- test.expect(1);
114
- const next = function () {
115
- test.ok(this.connection.transaction.results.get('clamd').skip.length === 0);
116
- test.done();
117
- }.bind(this);
118
- this.plugin.hook_data_post(next, this.connection);
119
- },
120
- 'skips local IP' (test) {
121
- this.connection.remote.is_local = true;
122
- this.plugin.cfg.check.local_ip = false;
123
-
124
- test.expect(1);
125
- const next = function () {
126
- test.ok(this.connection.transaction.results.get('clamd').skip.length > 0);
127
- test.done();
128
- }.bind(this);
129
- this.plugin.hook_data_post(next, this.connection);
130
- },
131
- 'checks private IP' (test) {
132
- this.connection.remote.is_private = true;
133
- this.plugin.cfg.check.private_ip = true;
134
-
135
- test.expect(1);
136
- const next = function () {
137
- test.ok(this.connection.transaction.results.get('clamd').skip.length === 0);
138
- test.done();
139
- }.bind(this);
140
- this.plugin.hook_data_post(next, this.connection);
141
- },
142
- 'skips private IP' (test) {
143
- this.connection.remote.is_private = true;
144
- this.plugin.cfg.check.private_ip = false;
145
-
146
- test.expect(1);
147
- const next = function () {
148
- test.ok(this.connection.transaction.results.get('clamd').skip.length > 0);
149
- test.done();
150
- }.bind(this);
151
- this.plugin.hook_data_post(next, this.connection);
152
- },
153
- 'checks public ip' (test) {
154
- test.expect(1);
155
- const next = function () {
156
- test.ok(this.connection.transaction.results.get('clamd').skip.length === 0);
157
- test.done();
158
- }.bind(this);
159
- this.plugin.hook_data_post(next, this.connection);
160
- },
161
- 'skip localhost if check.local_ip = false and check.private_ip = true' (test) {
162
- this.connection.remote.is_local = true;
163
- this.connection.remote.is_private = true;
164
-
165
- this.plugin.cfg.check.local_ip = false;
166
- this.plugin.cfg.check.private_ip = true;
167
-
168
- test.expect(1);
169
- const next = function () {
170
- test.ok(this.connection.transaction.results.get('clamd').skip.length > 0);
171
- test.done();
172
- }.bind(this);
173
- this.plugin.hook_data_post(next, this.connection);
174
- },
175
- 'checks localhost if check.local_ip = true and check.private_ip = false' (test) {
176
- this.connection.remote.is_local = true;
177
- this.connection.remote.is_private = true;
178
-
179
- this.plugin.cfg.check.local_ip = true;
180
- this.plugin.cfg.check.private_ip = false;
181
-
182
- test.expect(1);
183
- const next = function () {
184
- test.ok(this.connection.transaction.results.get('clamd').skip.length === 0);
185
- test.done();
186
- }.bind(this);
187
- this.plugin.hook_data_post(next, this.connection);
188
- },
189
- 'message too big' (test) {
190
- this.connection.transaction.data_bytes=513;
191
- this.plugin.cfg.main.max_size=512;
192
- test.expect(1);
193
- const next = function () {
194
- test.ok(this.connection.transaction.results.get('clamd').skip.length > 0);
195
- test.done();
196
- }.bind(this);
197
- this.plugin.hook_data_post(next, this.connection);
198
- },
199
- }
200
-
201
- exports.send_clamd_predata = {
202
- setUp : _set_up,
203
- 'writes the proper commands to clamd socket' (test) {
204
- test.expect(1);
205
- const server = new net.createServer((socket) => {
206
- socket.on('data', (data) => {
207
- test.ok(data.toString(), `zINSTREAM\0Received: from Haraka clamd plugin\r\n`)
208
- // console.log(`${data.toString()}`)
209
- })
210
- socket.on('end', () => {
211
- test.done()
212
- })
213
- })
214
-
215
- server.listen(65535, () => {
216
- const client = new net.Socket();
217
- client.connect(65535, () => {
218
- this.plugin.send_clamd_predata(client, () => {
219
- client.end()
220
- })
221
- })
222
- })
223
- },
224
- }
@@ -1,140 +0,0 @@
1
- 'use strict';
2
-
3
- const fixtures = require('haraka-test-fixtures');
4
-
5
- function _set_up (done) {
6
-
7
- this.plugin = new fixtures.plugin('relay_acl');
8
- this.plugin.cfg = {};
9
-
10
- this.connection = fixtures.connection.createConnection();
11
- this.connection.transaction = {
12
- results: new fixtures.results(this.connection),
13
- };
14
-
15
- done();
16
- }
17
-
18
- exports.is_acl_allowed = {
19
- setUp : _set_up,
20
- 'bare IP' (test) {
21
- test.expect(3);
22
- this.plugin.acl_allow=['127.0.0.6'];
23
- this.connection.remote.ip='127.0.0.6';
24
- test.equal(true, this.plugin.is_acl_allowed(this.connection));
25
- this.connection.remote.ip='127.0.0.5';
26
- test.equal(false, this.plugin.is_acl_allowed(this.connection));
27
- this.connection.remote.ip='127.0.1.5';
28
- test.equal(false, this.plugin.is_acl_allowed(this.connection));
29
- test.done();
30
- },
31
- 'netmask' (test) {
32
- test.expect(3);
33
- this.plugin.acl_allow=['127.0.0.6/24'];
34
- this.connection.remote.ip='127.0.0.6';
35
- test.equal(true, this.plugin.is_acl_allowed(this.connection));
36
- this.connection.remote.ip='127.0.0.5';
37
- test.equal(true, this.plugin.is_acl_allowed(this.connection));
38
- this.connection.remote.ip='127.0.1.5';
39
- test.equal(false, this.plugin.is_acl_allowed(this.connection));
40
- test.done();
41
- },
42
- 'mixed (ipv4 & ipv6 (Issue #428))' (test) {
43
- test.expect(3);
44
- this.connection.remote.ip='2607:f060:b008:feed::2';
45
- test.equal(false, this.plugin.is_acl_allowed(this.connection));
46
-
47
- this.plugin.acl_allow=['2607:f060:b008:feed::2/64'];
48
- this.connection.remote.ip='2607:f060:b008:feed::2';
49
- test.equal(true, this.plugin.is_acl_allowed(this.connection));
50
-
51
- this.plugin.acl_allow=['127.0.0.6/24'];
52
- this.connection.remote.ip='2607:f060:b008:feed::2';
53
- test.equal(false, this.plugin.is_acl_allowed(this.connection));
54
-
55
- test.done();
56
- },
57
- }
58
-
59
- exports.relay_dest_domains = {
60
- setUp : _set_up,
61
- 'relaying' (test) {
62
- test.expect(2);
63
- const outer = this;
64
- function next () {
65
- // console.log(outer.connection.results.get('relay_acl'));
66
- // console.log(outer.connection.transaction.results.get('relay_acl'));
67
- test.equal(undefined, arguments[0]);
68
- test.equal(1, outer.connection.transaction.results.get('relay_acl').skip.length);
69
- test.done();
70
- }
71
- this.connection.relaying=true;
72
- this.plugin.relay_dest_domains(next, this.connection, [{host:'foo'}]);
73
- },
74
- 'no config' (test) {
75
- test.expect(2);
76
- const outer = this;
77
- function next () {
78
- test.equal(undefined, arguments[0]);
79
- test.equal(1, outer.connection.transaction.results.get('relay_acl').skip.length);
80
- test.done();
81
- }
82
- this.plugin.relay_dest_domains(next, this.connection, [{host:'foo'}]);
83
- },
84
- 'action=undef' (test) {
85
- test.expect(2);
86
- const outer = this;
87
- function next () {
88
- test.equal(DENY, arguments[0]);
89
- test.equal(1, outer.connection.transaction.results.get('relay_acl').fail.length);
90
- test.done();
91
- }
92
- this.plugin.cfg.domains = { foo: '{"action":"dunno"}' };
93
- this.plugin.relay_dest_domains(next, this.connection, [{host:'foo'}]);
94
- },
95
- 'action=deny' (test) {
96
- test.expect(2);
97
- const outer = this;
98
- function next () {
99
- test.equal(DENY, arguments[0]);
100
- test.equal(1, outer.connection.transaction.results.get('relay_acl').fail.length);
101
- test.done();
102
- }
103
- this.plugin.cfg.domains = { foo: '{"action":"deny"}' };
104
- this.plugin.relay_dest_domains(next, this.connection, [{host:'foo'}]);
105
- },
106
- 'action=continue' (test) {
107
- test.expect(2);
108
- const outer = this;
109
- function next () {
110
- test.equal(CONT, arguments[0]);
111
- test.equal(1, outer.connection.transaction.results.get('relay_acl').pass.length);
112
- test.done();
113
- }
114
- this.plugin.cfg.domains = { foo: '{"action":"continue"}' };
115
- this.plugin.relay_dest_domains(next, this.connection, [{host:'foo'}]);
116
- },
117
- 'action=accept' (test) {
118
- test.expect(2);
119
- const outer = this;
120
- function next () {
121
- test.equal(CONT, arguments[0]);
122
- test.equal(1, outer.connection.transaction.results.get('relay_acl').pass.length);
123
- test.done();
124
- }
125
- this.plugin.cfg.domains = { foo: '{"action":"continue"}' };
126
- this.plugin.relay_dest_domains(next, this.connection, [{host:'foo'}]);
127
- },
128
- }
129
-
130
- exports.refresh_config = {
131
- setUp : _set_up,
132
- 'callback' (test) {
133
- test.expect(1);
134
- function next () {
135
- test.equal(undefined, arguments[0]);
136
- test.done();
137
- }
138
- this.plugin.refresh_config(next, this.connection);
139
- },
140
- }