Skip to content

Commit

Permalink
helo.checks: only skip subsequent checks if success (#3352)
Browse files Browse the repository at this point in the history
- helo: emit log entry after all other hooks
- clean up stray config files from repackaged plugins
  • Loading branch information
msimerson committed May 8, 2024
1 parent 24fc2d3 commit 905a7a2
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 84 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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

0 comments on commit 905a7a2

Please sign in to comment.