1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00
Commit Graph

507 Commits

Author SHA1 Message Date
Alberto Bertogli
ac1c849a27 docs: Document how to report a security issue
Some systems, like GitHub, can use `docs/SECURITY.md` to inform users on
how to report security issues.

This patch adds one to the tree. It is not linked explicitly in mkdocs
because the same information is already covered in the doc index and
README already.
2023-07-28 10:05:15 +01:00
Alberto Bertogli
2e279de304 github: Run coverage tests
This patch adds a job to the docker workflow to run coverage tests, and
upload the results to coveralls.
2023-07-28 10:05:15 +01:00
Alberto Bertogli
a3f7914e29 sts: Remove unused struct member
There is no synchronization needed in the sts cache, because changes are
handled atomically on-disk and there is no in-memory persistence.
2023-07-28 10:05:15 +01:00
Alberto Bertogli
2b7e33a615 domaininfo: Do not reload the database periodically
It is not expected that the user modifies the domaininfo database behind
chasquid's back, and reloading it can be somewhat expensive.

So this patch removes the periodic reload, and instead makes it triggered
by SIGHUP so the user can trigger a reload manually if needed.
2023-07-28 10:05:15 +01:00
znerol
ad0dbb9cda smtp-check: Add flag to specify local name
Some MTAs reject client connections unless the local name (used in the
HELO/EHLO command) looks like an FQDN. Currently, smtp-check always uses
`localhost`, which does not look like an FQDN.

This patch adds a command line flag to smtp-check to specify the
local name to be used.

Fixes https://github.com/albertito/chasquid/issues/37.

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Minor edits to the commit message, adjust flag name, go fmt.
2023-07-16 10:03:50 +01:00
Alberto Bertogli
9e8452520a docs: Update badge/link to the CI status
The current badge, which covers all the branch checks doesn't work, it
always says "pending".

This patch replaces it with the gotest workflow status. It is much more
narrow, but at least it works and gives a decent indication of the
testing status.
2023-05-24 22:18:12 +01:00
Alberto Bertogli
01a6d088e2 test: Add a set of tests for handling bad/invalid configs
This patch adds a set of tests to validate chasquid's handling of bad
and invalid configurations, to make sure we fail as expected.
2023-05-17 00:44:54 +01:00
Alberto Bertogli
0c9d1536db docs: Update tests.md to reflect coverage changes, and add links
This patch updates tests.md to reflect the recent changes around
coverage testing, specifically we no longer have coverage issues with
fatal/non-zero exits, so remove that section from the docs.

Also while at it, add links to the software we reference, for
convenience.
2023-05-16 10:50:26 +01:00
Alberto Bertogli
e85ad54a73 Regenerate auto-generated files
This patch regenerates the auto-generated files.

There are no significant changes, the protobuf just get an updated
comment due to protoc version change, but it is just informational.

Two new TLS ciphers are added, matching the new IANA assignments.
2023-03-03 11:24:40 +00:00
Alberto Bertogli
fd9c6a748b courier/smtp: Retry over plaintext on STARTTLS errors
When the SMTP courier gets an error on STARTTLS (either because the
command itself failed, or because there was a low-level TLS negotiation
error), today we just fail that attempt.

This can cause messages to never be delivered if the underlying reason
is a server misconfiguration (e.g. a server certificate that Go cannot
parse). This is quite rare in practice, but it can happen.

To prevent this situation, this patch adds logic so that the SMTP
courier retries over plaintext when STARTTLS fails.

This is still subject to security level checks, so this type of failures
cannot be used to downgrade connections to domains we successfully
established a TLS connection previously.

Note that certificate validation issues are NOT included in this
type of failure, so they will not trigger a retry. The certificate
validation handling is unchanged by this patch.
2023-03-03 09:51:48 +00:00
Alberto Bertogli
1927e15ea2 docs: v1.11 release notes v1.11 2023-02-19 16:20:50 +00:00
Alberto Bertogli
34977fe834 modules: Update Go modules
This patch does a general pass updating Go modules to recent versions.

This should fix a minor security advisories around http/2 handling. Even
though chasquid doesn't directly expose http/2, the monitoring server
could be affected.
Reference: https://pkg.go.dev/vuln/GO-2023-1495.
2023-02-19 08:54:44 +00:00
Alberto Bertogli
efefee9fbb test: Update fuzz tests to use the built-in infrastructure
Go 1.18 supports fuzzing natively, so this patch migrates our fuzzing
tests to make use of it.
2023-02-05 12:30:25 +00:00
Alberto Bertogli
a54d81f406 monitoring: Get build information from Go's runtime
Currently, chasquid gets version information from build-time flags that
have to be passed by the user.

