Commit Graph
3438 Commits
Author SHA1 Message Date
Wez Furlong 2bec97dbe1 ci: fixup some flakeyness in maildir_batch_452_b 2025-12-18 14:12:05 +00:00
Wez Furlong 1598adb8cc add explicit http auth integration test
So far this has been mostly implicitly covered by other tests.
Add an explicit test for directly testing http auth with a password.
2025-12-18 10:34:08 +00:00
Wez Furlong 07ab3d44a3 inject+xfer: cut over to AuthInfo from AuthKind
Replace the older type with the newer one.

Serialize a copy of auth_info when handling deferred generation,
so that we have a lossless representation of that state when
we eventually process the request.  That doesn't change really
anything today, but will enable more granular ACL checks in
the future.

Pass the auth_info through to the http_message_generated and
xfer_message_received events to enable more granular access
control policies to be scripted.
2025-12-18 10:19:09 +00:00
Wez Furlong 5926112956 acct: add kumo.aaa.configure_acct_log
This function sets up the accounting log which records authentication
and authorization events to a local log file.

Add some test assertions that we're not seeing any failed authn/authz
in a number of integration tests.

Add explicit check for failed a request to kcli's streaming metrics
parser, which previously would ignore the request status.
2025-12-18 08:22:31 +00:00
Wez Furlong 3e85297fca authn: allow returning AuthInfo from smtp/http auth event callbacks
This commit allows the policy to return a richer representation of
the authentication information, which can include multiple identities
and group membership information.
2025-12-18 06:30:06 +00:00
Wez Furlong 4055c50522 authz: introduce an ACL facility
This commit is a step towards some general improvements around
our handling of authentication and authorization.

This commit is focused primarily on authorization, but there are
some adjustments to how we track authentication as part of enabling
that.

We now have a separate AuthInfo type that holds the overall
authentication information/context associated with an inbound
SMTP or HTTP session.

It is populated with the peer_address as a fact rather than a statement
of trust.

If authentication via the appropriate lua auth callback is successful,
then the AuthInfo has additional identities added.

There are some types and events for loading access control lists and
matching their rules against an AuthInfo.

There is now a system default ACL that is equivalent to the prior
hard-coded access policy that was encoded into each HTTP endpoint.

This change makes it possible to replace the ACL with a
user-defined ACL.

Later will be some work on authentication to allow more options
for HTTP auth.
2025-12-18 06:30:06 +00:00
Wez Furlong 5d71c9d446 shaping: surface http errors more robustly when loading shaping files
Previously we'd ignore the HTTP status code and try to parse the body
as TOML regardless.

This commit raises an explicit error with the HTTP status code and
response body before trying to parse as TOML.
2025-12-18 06:30:05 +00:00
Wez Furlong 2a52388a98 config: refactor callback calling
Centralize the logic of walking and calling the registered handlers
so that we don't have 3 or more slightly different versions of it.

Introduce a CallbackDisposition type that can be used to drive
the default handling with more nuance; this will be useful
in a later commit where we need to distinguish between an
explicit nil being returned by a handler, and no handler
being defined.
2025-12-18 06:30:05 +00:00
Wez Furlong d68a4eca30 fix: log errors raised during should_enqueue_log_record
Previously, errors raised there would be silently discarded.
This commit logs them to the diagnostic log.
2025-12-18 06:23:43 +00:00
Wez Furlong fead711c80 mailparsing: improve charset detection/conformance fixing
We found an interesting issue where a MIME part was labelled as `text/`
with no explicit charset (and was thus implicitly "us-ascii", according
to the specs).  The content was actually UTF-8 encoded farsi text.

Since encoding_rs treats us-ascii as being an alias for windows-1252,
that part was re-encoded as bogus data, rather than being recognized as
UTF-8.

This commit improves the outcome in this situation:

1. Remove encoding_rs.  Replace its Charset type with the Encoding type
   that I added to the charset-normalizer crate in
   https://github.com/nickspring/charset-normalizer-rs/pull/45
   which allows us to actually differentiate between 7-bit ascii
   and latin-1.
2. Improve the handling of body part extraction; there were a couple
   of cases where we didn't consider the charset for text parts(!)
   and now we do, with some additional smarts for when the charset
   fails to decode.
