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