This patch extends this logic so, if no flags are given, Go's build
information will be used to construct a synthetic version string.
2023-02-05 11:01:36 +00:00
Alberto Bertogli
ab63834cba Update minimum supported Go version 1.17 -> 1.18, and modules
This patch updates the minimum supported Go version from 1.17 to 1.18,
and also the versions of our dependencies.

Go 1.18 is now 2 releases old, and easily available in most Linux
distributions, including Debian stable (via backports).
2023-02-05 10:42:37 +00:00
Alberto Bertogli
77328b88ed test: Remove unnecessary "exit" calls 2023-02-01 23:45:51 +00:00
Alberto Bertogli
7d6a59ba77 test: Update coverage tests to Go 1.20
Go 1.20 finally includes proper support for instrumenting binaries for
coverage. This allows us to drop quite a few hacks and workarounds that
we used for it, and we can now also test exiting cases.

The downside is that coverage tests now require Go 1.20, but it is an
acceptable price to pay for the more accurate results.

Normal integration tests are unchanged.

This patch updates the coverage testing infrastructure to make use of
the new Go 1.20 features.
2023-02-01 23:43:12 +00:00
Alberto Bertogli
795f2a7ceb ci: Use Github Actions to run integration tests and push Docker images
We're running against the usage limits in Gitlab CI (500), and Github
Actions should have more (2000).

So this patch replaces Gitlab CI with Github actions for running
integration tests, and build and push Docker images (to Dockerhub and
Gitlab registry).

We'll see how the usage levels are in a few months.
2022-11-13 19:16:10 +00:00
Alberto Bertogli
948cee1ce1 Improve bash quoting, and other similar best practices
This patch updates the shell scripts with some of the common best
practices, which should make them more resilient to unusual failures and
unexpected environments (in particular, directories with spaces).

Most of these were identified by shellcheck.
2022-11-13 11:09:19 +00:00
Alberto Bertogli
e2481b07a9 cirrus: Remove the golangci-lint test
Cirrus CI runs golangci-lint, which is often way too noisy with false
positives and irrelevant checks. Last one was errcheck on
http.ResponseWriter.Write, but there have been others before.

Disable it for now, since it doesn't add enough value to justify the
introduced friction.
2022-11-13 11:09:19 +00:00
Alberto Bertogli
4d1526e0c8 test: Reduce main sources of overhead in integration tests
The integration tests spend a lot of time on some ancilliary actions,
which slows them down: generating certificates, adding users, and
waiting for things to happen.

To improve the performance of those actions, this patch:

- Makes (most) tests use plain passwords (-20%)
- Adds a certificate cache to reuse certs (-10%)
- Tightens the sleep loops (-5%)

In aggregate, this patch results in a speedup of the integration tests
of ~30-40%.

Note that some of the tests required adjusting the username, because
`chasquid-util user-add` would convert them to lowercase as per PRECIS
mapping.
2022-11-13 11:09:19 +00:00
Alberto Bertogli
4a00a83c23 Add tracing annotations
This patch changes several internal packages to receive and pass tracing
annotations, making use of the new tracing library, so we can have
better debugging information.
2022-11-13 11:09:19 +00:00
Alberto Bertogli
9c6661eca2 nettrace: Add a new tracing library
This commit introduces a new tracing library, that replaces
golang.org/x/net/trace, and supports (amongts other thing) nested
traces.

This is a minimal change, future patches will make use of the new
functionality.
2022-11-13 11:09:19 +00:00
Alberto Bertogli
3ebe5c5173 Replace uses of ioutil
ioutil package was deprecated in Go 1.16, replace all uses with their
respective replacements.

This patch was generated with a combination of `gofmt -r`, `eg`, and
manually (for `ioutil.ReadDir`).
2022-11-12 20:06:35 +00:00
Alberto Bertogli
008367d320 Update minimum supported Go version 1.15 -> 1.17
The latest version of some packages we depend on (golang.org/x/sys,
indirectly) do not support 1.15 anymore.

We kept 1.15 because it's the version on Debian stable, but that release
is more than 2y old, and newer versions are readily available in Debian
stable backports.

