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,525 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const fixtures = require('haraka-test-fixtures');
5
-
6
- const _set_up = function (done) {
7
-
8
- this.plugin = new fixtures.plugin('helo.checks');
9
- this.plugin.config.root_path = path.resolve('tests', 'config');
10
-
11
- this.connection = fixtures.connection.createConnection();
12
- this.connection.remote.ip='208.75.199.19';
13
-
14
- this.plugin.register();
15
-
16
- done();
17
- }
18
-
19
- exports.init = {
20
- setUp: _set_up,
21
- 'ensure init is always run' (test) {
22
- test.expect(4);
23
- test.equal(this.plugin.register_hook.args[2][0], 'helo');
24
- test.equal(this.plugin.register_hook.args[2][1], 'init');
25
- test.equal(this.plugin.register_hook.args[3][0], 'ehlo');
26
- test.equal(this.plugin.register_hook.args[3][1], 'init');
27
- test.done();
28
- },
29
- 'hooks are registered' (test) {
30
- test.expect(1);
31
- test.equal(this.plugin.register_hook.args.length, 24)
32
- test.done();
33
- },
34
- 'test config is loaded' (test) {
35
- test.expect(1);
36
- test.deepEqual(this.plugin.cfg, {
37
- main: {},
38
- skip: { private_ip: true, whitelist: true, relaying: true },
39
- bigco: {
40
- 'msn.com': 'msn.com',
41
- 'hotmail.com': 'hotmail.com',
42
- 'yahoo.com': 'yahoo.com,yahoo.co.jp',
43
- 'yahoo.co.jp': 'yahoo.com,yahoo.co.jp',
44
- 'yahoo.co.uk': 'yahoo.co.uk',
45
- 'excite.com': 'excite.com,excitenetwork.com',
46
- 'mailexcite.com': 'excite.com,excitenetwork.com',
47
- 'aol.com': 'aol.com',
48
- 'compuserve.com': 'compuserve.com,adelphia.net',
49
- 'nortelnetworks.com': 'nortelnetworks.com,nortel.com',
50
- 'earthlink.net': 'earthlink.net',
51
- 'earthling.net': 'earthling.net',
52
- 'google.com': 'google.com',
53
- 'gmail.com': 'google.com,gmail.com'
54
- },
55
- check: {
56
- proto_mismatch: true,
57
- match_re: true,
58
- bare_ip: true,
59
- dynamic: true,
60
- big_company: true,
61
- valid_hostname: true,
62
- rdns_match: true,
63
- forward_dns: true,
64
- host_mismatch: true,
65
- literal_mismatch: 2
66
- },
67
- reject: {
68
- proto_mismatch: true,
69
- match_re: false,
70
- bare_ip: true,
71
- dynamic: true,
72
- big_company: true,
73
- valid_hostname: true,
74
- rdns_match: true,
75
- forward_dns: true,
76
- host_mismatch: true,
77
- literal_mismatch: 'true'
78
- },
79
- list_re: /^()$/i,
80
- })
81
- test.done();
82
- }
83
- }
84
-
85
- exports.host_mismatch = {
86
- setUp : _set_up,
87
- 'host_mismatch, reject=false' (test) {
88
- test.expect(2);
89
- const outer = this;
90
- this.plugin.init(() => {}, this.connection, 'helo.example.com');
91
- this.plugin.cfg.check.host_mismatch=true;
92
- this.plugin.cfg.reject.host_mismatch=false;
93
- this.plugin.host_mismatch(function () {
94
- test.equal(undefined, arguments[0]);
95
- test.ok(outer.connection.results.get('helo.checks').fail.length);
96
- test.done();
97
- }, this.connection, 'anything');
98
- },
99
- 'host_mismatch, reject=true' (test) {
100
- test.expect(2);
101
- const outer = this;
102
- this.plugin.init(() => { }, this.connection, 'helo.example.com');
103
- this.plugin.cfg.check.host_mismatch=true;
104
- this.plugin.cfg.reject.host_mismatch=true;
105
- this.plugin.host_mismatch(function () {
106
- test.equal(DENY, arguments[0]);
107
- test.ok(outer.connection.results.get('helo.checks').fail.length);
108
- test.done();
109
- }, this.connection, 'anything');
110
- },
111
- }
112
-
113
- exports.proto_mismatch = {
114
- setUp : _set_up,
115
- 'proto_mismatch, reject=false, esmtp=false' (test) {
116
- test.expect(2);
117
- const outer = this;
118
- this.plugin.init(() => {}, this.connection, 'helo.example.com');
119
- this.connection.esmtp = false;
120
- this.plugin.cfg.check.proto_mismatch=true;
121
- this.plugin.cfg.reject.proto_mismatch=false;
122
- this.plugin.proto_mismatch(function () {
123
- test.equal(undefined, arguments[0]);
124
- test.ok(outer.connection.results.get('helo.checks').fail.length);
125
- test.done();
126
- }, this.connection, 'anything', 'esmtp');
127
- },
128
- 'proto_mismatch, reject=false, esmtp=true' (test) {
129
- test.expect(2);
130
- const outer = this;
131
- this.plugin.init(() => { }, this.connection, 'helo.example.com');
132
- this.connection.esmtp = true;
133
- this.plugin.cfg.check.proto_mismatch=true;
134
- this.plugin.cfg.reject.proto_mismatch=false;
135
- this.plugin.proto_mismatch(function () {
136
- test.equal(undefined, arguments[0]);
137
- test.ok(outer.connection.results.get('helo.checks').fail.length === 0);
138
- test.done();
139
- }, this.connection, 'anything', 'esmtp');
140
- },
141
- 'proto_mismatch, reject=true' (test) {
142
- test.expect(2);
143
- const outer = this;
144
- this.plugin.init(() => { }, this.connection, 'helo.example.com');
145
- this.connection.esmtp = false;
146
- this.plugin.cfg.check.proto_mismatch=true;
147
- this.plugin.cfg.reject.proto_mismatch=true;
148
- this.plugin.proto_mismatch(function () {
149
- test.equal(DENY, arguments[0]);
150
- test.ok(outer.connection.results.get('helo.checks').fail.length);
151
- test.done();
152
- }, this.connection, 'anything', 'esmtp');
153
- },
154
- }
155
-
156
- exports.rdns_match = {
157
- setUp : _set_up,
158
- 'pass' (test) {
159
- test.expect(2);
160
- const outer = this;
161
- this.connection.remote.host='helo.example.com';
162
- this.plugin.cfg.check.rdns_match=true;
163
- this.plugin.cfg.reject.rdns_match=true;
164
- this.plugin.rdns_match(function () {
165
- test.equal(undefined, arguments[0]);
166
- test.ok(outer.connection.results.get('helo.checks').pass.length);
167
- test.done();
168
- }, this.connection, 'helo.example.com');
169
- },
170
- 'pass (org dom match)' (test) {
171
- test.expect(2);
172
- const outer = this;
173
- this.connection.remote.host='ehlo.example.com';
174
- this.plugin.cfg.check.rdns_match=true;
175
- this.plugin.cfg.reject.rdns_match=false;
176
- this.plugin.rdns_match(function () {
177
- test.equal(undefined, arguments[0]);
178
- test.ok(outer.connection.results.get('helo.checks').pass.length);
179
- test.done();
180
- }, this.connection, 'helo.example.com');
181
- },
182
- 'fail' (test) {
183
- test.expect(2);
184
- const outer = this;
185
- this.connection.remote.host='ehlo.gmail.com';
186
- this.plugin.cfg.check.rdns_match=true;
187
- this.plugin.cfg.reject.rdns_match=false;
188
- this.plugin.rdns_match(function () {
189
- test.equal(undefined, arguments[0]);
190
- test.ok(outer.connection.results.get('helo.checks').fail.length);
191
- test.done();
192
- }, this.connection, 'helo.example.com');
193
- },
194
- 'fail, reject' (test) {
195
- test.expect(2);
196
- const outer = this;
197
- this.connection.remote.host='ehlo.gmail.com';
198
- this.plugin.cfg.check.rdns_match=true;
199
- this.plugin.cfg.reject.rdns_match=true;
200
- this.plugin.rdns_match(function () {
201
- test.equal(DENY, arguments[0]);
202
- test.ok(outer.connection.results.get('helo.checks').fail.length);
203
- test.done();
204
- }, this.connection, 'helo.example.com');
205
- },
206
- }
207
-
208
- exports.bare_ip = {
209
- setUp : _set_up,
210
- 'pass' (test) {
211
- test.expect(2);
212
- const outer = this;
213
- this.plugin.cfg.check.bare_ip=true;
214
- this.plugin.cfg.reject.bare_ip=true;
215
- this.plugin.bare_ip(function () {
216
- test.equal(undefined, arguments[0]);
217
- test.ok(outer.connection.results.get('helo.checks').pass.length);
218
- test.done();
219
- }, this.connection, '[192.168.1.2]');
220
- },
221
- 'fail' (test) {
222
- test.expect(2);
223
- const outer = this;
224
- this.plugin.cfg.check.bare_ip=true;
225
- this.plugin.cfg.reject.bare_ip=false;
226
- this.plugin.bare_ip(function () {
227
- test.equal(undefined, arguments[0]);
228
- test.ok(outer.connection.results.get('helo.checks').fail.length);
229
- test.done();
230
- }, this.connection, '192.168.1.1');
231
- },
232
- 'fail, reject' (test) {
233
- test.expect(2);
234
- const outer = this;
235
- this.plugin.cfg.check.bare_ip=true;
236
- this.plugin.cfg.reject.bare_ip=true;
237
- this.plugin.bare_ip(function () {
238
- test.equal(DENY, arguments[0]);
239
- test.ok(outer.connection.results.get('helo.checks').fail.length);
240
- test.done();
241
- }, this.connection, '192.168.1.1');
242
- },
243
- }
244
-
245
- exports.dynamic = {
246
- setUp : _set_up,
247
- 'pass' (test) {
248
- test.expect(2);
249
- const outer = this;
250
- const test_helo = 'matt.simerson.tld';
251
- this.connection.remote.ip='208.75.177.99';
252
- this.plugin.cfg.check.dynamic=true;
253
- this.plugin.cfg.reject.dynamic=true;
254
- this.plugin.dynamic(function () {
255
- test.equal(undefined, arguments[0]);
256
- test.ok(outer.connection.results.get('helo.checks').pass.length);
257
- test.done();
258
- }, this.connection, test_helo);
259
- },
260
- 'fail' (test) {
261
- test.expect(2);
262
- const outer = this;
263
- const test_helo = 'c-76-121-96-159.hsd1.wa.comcast.net';
264
- this.connection.remote.ip='76.121.96.159';
265
- this.plugin.cfg.check.dynamic=true;
266
- this.plugin.cfg.reject.dynamic=false;
267
- this.plugin.dynamic(function () {
268
- test.equal(undefined, arguments[0]);
269
- test.ok(outer.connection.results.get('helo.checks').fail.length);
270
- test.done();
271
- }, this.connection, test_helo);
272
- },
273
- 'fail, reject' (test) {
274
- test.expect(2);
275
- const outer = this;
276
- const test_helo = 'c-76-121-96-159.hsd1.wa.comcast.net';
277
- this.connection.remote.ip='76.121.96.159';
278
- this.plugin.cfg.check.dynamic=true;
279
- this.plugin.cfg.reject.dynamic=true;
280
- this.plugin.dynamic(function () {
281
- test.equal(DENY, arguments[0]);
282
- test.ok(outer.connection.results.get('helo.checks').fail.length);
283
- test.done();
284
- }, this.connection, test_helo);
285
- },
286
- }
287
-
288
- exports.big_company = {
289
- setUp : _set_up,
290
- 'pass, reject=false' (test) {
291
- test.expect(2);
292
- const outer = this;
293
- const test_helo = 'yahoo.com';
294
- this.connection.remote.host='yahoo.com';
295
- this.plugin.cfg.check.big_company=true;
296
- this.plugin.cfg.reject.big_company=true;
297
- this.plugin.big_company(function () {
298
- test.equal(undefined, arguments[0]);
299
- test.ok(outer.connection.results.get('helo.checks').pass.length);
300
- test.done();
301
- }, this.connection, test_helo);
302
- },
303
- 'fail, reject=false' (test) {
304
- test.expect(2);
305
- const outer = this;
306
- const test_helo = 'yahoo.com';
307
- this.connection.remote.host='anything-else.com';
308
- this.connection.remote.is_private=false;
309
- this.plugin.cfg.check.big_company=true;
310
- this.plugin.cfg.reject.big_company=false;
311
- this.plugin.big_company(function () {
312
- test.equal(undefined, arguments[0]);
313
- test.ok(outer.connection.results.get('helo.checks').fail.length);
314
- test.done();
315
- }, this.connection, test_helo);
316
- },
317
- 'fail, reject=true' (test) {
318
- test.expect(2);
319
- const outer = this;
320
- const test_helo = 'yahoo.com';
321
- this.connection.remote.host='anything-else.com';
322
- this.plugin.cfg.check.big_company=true;
323
- this.plugin.cfg.reject.big_company=true;
324
- this.plugin.big_company(function () {
325
- test.equal(DENY, arguments[0]);
326
- test.ok(outer.connection.results.get('helo.checks').fail.length);
327
- test.done();
328
- }, this.connection, test_helo);
329
- },
330
- }
331
-
332
- exports.literal_mismatch = {
333
- setUp : _set_up,
334
- 'pass' (test) {
335
- test.expect(2);
336
- const outer = this;
337
- const test_helo = '[10.0.1.1]';
338
- this.connection.remote.ip='10.0.1.1';
339
- this.connection.remote.is_private=true;
340
- this.plugin.cfg.check.literal_mismatch=1;
341
- this.plugin.cfg.reject.literal_mismatch=true;
342
- this.plugin.literal_mismatch(function () {
343
- test.equal(undefined, arguments[0]);
344
- test.ok(outer.connection.results.get('helo.checks').skip.length);
345
- test.done();
346
- }, this.connection, test_helo);
347
- },
348
- 'pass, network' (test) {
349
- test.expect(2);
350
- const outer = this;
351
- const test_helo = '[10.0.1.1]';
352
- this.connection.remote.ip='10.0.1.2';
353
- this.connection.remote.is_private=true;
354
- this.plugin.cfg.check.literal_mismatch=2;
355
- this.plugin.cfg.reject.literal_mismatch=true;
356
- this.plugin.literal_mismatch(function () {
357
- test.equal(undefined, arguments[0]);
358
- test.ok(outer.connection.results.get('helo.checks').skip.length);
359
- test.done();
360
- }, this.connection, test_helo);
361
- },
362
- 'fail, reject=false' (test) {
363
- test.expect(2);
364
- const outer = this;
365
- const test_helo = '[10.0.1.1]';
366
- this.connection.remote.ip='10.0.1.2';
367
- this.connection.remote.is_private=true;
368
- this.plugin.cfg.check.literal_mismatch=0;
369
- this.plugin.cfg.reject.literal_mismatch=false;
370
- this.plugin.literal_mismatch(function () {
371
- test.equal(undefined, arguments[0]);
372
- test.ok(outer.connection.results.get('helo.checks').skip.length);
373
- test.done();
374
- }, this.connection, test_helo);
375
- },
376
- 'fail, reject=true' (test) {
377
- test.expect(2);
378
- const outer = this;
379
- const test_helo = '[10.0.1.1]';
380
- this.connection.remote.ip='10.0.1.2';
381
- this.connection.remote.is_private=true;
382
- this.plugin.cfg.check.literal_mismatch=0;
383
- this.plugin.cfg.reject.literal_mismatch=true;
384
- this.plugin.literal_mismatch(function () {
385
- test.equal(undefined, arguments[0]);
386
- test.ok(outer.connection.results.get('helo.checks').skip.length);
387
- test.done();
388
- }, this.connection, test_helo);
389
- },
390
- }
391
-
392
- exports.valid_hostname = {
393
- setUp : _set_up,
394
- 'pass' (test) {
395
- test.expect(2);
396
- const test_helo = 'great.domain.com';
397
- const outer = this;
398
- this.plugin.cfg.check.valid_hostname=true;
399
- this.plugin.cfg.reject.valid_hostname=true;
400
- this.plugin.valid_hostname(function () {
401
- test.equal(undefined, arguments[0]);
402
- test.ok(outer.connection.results.get('helo.checks').pass.length);
403
- test.done();
404
- }, this.connection, test_helo);
405
- },
406
- 'fail, reject=false' (test) {
407
- test.expect(2);
408
- const test_helo = 'great.domain.non-existent-tld';
409
- const outer = this;
410
- this.plugin.cfg.check.valid_hostname=true;
411
- this.plugin.cfg.reject.valid_hostname=false;
412
- this.plugin.valid_hostname(function () {
413
- test.equal(undefined, arguments[0]);
414
- test.ok(outer.connection.results.get('helo.checks').fail.length);
415
- test.done();
416
- }, this.connection, test_helo);
417
- },
418
- 'fail, reject=true' (test) {
419
- test.expect(2);
420
- const test_helo = 'great.domain.non-existent-tld';
421
- const outer = this;
422
- this.plugin.cfg.check.valid_hostname=true;
423
- this.plugin.cfg.reject.valid_hostname=true;
424
- this.plugin.valid_hostname(function () {
425
- test.equal(DENY, arguments[0]);
426
- test.ok(outer.connection.results.get('helo.checks').fail.length);
427
- test.done();
428
- }, this.connection, test_helo);
429
- },
430
- }
431
-
432
- exports.forward_dns = {
433
- setUp : _set_up,
434
- 'pass' (test) {
435
- test.expect(2);
436
- const outer = this;
437
- const test_helo = 'b.resolvers.level3.net';
438
- this.connection.remote.ip='4.2.2.2';
439
- this.plugin.cfg.check.forward_dns=true;
440
- this.plugin.cfg.reject.forward_dns=true;
441
- this.connection.results.add(this.plugin, {pass: 'valid_hostname'});
442
- this.plugin.forward_dns(function () {
443
- test.equal(undefined, arguments[0]);
444
- test.ok(outer.connection.results.get('helo.checks').pass.length);
445
- test.done();
446
- }, this.connection, test_helo);
447
- },
448
- 'fail, reject=false' (test) {
449
- test.expect(2);
450
- const outer = this;
451
- const test_helo = 'www.google.com';
452
- this.connection.remote.ip='66.128.51.163';
453
- this.plugin.cfg.check.forward_dns=true;
454
- this.plugin.cfg.reject.forward_dns=false;
455
- this.plugin.forward_dns(function () {
456
- test.equal(undefined, arguments[0]);
457
- test.ok(outer.connection.results.get('helo.checks').fail.length);
458
- test.done();
459
- }, this.connection, test_helo);
460
- },
461
- 'fail, reject=true' (test) {
462
- test.expect(2);
463
- const outer = this;
464
- const test_helo = 'www.google.com';
465
- this.connection.remote.ip = '66.128.51.163';
466
- this.plugin.cfg.check.forward_dns=true;
467
- this.plugin.cfg.reject.forward_dns=true;
468
- this.plugin.forward_dns(function () {
469
- test.equal(DENY, arguments[0]);
470
- test.ok(outer.connection.results.get('helo.checks').fail.length);
471
- test.done();
472
- }, this.connection, test_helo);
473
- },
474
- }
475
-
476
- exports.match_re = {
477
- setUp : _set_up,
478
- 'miss' (test) {
479
- test.expect(3);
480
- const test_helo = 'not_in_re_list.net';
481
- this.plugin.cfg.list_re = new RegExp(`^(${['bad.tld'].join('|')})$`, 'i');
482
- this.plugin.match_re((rc, msg) => {
483
- test.equal(undefined, rc);
484
- test.equal(undefined, msg);
485
- test.ok(this.connection.results.get('helo.checks').pass.length);
486
- test.done();
487
- }, this.connection, test_helo);
488
- },
489
- 'hit, reject=no' (test) {
490
- test.expect(3);
491
- const test_helo = 'ylmf-pc';
492
- this.plugin.cfg.reject.match_re = false;
493
- this.plugin.cfg.list_re = new RegExp(`^(${['ylmf-pc'].join('|')})$`, 'i');
494
- this.plugin.match_re((rc, msg) => {
495
- test.equal(undefined, rc);
496
- test.equal(undefined, msg);
497
- test.ok(this.connection.results.get('helo.checks').fail.length);
498
- test.done();
499
- }, this.connection, test_helo);
500
- },
501
- 'hit, reject=yes, exact' (test) {
502
- test.expect(3);
503
- const test_helo = 'ylmf-pc';
504
- this.plugin.cfg.reject.match_re = true;
505
- this.plugin.cfg.list_re = new RegExp(`^(${['ylmf-pc'].join('|')})$`, 'i');
506
- this.plugin.match_re((rc, msg) => {
507
- test.equal(DENY, rc);
508
- test.equal('That HELO not allowed here', msg);
509
- test.ok(this.connection.results.get('helo.checks').fail.length);
510
- test.done();
511
- }, this.connection, test_helo);
512
- },
513
- 'hit, reject=yes, pattern' (test) {
514
- test.expect(3);
515
- const test_helo = 'ylmf-pc';
516
- this.plugin.cfg.reject.match_re = true;
517
- this.plugin.cfg.list_re = new RegExp(`^(${['ylm.*'].join('|')})$`, 'i');
518
- this.plugin.match_re((rc, msg) => {
519
- test.equal(DENY, rc);
520
- test.equal('That HELO not allowed here', msg);
521
- test.ok(this.connection.results.get('helo.checks').fail.length);
522
- test.done();
523
- }, this.connection, test_helo);
524
- },
525
- }
@@ -1,116 +0,0 @@
1
- 'use strict';
2
-
3
- const fixtures = require('haraka-test-fixtures');
4
- const dns = require('dns');
5
-
6
- const _set_up = function (done) {
7
-
8
- this.plugin = new fixtures.plugin('mail_from.is_resolvable');
9
- this.plugin.register();
10
-
11
- this.connection = fixtures.connection.createConnection();
12
-
13
- this.connection.transaction = {
14
- notes: {},
15
- results: new fixtures.results(this.plugin),
16
- };
17
-
18
- done();
19
- }
20
-
21
- exports.mxErr = {
22
- setUp : _set_up,
23
- 'any.com, no err code' (test) {
24
- test.expect(3);
25
- const txn = this.connection.transaction;
26
- const err = new Error('oops');
27
- err.code = null;
28
- let called = false;
29
- function cb () { called = true; }
30
- const r = this.plugin.mxErr(this.connection, 'any.com', 'MX', err, cb);
31
- test.equal(r, true);
32
- test.equal(called, true);
33
- const mf = txn.results.get('mail_from.is_resolvable');
34
- test.equal(mf.msg[0], 'any.com:MX:oops');
35
- test.done();
36
- },
37
- 'any.com, bypass err code' (test) {
38
- test.expect(3);
39
- const txn = this.connection.transaction;
40
- const err = new Error('oops');
41
- err.code=dns.NOTFOUND;
42
- let called = false;
43
- function cb () { called = true; }
44
- const r = this.plugin.mxErr(this.connection, 'any.com', 'MX', err, cb);
45
- test.equal(r, false);
46
- test.equal(called, false);
47
- const mf = txn.results.get('mail_from.is_resolvable');
48
- test.equal(mf.msg[0], 'any.com:MX:oops');
49
- test.done();
50
- }
51
- }
52
-
53
- exports.implicit_mx = {
54
- setUp : _set_up,
55
- 'tnpi.net' (test) {
56
- test.expect(2);
57
- const txn = this.connection.transaction;
58
- this.plugin.implicit_mx(this.connection, 'tnpi.net', err => {
59
- test.equal(err, undefined);
60
- const mf = txn.results.get('mail_from.is_resolvable');
61
- test.equal(mf.pass.length, 1);
62
- test.done();
63
- });
64
- },
65
- 'harakamail.com' (test) {
66
- test.expect(1);
67
- const txn = this.connection.transaction;
68
- this.plugin.implicit_mx(this.connection, 'harakamail.com', () => {
69
- // console.log(arguments);
70
- const mf = txn.results.get('mail_from.is_resolvable');
71
- // console.log(mf);
72
- test.equal(mf.pass.length, 1);
73
- test.done();
74
- });
75
- },
76
- 'mx.theartfarm.com' (test) {
77
- test.expect(1);
78
- const txn = this.connection.transaction;
79
- this.plugin.implicit_mx(this.connection, 'mx.theartfarm.com', () => {
80
- const mf = txn.results.get('mail_from.is_resolvable');
81
- // console.log(mf);
82
- test.equal(mf.fail.length, 1);
83
- test.done();
84
- });
85
- },
86
- 'resolve-fail-definitive.josef-froehle.de' (test) {
87
- test.expect(1);
88
- const txn = this.connection.transaction;
89
- this.plugin.implicit_mx(this.connection, 'resolve-fail-definitive.josef-froehle.de', () => {
90
- const mf = txn.results.get('mail_from.is_resolvable');
91
- //console.log(mf);
92
- test.equal(mf.fail.length, 1);
93
- test.done();
94
- });
95
- },
96
- 'resolve-fail-a.josef-froehle.de' (test) {
97
- test.expect(1);
98
- const txn = this.connection.transaction;
99
- this.plugin.implicit_mx(this.connection, 'resolve-fail-a.josef-froehle.de', () => {
100
- const mf = txn.results.get('mail_from.is_resolvable');
101
- //console.log(mf);
102
- test.equal(mf.fail.length, 1);
103
- test.done();
104
- });
105
- },
106
- 'resolve-fail-aaaa.josef-froehle.de' (test) {
107
- test.expect(1);
108
- const txn = this.connection.transaction;
109
- this.plugin.implicit_mx(this.connection, 'resolve-fail-aaaa.josef-froehle.de', () => {
110
- const mf = txn.results.get('mail_from.is_resolvable');
111
- //console.log(mf);
112
- test.equal(mf.fail.length, 1);
113
- test.done();
114
- });
115
- },
116
- }