Skip to content

Commit d3e8b09

Browse files
authored
Merge pull request #99 from moisseev/fuzzy-flags
Document fuzzy_check read_only default and flag uniqueness behavior
2 parents b94abe9 + c9befec commit d3e8b09

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

docs/modules/fuzzy_check.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ rule "FUZZY_EXAMPLE" {
5050
# Hash algorithm: mumhash (default), fasthash, xxhash, siphash
5151
algorithm = "mumhash";
5252
53-
# Allow learning to this storage (default: true = read-only)
53+
# Allow write operations (learning) to this storage; set true to disallow
5454
read_only = false;
5555
5656
# Map flags to symbols
@@ -187,7 +187,7 @@ Each `rule` section defines a fuzzy storage connection:
187187
| `max_score` | float || Global threshold for this rule (deprecated, use per-flag). |
188188
| `max_hits` | int || Maximum matches per message for this rule. |
189189
| `mime_types` | array || MIME types to check: `["*"]`, `["application/*"]`, etc. |
190-
| `read_only` | boolean | `true` | If `false`, allow learning to this storage. |
190+
| `read_only` | boolean | `false` | If `true`, disallow learning (write operations) to this storage. |
191191
| `skip_unknown` | boolean | `false` | If `true`, don't add default symbol for unmatched flags. |
192192
| `symbol` | string || Default symbol for this rule. |
193193
| `short_text_direct_hash` | boolean | `false` | Use exact hash for texts shorter than `min_length`. |
@@ -208,6 +208,12 @@ fuzzy_map = {
208208
}
209209
```
210210

211+
:::warning Flag Uniqueness for Writable Rules
212+
Flag numbers must be unique across all rules that do not have `read_only = true`. When Rspamd performs a write operation (add or delete), it sends the request to **all** rules whose `fuzzy_map` contains the matching flag and that are not read-only—regardless of which rule matched during scanning. If two writable rules share a flag and one storage rejects writes (e.g., a public third-party server that does not permit writes from your host), a 503 error will be returned.
213+
214+
To avoid this: use distinct flag numbers for each writable rule, or set `read_only = true` on third-party rules that should not receive write operations. Setting `read_only = true` on your own local storage rule instead will result in a 404 error when attempting to learn.
215+
:::
216+
211217
Different flags allow a single storage to contain multiple hash categories:
212218

213219
| Flag | Purpose | Example Symbol |

docs/tutorials/fuzzy_storage.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,19 @@ One option is `max_score`, which specifies the threshold for a hash weight:
375375

376376
The `mime_types` option specifies which attachment types are checked (or learned) using this fuzzy rule. This option takes a list of valid types in the following format: `["type/subtype", "*/subtype", "type/*", "*"]`, where `*` represents any valid type. In practice, it can be useful to save the hashes for all `application/*` attachments. Texts and embedded images are implicitly checked by `fuzzy_check` plugin, so there is no need to add `image/*` in the list of scanned attachments. Note that attachments and images are searched for an exact match, while texts are matched using the approximate algorithm (shingles).
377377

378-
`read_only` is quite an important option required for storage learning. It is set to `read_only=true` by default, restricting thus a storage's learning:
378+
`read_only` is quite an important option required for storage learning. By default, a rule allows learning (`read_only = false`):
379379

380380
~~~hcl
381381
read_only = true; # disallow learning
382-
read_only = false; # allow learning
382+
read_only = false; # allow learning (default)
383383
~~~
384384

385+
:::warning Flag Uniqueness for Writable Rules
386+
Flag numbers must be unique across all rules that do not have `read_only = true`. Write operations (add/delete) are sent to **all** rules whose `fuzzy_map` contains the matching flag and that are not read-only—regardless of which rule was used for scanning. If two writable rules share a flag and one storage rejects writes (e.g., a public or third-party server that does not permit writes from your host), a 503 error will be returned.
387+
388+
To avoid this: use distinct flag numbers for each writable rule, or explicitly set `read_only = true` on third-party rules that should not receive write operations. Setting `read_only = true` on your own local storage rule instead will result in a 404 error when attempting to learn.
389+
:::
390+
385391
`Encryption_key` parameter specifies the **public** key of a storage and enables encryption for all requests.
386392

387393
`Algorithm` parameter specifies the algorithm for generating hashes from text parts of emails (for attachments and images [blake2b](https://blake2.net/) is always used).

0 commit comments

Comments
 (0)