3. Improve the conformance checking.  We do the majority of this
   during parsing, but we don't check for deeper issues such as
   the charset not matching the transfer-decoded payload because
   that is too costly to do for the majoriy of parses.  This commit
   introduces a deep conformance check that does validate that we
   can extract the part, flagging any failures as
   NEEDS_TRANSFER_ENCODING.
4. The charset detection options are threaded through the conformance
   checks and into the logic that extracts the parts during a rebuild,
   so that we can fix up those parts during rebuild.

The bulk of the conformance checking/fixing has been moved into the
mailparsing crate from the message crate, which makes the above a bit
easier and centralizes that logic better--fewer places to look to figure
things out.
2025-12-17 10:31:59 +00:00
Wez Furlong 6119250ebf templates: enable recursive lookup for Handlebars 2025-12-17 06:31:14 +00:00
Wez Furlong 716f880d41 spf: fix a potential panic if spf record contains U+200B
Adopting the get() method to handle the case where a string index is not
valid allows trapping and dealing appropriately with this abberant
input.
2025-12-16 13:53:27 +00:00
Daniel Smith 9738d2913b add some rules and divide other rules into appropriate labels 2025-12-04 14:56:34 -05:00
Wez Furlong b551d6b4c7 docs: update for release 2025.12.02-67ee9e96 2025-12-02 11:11:05 +00:00
Wez Furlong 67ee9e96ea docs: mail_auth: dmarc is implemented and available 2025-12-02 10:54:29 +00:00
Wez Furlong c379a931a1 docs: fix typo 2025-11-27 17:18:11 +00:00
Wez Furlong 0523263b0d message: ensure all meta-loading methods are async and load meta
This commit follows in the same vein as
1795fa6f56 and makes all the message
meta accessors async and capable of loading meta on demand.
2025-11-27 12:51:54 +00:00
Wez Furlong f0c2b490f4 metrics: fix prefix not being applied to metrics with multiple labels
we were producing output like this when `prefix=kumomta_`:

```
 # HELP kumomta_total_readyq_runs total number of times a readyq maintainer was run
 # TYPE kumomta_total_readyq_runs counter
 kumomta_total_readyq_runs 17
 # HELP kumomta_connection_count number of active connections
 # TYPE kumomta_connection_count gauge
 connection_count{service="smtp_client"} 0
 connection_count{service="esmtp_listener"} 0
 connection_count{service="lua"} 0
```

