]> git.ipfire.org Git - thirdparty/rspamd.git/log
thirdparty/rspamd.git
3 weeks ago[Feature] Allow skipping local/auth'd mail in default bayes autolearn condition 5679/head
Andrew Lewis [Mon, 13 Oct 2025 14:58:53 +0000 (16:58 +0200)] 
[Feature] Allow skipping local/auth'd mail in default bayes autolearn condition

3 weeks agoMerge pull request #5678 from moisseev/search
Vsevolod Stakhov [Sun, 12 Oct 2025 20:01:46 +0000 (21:01 +0100)] 
Merge pull request #5678 from moisseev/search

[Minor] Add search syntax hint to history table filter input

3 weeks ago[Minor] Add search syntax hint to history table filter input 5678/head
Copilot [Sun, 12 Oct 2025 17:10:43 +0000 (20:10 +0300)] 
[Minor] Add search syntax hint to history table filter input

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: moisseev <2275981+moisseev@users.noreply.github.com>
3 weeks agoMerge pull request #5675 from moisseev/visibility
Vsevolod Stakhov [Sat, 11 Oct 2025 17:04:27 +0000 (18:04 +0100)] 
Merge pull request #5675 from moisseev/visibility

[Rework] Refactor element visibility control to use Bootstrap classes

4 weeks ago[Rework] Refactor element visibility control to use Bootstrap classes 5675/head
Copilot [Fri, 10 Oct 2025 17:17:41 +0000 (20:17 +0300)] 
[Rework] Refactor element visibility control to use Bootstrap classes

Replace inline styles and mixed jQuery methods with consistent helper functions and `d-none` class for better maintainability and performance.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: moisseev <2275981+moisseev@users.noreply.github.com>
4 weeks ago[Feature] Improve body rewriting support in rspamc and proxy
Vsevolod Stakhov [Fri, 10 Oct 2025 12:37:32 +0000 (13:37 +0100)] 
[Feature] Improve body rewriting support in rspamc and proxy

- Add --output-body option to rspamc for saving rewritten message body to file
  instead of printing to stdout
- Enable body_block protocol flag in proxy for non-milter mode to ensure
  message body is always available for rewriting operations
- This ensures consistent body rewriting capability across all protocol modes
  (rspamc, milter, and proxy)

4 weeks agoMerge pull request #5673 from rspamd/cursor/RSP-26-fix-milter-remove-headers-array...
Vsevolod Stakhov [Thu, 9 Oct 2025 18:48:58 +0000 (19:48 +0100)] 
Merge pull request #5673 from rspamd/cursor/RSP-26-fix-milter-remove-headers-array-handling-1740

Fix milter remove_headers array handling

4 weeks agofeat: Support array of positions for remove_headers 5673/head
Cursor Agent [Thu, 9 Oct 2025 15:45:51 +0000 (15:45 +0000)] 
feat: Support array of positions for remove_headers

Co-authored-by: v <v@rspamd.com>
4 weeks agoMerge pull request #5669 from rspamd/vstakhov-fuzzy-tcp-rework
Vsevolod Stakhov [Thu, 9 Oct 2025 15:42:21 +0000 (16:42 +0100)] 
Merge pull request #5669 from rspamd/vstakhov-fuzzy-tcp-rework

Add TCP protocol support for fuzzy storage

4 weeks agoMerge pull request #5672 from moisseev/liners
Vsevolod Stakhov [Thu, 9 Oct 2025 15:33:08 +0000 (16:33 +0100)] 
Merge pull request #5672 from moisseev/liners

[Test] Update JS linters

4 weeks ago[Test] Update JS linters 5672/head
Alexander Moisseev [Thu, 9 Oct 2025 13:20:16 +0000 (16:20 +0300)] 
[Test] Update JS linters

4 weeks ago[Fix] Fix double-release of fuzzy_tcp_session on invalid commands 5669/head
Vsevolod Stakhov [Thu, 9 Oct 2025 10:36:02 +0000 (11:36 +0100)] 
[Fix] Fix double-release of fuzzy_tcp_session on invalid commands

When a TCP command fails to parse in rspamd_fuzzy_tcp_io, the
fuzzy_tcp_session was released prematurely while cmd_session still
held a reference to it. This caused a double-release when cmd_session
was destroyed, potentially leading to memory corruption.

4 weeks agoMerge pull request #5671 from rspamd/cursor/RSP-278-fix-proxy-client-ip-forwarding...
Vsevolod Stakhov [Thu, 9 Oct 2025 10:07:32 +0000 (11:07 +0100)] 
Merge pull request #5671 from rspamd/cursor/RSP-278-fix-proxy-client-ip-forwarding-c0ae

Fix proxy client ip forwarding

4 weeks ago[Fix] Preserve IP header from upstream proxy in chain 5671/head
Vsevolod Stakhov [Thu, 9 Oct 2025 09:43:35 +0000 (10:43 +0100)] 
[Fix] Preserve IP header from upstream proxy in chain

4 weeks ago[Fix] Fix refcount leak in fuzzy_session destructor for TCP sessions
Vsevolod Stakhov [Thu, 9 Oct 2025 09:06:22 +0000 (10:06 +0100)] 
[Fix] Fix refcount leak in fuzzy_session destructor for TCP sessions

The fuzzy_session created for TCP command processing holds a reference
to its parent fuzzy_tcp_session but failed to release it in the destructor,
causing a refcount leak and potential use-after-free issue.

4 weeks ago[Fix] Use rspamd event wrapper consistently for TCP session timer
Vsevolod Stakhov [Thu, 9 Oct 2025 08:55:34 +0000 (09:55 +0100)] 
[Fix] Use rspamd event wrapper consistently for TCP session timer

The TCP session timer was incorrectly mixing rspamd's rspamd_io_ev wrapper
with direct libev API calls (ev_timer_init/start/stop), creating inconsistent
state that could lead to resource management issues.

Fixed by using rspamd_ev_watcher_init/start/stop consistently throughout,
passing fd=-1 for pure timers without file descriptors. Also removed the
now-unused fuzzy_tcp_timer_libev_cb wrapper function.