So this patch updates the minimum supported Go version to 1.17.
2022-11-12 20:06:35 +00:00
Alberto Bertogli
6896b221e8 github: Use the latest Go version for govulncheck
govulncheck will complain when run on older Go versions that are known
to have security issues. Github setup-go action has a cache for the
"latest" go version and sometimes the latest isn't really used.

So sometimes, this generates false positives because govulncheck is run
on an older Go version, which is not a problem in chasquid itself.

To prevent those false positives, this patch asks the Github CI to
always check for the latest Go version when running govulncheck.
2022-11-12 18:31:57 +00:00
Alberto Bertogli
f5949a79f1 test: Update expected DSN to accept headers set by latest msmtp
Newer versions of msmtp now set In-Reply-To and References header,
causing t-16-spf test to fail because we expect them to be empty (for no
particular reason).

So this patch changes our expected DSN used for testing to ignore their
values.
2022-11-12 18:21:13 +00:00
Alberto Bertogli
c738c7edf9 courier: Move the test fake server into a separate file
In future patches we will use the test fake server in other tests, so
move it to a separate file for clarity.
2022-11-12 16:34:35 +00:00
Alberto Bertogli
cbb620eec2 modules: Update Go modules
This patch does a general pass updating Go modules to recent versions.

The main purpose is to make sure people building from source are using
relatively recent versions of our dependencies.
2022-11-12 11:52:26 +00:00
Alberto Bertogli
2bad7a14be etc: Simplify default config by removing systemd sockets
Having systemd open sockets and pass them to chasquid is neat, but also
adds some complexity to the default config, for very little value in
practice.

This patch simplifies the default config by having chasquid open the
sockets instead.

Note that systemd file descriptor passing continues to be supported, and
existing installations will not be affected.
2022-11-12 11:49:20 +00:00
Alberto Bertogli
48da3c1657 etc: Add missing submission_over_tls_address docs to chasquid.conf
This patch adds documentation for submission_over_tls_address in the
default chasquid.conf, which was accidentally missing.
2022-11-12 11:48:46 +00:00
Alberto Bertogli
c3b4cde29a monitoring: Add dark mode CSS to the monitoring home page 2022-10-21 10:12:06 +01:00
Alberto Bertogli
fbb9bed366 ci: Add Github workflows
This patch adds two github workflows that will run on each commit, and
also regularly: CodeQL and govulncheck.
2022-10-21 10:11:37 +01:00
Alberto Bertogli
b9c2ef68f9 Use git describe --tags to include non-annotated tags
By default, `git describe` uses only annotated tags. Since some may not
be annotated (like v1.10) this causes some scripts to pick a confusing
version identifier.

This patch fixes the issue by passing `--tags`, which means all tags
will be considered.
2022-09-04 13:10:07 +01:00
Alberto Bertogli
ddcfacccd0 docs: v1.10 release notes v1.10 2022-09-02 16:01:43 +01:00
Alberto Bertogli
776bdc58ab Update Go doc comments to Go 1.19's format
This patch is the result of running Go 1.19's `gofmt` on the codebase,
which automatically updates all Go doc comments to the new format.

https://tip.golang.org/doc/go1.19#go-doc
2022-09-02 11:11:40 +01:00
Alberto Bertogli
7e38a877e8 hooks: Fix dkimpy's diff check
When running a diff for dkimpy's output, we expect that diff to exit with
non-zero code.

