Skip to content

Commit

Permalink
Merge pull request #4596 from fatalbanana/rbl_numeric_urls
Browse files Browse the repository at this point in the history
[Feature] rbl: support checking numeric URLs in isolation
  • Loading branch information
vstakhov committed Sep 12, 2023
2 parents aa4de77 + 076ca2c commit 7ff64cd
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lualib/plugins/rbl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ local check_types = {
},
urls = {},
content_urls = {},
numeric_urls = {},
emails = {},
replyto = {},
dkim = {},
Expand Down Expand Up @@ -212,4 +213,4 @@ return {
rule_schema = ts.shape(rule_schema_tbl),
default_options = default_options,
convert_checks = convert_checks,
}
}
5 changes: 4 additions & 1 deletion src/plugins/lua/rbl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ local function gen_rbl_callback(rule)
if rule.images then
table.insert(ex_params.flags, 'image')
end
if rule.numeric_urls then
table.insert(ex_params.flags, 'numeric')
end
end

local urls = lua_util.extract_specific_urls(ex_params)
Expand Down Expand Up @@ -805,7 +808,7 @@ local function gen_rbl_callback(rule)
description[#description + 1] = 'replyto'
end

if rule.urls or rule.content_urls or rule.images then
if rule.urls or rule.content_urls or rule.images or rule.numeric_urls then
pipeline[#pipeline + 1] = check_urls
description[#description + 1] = 'urls'
end
Expand Down
5 changes: 5 additions & 0 deletions test/functional/cases/001_merged/300_rbl.robot
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,8 @@ SELECTORS COMBINED
... Settings={symbols_enabled = [RBL_SELECTOR_MULTIPLE]}
Expect Symbol With Option RBL_SELECTOR_MULTIPLE example.org:sel_from
Expect Symbol With Option RBL_SELECTOR_MULTIPLE example.org:sel_helo

NUMERIC URLS
Scan File ${RSPAMD_TESTDIR}/messages/numeric_urls.eml
... Settings={symbols_enabled = [URIBL_NUMERIC]}
Expect Symbol With Exact Options URIBL_NUMERIC 4.3.2.1:url
5 changes: 5 additions & 0 deletions test/functional/configs/merged-local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,11 @@ options = {
type = a;
replies = ["127.0.0.2"];
},
{
name = "4.3.2.1.test9.uribl";
type = a;
replies = ["127.0.0.2"];
},
{
name = "8.8.8.8.test9.uribl";
type = a;
Expand Down
4 changes: 4 additions & 0 deletions test/functional/configs/merged-override.conf
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ rbl {
RSPAMD_EMAILBL = "127.0.0.2";
}
}
URIBL_NUMERIC {
checks = ["numeric_urls"];
rbl = "test9.uribl";
}
URIBL_NOCONTENT {
rbl = "test9.uribl";
ignore_defaults = true;
Expand Down
3 changes: 3 additions & 0 deletions test/functional/messages/numeric_urls.eml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Content-type: text/plain

numeric http://1.2.3.4 and not http://example.org ok

0 comments on commit 7ff64cd

Please sign in to comment.