4 weeks agofeat: Add client IP to proxy messages
Cursor Agent [Thu, 9 Oct 2025 08:10:58 +0000 (08:10 +0000)] 
feat: Add client IP to proxy messages

Co-authored-by: v <v@rspamd.com>
4 weeks agoMerge branch 'master' into vstakhov-fuzzy-tcp-rework
Vsevolod Stakhov [Thu, 9 Oct 2025 07:31:51 +0000 (08:31 +0100)] 
Merge branch 'master' into vstakhov-fuzzy-tcp-rework

Resolved conflict in src/plugins/fuzzy_check.c by including both:
- HTML shingles configuration parsing from master
- TCP connection initialization from feature branch

Fixed trailing whitespace in config files from master.

4 weeks agoMerge pull request #5661 from rspamd/vstakhov-html-fuzzy
Vsevolod Stakhov [Wed, 8 Oct 2025 21:38:57 +0000 (22:38 +0100)] 
Merge pull request #5661 from rspamd/vstakhov-html-fuzzy

[Feature] Add HTML fuzzy hashing for structural similarity matching

4 weeks ago[Fix] Fix frequency-based ordering in HTML domain hashing 5661/head
Vsevolod Stakhov [Wed, 8 Oct 2025 16:23:10 +0000 (17:23 +0100)] 
[Fix] Fix frequency-based ordering in HTML domain hashing

The hash_top_domains function was sorting domains by frequency (descending),
but hash_domain_list was immediately re-sorting them alphabetically, which
negated the frequency information. This resulted in incorrect hashes where
domain order mattered for fuzzy matching.

Added preserve_order parameter to hash_domain_list to optionally skip
alphabetical re-sorting when frequency-based ordering should be maintained.

4 weeks agoMerge branch 'master' into vstakhov-html-fuzzy
Vsevolod Stakhov [Wed, 8 Oct 2025 16:12:17 +0000 (17:12 +0100)] 
Merge branch 'master' into vstakhov-html-fuzzy

4 weeks ago[Fix] Fix HTML shingles hash generation bugs
Vsevolod Stakhov [Wed, 8 Oct 2025 15:12:02 +0000 (16:12 +0100)] 
[Fix] Fix HTML shingles hash generation bugs

- Skip empty domains in hash_domain_list and hash_top_domains
- Validate HTML features are initialized before hashing
- Return zero hash for invalid/empty input instead of garbage

4 weeks ago[Fix] Fix memory leaks in HTML shingles generation
Vsevolod Stakhov [Wed, 8 Oct 2025 14:58:58 +0000 (15:58 +0100)] 
[Fix] Fix memory leaks in HTML shingles generation

- Require mempool parameter (cannot be NULL) for consistent memory management
- Change helper function to fill shingle structure in-place instead of allocating
- Eliminate unnecessary allocation, memcpy, and potential memory leaks
- All allocations now use rspamd_mempool_alloc0 consistently

4 weeks agoMerge pull request #5655 from rspamd/vstakhov-aliases-rewamp
Vsevolod Stakhov [Wed, 8 Oct 2025 14:23:34 +0000 (15:23 +0100)] 
Merge pull request #5655 from rspamd/vstakhov-aliases-rewamp

[Feature] Email aliases resolution and message classification

4 weeks ago[Fix] Fix set_addr validation to prevent malformed addresses 5655/head
Vsevolod Stakhov [Wed, 8 Oct 2025 10:16:32 +0000 (11:16 +0100)] 
[Fix] Fix set_addr validation to prevent malformed addresses

The set_addr function now properly checks that both addr.user and addr.domain
are non-empty strings before constructing addr.addr and addr.raw. This prevents
creating malformed addresses like '@domain.com' when addr.user is empty, and
ensures consistent state when addr.domain is empty.

4 weeks ago[Fix] Fix alias loop detection for converging paths in expand_multiple mode
Vsevolod Stakhov [Wed, 8 Oct 2025 10:11:29 +0000 (11:11 +0100)] 
[Fix] Fix alias loop detection for converging paths in expand_multiple mode

4 weeks ago[Fix] Fix is_local_domain to support backend objects
Vsevolod Stakhov [Wed, 8 Oct 2025 10:09:26 +0000 (11:09 +0100)] 
[Fix] Fix is_local_domain to support backend objects

The is_local_domain function was directly accessing module_state.local_domains
as a table, which caused it to always return false when local_domains was
configured as a backend object (MapBackend, CDBBackend, etc).

Fixed by:
- Moving get_from_source helper function before is_local_domain
- Using get_from_source to handle both plain tables and backend objects
- Updating return logic to handle different truthy values from backends

4 weeks ago[Minor] Fuzzy TCP: enable TCP_NODELAY for reduced latency
Vsevolod Stakhov [Wed, 8 Oct 2025 09:54:56 +0000 (10:54 +0100)] 
[Minor] Fuzzy TCP: enable TCP_NODELAY for reduced latency

Disables Nagle's algorithm on fuzzy TCP connections to minimize latency
for request-response traffic patterns. This prevents small packets from
being buffered, which is optimal for the fuzzy check protocol.

4 weeks ago[Fix] Fuzzy TCP: refresh timeout during active data transfer
Vsevolod Stakhov [Wed, 8 Oct 2025 09:50:24 +0000 (10:50 +0100)] 
[Fix] Fuzzy TCP: refresh timeout during active data transfer

Prevents active TCP connections from timing out when data is being actively transferred.
The timeout is now refreshed after each successful read/write operation, ensuring that
connections only timeout during actual inactivity, not during normal traffic flow.

4 weeks ago[Fix] Fuzzy TCP: separate session timeouts from connection failures
Vsevolod Stakhov [Wed, 8 Oct 2025 09:45:04 +0000 (10:45 +0100)] 
[Fix] Fuzzy TCP: separate session timeouts from connection failures

This addresses several timeout handling issues:
- Session timeouts no longer mark entire TCP connection as failed, allowing other sessions to continue
- Made tcp_retry_delay configurable (default: 10.0s)
- Added diagnostic reason strings to all cleanup paths
- Fixed reference counting with proper free_func for connection pool
- Added periodic timeout checks to detect stalled requests
- Unconditional timer cleanup (ev_timer_stop is safe to call)
- Enhanced logging with connection state and elapsed time details

