From eb1f94dd69512d84205128f9f23bad66a36ac584 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 10 Apr 2024 22:27:13 -0700 Subject: [PATCH] Release v1.1.0 (#6) - feat: imported backscatterer from haraka/Haraka --- .release | 2 +- CHANGELOG.md | 5 +++++ CONTRIBUTORS.md | 4 ++-- config/dns-list.ini | 3 +++ index.js | 21 +++++++++++++++++++++ package.json | 2 +- test/dns-list.js | 6 +++--- 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.release b/.release index e5763bc..36bb27a 160000 --- a/.release +++ b/.release @@ -1 +1 @@ -Subproject commit e5763bcea4decd4298e432b2d6251a364f755c12 +Subproject commit 36bb27a93862517943e04f24fd67b0df2da6cbbe diff --git a/CHANGELOG.md b/CHANGELOG.md index f484e6a..41af8c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Unreleased +### [1.1.0] - 2024-04-10 + +- feat: imported backscatterer from haraka/Haraka + ### [1.0.3] - 2024-04-10 - emit a log entry when all DNS lists pass (to show its working) @@ -24,3 +28,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). [1.0.1]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/1.0.1 [1.0.2]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/v1.0.2 [1.0.3]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/v1.0.3 +[1.1.0]: https://github.com/haraka/haraka-plugin-dns-list/releases/tag/v1.1.0 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e9858c7..c4c2d49 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,7 +2,7 @@ This handcrafted artisinal software is brought to you by: -|
msimerson (5) |
lnedry (1) | -| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | +|
msimerson (6) |
lnedry (1) | +| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | this file is maintained by [.release](https://github.com/msimerson/.release) diff --git a/config/dns-list.ini b/config/dns-list.ini index 3660d0f..c21e0e3 100644 --- a/config/dns-list.ini +++ b/config/dns-list.ini @@ -120,3 +120,6 @@ type=allow ; 1 = low – reduce chance of false positives (-1.0) ; 2 = medium – make sure to avoid false positives but allow override for clear cases (-10.0) ; 3 = high – avoid override (-100.0) + +[ips.backscatterer.org] +enable=false diff --git a/index.js b/index.js index 5959047..6f0495a 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,7 @@ exports.register = function () { for (const hook of ['ehlo', 'helo', 'mail']) { this.register_hook(hook, 'check_dnswl') } + this.register_hook('mail', 'check_backscatterer') } exports.load_config = function () { @@ -31,6 +32,7 @@ exports.load_config = function () { '*.reject', '*.ipv6', '*.loopback_is_rejected', + '-ips.backscatterer.org.enable', ], }, () => { @@ -158,6 +160,25 @@ exports.onConnect = function (next, connection) { exports.check_dnswl = (next, connection) => connection.notes.dnswl ? next(OK) : next() +exports.check_backscatterer = async function (next, connection, params) { + if (!this.cfg['ips.backscatterer.org'].enable) return next() + + const user = params[0]?.user ? params[0].user.toLowerCase() : null + if (!(!user || user === 'postmaster')) return next() + + try { + const a = await this.lookup(connection.remote.ip, 'ips.backscatterer.org') + if (a) + return next( + DENY, + `Host ${connection.remote.host} [${connection.remote.ip}] is listed by ips.backscatterer.org`, + ) + } catch (err) { + connection.logerror(this, err) + } + next() +} + function ipQuery(ip, zone) { // 1.2.3.4 -> 4.3.2.1.$zone. if (net.isIPv6(ip)) return [net_utils.ipv6_reverse(ip), zone, ''].join('.') diff --git a/package.json b/package.json index 9965ec7..cca2e1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "haraka-plugin-dns-list", - "version": "1.0.3", + "version": "1.1.0", "description": "Haraka plugin for DNS lists (DNSBL, DNSWL)", "main": "index.js", "files": [ diff --git a/test/dns-list.js b/test/dns-list.js index 8147fb1..438e7c3 100644 --- a/test/dns-list.js +++ b/test/dns-list.js @@ -17,12 +17,12 @@ describe('dns-list', function () { it('loads config/dns-list.ini', function () { this.plugin.load_config() - // console.log(this.plugin.cfg) assert.ok(this.plugin.cfg) }) it('config initializes a boolean', function () { assert.equal(this.plugin.cfg.stats.enable, false, this.plugin.cfg) + assert.equal(this.plugin.cfg['ips.backscatterer.org'].enable, false) }) it('sets up a connection', function () { @@ -83,10 +83,10 @@ describe('check_zone', function () { }) describe('check_zones', function () { - this.timeout(22000) + this.timeout(29000) it('tests each block list', async function () { - await this.plugin.check_zones(6000) + await this.plugin.check_zones(8000) }) })