File: url_filter.lua

package info (click to toggle)
rspamd 3.14.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 35,064 kB
  • sloc: ansic: 247,728; cpp: 107,741; javascript: 31,385; perl: 3,089; asm: 2,512; pascal: 1,625; python: 1,510; sh: 589; sql: 313; makefile: 195; xml: 74
file content (51 lines) | stat: -rw-r--r-- 1,393 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--[[
URL Filter Configuration
This is a configuration template for the URL filter library.

The URL filter runs during parsing (before URL objects are created).
It provides fast validation to reject obvious garbage URLs.

Most users don't need to configure this - the defaults work well.
]]--

-- Enable/disable the filter
-- enabled = true;

-- Built-in filter configuration
-- builtin_filters = {
--   # Reject URLs with extremely long user fields
--   oversized_user = {
--     enabled = true;
--     max_length = 512;  # Absolute limit for user field length
--   };
--
--   # Reject URLs with invalid UTF-8
--   basic_unicode = {
--     enabled = true;
--     reject_invalid_utf8 = true;
--   };
--
--   # Reject obvious garbage patterns
--   garbage_pattern = {
--     enabled = true;
--     max_at_signs = 20;  # URLs with >20 @ signs are garbage
--   };
-- };

-- ADVANCED: Custom filters
-- You can add your own filters that run during URL parsing.
-- Filter function signature: function(url_text, url_obj, flags)
-- Return: "accept", "suspicious", or "reject"
--
-- Example:
-- custom_filters = {
--   my_domain_filter = function(url_text, url_obj, flags)
--     if url_obj then
--       local host = url_obj:get_host()
--       if host == "blocked-domain.com" then
--         return "reject"  -- Don't create URL object
--       end
--     end
--     return "accept"
--   end;
-- };