4 weeks ago[Minor] Fix UDP fallback path to use proper upstream rotation
Vsevolod Stakhov [Wed, 8 Oct 2025 08:13:15 +0000 (09:13 +0100)] 
[Minor] Fix UDP fallback path to use proper upstream rotation

4 weeks ago[Fix] Fix TCP framing protocol endianness mismatch
Vsevolod Stakhov [Wed, 8 Oct 2025 08:10:09 +0000 (09:10 +0100)] 
[Fix] Fix TCP framing protocol endianness mismatch

The TCP framing protocol had an endianness mismatch for the 2-byte frame size header. The client was sending and expecting frame lengths in little-endian, while the server was sending and expecting them in network byte order (big-endian). This inconsistency corrupted frame lengths, leading to protocol errors and communication failures.

Changes:
* Server now uses GUINT16_TO_LE() instead of htons() for frame length encoding
* Server now uses GUINT16_FROM_LE() instead of ntohs() for frame length reading
* Server frame length parsing now reconstructs little-endian format
* Updated comment to reflect little-endian byte order consistency

All TCP frame lengths are now consistently transferred as little-endian numbers.

4 weeks agoMerge pull request #5663 from rspamd/cursor/RSP-246-parse-esmtp-arguments-for-lua...
Vsevolod Stakhov [Tue, 7 Oct 2025 20:41:35 +0000 (21:41 +0100)] 
Merge pull request #5663 from rspamd/cursor/RSP-246-parse-esmtp-arguments-for-lua-api-2fa5

Parse esmtp arguments for lua api

4 weeks ago[Minor] Address review comments
Vsevolod Stakhov [Tue, 7 Oct 2025 20:24:16 +0000 (21:24 +0100)] 
[Minor] Address review comments

4 weeks ago[Test] Remove redundant document
Vsevolod Stakhov [Tue, 7 Oct 2025 19:23:51 +0000 (20:23 +0100)] 
[Test] Remove redundant document

4 weeks ago[Test] Fix write-only fuzzy test expectations
Vsevolod Stakhov [Tue, 7 Oct 2025 19:10:35 +0000 (20:10 +0100)] 
[Test] Fix write-only fuzzy test expectations

The write-only mode test was failing because after fixing the
variable name (RSPAMD_SETTINGS_FUZZY_CHECK), the mode was correctly
applied to the client. In write-only mode, clients do not send
CHECK requests, so symbols should not appear during scanning.

The test was incorrectly expecting symbols to be found after adding
hashes. Changed test to verify correct write-only behavior:
- Hashes can be added via controller
- Scanning does not find symbols (CHECK not sent in write-only)
- Random messages still don't match

This validates that write-only mode prevents fuzzy checks while
allowing hash updates.

4 weeks ago[Fix] Fuzzy TCP: fix server replies and client event handling
Vsevolod Stakhov [Tue, 7 Oct 2025 18:20:03 +0000 (19:20 +0100)] 
[Fix] Fuzzy TCP: fix server replies and client event handling

Server was accepting TCP connections but never sending replies back,
causing all TCP requests to timeout. The issue had multiple causes:

Server side:
- TCP replies were routed through UDP code path, which doesn't queue
  replies for TCP sessions
- Async backend operations used stack-allocated session, causing
  segfaults when callback executed after stack frame destroyed

Client side:
- Event handler used equality checks (==) instead of bitwise (&)
  for libev event flags, preventing read events from being processed
- Timer initialization used rspamd IO wrapper for pure timer,
  causing fd=-1 assertion failures in ev_io_start
- Pending requests not cleaned up on timeout, causing use-after-free
  when late replies arrived after task completion

Fix by implementing TCP reply queue on server, using heap allocation
for async operations with proper reference counting, fixing event
handling to use bitwise operators, and implementing pure libev timer
for TCP timeout handling.

4 weeks agoMerge branch 'master' into vstakhov-fuzzy-tcp-rework
Vsevolod Stakhov [Tue, 7 Oct 2025 13:58:40 +0000 (14:58 +0100)] 
Merge branch 'master' into vstakhov-fuzzy-tcp-rework

4 weeks ago[Fix] Fix memory management issues in html_cta.process_html_links
Vsevolod Stakhov [Tue, 7 Oct 2025 13:58:02 +0000 (14:58 +0100)] 
[Fix] Fix memory management issues in html_cta.process_html_links

4 weeks ago[Fix] Fuzzy TCP: fix printf formats, buffer overflow, and timeout handling
Vsevolod Stakhov [Tue, 7 Oct 2025 13:53:16 +0000 (14:53 +0100)] 
[Fix] Fuzzy TCP: fix printf formats, buffer overflow, and timeout handling

- Fix printf format strings: use %ud instead of %u (rspamd printf requirement)
- Fix TCP write handler buffer overflow when writing frame header
  (ASAN error: remaining was calculated incorrectly)
- Fix timeout handling: mark commands as replied and check session completion
  to prevent task hanging on connection/request timeouts
- Fix Robot Framework test variables: add RSPAMD_ prefix for proper export
- Remove debug config dump

4 weeks ago[Feature] Fuzzy check: add protocol logging and TCP tests
Vsevolod Stakhov [Tue, 7 Oct 2025 12:22:50 +0000 (13:22 +0100)] 
[Feature] Fuzzy check: add protocol logging and TCP tests

Add explicit protocol logging:
- Log TCP vs UDP decision with rate and threshold
- Log actual protocol used for each request
- Log TCP connection status and fallbacks
- Shows current request rate for TCP auto-switch

Add functional tests for TCP:
- tcp.robot - basic TCP with auto-switch
- tcp-explicit.robot - forced TCP mode
- tcp-encrypted.robot - TCP with encryption
- Test high rate scenario and protocol switching

Update test configuration:
- Support SETTINGS_FUZZY_WORKER and SETTINGS_FUZZY_CHECK
- Allow dynamic TCP configuration in tests

4 weeks ago[Feature] Fuzzy check: add reply processing and lifecycle management
Vsevolod Stakhov [Tue, 7 Oct 2025 12:00:58 +0000 (13:00 +0100)] 
[Feature] Fuzzy check: add reply processing and lifecycle management

