Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/about/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ See [Statistic configuration](/configuration/statistic), [Neural module](/module

Example custom rule:
```lua
-- /etc/rspamd/local.d/custom_rules.lua
-- /etc/rspamd/lua.local.d/custom_rule.lua
-- `custom_rule` basename is arbitrary
rspamd_config.SUSPICIOUS_ATTACHMENT = {
callback = function(task)
local parts = task:get_parts()
Expand Down
4 changes: 2 additions & 2 deletions docs/configuration/selectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ In general, you need not be overly concerned about type safety unless you encoun

## Own selectors

You have the option to incorporate your custom extractors and processing functions. However, it's crucial to implement this setup before utilizing these selectors in any other context. For instance, the execution of `rspamd.local.lua` precedes the initialization of plugins, making it a secure location to register your functions. Here is a small example about how to register your own extractors and processors.
You have the option to incorporate your custom extractors and processing functions. However, it's crucial to implement this setup before utilizing these selectors in any other context. For instance, the execution of scripts located inside `lua.local.d/` precedes the initialization of plugins, making it a secure location to register your functions. Here is a small example about how to register your own extractors and processors.

~~~lua
local lua_selectors = require "lua_selectors" -- Import module
Expand Down Expand Up @@ -398,7 +398,7 @@ You can use these functions in your selectors subsequently.

You can also leverage selectors with Rspamd's [regexp module](/modules/regexp). This approach allows you to utilize the data extracted and processed by the selector framework to match it against various regular expressions.

To start, you'll need to register a selector in the regexp module. You can achieve this by adding the following code to your `rspamd.local.lua` file:
To start, you'll need to register a selector in the regexp module. You can achieve this by adding the following code to a Lua script inside `lua.local.d/` directory:

~~~lua
rspamd_config:register_re_selector('test', 'user.lower;header(Subject).lower', ' ')
Expand Down
2 changes: 1 addition & 1 deletion docs/developers/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ title: Lua rules examples

Here is the collection of the useful Lua rules snippets that are not the official rules but could be used to filter specific spam.

To enable these snippets, you can place them to the `rspamd.local.lua` file. Typically it will be `/etc/rspamd/rspamd.local.lua` file for the Linux distros (or `/usr/local/etc/rspamd/rspamd.local.lua` for others).
To enable these snippets, you can place them to any `.lua` file located under the `lua.local.d` directory. Typically the path will be `/etc/rspamd/lua.local.d/` for the Linux distros (or `/usr/local/etc/rspamd/lua.local.d/` for others).



Expand Down
5 changes: 2 additions & 3 deletions docs/developers/writing_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ rspamd_config:register_symbol({
### Your first symbol

```lua
-- /etc/rspamd/local.d/custom_rules.lua
-- /etc/rspamd/lua.local.d/custom_rule.lua
-- `custom_rule` basename is arbitrary
local function always_fires(task)
return true
end
Expand Down Expand Up @@ -360,5 +361,3 @@ config['regexp']['SYMBOL'] = { callback = function(task) ... end }
| Post-filters | After normal filters and composites |
| Composites (pass 2) | Combine results including postfilters |
| Idempotent filters | Must not change result |


2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ enabled = false;

### How do I disable a specific rule?

Add a condition in `/etc/rspamd/rspamd.local.lua`:
Create a `.lua` file in `/etc/rspamd/lua.local.d/` and add a condition:

```lua
rspamd_config:add_condition('SOME_SYMBOL', function(task) return false end)
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/external_relay.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Different strategies for identifying mail to tamper with and the point of hand-o

If the strategies are too broad to be used in your setup you might limit them using `rspamd_config:add_condition()`, for example:
~~~lua
# /etc/rspamd/rspamd.local.lua
-- /etc/rspamd/lua.local.d/external_relay.lua
-- add some condition for the symbol called EXTERNAL_RELAY_COUNT
rspamd_config:add_condition('EXTERNAL_RELAY_COUNT', function(task)
-- only apply this rule if authenticated user is postmaster@example.net
Expand Down
11 changes: 6 additions & 5 deletions docs/tutorials/clickhouse_analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ extra_columns = {
"from_domain" = "from:domain";
"mime_type" = "header('Content-Type')";
"user_agent" = "header('User-Agent')";
# Custom selectors (must be registered in rspamd.local.lua first!)

# Custom selectors (must be registered in lua.local.d/ first!)
"attachment_count" = "attachment_count()";
"has_executable" = "has_dangerous_attachment()";
"attachment_extensions" = "attachment_types()";
Expand Down Expand Up @@ -229,10 +229,11 @@ Here's how to integrate custom selectors with ClickHouse from start to finish:

#### Step 1: Register Custom Selectors

First, register your custom selectors in `/etc/rspamd/rspamd.local.lua`:
First, register your custom selectors in `/etc/rspamd/lua.local.d/`:

```lua
-- /etc/rspamd/rspamd.local.lua
-- /etc/rspamd/lua.local.d/custom_selectors.lua
-- `custom_selectors` is arbitrary

local lua_selectors = require "lua_selectors"

Expand Down Expand Up @@ -560,7 +561,7 @@ ORDER BY Messages DESC;
```

**Key Points:**
- Selector names in `rspamd.local.lua` must match those used in `clickhouse.conf`
- Selector names in `lua.local.d/custom_selectors.lua` must match those used in `clickhouse.conf`
- All custom selectors return string values to ClickHouse
- Restart Rspamd after adding new selectors
- Custom columns appear automatically in the ClickHouse table
Expand Down