summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLBahtarliev <22945773+lbahtarliev@users.noreply.github.com>2023-09-12 23:59:56 +0300
committerGitHub <noreply@github.com>2023-09-12 23:59:56 +0300
commit7846b2f3203c1fefce8560fb89ef198e2323d939 (patch)
tree1c0ef246d8dd5a2f52a7c9cbea99e0ef89199032
parent4824b17181d300954751b84272543ece4b81e9a7 (diff)
parent7ff64cd1359375974155e560c7d3200f03a4e500 (diff)
downloadrspamd-7846b2f3203c1fefce8560fb89ef198e2323d939.tar.gz
rspamd-7846b2f3203c1fefce8560fb89ef198e2323d939.zip
Merge branch 'rspamd:master' into master
-rw-r--r--lualib/plugins/rbl.lua3
-rw-r--r--lualib/rspamadm/mime.lua4
-rw-r--r--src/lua/lua_ip.c20
-rw-r--r--src/plugins/lua/rbl.lua5
-rw-r--r--src/ragel/content_disposition.rl4
-rw-r--r--test/functional/cases/001_merged/300_rbl.robot5
-rw-r--r--test/functional/configs/merged-local.conf5
-rw-r--r--test/functional/configs/merged-override.conf4
-rw-r--r--test/functional/messages/numeric_urls.eml3
9 files changed, 37 insertions, 16 deletions
diff --git a/lualib/plugins/rbl.lua b/lualib/plugins/rbl.lua
index bff53f9ba..02d0d3338 100644
--- a/lualib/plugins/rbl.lua
+++ b/lualib/plugins/rbl.lua
@@ -30,6 +30,7 @@ local check_types = {
},
urls = {},
content_urls = {},
+ numeric_urls = {},
emails = {},
replyto = {},
dkim = {},
@@ -212,4 +213,4 @@ return {
rule_schema = ts.shape(rule_schema_tbl),
default_options = default_options,
convert_checks = convert_checks,
-} \ No newline at end of file
+}
diff --git a/lualib/rspamadm/mime.lua b/lualib/rspamadm/mime.lua
index 0b0605582..6a589d66a 100644
--- a/lualib/rspamadm/mime.lua
+++ b/lualib/rspamadm/mime.lua
@@ -179,7 +179,7 @@ sign:option "-k --key"
:description "Use specific key of file"
:argname "<key>"
:count "1"
-sign:option "-t type"
+sign:option "-t --type"
:description "ARC or DKIM signing"
:argname("<arc|dkim>")
:convert {
@@ -1009,4 +1009,4 @@ return {
aliases = { 'mime_tool' },
handler = handler,
description = parser._description
-} \ No newline at end of file
+}
diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c
index 92a066406..ac24dc52b 100644
--- a/src/lua/lua_ip.c
+++ b/src/lua/lua_ip.c
@@ -87,24 +87,24 @@ LUA_FUNCTION_DEF(ip, to_table);
* @see ip:to_table() is that this method returns just hex strings for ipv6
* addresses.
* @return {table or nil} string octets of IP address or `nil` if IP is invalid
+ * @example
+local ip = rspamd_ip.from_string('fe80::11')
+print(table.concat(ip:str_octets(), "."))
+-- Output:
+-- f.e.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.1
*/
LUA_FUNCTION_DEF(ip, str_octets);
/***
- * @method ip:str_octets()
+ * @method ip:inversed_str_octets()
* Converts valid IP address to the table of string octets in reversed order. The difference from
* @see ip:to_table() is that this method returns just hex strings for ipv6
- * addresses.
+ * addresses in reversed order.
* @return {table or nil} string octets of IP address or `nil` if IP is invalid
* @example
-local ip = rspamd_ip.from_string('127.0.0.1')
-for _,o in ipairs(ip:to_table()) do
- print(o)
-end
+local ip = rspamd_ip.from_string('fe80::11')
+print(table.concat(ip:inversed_str_octets(), "."))
-- Output:
--- 1
--- 0
--- 0
--- 127
+-- 1.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f
*/
LUA_FUNCTION_DEF(ip, inversed_str_octets);
/***
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index 6dce0e0f1..c5cdbef1c 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -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)
@@ -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
diff --git a/src/ragel/content_disposition.rl b/src/ragel/content_disposition.rl
index 6087d3d17..862015ea1 100644
--- a/src/ragel/content_disposition.rl
+++ b/src/ragel/content_disposition.rl
@@ -13,8 +13,8 @@
(((FWS? qcontent)* FWS?) >Quoted_Str_Start %Quoted_Str_End)
DQUOTE) CFWS?;
token = 0x21..0x27 | 0x2a..0x2b | 0x2c..0x2e | 0x30..0x39 | 0x41..0x5a | 0x5e..0x7e;
- value = (quoted_string | (token -- '"' | 0x3d | utf8_2c | utf8_3c | utf8_4c)+) >Param_Value_Start %Param_Value_End;
- attribute = (quoted_string | (token -- '"' | 0x3d)+) >Param_Name_Start %Param_Name_End;
+ value = (quoted_string | (token -- ('"' | 0x3d | utf8_2c | utf8_3c | utf8_4c))+) >Param_Value_Start %Param_Value_End;
+ attribute = (quoted_string | (token -- ('"' | '='))+) >Param_Name_Start %Param_Name_End;
parameter = CFWS? attribute FWS? "=" FWS? value CFWS?;
ietf_token = token+;
diff --git a/test/functional/cases/001_merged/300_rbl.robot b/test/functional/cases/001_merged/300_rbl.robot
index 094eec409..c0e7fde95 100644
--- a/test/functional/cases/001_merged/300_rbl.robot
+++ b/test/functional/cases/001_merged/300_rbl.robot
@@ -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
diff --git a/test/functional/configs/merged-local.conf b/test/functional/configs/merged-local.conf
index 27738dd5e..82d609730 100644
--- a/test/functional/configs/merged-local.conf
+++ b/test/functional/configs/merged-local.conf
@@ -876,6 +876,11 @@ options = {
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;
replies = ["127.0.0.2"];
diff --git a/test/functional/configs/merged-override.conf b/test/functional/configs/merged-override.conf
index 74d9b441f..04b879db6 100644
--- a/test/functional/configs/merged-override.conf
+++ b/test/functional/configs/merged-override.conf
@@ -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;
diff --git a/test/functional/messages/numeric_urls.eml b/test/functional/messages/numeric_urls.eml
new file mode 100644
index 000000000..139a52c66
--- /dev/null
+++ b/test/functional/messages/numeric_urls.eml
@@ -0,0 +1,3 @@
+Content-type: text/plain
+
+numeric http://1.2.3.4 and not http://example.org ok