Complete TCP reply handling:
- Process all error codes (403, 503, 415, 401) like UDP
- Handle FUZZY_STAT commands with proper storage
- Mark commands as replied and check session completion

Add memory safety and lifecycle management:
- Cleanup pending requests when task finishes before reply
- Timeout checking for pending requests (io_timeout)
- Proper session cleanup for TCP (no fd/ev_watcher)
- Initialize TCP session fields (fd=-1, event_loop)

Prevents use-after-free when:
- Task completes before TCP reply arrives
- Reply takes too long (timeout)
- Connection fails with pending requests

4 weeks ago[Feature] Fuzzy check: implement TCP error handling and command sending
Vsevolod Stakhov [Tue, 7 Oct 2025 11:20:10 +0000 (12:20 +0100)] 
[Feature] Fuzzy check: implement TCP error handling and command sending

Add comprehensive error handling for TCP connections:
- Cleanup pending requests when connections fail
- Handle timeout, write, read, and protocol errors
- Track connection per pending command for cleanup

Implement TCP command sending:
- Add TCP framing to encrypted commands
- Queue commands for asynchronous sending
- Register in pending pool for reply matching
- Integrate with main check flow with UDP fallback

4 weeks ago[Feature] Fuzzy check: implement TCP connection management
Vsevolod Stakhov [Tue, 7 Oct 2025 08:19:40 +0000 (09:19 +0100)] 
[Feature] Fuzzy check: implement TCP connection management

Add async TCP connection establishment and I/O framework. This
implements Phase 2 of the TCP support - connection management with
event-driven architecture.

Changes:
- Add fuzzy_tcp_connection structure for per-rule TCP state
- Add fuzzy_tcp_pending_command for request/reply matching
- Implement fuzzy_tcp_connect_async() with non-blocking connect
- Implement fuzzy_tcp_io_handler() for connection/read/write events
- Add connection lifecycle management with reference counting
- Handle connection establishment with getsockopt SO_ERROR check
- Add timeout handling and upstream failure reporting
- Add placeholder write and read handlers for next phase

TCP connection is established lazily when rate threshold is exceeded.
Event handler manages connection state machine: connecting -> connected.
Write/read handlers will be implemented in Phase 3.

4 weeks ago[Feature] Fuzzy check: add TCP support with auto-switch
Vsevolod Stakhov [Tue, 7 Oct 2025 07:57:04 +0000 (08:57 +0100)] 
[Feature] Fuzzy check: add TCP support with auto-switch

Add TCP protocol support to fuzzy check client with rate-based
automatic switching between UDP and TCP transports. This enables
efficient bulk checking while maintaining UDP fallback.

Changes:
- Add TCP configuration parameters (enabled, auto, threshold, window, timeout)
- Implement sliding window rate tracker for request frequency monitoring
- Add TCP connection state tracking (connected, connecting)
- Implement fuzzy_should_use_tcp() decision logic
- Add fuzzy_update_rate_tracker() for rate tracking
- Add fuzzy_tcp_connect_async() placeholder for lazy TCP connection
- Integrate TCP/UDP selection in register_fuzzy_client_call()

Configuration:
  tcp = true;  # Enable TCP explicitly
  tcp = {      # Auto-switch configuration
    auto = true;
    threshold = 1.0;  # req/sec threshold
    window = 1.0;     # time window in seconds
  };

TCP connections are established lazily when rate threshold is exceeded.
Falls back to UDP if TCP is not available.

4 weeks ago[Feature] Fuzzy storage: implement TCP protocol support
Vsevolod Stakhov [Tue, 7 Oct 2025 07:56:32 +0000 (08:56 +0100)] 
[Feature] Fuzzy storage: implement TCP protocol support

Implement TCP transport for fuzzy storage protocol to enable efficient
bulk request handling. This adds TCP accept handlers, frame-based I/O
processing, and proper session management.

Changes:
- Add TCP session structure with framing state machine
- Implement TCP accept handler with rate limiting and access control
- Add TCP I/O handler supporting frame-based protocol (size header + payload)
- Implement TCP write reply with queuing support
- Add TCP timeout configuration parameter (default: 5.0 seconds)
- Refactor rate limit checks to accept parameters instead of session objects
- Update worker socket type to support both UDP and TCP
- Add debug logging infrastructure for fuzzy storage

TCP framing protocol: [uint16_t size][encrypted_payload]
Frame processing uses state machine: 0x0000 (idle) -> 0x8000 (have size) -> 0xC000 (complete)

4 weeks agoMerge pull request #5668 from rspamd/vstakhov-lua-logger-imps
Vsevolod Stakhov [Mon, 6 Oct 2025 13:44:38 +0000 (14:44 +0100)] 
Merge pull request #5668 from rspamd/vstakhov-lua-logger-imps

[Feature] Add type specifiers support to lua_logger

4 weeks agoMerge pull request #5666 from moisseev/webui
Vsevolod Stakhov [Mon, 6 Oct 2025 13:30:56 +0000 (14:30 +0100)] 
Merge pull request #5666 from moisseev/webui

[Fix] WebUI: repopulate classifier dropdown

4 weeks ago[Feature] Add type specifiers support to lua_logger 5668/head
Vsevolod Stakhov [Mon, 6 Oct 2025 13:22:26 +0000 (14:22 +0100)] 
[Feature] Add type specifiers support to lua_logger

Add support for format type specifiers in lua_logger:
- %d - signed integer (int64)
- %ud - unsigned integer (uint64)
- %f - floating point with smart formatting (no trailing zeros)
- %.Nf - floating point with N decimal places precision
- %% - escape literal percent sign

Type specifiers can be combined with positional (%1d) and
sequential (%d) argument references. String to number conversion
is supported. Added comprehensive unit tests.

4 weeks ago[Minor] WebUI: keep classifiers list when request is skipped 5666/head
Alexander Moisseev [Mon, 6 Oct 2025 12:39:26 +0000 (15:39 +0300)] 
[Minor] WebUI: keep classifiers list when request is skipped

