Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helo.checks: only skip subsequent checks if success #3352

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- deps: bump all versions to latest #3303, #3344
- dkim: repackaged as NPM module #3311
- greylist: repackaged as NPM module
- helo.checks: require a successful HELO/EHLO #3352
- new NPM plugin dns-list, repackages dnsbl, dnswl, backscatterer #3313
- when using message-stream, don't send default options #3290
- rcpt_to.host_list: add connection ID to log messages #3322
Expand Down
13 changes: 0 additions & 13 deletions config/access.domains

This file was deleted.

2 changes: 0 additions & 2 deletions config/attachment.ctype.regex

This file was deleted.

1 change: 0 additions & 1 deletion config/attachment.filename.regex

This file was deleted.

61 changes: 0 additions & 61 deletions config/data.headers.ini

This file was deleted.

10 changes: 5 additions & 5 deletions plugins/helo.checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ exports.register = function () {
this.register_hook('ehlo', c);
}

// Always emit a log entry
this.register_hook('helo', 'emit_log');
this.register_hook('ehlo', 'emit_log');

// IP literal that doesn't match remote IP
this.register_hook('helo', 'literal_mismatch');
this.register_hook('ehlo', 'literal_mismatch');

this.cfg.check.literal_mismatch = this.cfg.check.literal_mismatch ?? 2;
this.cfg.reject.literal_mismatch = this.cfg.reject.literal_mismatch ?? false;

// Always emit a log entry
this.register_hook('helo', 'emit_log');
this.register_hook('ehlo', 'emit_log');

if (this.cfg.check.match_re) {
const load_re_file = () => {
const regex_list = utils.valid_regexes(this.config.get('helo.checks.regexps', 'list', load_re_file));
Expand Down Expand Up @@ -110,7 +110,7 @@ exports.init = function (next, connection, helo) {
}

exports.should_skip = function (connection, test_name) {
if (connection.results.has('helo.checks', '_skip_hooks', test_name)) {
if (connection.hello.host && connection.results.has('helo.checks', '_skip_hooks', test_name)) {
this.logdebug(connection, `SKIPPING: ${test_name}`);
return true;
}
Expand Down
8 changes: 6 additions & 2 deletions test/plugins/helo.checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,12 @@ describe('helo.checks', () => {
this.plugin.cfg.reject.big_company=true;
this.plugin.big_company((rc) => {
assert.equal(rc, DENY);
assert.ok(this.connection.results.get('helo.checks').fail.length);
done();
assert.equal(this.connection.results.get('helo.checks').fail.length, 1);
this.plugin.big_company((rc) => {
assert.equal(rc, DENY);
assert.ok(this.connection.results.get('helo.checks').fail.length, 2);
done();
}, this.connection, test_helo);
}, this.connection, test_helo);
})
})
Expand Down
Loading