Skip to content

Commit

Permalink
helo.checks: only skip subsequent checks if success
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed May 8, 2024
1 parent 2e6ff61 commit bf948fa
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 71 deletions.
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 bf948fa

Please sign in to comment.