4 weeks ago[Rework] Use postconf utility for Postfix configuration in configwizard
Vsevolod Stakhov [Mon, 6 Oct 2025 12:27:28 +0000 (13:27 +0100)] 
[Rework] Use postconf utility for Postfix configuration in configwizard

Replace direct file reading with postconf calls for better portability:
- Use postconf to get config_directory, alias_maps, virtual_alias_maps
- Use postconf to get mydestination instead of parsing main.cf
- Use postconf to check milter configuration (smtpd_milters, non_smtpd_milters)
- Add proper parsing of postconf output (handle prefixes like "hash:")
- Improve cross-platform compatibility by relying on Postfix's own tools

This approach is more portable and handles Postfix variables ($myhostname, etc.) correctly.

4 weeks agoMerge branch 'master' into vstakhov-aliases-rewamp
Vsevolod Stakhov [Mon, 6 Oct 2025 11:56:30 +0000 (12:56 +0100)] 
Merge branch 'master' into vstakhov-aliases-rewamp

4 weeks agoMerge pull request #5667 from rspamd/vstakhov-agents-improvements
Vsevolod Stakhov [Mon, 6 Oct 2025 11:39:55 +0000 (12:39 +0100)] 
Merge pull request #5667 from rspamd/vstakhov-agents-improvements

[Minor] Add Claude Code and Cursor AI assistant configuration

4 weeks ago[Project] Add Claude Code and Cursor AI assistant configuration 5667/head
Vsevolod Stakhov [Mon, 6 Oct 2025 11:34:07 +0000 (12:34 +0100)] 
[Project] Add Claude Code and Cursor AI assistant configuration

Add comprehensive configuration for AI development assistants:

.claude/ - Claude Code configuration:
- project_context.md: Project rules, code style, commit format, build system
- commands/: Custom slash commands for development workflow
  - build, test, build-and-test: Build and testing commands
  - check-code, format-code, test-lua: Code quality commands
  - prepare-commit, review-pr, create-release: Git workflow commands
- README.md: Documentation for all commands and features

.cursor/rules/ - Cursor rules:
- build-and-test.mdc: Build system and testing workflow documentation

Features:
- Automated code quality checks (luacheck, clang-format)
- Build system integration (ninja in ~/rspamd.build)
- Unit test execution (C/C++ and Lua tests)
- Commit message validation and formatting
- PR review assistance
- Release process automation

This enables AI assistants to follow Rspamd development practices
and automate common development tasks.

4 weeks ago[Feature] Add Postfix integration wizard to configwizard
Vsevolod Stakhov [Mon, 6 Oct 2025 11:23:14 +0000 (12:23 +0100)] 
[Feature] Add Postfix integration wizard to configwizard

Add setup_postfix() function to rspamadm configwizard that provides
guided configuration for Postfix mail server integration:

- Auto-detect Postfix configuration files (main.cf, master.cf)
- Parse mydestination for local domains
- Configure aliases module (system_aliases, virtual_aliases, local_domains)
- Check and provide instructions for milter integration
- Optional rate limiting and ARC signing configuration

Usage: rspamadm configwizard postfix

4 weeks ago[Fix] aliases: correct to_local when no recipients present
Vsevolod Stakhov [Mon, 6 Oct 2025 10:27:43 +0000 (11:27 +0100)] 
[Fix] aliases: correct to_local when no recipients present

4 weeks ago[Fix] WebUI: repopulate classifier dropdown
Alexander Moisseev [Mon, 6 Oct 2025 06:45:23 +0000 (09:45 +0300)] 
[Fix] WebUI: repopulate classifier dropdown

after reconnect from read-only

Ensure classifiers are fetched when the dropdown is empty even if cache suggests skipping,
preventing an empty selector on Scan tab after RO → Disconnect → Enable.

4 weeks ago[Minor] Remove unused constant 5663/head
Vsevolod Stakhov [Mon, 6 Oct 2025 10:03:19 +0000 (11:03 +0100)] 
[Minor] Remove unused constant

4 weeks ago[Minor] Remove unused variables after Lua ESMTP args rework
Vsevolod Stakhov [Mon, 6 Oct 2025 09:59:54 +0000 (10:59 +0100)] 
[Minor] Remove unused variables after Lua ESMTP args rework

4 weeks ago[Test] Add e2e for classifier dropdown population
Alexander Moisseev [Sun, 5 Oct 2025 17:08:30 +0000 (20:08 +0300)] 
[Test] Add e2e for classifier dropdown population

after RO → Disconnect → Enable

4 weeks ago[Rework] Remove Lua-level HTTP header parsing in ESMTP args getters; rely solely...
Vsevolod Stakhov [Mon, 6 Oct 2025 09:50:04 +0000 (10:50 +0100)] 
[Rework] Remove Lua-level HTTP header parsing in ESMTP args getters; rely solely on protocol layer to populate task fields

4 weeks ago[Fix] Correct Lua stack cleanup in lua_task_get_rcpt_esmtp_args by removing temporary...
Vsevolod Stakhov [Mon, 6 Oct 2025 09:36:49 +0000 (10:36 +0100)] 
[Fix] Correct Lua stack cleanup in lua_task_get_rcpt_esmtp_args by removing temporary tables in descending order to avoid index shifts and crashes

4 weeks ago[Fix] milter: robust RCPT ESMTP args parsing and safe cursor advance
Vsevolod Stakhov [Mon, 6 Oct 2025 09:30:37 +0000 (10:30 +0100)] 
[Fix] milter: robust RCPT ESMTP args parsing and safe cursor advance

- Walk ESMTP args as NUL-terminated tokens until double-NUL or end
- Pass the correct range to rspamd_milter_parse_esmtp_args
- Advance cursor past args terminator to avoid infinite loop or OOB read
- Keep rcpts/rcpt_esmtp_args indices aligned with NULL placeholders

4 weeks ago[Minor] Fix parsing of ESMTP arguments for Lua API
Vsevolod Stakhov [Mon, 6 Oct 2025 08:34:52 +0000 (09:34 +0100)] 
[Minor] Fix parsing of ESMTP arguments for Lua API

4 weeks ago[Fix] Correct per-recipient ESMTP args parsing in milter RCPT handling
Vsevolod Stakhov [Mon, 6 Oct 2025 08:29:54 +0000 (09:29 +0100)] 
[Fix] Correct per-recipient ESMTP args parsing in milter RCPT handling