Unfortunately, the way we set that expectation (by prefixing the diff
invocation with `!` is incorrect.

Running `! diff ...` will not cause the hook to fail if diff exits with
0, instead `!` will cause the exit code to be ignored.

This patch fixes the problem by running `diff ... && exit 1` instead.

This was caught by shellcheck, https://www.shellcheck.net/wiki/SC2251.
2022-08-27 23:58:26 +01:00
Alberto Bertogli
e85c31782b Fix misc. linter issues (comments, variable naming, etc.)
We've accumulated a few linter issues around comments and a couple of
variable names.

While none of them is major, this patch cleans them up so it's easier to
go through the linter output, and we can start being more strict about
it.
2022-08-27 23:49:33 +01:00
Alberto Bertogli
6dfff9a790 modules: Update Go modules and regenerate protobufs
This patch does a general pass updating Go modules to recent versions, and
regenerates the protobufs accordingly.

The main purpose is to make sure people building from source are using
relatively recent versions of our dependencies.
2022-08-27 23:39:40 +01:00
Alberto Bertogli
3eed7cd1a9 test: Use our own generate_cert helper
The current generate_cert helper was originally taken from Go's source,
and is more complex than we need it to be.

This patch replaces it with our own version, rewritten from scratch
independently.
2022-08-27 23:39:40 +01:00
Alberto Bertogli
21e8d50df6 test: Improve layout of helper binaries
This patch moves the test helper binaries to a "one directory per
helper" layout, and also makes them to be ignored in the coverage build
instead of all builds.

With this change, "go build ./..." will build all binaries including the
test helpers, which helps make sure that module manage automation also
considers them. In particular, this makes "go mod tidy" work fine.
2022-08-27 18:46:54 +01:00
Alberto Bertogli
567ad35122 docker: Only do setfacl if we issued the certificates
Today, we do setfacl unconditionally; this can be a problem for
user-provided certificates because they may be located somewhere else.

This patch fixes the problem by only doing setfacl after renewing the
certificates.

Externally provided certificates will be untouched, and the user is
responsible for ensuring that chasquid can read them.

Thanks to Alex Ellwein (aellwein@github) for reporting this in
https://github.com/albertito/chasquid/issues/29!
2022-08-23 23:48:35 +01:00
Alberto Bertogli
b779941f90 Remove spf-check debugging tool
The spf-check debugging tool is quite primitive, rarely (if ever) used,
not tested, and has been superceded by the one in the spf library
(https://blitiri.com.ar/git/r/spf/b/master/t/cmd/spf-check/f=spf-check.go.html).

This patch removes it.
2022-08-08 17:56:58 +01:00
Alberto Bertogli
5bb17c7066 Update build tag constraints
This patch updates all build tag constraints to add the new format,
alongside the old one, to maintain backwards compatibility.

This was done by using `go fmt`.

See https://go.dev/doc/go1.17#gofmt and
https://golang.org/design/draft-gobuild for more details.
2022-08-08 17:52:34 +01:00
Alberto Bertogli
d4b89db6c3 modules: Update blitiri.com.ar/go/spf to 1.5.0
This patch updates the dependency on blitiri.com.ar/go/spf from v1.4.0
to v1.5.0, which includes a few bug fixes.

There are no code changes needed.
2022-08-08 17:36:01 +01:00
Alberto Bertogli
735613cdf7 test: Set state_dir in Dovecot config
Dovecot's `state_dir` usually defaults to be at `/var/lib/dovecot`, or a
similar system-wide path.

Under some conditions, our test Dovecot instance can fail, because it's
wanting to write to state_dir, but it is not writeable by us in the test
environment.

This was reported by foxcpp in
https://github.com/albertito/chasquid/issues/28.

This patch fixes the problem by setting a custom state_dir to be within
our testing directory.

Thanks to foxcpp for reporting this problem and suggesting a fix.
2022-07-04 09:46:50 +01:00
Alberto Bertogli
7fe22ef104 docs: Update URL for Arch binary packages
This patch updates the URL for the Arch binary packages, which has moved.

Thanks to foxcpp for maintaining them and letting me know about the
change.
2022-07-04 09:46:11 +01:00
Alberto Bertogli
5c51f74941 modules: Update blitiri.com.ar/go/spf to v1.4.0
This patch updates the dependency on blitiri.com.ar/go/spf from v1.3.0
to v1.4.0.

There are no code changes needed, but the new version contains some
important fixes around lookup limits counting.
2022-06-19 12:11:27 +01:00
Alberto Bertogli
faadae15ca tests: Detect buggy dkimpy versions, and skip the test if needed
Some dkimpy versions have a bug where it can't parse the keys generated
by its own key generator. That causes the dkimpy test to fail.

See https://bugs.launchpad.net/dkimpy/+bug/1978835 for more details.

This patch adds a workaround which detects the buggy version, and skip
the test if needed.
2022-06-19 11:56:30 +01:00
Alberto Bertogli
f303e43082 aliases: Implement catch-all
This patch implements support for catch-all aliases, where users can add
a `*: destination` alias. Mails sent to unknown users (or other aliases)
will not be rejected, but sent to the indicated destination instead.

Please see https://github.com/albertito/chasquid/issues/23 and
https://github.com/albertito/chasquid/pull/24 for more discussion and
background.

Thanks to Alex Ellwein (aellwein@github) for the alternative patch and
help with testing; and to ThinkChaos (ThinkChaos@github) for help with
testing.
2022-03-11 20:51:06 +00:00