Commit graph

1154 commits

Author SHA1 Message Date
NickOvt
86d26276a5
fix(logging-redis): ZMSA-78: Improve redis config, error logging and retry handling (#987)
* ZMSA-78: Add gelf logging to redis issues

* improve redis config

* when receiving redis config through tools, set request retry count to default
2026-02-03 11:57:40 +02:00
NickOvt
7b43049a61
fix(logging-autoreply): ZMSA-65: loggelf autoreply error in filterHandler.storeMessage (#983) 2026-02-02 11:34:39 +02:00
NickOvt
24ba57520a
fix: ZMSA-64: on API outbound email sends add passwordType: master to envelope object (#978) 2026-02-02 11:31:09 +02:00
NickOvt
545800d17a
fix(imap-indexer): Revert "fix(rebuild): ZMSA-48: fix rebuilding of multipart parts (#942)" (#980)
This reverts commit 11b4fcbcd4.
2026-01-29 11:14:54 +02:00
NickOvt
f7fe4d7334
fix(api): ZMSA-62: API response type fixes (#975)
* ZMSA-62: update create new user address address request object definition

* ZMSA-62: improve archive endpoints summaries and descriptions

* ZMSA-62: getArchivedMessages make the response same as classic message listing, just for archived messages now

* ZMSA-62: getMessages return fix response bimi object type

* ZMSA-62: messages.js fix references response type

* ZMSA-62: getMessage fix mailing list response type

* ZMSA-62: deleteMessagesInMailbox fix response type

* ZMSA-62: getMailbox: fix response type, add retention field

* ZMSA-62: authlog fix response types

* ZMSA-62: getAllFilters fix response type

* ZMSA-62: fix getMessage response type
2026-01-26 15:19:47 +02:00
NickOvt
0529f8f5d7
fix(filters-actions-spam): ZMSA-71-2: Allow spam action to be null thus deleting it (#967)
* ZMSA-71-2: Allow spam action to be null thus deleting it

* remove .only from filter spam action tests
2026-01-22 16:01:17 +02:00
NickOvt
cdc7c63ad3
fix(filters-list): ZMSA-71: when requesting filters list value also return original query and action field values (#965)
* when requesting filters list value also return original query and action field values

* originalQuery and originalAction add joi schemas to response
2026-01-22 16:00:18 +02:00
NickOvt
967e4b1fd3
fix(on-move): ZMSA-73: on move if failed to get folder write lock, treat as tempfail (#970)
* ZMSA-73: on move if failed to get folder write lock, return error message as string instead of object

* regard write lock error as tempfail
2026-01-22 15:59:01 +02:00
NickOvt
88ea15c75a
fix(logging): ZMSA-56: IMAP and POP3 servers loggelf errors (#962) 2026-01-22 12:19:25 +02:00
NickOvt
fb32e9e587
fix(filter-handler): ZMSA-63: filter handler store message return stored message size (#968) 2026-01-22 12:16:04 +02:00
NickOvt
3b14035f05
fix(imap-client-uid-search): ZMSA-70: optimize search query client command parsing (#963)
* ZMSA-70: optimize search query client command parsing

* add uid search tests

* shuffle client sent UIDs in some tests
2026-01-22 11:24:28 +02:00
NickOvt
11b4fcbcd4
fix(rebuild): ZMSA-48: fix rebuilding of multipart parts (#942)
* fix rebuilding of multipart parts

* input and output (downloaded) .eml files must be identical, the provided fixes do this

* fix tests, fix indexer, add size when fetching imap
2026-01-19 11:22:17 +02:00
NickOvt
6ffd0e6d1e
fix(uid-search): ZMSA-67: improve UID SEARCH performance by reducing calls to imap-compiler (#955)
* ZMSA-67: improve UID SEARCH performance by reducing calls to imap-compiler

* mongodb, when fetching contiguous uid then use range query
2026-01-14 15:26:54 +02:00
NickOvt
dec117ddf4
fix(logging): ZMSA-58: revert ZMS-216 (#956) 2026-01-14 15:25:25 +02:00
titanism
ea86c9fd46
fix(pop3): fix pipelining race condition causing mpop "invalid reply" errors (#950)
* fix(pop3): ensure pipelined RETR commands complete before processing next command

When POP3 clients use PIPELINING to send multiple RETR commands, the server
must ensure each message is fully transmitted (including the terminating dot)
before processing the next command. Previously, the server would call next()
when the source stream ended, but the DataStream transform (which adds the
terminating dot) might not have finished flushing to the socket yet.

This caused race conditions where the +OK response for the next RETR command
could be sent before the previous message's terminating dot, violating the
POP3 protocol and causing clients like mpop to report "invalid reply" errors.

The fix listens for the 'end' event on the DataStream (after it has written
the terminating dot) rather than the source stream, ensuring proper sequencing
of pipelined responses.

* test(pop3): add pipelining tests for RETR command race condition fix

Add comprehensive tests to verify that pipelined RETR commands are handled
correctly without interleaving responses. These tests simulate aggressive
POP3 client behavior (like mpop) that sends multiple RETR commands without
waiting for individual responses.

The tests verify:
- Multiple pipelined RETR commands complete in order
- Message terminating dot is sent before next +OK response
- The fix code exists in connection.js
- Rapid pipelining with 10 messages works correctly

* chore(test): add POP3 tests to grunt proto task

Update Gruntfile to include POP3 tests in the proto task, allowing protocol-
level tests (IMAP unit + POP3) to run without requiring MongoDB/Redis.

Changes:
- Add mochaTest:pop3 configuration for POP3 tests
- Add mochaTest:imap-unit for IMAP tests that don't require MongoDB
- Update proto task to run both imap-unit and pop3 tests

* fix(pop3): add defensive checks for stream.options.ttlcounter

Add defensive checks in RETR and TOP commands to handle streams
that don't have the options.ttlcounter property set. This fixes
a TypeError crash in Forward Email and other implementations that
don't set stream.options when returning from onFetchMessage.

The fix checks if stream?.options?.ttlcounter is a function before
calling it, and skips the ttlcounter call if not available.

Also adds:
- mpop pipelining tests for real-world client compatibility
- Tests for streams without options property
- Tests for streams with options but missing ttlcounter
- CI configuration to install mpop for testing
2026-01-08 09:36:27 +02:00
NickOvt
f8e14f5699
fix(userHandler-asyncGetDeleted): ZMSA-52: user-handler create new asyncGetDeleted function to get deleted user by username, id, main address (#947)
* ZMSA-52: user-handler create new asyncGetDeleted function to get deleted user by username, id, main address

* add indexes for deletedusers collection

* user-handler asyncGetDeleted tests

* users-async-get-deleted-test.js remove .only from describe

* indexes, deletedusers indexes don't need to be unique indexes
2026-01-06 09:54:26 +02:00
NickOvt
b9d89576db
fix(POP3-TLSSocket): ZMSA-57 fix bug: Possible EventEmitter memory leak detected. 11 timeout listeners added to [TLSSocket] (#939) 2026-01-04 20:35:50 +02:00
NickOvt
538b22e78c
fix(crypto.createDecipher): ZMSA-47: dkim legacy decipher fixes (#935)
* dkim legacy decipher, use createDecipheriv instead of deprecated createDecipher, implement openssl evpBytesToKey

* add createDecipher unit tests
2025-12-11 11:39:22 +02:00
NickOvt
5fa7139c1a
fix(pop3-snicallback): ZMSA-43: fix critical SNICallback bug in POP3 server (#931) 2025-12-04 11:18:41 +02:00
NickOvt
25ce95fb5d
fix(tls-logging): ZMSA-40: where possible use _ip in gelf logs instead of _remoteAddress (#929)
* where possible use _ip in gelf logs instead of _remoteAddress

* api.js add _req when logging remoteAddress
2025-12-04 09:57:22 +02:00
NickOvt
4ab6f8e22c
fix(gridstore-upload): ZMSA-17: fix gridstore upload deadlock (#918)
* fix gridstore upload deadlock

* releaseLock add callback if no calculatedFileContentHash

* gridstore-storage improve flow, refactor

* gridstore create handle case if lock variable is set but lock was not acquired

* gridstore attachmentCallback refactor

* refactor already returned logic in gristore create
2025-12-04 09:51:22 +02:00
NickOvt
97149a8d55
fix(tls-sni-logging): ZMSA-38: imap and pop3 servers when tls errors log meta regardless of error (#928)
* imap and pop3 servers when tls errors log meta regardless of error, also add TLS protocol version

* remove console.log

* for SNI requests log connecting client address
2025-12-02 12:11:07 +02:00
NickOvt
cf66a99196
fix(authlog): ZMSA-34: authLog add protocol for better logging in user update and asp generate and delete (#924) 2025-11-28 15:20:12 +02:00
NickOvt
c42ad5cc0e
fix: ZMSA-33: request user information also return requirePasswordChange flag value (#923) 2025-11-28 15:19:00 +02:00
NickOvt
a58d037709
fix: ZMSA-28: make migrations configurable (#922)
* make migrations configurable

* default.toml add missing newline before end
2025-11-27 11:19:56 +02:00
NickOvt
551860cb0c
fix: ZMSA-31: when updating password set requirePasswordChange false (#916) 2025-11-24 11:52:14 +02:00
NickOvt
4442eb52e6
fix: ZMSA-29: POP3 TOP command calculate counters correctly and correctly update them (#914) 2025-11-24 10:27:42 +02:00
NickOvt
1e2bdcd613
fix: ZMSA-24: when updating user info and setting new password reset pwned checks (#912) 2025-11-19 17:20:02 +02:00
NickOvt
78fbe8a669
fix: ZMSA-24: unset lastPwnedCheck and passwordPwned when resetting user password (#911) 2025-11-19 15:49:24 +02:00
NickOvt
03c4ffd9cd
fix: ZMSA-17: improve filterHandler and messageHandler logging (#907)
* improve filterHandler and messageHandler logging

* message-handler logging fix sessions
2025-11-19 13:06:25 +02:00
NickOvt
f494c83895
fix: ZMSA-21 & ZMSA-22: fixes to pwned check and return pwned infor on get user api query (#909)
* ZMSA-21: /users/:user get request to return lastPwnedCheck and passwordPwned values

* ZMSA-22: user-handler when checking for pwned password use DB value initially
2025-11-19 13:02:48 +02:00
NickOvt
5c508fe491
fix(messageHandler-logging): ZMSA-15: improve message-handler logging (#903) 2025-11-12 14:48:51 +02:00
NickOvt
81c746c280
fix(threading): ZMS-281: refactor threading (#899)
* refactor threading

* remove dangling console log

* revert last commit. add _id projection when creating thread
2025-11-12 14:41:07 +02:00
NickOvt
34e6be84ab
fix: check password against hibp on hardfail too (#904) 2025-11-11 18:45:37 +02:00
NickOvt
ca38ef2b9a
fix(hibp): ZMSA-11: check user password in HIBP after successful password check (#901)
* check user password in HIBP after successful check

* authSuccess pwned check refactor and clean code

* fix typo
2025-11-11 15:03:19 +02:00
NickOvt
1d42bc7c1b
fix(hibp-use-keepalive): ZMSA-12: use keepalive when querying HIBP database (#900) 2025-11-07 10:59:42 +02:00
NickOvt
52d54492bf
fix(threading): fix threading (#895) 2025-10-31 10:34:29 +02:00
NickOvt
7b8810993c
fix(threading): ZMSA-5: if referencing a deleted thread then recreate it (#893)
* if referencing a deleted thread then recreate it

* fix comment
2025-10-27 11:07:50 +02:00
NickOvt
2e89a0e8f0
fix(addAsync-thread): ZMSA-2: message addAsync, if a message is referenced then use reference's thread (#889)
* message addAsync, if a message is referenced then use reference's thread

* access referenced message through other object in addAsync, fix if statement
2025-10-23 11:41:17 +03:00
NickOvt
35ed9fcfe8
fix(health): ZMSA-4: health endpoint also add WD API version (#890)
* health endpoints add also WD API version

* rename error response object

* fix HealthErrorResponse
2025-10-23 11:12:49 +03:00
NickOvt
e3d3221bd5
fix: ZMSA-1: update release workflow, update deps, use updated deps, scope package (#887)
* update release workflow

* update deps, use scoped packages, scope package
2025-10-17 12:04:48 +03:00
NickOvt
479e5bcccd
fix(pluginhandler): ZMS-269: plugins - use wild-plugins, update options, allow for dynamic config (#886)
* plugins - use wild-plugins, update options, allow for dynamic config

* wild-plugins update deps, use scoped package

* update deps
2025-10-14 13:25:24 +03:00
NickOvt
6e4b701a88
fix(imap-append): ZMS-276: imap append improve logging add new fields to logging (#884)
message-handler addAsync return prepared too
2025-10-13 10:52:35 +03:00
NickOvt
1dc422f993
fix(search-apply): ZMS-275: search-apply allow to delete found messages (#881)
* search-apply allow to delete found messages in Trash and Junk folders

* fix comment, refactor description

* allow search and apply delete in Drafts folder too

* search-apply do not allow other fields in API if delete true, refactor search-apply task, improve readability

* search-apply task refactor, allow to delete in any mailbox

* if moving to same mailbox then update message data instead
2025-10-07 14:58:02 +03:00
NickOvt
f71972d123
fix(migrations): ZMS-274 Implement MongoDb Migrations in Wildduck (#879)
* implement simple MongoDB Migrations Manager in WD

* add migrate command to package.json

* revert pop3.js change

* rename print to log, remove unnecessary comments, refactor

* refactor, add migrate package json command

* export runMigrations

* move migrations under the tasks handler

* rename migrations-manager to migrations-handler

* package.json remove migrate script

* run migrations task as background task on start
2025-10-01 12:43:17 +03:00
NickOvt
4db839ed8d
Revert "ZMS-274 Implement MongoDb Migrations in Wildduck (#877)" (#878)
This reverts commit 4866524dce.
2025-10-01 12:41:43 +03:00
NickOvt
fb019774c3
fix(pwned-check): ZMS-264: Add feature to check password with PwnedPassword API on User Login (#864)
* implement PwnedPasswords check on each login

* cache pwnedpasswords API response and reuse the value

* refactor, move cache check and api request to separate function

* add pwnedpassword check function to tools.js

* tools.js and pwned password check in user-handler refactor, remove code repetitions

* refactor, improve code readability

* checkPwnedPasswordForUser add check for empty password

* user-handler improve pwned password cache logic, refactor, fix bug

* checkPwnedPasswordForUser use function with await as it is a promise, auth.js add passwordPwned to response and to the schema

* slightly optimize checkRes in checkPwnedPassword and make it more readable

* remove pwnedpasswords dependency, refactor users.js, checkPwnedPassword fix incorrect cast to number

* tools.checkPwnedPassword call in users.js - grab the correct data

* default.toml remove rudimentary comment

* on request timeout reject with an error object

* do not check for pwned password in cache on every login, check every two weeks

* when receiving userData also add lastPwnedCheck to projection

* remove redis cache, make pwnedpasswords api url configurable

* default.toml fix comments

* add user id when user has pwned passwords
2025-10-01 12:21:11 +03:00
NickOvt
4866524dce
ZMS-274 Implement MongoDb Migrations in Wildduck (#877)
* implement simple MongoDB Migrations Manager in WD

* add migrate command to package.json

* revert pop3.js change

* rename print to log, remove unnecessary comments, refactor

* refactor, add migrate package json command

* export runMigrations

* move migrations under the tasks handler

* rename migrations-manager to migrations-handler

* package.json remove migrate script

* run migrations task as background task on start
2025-10-01 12:17:15 +03:00
NickOvt
08e5070f45
fix(addressregister): ZMS-268: add new addressregister endpoint to disable an entry or edit it (#873)
* add new addressregister endpoint to disable an entry or edit it

* readOwn,readAny -> createOwn, createAny for addressregister updates. Fix indexes. Make query more constraint

* remove unused indexes
2025-10-01 12:01:08 +03:00
NickOvt
63811c7787
fix(messages-search): ZMS-271: optimize user messages search query (#876)
* optimize user messages search query

* add comments, refactor, add logging

* fix comment typo

* when logging retry to gelf specify that it is indeed retry
2025-10-01 11:36:04 +03:00