4 weeks ago[Fix] Refcount ESMTP args in proxy_session_refresh to avoid use-after-free
Vsevolod Stakhov [Mon, 6 Oct 2025 08:05:52 +0000 (09:05 +0100)] 
[Fix] Refcount ESMTP args in proxy_session_refresh to avoid use-after-free

4 weeks ago[Feature] Persist milter ESMTP args in task and expose via Lua API
Vsevolod Stakhov [Sun, 5 Oct 2025 20:31:22 +0000 (21:31 +0100)] 
[Feature] Persist milter ESMTP args in task and expose via Lua API

- Store MAIL/RCPT ESMTP arguments in task (mempool-backed)
- Transfer args from milter session and over HTTP headers
- Parse X-Rspamd-{Mail,Rcpt}-Esmtp-Args in protocol and fill task
- Update Lua API to read from task with HTTP fallback
- Keep milter flag semantics intact and robust across proxy hops

4 weeks agoMerge branch 'master' into cursor/RSP-246-parse-esmtp-arguments-for-lua-api-2fa5
Vsevolod Stakhov [Sun, 5 Oct 2025 18:38:13 +0000 (19:38 +0100)] 
Merge branch 'master' into cursor/RSP-246-parse-esmtp-arguments-for-lua-api-2fa5

4 weeks ago[Minor] Update version of rspamd to 3.13.3
Vsevolod Stakhov [Sun, 5 Oct 2025 18:05:11 +0000 (19:05 +0100)] 
[Minor] Update version of rspamd to 3.13.3

4 weeks agoRelease 3.13.2 3.13.2
Vsevolod Stakhov [Sun, 5 Oct 2025 18:04:57 +0000 (19:04 +0100)] 
Release 3.13.2

* [Feature] Fuzzy check: Add separate encryption keys for read and write operations
* [Feature] DKIM: Add ED25519 support for DKIM signing and verification with OpenSSL version checks
* [Feature] Vault: Add HashiCorp Vault KV version 2 support for DKIM key management
* [Feature] MetaDefender: Add MetaDefender Cloud Lua module for SHA256 hash lookups
* [Feature] LLM: Add user/domain context support for LLM-based classification with Redis-based conversation context
* [Feature] DMARC: Add RUA address exclusion configuration option
* [Fix] DKIM: Fix relaxed bodyhash calculation for lines with only spaces to comply with RFC 6376
* [Fix] DKIM: Fix ED25519 key loading to prevent memory corruption in union handling
* [Fix] HTTP maps: Enforce server-controlled refresh intervals and prevent aggressive polling
* [Fix] HTTP maps: Prevent time_t overflow in expires header processing
* [Fix] Once received plugin: Fix duplicate symbol addition by changing break to return
* [Fix] Redis: Propagate unused Sentinel options properly
* [Fix] Fuzzy check: Fix reply decryption when using separate read/write keys
* [Fix] Fuzzy check: Add fallback when only one specific encryption key is set
* [Fix] Fuzzy check: Fix duplicate key filtering in reply decryption
* [Fix] Fuzzy ping: Allow read/write servers configuration
* [Minor] Fuzzy check: Refactor encryption key selection into helper functions
* [Minor] Fuzzy check: Stop early when found a correct key
* [Minor] Add cursor rules for development

4 weeks ago[Fix] Use correct html_features field to fix compilation error
Vsevolod Stakhov [Sun, 5 Oct 2025 16:43:36 +0000 (17:43 +0100)] 
[Fix] Use correct html_features field to fix compilation error

The part->html->features path was incorrect since part->html is void*.
Use the correct part->html_features field which is populated by
rspamd_html_get_features() during message parsing. Also added NULL check
for html_features before accessing its fields.

4 weeks ago[Minor] Add NULL check in hash_html_features for safety
Vsevolod Stakhov [Sun, 5 Oct 2025 16:21:09 +0000 (17:21 +0100)] 
[Minor] Add NULL check in hash_html_features for safety

Add explicit NULL check for html_content pointer in hash_html_features()
to prevent potential undefined behavior. While features are initialized by
the HTML parser and checked in rspamd_shingles_from_html(), this provides
an additional safety layer against unexpected function calls.

4 weeks ago[Fix] Fix segfault due to incorrect HTML features access
Vsevolod Stakhov [Sun, 5 Oct 2025 16:09:46 +0000 (17:09 +0100)] 
[Fix] Fix segfault due to incorrect HTML features access