Those `connection_count` lines should be `kumomta_connection_count`.
2025-11-27 05:00:13 +00:00
Wez Furlong 3c4553ad7b docs: add logo 2025-11-26 16:46:25 +00:00
Wez Furlong c5266e260e docs: changelog for #457 2025-11-25 13:17:46 +00:00
Wez Furlong 38a15fe891 docs: format aws_sign_v4
refs: https://github.com/KumoCorp/kumomta/pull/457
2025-11-25 13:16:20 +00:00
Wez Furlong d47e280b9a ci: pruning in the builder images 2025-11-25 13:14:56 +00:00
Aditya GantiandAditya Ganti b96dd0843f Add AWS SigV4 signature module (#457)
* Add AWS SigV4 signature module

 - Implements complete AWS Signature Version 4 algorithm
 - Supports all AWS services (S3, SNS, SQS, Kinesis Firehose, etc.)
 - Includes SHA256 hashing and HMAC-SHA256 signing
 - Secure key management via KeySource (files, Vault, inline)
 - Session token support for temporary credentials
 - Comprehensive documentation and examples
 - 5 unit tests and 5 integration tests (all passing)

 Exposes kumo.aws.sign_v4() function to Lua for signing AWS API
 requests. This enables KumoMTA to integrate with AWS services for
 streaming logs to Kinesis Firehose, storing data in S3, sending
 notifications via SNS, and more.

 Tested with:
 - S3 GET/PUT requests
 - SNS POST requests
 - SQS with query parameters
 - Kinesis Firehose PutRecord

updating README.md file

Co-authored-by: Aditya Ganti <adityaganti@mac.mynetworksettings.com>
2025-11-25 06:14:48 -07:00
Mike Hillyer 7186aa380d Add reference to community contributed Mautic Webhook Callback. 2025-11-24 16:02:02 -05:00
Wez Furlong a76857cffb ci: try alternative way to install the rust-toolchain version
This should avoid having two different versions of the toolchain in the
common case, and reduces the size of the builder image.
2025-11-23 10:21:00 +00:00
Wez Furlong 7b583047d2 ci: pre-download the rust-toolchain version in the builder image 2025-11-23 10:04:45 +00:00
Wez Furlong 0b2c7871b6 ci: improve deb package compression performance 2025-11-23 09:56:30 +00:00
Wez Furlong cc03878c23 ci: adjust builder sccache build for amazonlinux:2
It doesn't like the full sccache build due to some wonkyness
with openss on this old distro.

Let's just pave over this by not enabling the full build
on that platform.
2025-11-22 21:44:41 +00:00
Wez Furlong 3c75f92d76 ci: re-enable sccache default features
At some point turning off most features used to make things work in our
environments, but looking at things today, I think it basically makes
it do nothing useful any more.

Turning things off just made the image build a hair faster and the
image a hair lighter.

So let's just turn it back on
2025-11-22 21:26:53 +00:00
Wez Furlong 08a72bb9b1 CI: implement dependency cooldown for github actions
See: https://blog.yossarian.net/2025/11/21/We-should-all-be-using-dependency-cooldowns
2025-11-21 21:04:09 +00:00
Wez Furlong 2d557f68bf kcli: expose smtp_server_rejections counter 2025-11-20 15:39:36 +00:00
Wez Furlong 245221ae29 docs: clarify Time and TimeDelta
It wasn't clear that these pages were describing a class rather than a
literal object.

Add some more usage examples.
2025-11-20 15:26:42 +00:00
Wez Furlong 3d7802db37 docs: changelog for keysource event callback 2025-11-20 15:12:35 +00:00
Wez Furlong 65fde5c03b docs: fixup whitespace in changelog 2025-11-20 15:09:16 +00:00
crxandWez Furlong 39fbf150a9 traffic-gen header in changelog (#455)
* Changelog update

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2025-11-20 08:08:15 -07:00
Wez Furlong 027e3e9f75 docs: wrap examples in normalize_smtp_response.md 2025-11-20 14:54:26 +00:00
Wez Furlong 7b240db3e1 docs: fix copypasta in smtp_server_rewrite_response page
It said smtp_CLIENT instead of server
2025-11-20 14:53:03 +00:00
Wez Furlong 2023aba6af docs: mention template dialect in injection and eval_template APIs 2025-11-20 14:50:15 +00:00
Wez Furlong 3781ff7d95 docs: format 2025-11-19 07:57:37 +00:00
Wez Furlong 984e4a3156 CI: try out automatic mirroring to codeberg 2025-11-18 22:14:40 +00:00
Wez Furlong a28508ea07 rfc5321: improve error message formatting
In reviewing some live logs, I could see that some timeout errors
were including the debug repr of the SMTP command, which is too verbose
to be useful in the error log line, so let's tidy that up a bit
here to make it easier to understand.
2025-11-18 16:55:57 +00:00
Wez Furlong 6f53931fde add kumo.invoke_get_egress_(pool|source)
These functions are similar to the existing
invoke_get_egress_path_config and invoke_get_queue_config functions;
they return the configuration information that is defined by your
overall policy in the same way that the system does.

The intent is for more advanced policies that need that info to
decide how to configure other parts of the policy.

Docs are included, and I fleshed out the missing docs for the two
pre-existing functions.
2025-11-14 07:04:58 +00:00
Wez Furlong 4c89acae96 docs and changelog for require_proxy_protocol #440 2025-11-13 15:27:39 +00:00
4e767ff96f Add support for proxy protocol (#440)
Add support for proxy_protocol for start_esmtp_listener

Co-authored-by: Solvik Blum <solvik@solvik.fr>
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
Co-authored-by: ncai <ncai@chapsvision.com>
2025-11-13 07:54:36 -07:00
Wez Furlong f2f792e74f kumo.digest: add various HMAC_SHAXXX functions 2025-11-13 12:06:32 +00:00
Wez Furlong fdd2276dfb mod-digest: switch from ring::digest to aws-lc-rs::digest
Switch away from ring to aws-lc-rs which API compatible and has support
for more digest algorithms.

Add support for all of the current algorithms.
2025-11-13 11:10:13 +00:00
Wez Furlong 26a0c86c49 Expose version number to lua via kumo.version
I'm surprised that we didn't already do this!
It allows phrasing the policy to accommodate different versions
of kumo.
2025-11-13 06:30:35 +00:00
Wez Furlong 1c3b6dc14a smtp_dispatcher: fix reverse order for mx_list
When using an explicit mx_list, rather than consuming the DNS-provided
MX records, we were populating the connection plan LIFO with the mx_list
which is specified as a FIFO.

The result was that we would connect to the addresses in the reverse of
the intended order.

Most users only populate a single entry for mx_list, if they use this at
all, so it has flown under the radar.  This issue was introduced
together with the mx_list feature in bcd2946c53.

This commit corrects that issue so that the behavior conforms to the
intended and documented ordering, and tweaks the tests to accommodate
it; the test changes required were:

1. disconnect_in_data was actually sensitive to the order, and encoded
   the reverse ordering in its expectations. :-/
   It now correctly encodes the correct order, which should allow
   detection of regression in the future.

2. disconnect_terminate_ok is sensitive to extraneous TransientFailures.
   It was implicitly dependent on the ordering of the mx_list in the
   sense that it relied on the FIFO list returning as [127.0.0.1, ::1],
   which resulted in trying ::1 first (because that list is consumed as
   LIFO), failing due to ::1 not actually being bound in the test
   environment, and proceeding to test with 127.0.0.1 being the last
   working address.

   With the ordering fixed that test started to fail because the second
   host in the correct connection plan was ::1 and that was not
   reachable, triggering a TransientFailure against the expectations
   of the test.

   The goal of the test was to verify the behavior in the
   exhausted-connection-plan case, rather than the
   unreachable-final-mx-case, so the resolution here is to add v6
   addresses to the skip_hosts config.  Will that come back to haunt us?
   Time will tell.
2025-11-13 06:12:38 +00:00
Wez Furlong 9e0b019155 response normalizer: allow seeing into parentheticals
For a sequence like `[BASE64 IP: IPADDR]` we were not previously
able to see the base64 or IP address inside the square brackets.

This commit adds a pre-processing step to strip out parentheticals
surrounded by spaces (or the end of the string) so that our existing
tokenization can take effect.

I spent a few hours today trying a few different matching strategies,
rewriting this crate 3 different ways to try to simplify the logic and
lean more heavily on the regex or fancy_regex crate so that we can avoid
special cases.  While they all worked, they all were over an order of
magnitude worse in terms of throughput and performance.

The strategy here is to perform a very cheap SIMD-assisted test to see
if we need to pre-process the string so that we can avoid the overhead
of the additional string allocation and full processing step.

The result is that the performance before and after this change is very
close to neutral when the response contains no brackets, but 33% slower
(and 50% throughput) when brackets are present.  That's still 180MiB/s
on my threadripper which is still decent for this application.

While grubbing around in here today, I noticed that a couple of regexeps
had typos: `(:?` when they should have been `(?:`, and I annotated more
sub-expressions to be non-capturing as well.
2025-11-12 15:40:28 +00:00
Wez Furlong 1795fa6f56 message: ensure all data-loading methods are async and load data
This commit tidies up a bit of an API wart that stems from
the initial implementation where we couldn't guarantee that
the message crate would know how to get a spool handle to
implicitly load data when needed.

This has resulted in a couple of issues over time where we try to
operate on the message data and it just hasn't been loaded, leading to
transient errors being raised in the best case, but in a possible worst
case, a silent error condition.

During the rebind_message event, if the message is not loaded,
msg:get_data() could return the placeholder empty data value.  If the
rebind_message event is trying to mutate the message then the best case
is that an error is raised, a medium-bad case is that operations like
`msg:append_header` will fail to find the header block and thus fail,
and the worst case is that mutation operations that blinding prepend
data (perhaps msg:prepend_header) could end up assigning a bogus
truncated message.  While we don't generally recommend this sort of
action, this is potentially a very gnarly consequence of trying things
out.

Let's just head all of these sorts of issues off by making the accessors
async and have them internally load the data as required.
2025-11-11 10:28:51 +00:00