[WIP] Refactor DNSBL response handling for detailed severity#2
Closed
[WIP] Refactor DNSBL response handling for detailed severity#2
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.
Original prompt
Problem
Currently, Maddy's DNSBL implementation treats all response codes within a configured range equally. When using combined DNSBLs like Spamhaus ZEN (
zen.spamhaus.org), different return codes indicate different listing types with different severity:127.0.0.2,127.0.0.3→ SBL (known spam sources) - high severity127.0.0.4-127.0.0.7→ XBL (exploited/compromised hosts) - high severity127.0.0.10,127.0.0.11→ PBL (policy block, dynamic IPs) - lower severityCurrently, Maddy:
127.0.0.1/24as a single "hit"127.0.0.3,127.0.0.11,127.0.0.4), they all count as one hit with one scoreThis means users who want different scores for different listing types must query separate lists (sbl.spamhaus.org, xbl.spamhaus.org, pbl.spamhaus.org), resulting in 3 DNS queries instead of 1.
Reference: https://docs.spamhaus.com/datasets/docs/source/40-real-world-usage/PublicMirrors/MTAs/020-Postfix.html
Proposed Solution
Add a new
responseconfiguration block that allows per-response-code scoring and custom messages:Implementation Details
1. Add new
ResponseRulestruct ininternal/check/dnsbl/dnsbl.go:2. Update
Liststruct to includeResponseRules:3. Update
ListedErrininternal/check/dnsbl/common.goto include score and message:4. Update
checkIPfunction ininternal/check/dnsbl/common.goto handle ResponseRules:ResponseRulesis configured, match each returned IP against rules and sum scoresResponsesis configured, use existing behavior for backwards compatibilitycheckIPWithRules(new) andcheckIPLegacy(existing behavior)5. Update
checkListsininternal/check/dnsbl/dnsbl.goto use score fromListedErr:ListedErr.Scorewhen set (new behavior)list.ScoreAdjfor backwards compatibility6. Update
readListCfgininternal/check/dnsbl/dnsbl.goto parse newresponseblocks:parseResponseRulefunction to handle the new syntax7. Update documentation in
docs/reference/checks/dnsbl.mdFiles to Modify
internal/check/dnsbl/dnsbl.go- Add ResponseRule struct, update List struct, update checkLists, update readListCfg, add parseResponseRuleinternal/check/dnsbl/common.go- Update ListedErr, update checkIP to handle ResponseRulesinternal/check/dnsbl/dnsbl_test.go- Add test cases for new functionalitydocs/reference/checks/dnsbl.md- Document the new response block syntaxBenefits
responses+scorestill works)Test Cases to Add
responseblocks → existing behavior preservedThis pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.