Commit Graph
1617 Commits
Author SHA1 Message Date
Wez Furlong 4e8e616dad logging: load meta before retrieving the recipient_list
We had a sponsor report an issue where we'd log an error during
processing a log hook. It transpired that the recipient list we were
attempting to log was `["metadata is not loaded"]`, which doesn't parse
as a valid EnvelopeAddress (see prior commit:
52e2f95e9f)

This commit fixes up the recipient_list logic in the logging function to
avoid taking the error message as the recipient list, and moves the
metadata loading to happen just before we try to read the recipient
list.

This should work around the issue, but a consequence is that we might
be holding on to the metadata for that message in RAM for longer than
we should; will need to do some thinking about managing the resident
status in this situation better.
2025-11-04 07:26:43 +00:00
Wez Furlong 52e2f95e9f address.rs: add more context to invalid addresses when parsing fails 2025-11-03 21:35:39 +00:00
610b441e67 Allow temp/perm errors in dmarc (#441)
allow temp/perm errors in dmarc

Co-authored-by: Sophia Turner <sophiajt@users.noreply.github.com>
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2025-11-03 01:36:41 -07:00
Wez Furlong 4c6d7ca8ea add policy-extras.mail_auth module
This aggregates the various authentication-results producing auth checks
into a more convenient function.

Part of this change improves some plumbing in the dkim checking (we no
longer raise an error for a missing From, but instead indicate a failed
dkim result), and we now support passing down a resolver name to the
various checking functions, to facilitate testing and other more
advanced use cases.

refs: https://github.com/KumoCorp/kumomta/issues/16
refs: https://github.com/KumoCorp/kumomta/issues/84
2025-11-02 11:56:57 +00:00
Wez Furlong 49cdee1ec5 lruttl: expose pre-defined cache info to the docs
This commit adds some plumbing to allow us to collect metadata
about the caches and spit it out into a json file that we can
then use in the docs to show the predefined caches, capacities
and brief comments about their purpose.

We put that info on the set_lruttl_cache_capacity doc page.
2025-11-01 07:40:40 +00:00
Wez Furlong c085e368b2 dkim_(key|signer)_cache: enable thundering herd protection
Use the managed accessor for thundering herd protection.

May help with a situation as discussed in
https://github.com/KumoCorp/kumomta/pull/438
2025-10-31 18:04:17 +00:00
Wez Furlong e7f4806f1b dkim: add integration test assertions for signing cache
refs: https://github.com/KumoCorp/kumomta/pull/438
2025-10-31 17:27:05 +00:00
Wez Furlong 5ad7df0203 arc: expose arc_seal and arc_verify methods to lua
refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:32 +00:00
Wez Furlong 1da468ea9a arc: we can now produce an arc seal
refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:32 +00:00
Wez Furlong 4bd42ae57f arc: we can now validate an arc chain
refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:32 +00:00
Wez Furlong 823ee09db9 dkim: refactor and improve some of the test logic
refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:31 +00:00
Wez Furlong ee4266cd19 WIP: building out ARC processing
This is not fully baked yet, but I want to checkpoint.

refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:31 +00:00
Wez Furlong 93210b8346 dkim: add ARCSealHeader type
refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:31 +00:00
Wez Furlong 96cb74840e mailparsing: add ARCAuthenticationResults header type
refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:30 +00:00
Wez Furlong 714abd4910 dkim: add ARCMessageSignature type
This parses an ARC-Message-Signature header field

refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:30 +00:00
Wez Furlong 1f6e4ea72d dkim: refactor: rename HEADER to DKIM_SIGNATURE_HEADER_NAME
refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:30 +00:00
Wez Furlong e9deb2500d dkim: fix subdomain checking issue 2025-10-31 12:16:30 +00:00
Wez Furlong 6ccb337d8f dkim: extract header parsing guts to TaggedHeader struct
This should facilitate the implementation of ARC in a later commit.

refs: https://github.com/KumoCorp/kumomta/issues/16
2025-10-31 12:16:29 +00:00
Wez Furlong 12d31f0878 dkim: remove stale files 2025-10-31 11:48:21 +00:00
Wez Furlong 0e82d3eda7 ci: hopefully address flakeyness in xclient tests 2025-10-29 13:06:48 +00:00
Wez Furlong 6adb43221f Expose text wrapping function as kumo.string.wrap
Extracts the wrap function to its own little crate and expose that to
lua.
2025-10-29 12:06:06 +00:00
Wez Furlong 67bf14ca20 improve header wrapping functions
Augment the docs to clarify that msg:append_header and
msg:prepend_header do no modification of the value by default.

Adjust the wrapping used by Header:new_unstructured so that it
hard wraps before the SMTP line length limit.

Add optional encode parameter to msg:append_header and
msg:prepend_header so that those methods can opt-in to the
Header:new_unstructured formatting.

Add HeaderMap:append method to mirror the existing HeaderMap:prepend
method.

Add unit tests that demonstrate the effect of wrapping/encoding
for both the "dumb" msg:append_header and msg:prepend_header functions,
and the "smarter" HeaderMap:prepend and HeaderMap:append methods that
always encode their parameters.

Update the docs for the headermap flavor of these methods to indicate
that they will always encode the value.
2025-10-29 11:35:42 +00:00
Wez Furlong 1d70c2ffbb new smtp_server_rewrite_response event
This allows you to customize or otherwise adjust the responses
made by the smtp server.
2025-10-29 08:54:10 +00:00
Wez Furlong b2418cd304 queue: improve error context if maildir writing fails 2025-10-24 21:31:57 +01:00
Wez Furlong 3a9d0a994f data-loader: improve error message for file read error case 2025-10-24 21:22:14 +01:00
Wez Furlong 64ac5ad43b dmarc: adjust slack in pct rate test
I saw this failure in CI; we can relax things a bit more:

    Expected Left value to be lesser than Right value

    Left value:  6007
    Right value: 6000
2025-10-24 21:15:13 +01:00
crx 5132f87b96 Feature/traffic-gen custom headers (#434)
* traffic-gen: add support for --header
2025-10-24 09:08:42 -07:00
Wez Furlong c9f90ee5de logging: skip marking logs as done when in --validate mode
This enables running validation as a user that doesn't have write
permissions to the log directories.
2025-10-24 13:43:02 +01:00
Wez Furlong 47aac10ea6 data-loader: allow callback/event based loading of secrets
This allows a (more or less) arbitrary lua function to be used to load
data.

The primary advantage of this is that the size of the resulting
KeySource struct is smaller than it would be to hold the actual data
inline.  It also enables the surrounding code to be slightly better
factored.
2025-10-24 13:41:27 +01:00
Wez Furlong 6f31d5514c new Time and TimeDelta objects for lua
Motivated by https://github.com/KumoCorp/kumomta/pull/403,
this commit introduces reasonably full featured Time and TimeDelta
types built atop the chrono crate.

closes: https://github.com/KumoCorp/kumomta/pull/403
2025-10-22 17:26:35 +01:00
Dario MaiocchiandWez Furlong 847cc21e9b implement aes-cbc block with examples
Add CBC and ecb Block mode aes encryption/decryption.

To facilitate testing this better, and just to be nicer overall, adjust
data-loader's KeySource::key_data variant to support loading raw binary
bytes.

Co-authored-by: Wez Furlong <wez@wezfurlong.org>

Closes: https://github.com/KumoCorp/kumomta/pull/395
2025-10-22 11:55:16 +01:00
Sophia J. TurnerandSophia Turner 32e201d6a6 Add dmarc p/sp support (#433)
Add dmarc p/sp support

Co-authored-by: Sophia Turner <sophiajt@users.noreply.github.com>
2025-10-21 23:43:06 -07:00
Wez Furlong 6fc0d782ff spf: populate smtp.mailfrom in Auth-Results, add check_msg func
Add a convenience function that is intended to be used around the
time that you might be building up the overall set of
Authentication-Results.

Populate missing smtp.mailfrom in SPF authentication result.
2025-10-21 21:25:21 +01:00
Wez Furlong 0a117e9407 fix incorrectly treating 552 as TransientFailure
We should do this ONLY when the response is to a RCPT TO command,
otherwise it is a permanent failure.

refs: https://github.com/KumoCorp/kumomta/issues/431
2025-10-16 16:03:12 +01:00
Sophia Turner 4ba0f6c49b Move dmarc tests to use struct 2025-10-16 15:57:25 +01:00
Sophia Turner 30fb024eab Add psl to dmarc relaxed checks 2025-10-15 10:52:25 +01:00
Wez Furlong 42b65b2285 smtp_server: fixup data content
The recent message batching changes led to this bug; we were using
the unchanged data payload instead of the data that may have been
altered by lua callouts.

refs: https://github.com/KumoCorp/kumomta/pull/426#issuecomment-3400921174
2025-10-15 07:05:16 +01:00
Wez Furlong 8ba93b5454 add smtp_server_rejections counter to metrics
This is incremented each time we log a Rejection record from the smtp
server.

The service label identifies the listener address, and there is a
special `total` that is incremented as a rollup across all listeners.

```
 # HELP smtp_server_rejections number of Rejection records logged by the smtp server
 # TYPE smtp_server_rejections counter
 smtp_server_rejections{service="127.0.0.1:2025"} 1
 smtp_server_rejections{service="total"} 1
```

closes: https://github.com/KumoCorp/kumomta/issues/429
2025-10-15 06:59:56 +01:00
Wez Furlong 7eeb755f30 mailparsing: fix quoting issue with Mailbox display name
Let's base our quoting decisions based on whether the string is fully
atext compatible, and once quoting, on whether the character requires
quoting within the quoted string.

refs: https://github.com/KumoCorp/kumomta/issues/428
2025-10-14 14:59:04 +01:00
Wez Furlong 43e45e12c0 smtp_server: fix max_line_length issue
Partially reverts aac842439f and fixes the
underlying issue that led me to throw that together: the issue was that
the check_line_lengths function needed to add 2 to the index otherwise
iterations after the first would over-estimate the length of the
currently found line by 2, because the prior index included the CRLF
that it found in the input.

While poking at this, I found that there was a fairly harmless edge case
around non-DATA line handling: we used a 1024 stack buffer to read the
command in, and would accept anything that fit into that as valid, even
though the limit is set to a slightly smaller value.
2025-10-14 08:15:52 +01:00
Wez Furlong aac842439f smtp_server: increase line_length_hard_limit default to 1000
We were including the CRLF in the measurement that we were making,
while the default value was the value from the spec excluding the CRLF.
Let's increase the default value to 1000 to make things match up.
2025-10-13 09:53:03 +01:00
Wez Furlong 02989f1d49 dmarc: adjust pct test
I saw this flake out on the last push.  This commit adjusts the
expectations to allow 10% of slack either side of the theoretical
50% target specified by this test.
2025-10-13 09:44:39 +01:00
Wez Furlong adfdcef1f8 spf: improve test coverage, couple of fixes
* Add exp= test based on an example in the rfc
 * Discovered that we were a bit too strict and didn't allow spaces
   as shown in that example
 * Add integration test for the ehlo_domain string quoting issue
   resolved in 236afa417f
 * lua spf check: Assume ehlo_domain = domain when sender is none
2025-10-13 08:22:36 +01:00
Wez Furlong 236afa417f spf: avoid wrong kind of json -> string conversion
When populating ehlo_domain in particular, we were using the json
Value::to_string() impl which produces a json-serialized string
which includes quotes.

This is a bit of a foot-gun, so let's add a get_meta_string method
to ConnectionMetaData to parallel the equivalent
Message::get_meta_string method.
2025-10-11 07:00:21 +01:00
Wez Furlong b73d81b0fc dns: utilities and plumbing for querying DNSBLs
This commit does some plumbing work to allow defining alternative
resolvers with different names that can be used to query different
upstream DNS servers.

This is most useful when implement DNSBLs where you might have a custom
DNS server configured with one or more RBL zones that is reserved purely
for RBL lookups.

The plumbing introduces a more regular syntax for defining one of the
various implementations of the Resolver trait, as well as a new
Aggregate resolver impl that can query across multiple Resolvers until a
query is satisfied.

This allows some interesting and powerful configurations, such as
loading a static zone file into memory to query it directly, and/or
blending that together with querying either the system or some other
upstream DNS server as a fallback.

The various lookup functions (except for MX!) have been updated to
accept an optional alternate resolver name, so that they work together
with the above.

A new rbl_lookup function is also provided as a convenience for querying
the most common form of RBLS.

ptr_host and reverse_ip are two string utility functions that are likely
not going to be widely used, but are very convenient to have when you
do have a usecase that requires it!

closes: https://github.com/KumoCorp/kumomta/issues/269
2025-10-10 18:45:52 +01:00
Wez Furlong 32763a98b8 kcli provider-summary: dedup domains in domains list 2025-10-10 18:45:51 +01:00
Wez Furlong f582d60159 dns-resolver: standardize on Name::from_str_relaxed
In 34622edbd2 we made a similar change to
enable querying domain names with underscores.  Let's preemptively make
that same change to all places where we construct a Name.
2025-10-09 12:27:38 +01:00
Wez Furlong 8dfd591dd4 spf: ensure that all names are fqdn when resolving
No spf record should use the set of search domains in a local resolver;
all names are implicitly FQDN.  Let's explicitly mark up the names that
way so that we can avoid both potentially matching a surprising local
record and also excess DNS lookups for records that might not exist.
2025-10-09 12:22:59 +01:00
Wez Furlong 24602cff44 ci: reduce flakeyness in xclient test
I noticed a test failure where we hadn't yet received all of the
trace events that we wanted to inspect, so this commit introduces
the ability to wait for matching records to appear in the collected
set of data.
2025-10-09 09:12:41 +01:00
Wez Furlong 67061e3a24 spf: fixup handling of NoRecordsFound during exists: check
Similar to the general purpose resolve function, we should map
NoRecordsFound to empty list(s) of results in the specialized
ip, mx and ptr lookup functions, otherwise we can cause rule
evaluation to terminate too soon.
2025-10-09 08:47:09 +01:00