The fuzzy_cmd_from_html_part() function incorrectly accessed HTML features
via part->html_features (which doesn't exist), causing segmentation faults.
Fixed to use the correct path part->html->features for accessing tags_count,
links.total_links, and max_dom_depth properties.

4 weeks ago[Fix] Fix HTML fuzzy cache key to prevent overwriting text cache
Vsevolod Stakhov [Sun, 5 Oct 2025 16:06:57 +0000 (17:06 +0100)] 
[Fix] Fix HTML fuzzy cache key to prevent overwriting text cache

HTML fuzzy hashes were incorrectly cached using the standard text fuzzy
cache key via fuzzy_cmd_set_cached(), causing HTML hashes to overwrite
text hashes for the same part. Now HTML fuzzy uses the dedicated
html_cache_key for both read and write operations, preventing cache
conflicts and ensuring proper retrieval of HTML fuzzy data.

4 weeks ago[Fix] Fix memory leak in rspamd_shingles_from_html
Vsevolod Stakhov [Sun, 5 Oct 2025 16:01:48 +0000 (17:01 +0100)] 
[Fix] Fix memory leak in rspamd_shingles_from_html

The struct_sgl object from generate_shingles_from_string_tokens() was only
deleted when pool == nullptr, causing memory leaks when a memory pool was
active. Now struct_sgl is always deleted after copying to res, regardless
of pool allocation method.

4 weeks ago[Fix] Update HTML fuzzy encryption to use helper functions
Vsevolod Stakhov [Sun, 5 Oct 2025 15:36:23 +0000 (16:36 +0100)] 
[Fix] Update HTML fuzzy encryption to use helper functions

The fuzzy_cmd_from_html_part() function was using legacy encryption logic
that only checked rule->peer_key. Updated to use fuzzy_rule_has_encryption()
and fuzzy_select_encryption_keys() helpers for consistency with other fuzzy
command functions and to support separate read/write encryption keys.

4 weeks agoMerge branch 'master' into vstakhov-html-fuzzy
Vsevolod Stakhov [Sun, 5 Oct 2025 15:27:00 +0000 (16:27 +0100)] 
Merge branch 'master' into vstakhov-html-fuzzy

4 weeks agoMerge pull request #5665 from rspamd/vstakhov-fuzzy-rw-split
Vsevolod Stakhov [Sun, 5 Oct 2025 15:15:46 +0000 (16:15 +0100)] 
Merge pull request #5665 from rspamd/vstakhov-fuzzy-rw-split

[Feature] Add separate encryption keys for read/write operations in fuzzy_check

4 weeks ago[Minor] Stop early when found a correct key 5665/head
Vsevolod Stakhov [Sun, 5 Oct 2025 15:05:24 +0000 (16:05 +0100)] 
[Minor] Stop early when found a correct key

4 weeks ago[Fix] Add fallback when only one specific encryption key is set
Vsevolod Stakhov [Sun, 5 Oct 2025 14:57:35 +0000 (15:57 +0100)] 
[Fix] Add fallback when only one specific encryption key is set

When only read_encryption_key or write_encryption_key is configured without
a general encryption_key, the unspecified operation type was left with NULL
keys. Now if only one specific key is set, it's used for both read and write
operations as a fallback, ensuring encryption works in all configurations.

4 weeks ago[Fix] Fix duplicate key filtering in reply decryption
Vsevolod Stakhov [Sun, 5 Oct 2025 14:45:53 +0000 (15:45 +0100)] 
[Fix] Fix duplicate key filtering in reply decryption

When read/write encryption keys fall back to common encryption_key,
rspamd_pubkey_ref() returns pointer to the same object. Previous duplicate
checks using pointer comparison incorrectly filtered out these keys,
causing decryption failures. Now properly checks if key was already added
to the decryption attempt list before adding it.

4 weeks ago[Minor] Refactor encryption key selection into helper functions
Vsevolod Stakhov [Sun, 5 Oct 2025 14:32:09 +0000 (15:32 +0100)] 
[Minor] Refactor encryption key selection into helper functions

Extract repeated key selection logic into fuzzy_select_encryption_keys()
and fuzzy_rule_has_encryption() helper functions. This reduces code
duplication and improves readability across fuzzy_cmd_stat(),
fuzzy_cmd_ping(), fuzzy_cmd_hash(), fuzzy_cmd_from_text_part(),
fuzzy_cmd_from_data_part(), and fuzzy_process_reply() functions.

4 weeks ago[Fix] Fix reply decryption when using only separate read/write keys
Vsevolod Stakhov [Sun, 5 Oct 2025 14:03:48 +0000 (15:03 +0100)] 
[Fix] Fix reply decryption when using only separate read/write keys

In fuzzy_process_reply(), the tag was accessed from encrypted data before
decryption, leading to incorrect key selection. When only separate
read_encryption_key and write_encryption_key were configured (without common
encryption_key), the fallback to NULL keys caused crashes.

Now the function tries decryption with all available key pairs (read, write,
and common) until MAC verification succeeds, properly handling all key
configuration scenarios.

4 weeks ago[Fix] Ensure encryption works with separate read/write keys in fuzzy_check
Vsevolod Stakhov [Sun, 5 Oct 2025 13:51:24 +0000 (14:51 +0100)] 
[Fix] Ensure encryption works with separate read/write keys in fuzzy_check

Fix condition checks that determine whether to use encryption. Previously,
functions checked only rule->peer_key, causing encryption to be disabled
when using only read_encryption_key and write_encryption_key without a
common encryption_key. Now checks for any encryption keys (peer_key,
read_peer_key, or write_peer_key) to properly enable encryption.

4 weeks ago[Feature] Add separate encryption keys for read and write operations in fuzzy_check
Vsevolod Stakhov [Sun, 5 Oct 2025 13:38:24 +0000 (14:38 +0100)] 
[Feature] Add separate encryption keys for read and write operations in fuzzy_check

Allow using different encryption keys for read (CHECK, STAT, PING) and write
(WRITE, DEL) operations by introducing read_encryption_key and write_encryption_key
configuration parameters. Falls back to encryption_key if separate keys are not
specified for backward compatibility.

4 weeks ago[Fix] Allow read/write servers in fuzzy_ping
Vsevolod Stakhov [Sun, 5 Oct 2025 13:29:25 +0000 (14:29 +0100)] 
[Fix] Allow read/write servers in fuzzy_ping

4 weeks agoMerge pull request #5653 from croessner/patch-1
Vsevolod Stakhov [Sun, 5 Oct 2025 12:16:53 +0000 (13:16 +0100)] 
Merge pull request #5653 from croessner/patch-1

Feat: Added rua address exclusion in dmarc.lua

4 weeks ago[Minor] Add safety checks for short HTML to prevent false positives
Vsevolod Stakhov [Sun, 5 Oct 2025 07:32:54 +0000 (08:32 +0100)] 
[Minor] Add safety checks for short HTML to prevent false positives

Require minimum complexity for HTML fuzzy matching:
- At least 2 links (single-link emails too generic)
- At least DOM depth 3 (flat structures too common)

This prevents false positives on trivial HTML like:
  <html><body><p>text <a href="...">link</a></p></body></html>

Such simple structures are not unique enough for reliable fuzzy matching.

4 weeks ago[Minor] Forgotten file
Vsevolod Stakhov [Sat, 4 Oct 2025 21:44:04 +0000 (22:44 +0100)] 
[Minor] Forgotten file

4 weeks ago[Fix] Fix CSS class normalization in HTML fuzzy tokens
Vsevolod Stakhov [Sat, 4 Oct 2025 21:22:52 +0000 (22:22 +0100)] 
[Fix] Fix CSS class normalization in HTML fuzzy tokens

Multiple CSS classes (space-separated) were concatenated incorrectly,
causing token instability. Now take only first class for consistency.

Example:
- Before: class="button primary" → token "a.buttonprimary"
- After:  class="button primary" → token "a.button"

This ensures HTML structure tokens are stable across variations.

4 weeks ago[Minor] Use FUZZY_INCLUDE for HTML fuzzy test configuration
Vsevolod Stakhov [Sat, 4 Oct 2025 20:35:19 +0000 (21:35 +0100)] 
[Minor] Use FUZZY_INCLUDE for HTML fuzzy test configuration

Create fuzzy-html.conf with HTML-specific settings and use
RSPAMD_FUZZY_INCLUDE variable to include it in the fuzzy rule.
This is the correct way to add per-test rule settings.

4 weeks ago[Minor] Add debug logging to HTML fuzzy hash generation
Vsevolod Stakhov [Sat, 4 Oct 2025 20:30:53 +0000 (21:30 +0100)] 
[Minor] Add debug logging to HTML fuzzy hash generation

Add detailed debug messages to track HTML fuzzy hash generation flow:
- Log when fuzzy_cmd_from_html_part is called
- Log HTML shingles enabled/disabled status
- Log HTML part detection
- Log tag count checks
- Log successful/failed hash generation

This helps diagnose issues with HTML fuzzy matching in tests.

4 weeks ago[Minor] Fix HTML fuzzy test to use standard flags and keywords
Vsevolod Stakhov [Sat, 4 Oct 2025 18:46:05 +0000 (19:46 +0100)] 
[Minor] Fix HTML fuzzy test to use standard flags and keywords

Use RSPAMD_FLAG1_NUMBER (50) instead of custom flag 100 to match
existing fuzzy.conf configuration. Add proper test flow with setup
checks and standard Robot Framework keywords.

4 weeks ago[Test] Add functional tests for HTML fuzzy hashing
Vsevolod Stakhov [Sat, 4 Oct 2025 18:41:27 +0000 (19:41 +0100)] 
[Test] Add functional tests for HTML fuzzy hashing

Add Robot Framework tests for HTML fuzzy matching:
- html_template_1.eml: legitimate newsletter template
- html_template_1_variation.eml: same structure, different text
- html_phishing.eml: same structure, phishing CTA domains
- html-fuzzy.robot: test suite with add/check/phishing scenarios

Tests verify:
- HTML fuzzy hash generation and matching
- Template variation detection (same structure, different content)
- Phishing detection (same structure, different CTA domains)
- Integration with fuzzy storage backend

4 weeks ago[Minor] Fix luacheck warnings in HTML fuzzy Lua modules
Vsevolod Stakhov [Sat, 4 Oct 2025 18:41:25 +0000 (19:41 +0100)] 
[Minor] Fix luacheck warnings in HTML fuzzy Lua modules

- Remove unused variables (rspamd_logger, text_matches, etc.)
- Remove trailing whitespace
- Fix unused return value from register_symbol

4 weeks ago[Minor] Add html_features.h include to fuzzy_check.c
Vsevolod Stakhov [Sat, 4 Oct 2025 18:41:22 +0000 (19:41 +0100)] 
[Minor] Add html_features.h include to fuzzy_check.c

Required for accessing rspamd_html_features->tags_count field
when checking HTML fuzzy hash thresholds.

4 weeks ago[Feature] Integrate HTML fuzzy hashing into fuzzy_check module
Vsevolod Stakhov [Sat, 4 Oct 2025 18:34:48 +0000 (19:34 +0100)] 
[Feature] Integrate HTML fuzzy hashing into fuzzy_check module

Add support for HTML structure fuzzy hashing in fuzzy_check plugin:

Core integration:
- Add FUZZY_CMD_FLAG_HTML flag and FUZZY_RESULT_HTML result type
- Add html_shingles, min_html_tags, html_weight options to fuzzy_rule
- Implement fuzzy_cmd_from_html_part() to generate HTML fuzzy commands
- Integrate into fuzzy_generate_commands() for automatic hash generation
- Handle HTML results with configurable weight multiplier

Configuration:
- html_shingles: enable/disable HTML fuzzy hashing per rule
- min_html_tags: minimum HTML tags threshold (default 10)
- html_weight: score multiplier for HTML matches (default 1.0)

Use cases:
1. Brand protection: detect phishing with copied HTML but fake CTA
2. Spam campaigns: group messages by HTML structure
3. Template detection: identify newsletters/notifications
4. Phishing: text match + HTML CTA mismatch = suspicious

Files added:
- lualib/lua_fuzzy_html.lua: helper functions for mismatch detection
- conf/modules.d/fuzzy_check_html.conf: configuration examples
- test/functional/configs/fuzzy_html_test.conf: test configuration
- rules/fuzzy_html_phishing.lua: phishing detection rules

HTML fuzzy works alongside text fuzzy:
- Both hashes generated and sent to storage
- Separate result types allow different handling
- CTA domain verification prevents false positives

Next steps:
- Performance testing on real email corpus
- Fine-tune weights and thresholds
- Collect legitimate brand templates for whitelisting

4 weeks agoMerge branch 'master' into vstakhov-html-fuzzy
Vsevolod Stakhov [Sat, 4 Oct 2025 18:24:49 +0000 (19:24 +0100)] 
Merge branch 'master' into vstakhov-html-fuzzy

4 weeks agoMerge pull request #5662 from rspamd/cursor/RSP-259-fix-dkim-relaxed-bodyhash-calcula...
Vsevolod Stakhov [Sat, 4 Oct 2025 15:04:35 +0000 (21:04 +0600)] 
Merge pull request #5662 from rspamd/cursor/RSP-259-fix-dkim-relaxed-bodyhash-calculation-for-spaces-d7b8

Fix dkim relaxed bodyhash calculation for spaces

4 weeks agoMerge pull request #5664 from rspamd/cursor/RSP-108-fix-rspamd-dkim-key-loading-for...
Vsevolod Stakhov [Sat, 4 Oct 2025 15:02:05 +0000 (21:02 +0600)] 
Merge pull request #5664 from rspamd/cursor/RSP-108-fix-rspamd-dkim-key-loading-for-ed25519-da48

Fix rspamd dkim key loading for ed25519