Development
Prerequisites
Section titled “Prerequisites”- Rust (edition 2024)
protoconPATH(ferritor-core’s build compiles the proto withtonic-prost-build, andferritor-agent’s the Secrets Store CSI Driver’s provider API, vendored unchanged incrates/ferritor-agent/proto/, outsidebuf’s module: it isn’t ours to restyle)- Docker or Podman, for the two local databases
sqlx-clibuilt with thesqlx-tomlfeature (without it, it refuses to run in the store crates):cargo install sqlx-cli --no-default-features --features rustls,postgres,sqlx-toml- optionally
buf, to lint and format the proto - optionally a nightly toolchain and
cargo-fuzz, for the fuzz targets (see “Fuzzing”)
cp .env.example .envdocker compose up -d # keys DB on port 5433, data DB on 5434, user/password ferritor.env holds two pairs of URLs to the same two databases, for different
readers:
KEYS_DATABASE_URL,DATA_DATABASE_URL: the build (thequery!macros check SQL against them at compile time),sqlx-cliand the tests. Never needed in production: a release build uses the committed.sqlx/caches (SQLX_OFFLINE=true), and the server runs its own migrations at startup.FERRITOR_KEYS_DATABASE_URL,FERRITOR_DATA_DATABASE_URL: the server’s own settings, written as${KEYS_DATABASE_URL}and${DATA_DATABASE_URL}(dotenvy expands them), so each URL is written once.
Other server settings go in ferritor.toml (start from ferritor.example.toml)
or as more FERRITOR_* lines in .env.
Commands
Section titled “Commands”cargo buildcargo run -p ferritor-server # the servercargo run -p ferritor-cli -- status # the `ferritor` CLI (`--help` for commands)cargo test # everythingcargo test -p ferritor-core # one cratecargo test <name_substring>cargo fmtcargo clippy --all-targets --all-features --locked -- -D warnings # warnings are errorsbuf lint && buf format -w # the protoBenchmark or measure performance only with --release. A release build
of the server doesn’t read .env (only debug builds do; see
configuration), so export its variables into the shell first:
set -a; . ./.env; set +a # the shell expands the ${KEYS_DATABASE_URL} lines toocargo run --release -p ferritor-serversqlx with two databases
Section titled “sqlx with two databases”The query! macros check SQL against a live database at compile time, and
each crate can point at only one. So each database has its own crate, whose
sqlx.toml names the variable holding its URL: KEYS_DATABASE_URL for
ferritor-keystore, DATA_DATABASE_URL for ferritor-datastore. Never put a
query for one database in the other’s crate: it would be checked against
the wrong schema.
sqlx-cli reads sqlx.toml from the current directory, so run it inside
the store crate (it finds the workspace .env by searching upwards):
(cd crates/ferritor-keystore && sqlx migrate run)(cd crates/ferritor-keystore && sqlx migrate add <name>) # a new migration(cd crates/ferritor-keystore && cargo sqlx prepare) # refresh the offline query cache(cd crates/ferritor-keystore && cargo sqlx prepare --check) # fail if it's stale (CI)Offline builds. Each store crate commits its query cache in .sqlx/.
Without a database URL, or with SQLX_OFFLINE=true, the macros use it, so a
fresh checkout or CI builds without databases. After changing a query! or
a migration, run cargo sqlx prepare in that crate and commit .sqlx/ with
the change: with .env present, local builds check live and won’t notice a
stale cache, but --check and an offline build will.
The server runs both stores’ migrations at startup, on a separate connection
without statement_timeout.
Resetting the development databases. Nothing has been released, so a
schema may be replaced rather than migrated: both stores’ migration
histories were squashed into one 0001 each (the data database’s reshaped
into namespaces, paths and secret_versions), and a database migrated
with the old history refuses to start (sqlx: migration 1 was changed, or
migrations applied that are missing here). Start both databases over (this
deletes every local secret and the seal: init again afterwards), either
everything:
docker compose down -v && docker compose up -d # -v removes both volumesor only the two development databases, keeping the bench ones (the server,
or sqlx migrate run in each store crate, migrates them again):
docker compose exec -T keys-db psql -U ferritor -d postgres -c 'DROP DATABASE ferritor_keys WITH (FORCE)' -c 'CREATE DATABASE ferritor_keys'docker compose exec -T data-db psql -U ferritor -d postgres -c 'DROP DATABASE ferritor_data WITH (FORCE)' -c 'CREATE DATABASE ferritor_data'Store and server tests are integration tests (tests/) against the real
databases, through ferritor_testkit::TestDatabase: each test creates its own
ferritor_<name>_test_* database from the crate’s URL variable, runs the
migrations, and drops it when it passes. A failing test leaves its database
behind for inspection; to clean up:
for s in keys-db data-db; do echo "SELECT format('DROP DATABASE %I WITH (FORCE)', datname) FROM pg_database WHERE datname LIKE 'ferritor\_%\_test\_%' \gexec" | docker compose exec -T $s psql -U ferritor -d postgres -q; doneTLS tests use ferritor_testkit::pki::Ca, which makes certificates and CRLs at
run time, and workload-identity tests ferritor_testkit::jwt::TokenIssuer
(an Ed25519 key, its JWKS and the tokens it signs), so no keys are checked
in but one: crates/ferritor-server/tests/fixtures/jwt-test-rsa.pk8, an
RSA-2048 key for the RS256 and RSA-CSR tests (ring can’t generate RSA
keys), which signs nothing outside them. Audit entries are read through
ferritor_testkit::Captured::lines, which hides the hash chain’s own lines and
fields (Captured::raw has the bytes). CLI tests run the real ferritor
binary against an in-process server. The metrics tests (the server’s
tests/prometheus.rs and tests/metrics.rs, the agent’s and the CSI
provider’s ferritor-agent/tests/metrics.rs) each have their own binary,
since the OpenTelemetry provider is process-wide. Each holds a table in
monitoring to what a scrape returns, and
ferritor-metrics/tests/dashboards.rs holds the Grafana dashboards in
deploy/grafana/ to those tables: a dashboard may query only a documented
metric.
Auto-unseal is tested with MemoryKms, a provider that keeps its key in
memory (and can be switched off or slowed). The AWS client itself has one
test against the real service, tests/aws_kms.rs, which runs only when
FERRITOR_TEST_AWS_KMS_KEY names a key (its ARN) the caller may use, with
credentials from the SDK’s usual chain; otherwise it returns at once:
aws sso login --profile devAWS_PROFILE=dev FERRITOR_TEST_AWS_KMS_KEY=arn:aws:kms:…:key/… \ cargo test -p ferritor-server --test aws_kmsIt needs kms:Encrypt, kms:Decrypt and kms:DescribeKey on the key.
The Google Cloud KMS client, tests/gcp_kms.rs, runs against a double of
Cloud KMS’s REST API on loopback in every run (the requests, the AAD, how
refusals are sorted, the retry), and once more against the real service
when FERRITOR_TEST_GCP_KMS_KEY names a key (its resource name), with
Application Default Credentials. Impersonate the service account the
servers use, so the test runs with their permissions (it needs
roles/iam.serviceAccountTokenCreator on that account):
gcloud auth application-default login \ --impersonate-service-account ferritor-server@my-project.iam.gserviceaccount.comFERRITOR_TEST_GCP_KMS_KEY=projects/my-project/locations/…/keyRings/…/cryptoKeys/… \ cargo test -p ferritor-server --test gcp_kmsEach provider is a feature of ferritor-server, both on by default:
aws-kms (the AWS SDK) and gcp-kms (Google’s credentials crate and an
HTTP client for KMS’s REST API, on rustls with ring, never aws-lc-rs).
Without one (--no-default-features, then --features …), a config
naming its provider refuses to start.
The CSI provider in a cluster
Section titled “The CSI provider in a cluster”The provider’s tests stand in for the driver and the kubelet, so they
can’t show what those really do. e2e/cluster.sh runs it against the
real ones, in k3s through k3d, with the Secrets Store CSI Driver’s chart
(the chart by version, every image by digest, in the script); CI runs it
on every change (cluster, below):
cargo build --release --locked -p ferritor-clie2e/cluster.sh # creates the cluster ferritor-e2e, deletes it at the endKEEP=1 e2e/cluster.sh # keeps it, to look around (k3d cluster delete ferritor-e2e)It needs k3d, kubectl, helm, openssl and docker (podman’s works). A secured server and Postgres run in the cluster (a server on the host may be unreachable from it), the cluster’s service account tokens trusted for workload identity. The server and the provider run from the images, which the script builds and imports into the cluster (through files, so k3d needn’t share the store of the runtime that built them); the CLI runs on the host. Then it checks, each failing the run with the pods’ events and the logs:
- a pod mounting a
prefixvolume (with a subdirectory) and anobjectsvolume, read by a non-root user; - a new version and a new secret arriving at a refresh;
- a denied path keeping its pod in
ContainerCreating, the server asked once through the kubelet’s retries; - sealed: a new pod waits, never
Runningwith an empty volume, a running pod keeps its files, and the new pod starts once unsealed; - a revoked grant, the value kept (
onRevoked = "keep"); secretObjects: a file and a rendered.dockerconfigjsonsynced into Secrets, a new version reaching them, both deleted with a pod of its own, kept by a Deployment scaled to zero (owned by its ReplicaSet);- the exchange refusing a pod’s default token and mapping a
ferritorone.
A run takes about ten minutes, mostly the refreshes it waits for.
Images
Section titled “Images”The Dockerfile builds one image per binary, each the binary alone in an
empty (scratch) image:
docker build --target server -t ferritor-server .docker build --target csi-provider -t ferritor-csi-provider .docker build --target agent -t ferritor-agent .docker build --target cli -t ferritor-cli .Each release publishes the four on ghcr.io, for amd64 and arm64:
ghcr.io/ferritor/ferritor-server, ferritor-csi-provider,
ferritor-agent and ferritor-cli, tagged with the version (1.3.0)
and latest (see Releases).
- One build stage compiles all four, statically linked against musl
(
SQLX_OFFLINE, from.sqlx/), for the platform the build runs on, amd64 or arm64; after the first, the others take seconds. Its cache mounts (the cargo registry andtarget/) need BuildKit (Docker 23 and later) or Podman. - Nothing but the binary is in an image: no shell, no libc, no tools. The
server’s also has the build image’s CA bundle
(
/etc/ssl/certs/ca-certificates.crt), for the KMS clients (AWS and Google), which trust the system’s CAs. So anexecprobe or an agent’son_changecommand can’t run anything from the image. They run as UID and GID 65532 unless the pod says otherwise (the CSI provider’s DaemonSet runs it as root, for the driver’s socket directory). - The server’s static build allocates with mimalloc (for
target_env = "musl"only): with musl’s own allocator, reads were 2.8 times slower (performance). - The build context is an allowlist (
.dockerignore):Cargo.toml,Cargo.lock,crates/without their tests, andproto/. Nevertarget/,.env, or a key lying around.
Licenses
Section titled “Licenses”ferritor is MIT OR Apache-2.0 (LICENSE-MIT, LICENSE-APACHE; license
in [workspace.package], inherited by every crate, like publish = false:
nothing goes to crates.io). Its dependencies’ licenses are held to a list,
twice:
cargo deny --workspace check licensesfails on a dependency under any license not indeny.toml’s[licenses] allow(CI’sadvisoriesjob).THIRD-PARTY-LICENSES.txtholds the notices the binaries’ dependencies require (each crate’s license text and copyright lines; MIT for a crate that offers a choice), and every image carries it under/usr/share/doc/ferritor/, with ferritor’s own two files.cargo-aboutgenerates it fromCargo.lock(about.toml,about.hbs): the runtime dependencies of every target a release ships (the musl ones, and the CLI’s macOS and Windows ones: one file for every archive), not dev- or build-only ones, and not ferritor’s own crates. Generated offline, from the downloaded crates alone, so it’s the same on every machine. CI’slintfails while it’s stale, so regenerate it with anyCargo.lockchange:
cargo fetch --locked # every platform's crates, the musl-only ones toocargo about generate --frozen --workspace about.hbs -o THIRD-PARTY-LICENSES.txtA crate holding two texts of one license (a Rust wrapper’s and the C
library’s it compiles in, say) is named in about.toml with a clarify
section, each file by checksum: otherwise which text cargo-about picks
depends on the order the filesystem lists them in, and the file differs
between machines (libmimalloc-sys did, CI against a laptop).
A new license (a dependency under one neither list has) goes into both
deny.toml and about.toml’s accepted, after deciding it can be
distributed in the images: a copyleft one can’t, without changing what
ferritor’s own license allows.
Lints and conventions
Section titled “Lints and conventions”The workspace lints deny unwrap_used, expect_used and
allow_attributes, and forbid unsafe_code: return an error instead of
panicking, and use #[expect] rather than #[allow]. Generated proto code is
exempted. In tests unwrap is fine, but test helpers outside #[test]
functions return TestResult.
- Errors:
thiserrorin libraries and for server errors that map to status codes,anyhowonly at a binary’s top level. An error variant with a source doesn’t also interpolate it in its message. - Postgres has no unsigned integers: versions and counts are
INTEGERwithCHECKs, while the APIs useu32/u8; convert withtry_from, neveras. - Every store call is bounded client side (a timeout around each method), since Postgres’s own timeouts can’t see a hung connection.
- Share count and threshold always travel together as
ShareParams. - A new condition the gRPC code alone can’t tell apart gets a reason in
ferritor_core::messages::reason.
Debugging and profiling
Section titled “Debugging and profiling”The server marks itself undumpable first thing, in debug builds too (see
security): gdb, lldb, perf and profilers that attach to
a running process (py-spy, cargo flamegraph --pid) can’t attach to it as
your own user, /proc/<pid>/ belongs to root, and a crash writes no core
dump. Development behaves as production here on purpose; the bench server
is the same. Either use sudo, or start the server under the tool: a
tracer attached before the call keeps its access (checked with
gdb --args target/release/ferritor-server; perf record -- and
cargo flamegraph running the server themselves should behave alike, but
weren’t tried).
Load tests
Section titled “Load tests”bench/ runs a secured --release server against its own databases and
loads it with oha (and pgbench for Postgres alone): see the results in
performance. Never measure performance with a debug build
or in dev mode.
.github/workflows/ci.yml runs on every pull request and every push to
main:
| Job | Runs |
|---|---|
lint |
cargo fmt --check; shellcheck bench/*.sh e2e/*.sh; the offline build (SQLX_OFFLINE=true, from .sqlx/, no databases); clippy -D warnings; cargo doc with -D warnings; THIRD-PARTY-LICENSES.txt regenerated and compared (Licenses) |
proto |
buf lint, buf format --diff --exit-code, buf breaking against the pull request’s base (a push: the commit before it, or its parent after a force-push) |
test |
the two Postgres servers as in compose.yaml; the migrations; cargo sqlx prepare --check in both store crates; cargo test --workspace |
fuzz |
the fuzz crate’s fmt and clippy; that fuzz/Cargo.lock has Cargo.lock’s version of every crate both name; then every target (see “Fuzzing”) for 30 s, daily 5 minutes, from its seeds and the corpus the previous run left (cached). Every target runs even after one crashes; a crash’s input is kept as the run’s fuzz-artifacts |
cluster |
e2e/cluster.sh (above), after a release build of the CLI: the server’s and the provider’s images built, the CSI provider with the real driver and kubelet in k3s, k3d pinned and its download checked; then the agent’s and the CLI’s images, so every target builds |
cli-macos |
on a macOS runner (macos-15, Apple silicon) with Apple’s SDK: the CLI for aarch64-apple-darwin and x86_64-apple-darwin, as a release builds it (macOS 11 and later): clippy -D warnings on its library and binary, the release build, and the Apple silicon binary run (not its tests, which run the server, Linux-only). Then clippy on every target of ferritor-agent for both (not released there, but its Unix code builds there: a libc type differs). Natively, not cross-built: the CLI’s dependencies link Apple’s frameworks (CoreFoundation, through openidconnect’s chrono) |
windows |
on a Windows runner (windows-2025, whose user is an administrator, holding the link privilege): the CLI and the agent for x86_64-pc-windows-msvc, as a release builds them, the C runtime linked in (+crt-static, .cargo/config.toml): clippy -D warnings on the CLI’s library and binary and on every target of ferritor-agent and ferritor-winsec, their tests (the output directory’s links, access lists and held-open files, the config’s Windows refusals, ferritor-winsec’s calls; the tests that run a server are cfg(unix) and build empty), then the release build, checked with dumpbin to import no C runtime DLL (the archives must run where the Visual C++ runtime isn’t installed) |
advisories |
cargo deny check advisories sources (deny.toml; --workspace for the main one, whose root is a package), for both lockfiles: a RUSTSEC vulnerability, an unmaintained crate, a yanked version, or a crate from anywhere but crates.io fails the build. Also daily, since new advisories land without a change here. For the main lockfile licenses too: a dependency under a license not in deny.toml’s list fails it (the fuzz crate is never distributed) |
.github/workflows/docs.yml builds the docs site on the same events
(build, with Astro’s own action: install, build, and the site uploaded
for GitHub Pages), so a broken internal link, an SEO audit error or a page
that doesn’t render fails it. It runs on every change, not only to
docs/, so it can be a required check too (a workflow a path filter
skips never reports). On main only, deploy then publishes the build
to GitHub Pages, https://ferritor.dev: the only job that may, with the
repository’s Pages source set to “GitHub Actions” and the custom domain
in its Pages settings. A pull request’s build is never published.
A pull request is checked before it merges only if these nine jobs (the
eight above and the docs’ build) are
required status checks on main (branch protection); a push straight
to main is checked after it has landed. To run the same checks locally:
cargo fmt --all --checkshellcheck bench/*.sh e2e/*.shSQLX_OFFLINE=true cargo build --workspace --all-targets --lockedcargo clippy --workspace --all-targets --all-features --locked -- -D warningsRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --lockedbuf lint && buf format --diff --exit-code && buf breaking --against '.git#branch=main'(cd crates/ferritor-keystore && cargo sqlx prepare --check)(cd crates/ferritor-datastore && cargo sqlx prepare --check)cargo test --workspace --lockedcargo deny --workspace check advisories sources licensescargo fetch --locked && cargo about generate --frozen --workspace about.hbs -o THIRD-PARTY-LICENSES.txt && git diff --exit-code THIRD-PARTY-LICENSES.txtcargo deny --manifest-path fuzz/Cargo.toml check advisories sourcesfor t in aarch64-apple-darwin x86_64-apple-darwin; do # on a Mac: the CLI links Apple's frameworks SQLX_OFFLINE=true cargo clippy -p ferritor-cli --lib --bins --locked --target $t -- -D warnings && SQLX_OFFLINE=true MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --locked -p ferritor-cli --target $t && SQLX_OFFLINE=true cargo clippy -p ferritor-agent --all-targets --locked --target $t -- -D warningsdone# On Windows (Visual Studio Build Tools' C++ workload, rustup, protoc):# cargo clippy -p ferritor-cli --lib --bins --locked -- -D warnings# cargo clippy -p ferritor-agent -p ferritor-winsec --all-targets --locked -- -D warnings# cargo test --locked -p ferritor-agent -p ferritor-winsec# cargo build --release --locked -p ferritor-cli -p ferritor-agent(cd docs && pnpm install --frozen-lockfile && pnpm build)Pinned, so a new release can’t fail main with nothing changed here; bump
each deliberately, and fix what the new version finds in the same change:
- The Rust toolchain:
dtolnay/rust-toolchain’s commit for the version’s branch (1.100.0, in the comment beside it: the branch’s action has the version built in, and takes notoolchain:input), in every job that uses it, and therustimage in theDockerfile(its tag,1.100.0-slim-trixie, and its digest). Use the same version locally, or local clippy and CI’s can disagree. - buf:
version:ofbuf-action(1.73.0); its lint and format rules change between releases. Use the same locally. - sqlx-cli:
SQLX_CLI_VERSION, kept at thesqlxversion inCargo.lock. - k3d, for
cluster:K3D_VERSIONandK3D_SHA256(from the release’schecksums.txt). The imagese2e/cluster.shuses (k3s, Postgres, busybox) by digest, the tag kept beside it to say what it was, and the driver’s chart by version. The images come from Docker Hub anonymously, whose pull limit is per IP address and shared by CI’s runners: if runs start failing on pulls, point them at a pull-through mirror. - protoc on Windows, for
windowsand the release’swindows-binaries:PROTOC_VERSIONwithPROTOC_SHA256(the release asset’sdigest,gh api repos/protocolbuffers/protobuf/releases/tags/v<version>, ofprotoc-<version>-win64.zip), the same in both workflows. The Linux jobs take Ubuntu’s, macOS Homebrew’s. - The Windows runner, for
windowsand the release’swindows-binaries:windows-2025in both; its Visual Studio’s MSVC links the binaries, so an image update can change them: a release’s are checked as CI’s are (no C runtime DLL). - The macOS runner, for
cli-macosand the release’scli-macos:macos-15in both, andMACOSX_DEPLOYMENT_TARGET(11.0), the oldest macOS the CLI runs on. protoc and GNU tar come from Homebrew, unpinned: neither changes what’s built. - Nightly and cargo-fuzz, for
fuzzonly:toolchain:(a dated nightly) andCARGO_FUZZ_VERSION. - release-plz: the action’s commit and its
version:(0.4.2) inrelease-plz.yml; use the same locally. The artifact actions there (the images’ digests) by commit too, and cosign: the installer by commit, cosign itself bycosign-release:(v3.1.4), which the installer checks by signature. A new major version can change what a signature looks like, so checkcosign verifywith the docs’ command after a bump. - cargo-about:
tool: cargo-about@0.9.0inlint, installed bytaiki-e/install-action(by commit), which checks the download against its recorded checksum. A new version can word the notices differently: regenerate the file with it in the same change. - Node and pnpm, for the docs:
node-versionindocs.yml, andpackageManagerindocs/package.json(which pnpm itself honours locally too), the versionsdocs/pnpm-lock.yamlwas written with. - Actions: by commit, the tag in a comment; update both together.
Dependabot does (
.github/dependabot.yml): one grouped pull request a week,ci:commits, a release only once it’s a week old (cooldown), so a compromised one is likely pulled before this build runs it. Review it like any other: it changes what runs with this repository’s tokens. Notdtolnay/rust-toolchain, whose pins are Rust versions (above), bumped by hand.
Also:
- An advisory is fixed by updating the crate (
cargo update -p <crate>). Only if that’s impossible, add it todeny.toml’signore, with the reason and a date to look again. - The daily run stops on a quiet repository: GitHub disables scheduled workflows after 60 days without activity on a public repository. Re-enable it under Actions, or the advisory check silently stops.
- Checkouts keep no token (
persist-credentials: false): nothing here pushes, and every build script and proc-macro runs in these jobs. - Time limits: 30 minutes for
test, 45 forwindowsandcli-macos, 90 forfuzz, 40 forcluster, 20 for the rest, so a hung test or database doesn’t hold a runner for six hours.
Releases
Section titled “Releases”release-plz versions, writes the changelogs,
tags and creates the GitHub release (release-plz.toml,
.github/workflows/release-plz.yml). Nothing goes to crates.io: versions
come from git tags (git_only).
- Before a release, a pull request of its own moves the version the
docs download to the one about to be released:
version=in the README’s quick start, the quick start, production and the CLI reference, the image tagkubernetes.mdverifies, and the image tags in the Helm chart’s README. Every one is the current version written out, sogrep -rnF 1.3.0 README.md docs/src/content/docs deploy/helm --exclude-dir=contributing(with the current version) finds them all. - The release pull request.
release-propens or updates it when started by hand: Actions, Release-plz, Run workflow, onmain. It holds the next version and the changelogs’ new section, which can be edited there before merging. Run at every push, it rebuilt the pull request and ran its checks after every change. It refuses to run while a release is on its way (a release pull request merged, not yet tagged, becauseCIhasn’t passed on it): it would offer that version again. release-plz bumps the versions inCargo.lockonly, sorelease-pradds a commit of its own withfuzz/Cargo.lockbrought in line (the fuzz crate’s lockfile records the ferritor crates’ versions too, and CI builds it--locked). Merging it releases, and nothing else does (release_always = false): onceCIhas passed on the merge commit,releasetags that very commit and creates the GitHub release from the root changelog, as a draft. A push that isn’t a release pull request’s merge is never released, and a merge whoseCIfails isn’t either. - Draft, then published: the repository’s releases are immutable once
published (no asset can be added after), so the workflow completes the
draft first.
release-assetsattaches the binaries,SHA256SUMSand a cosign bundle (.sigstore.json) for each file, appends the images’ digests and how to verify to the notes, and only then publishes. If it fails the release stays a draft, and re-running the job completes it. - Binaries:
ferritor-<version>-x86_64-unknown-linux-musl.tar.gzand theaarch64one, each the four static binaries (ferritor-server,ferritor-csi-provider,ferritor-agent,ferritor) withLICENSE-MIT,LICENSE-APACHEandTHIRD-PARTY-LICENSES.txt: the same build as the images (the Dockerfile’sbinariestarget), packed reproducibly (sorted, the commit’s time, no owners, no gzip timestamp). Each is signed keyless with cosign, as the images are, socosign verify-blobwith the same identity checks it. - The agent for Windows (
windows-binaries, packed bycli-archives):ferritor-agent-<version>-x86_64-pc-windows-msvc.zip,ferritor-agent.exewith the three license files, packed as the CLI’s zip. - The CLI for macOS and Windows (
cli-macos;windows-binaries, packed bycli-archives):ferritor-cli-<version>-aarch64-apple-darwin.tar.gz, thex86_64-apple-darwinone andferritor-cli-<version>-x86_64-pc-windows-msvc.zip, each the CLI alone with the same three license files, packed the same reproducible way (the zip with the commit’s time on every entry, packed on Linux; the tarballs with GNU tar on macOS too). Each built natively, as CI builds it: the macOS ones on a macOS runner with Apple’s SDK (the CLI links Apple’s frameworks), ad-hoc signed by Apple’s linker (Apple silicon runs nothing unsigned); the Windows ones on a Windows runner, the msvc target with the C runtime linked in, so they need no Visual C++ runtime installed. Nothing is notarized or signed by a publisher; Gatekeeper and SmartScreen treat a browser download as unknown. Checksummed and signed with the rest. - Images: a release then builds the images from the
released commit, each architecture on its own runner (
images, amd64 onubuntu-24.04, arm64 onubuntu-24.04-arm: natively, since Rust under emulation takes hours), pushes them to ghcr.io by digest, andimage-tagstags each under the version andlatest, both architectures under one name, and signs it with cosign, keyless (by digest, each architecture’s image too,--recursive): the certificate namesrelease-plz.ymlonmain, which is what users verify (Kubernetes). A new package on ghcr.io starts private: make each public once, in its package settings. - One version for every crate (
version.workspace, oneversion_group), so a release bumps them all. - Changelogs: each crate’s
CHANGELOG.mdbeside itsCargo.toml, with the commits that touched its directory (release-plz counts a package’s own files only). The server’s is the rootCHANGELOG.md, the product’s: its commits, every other released crate’s, and the workspace root package’s. That one,ferritor(src/lib.rs, no code), exists for this: it owns every file outsidecrates/(Cargo.lock, the Dockerfile, the workflows, the docs,deny.toml), so a commit to those (a dependency’s security fix, a CI change) is in the product’s changelog too. It writes no changelog of its own.ferritor-testkitisn’t released. - Tags:
v0.9.1for the product (the server’s), with the GitHub release;ferritor-core-v0.9.1and so on for the crates, andferritor-workspace-v0.9.1for the root package: that’s how release-plz finds each one’s previous release. A tag ruleset lets only the App create, move or delete them. - Commit subjects sort a commit into the changelog by their start:
feat(Added),changed,deprecated,removed,fix(Fixed),perf(Performance),security; anything else is Other, but for merge commits, which are left out (Merge pull request #N from …andMerge branch '…', the subjects GitHub and git write): a pull request’s own commits are its entries. With conventional commits the start also chooses the version:fixa patch,feata minor (a patch while below 1.0), a breaking change (feat!:) a major (a minor below 1.0). - The release pull request is opened by a GitHub App,
ferritor-release, not with the workflow’s own token: a pull request opened withGITHUB_TOKENstarts no other workflow, soCIandDocswouldn’t run on it.release-prmints the App’s token for itself (actions/create-github-app-token: an hour at most, this repository, contents and pull requests), from the private key in therelease-plzenvironment’s secretRELEASE_PLZ_APP_PRIVATE_KEY, which onlymainmay use, and the variableRELEASE_PLZ_APP_CLIENT_ID.releaseruns as the App too, with contents write and pull requests read: a tag ruleset lets only the App create release tags (v*,ferritor-*-v*), sinceGITHUB_TOKENcan’t bypass a ruleset. The image jobs keepGITHUB_TOKEN, for ghcr.io. - A merge whose
CIfails is never released; fix it on a branch whose name starts withrelease-plz-, whose merge release-plz releases onceCIpasses.
To see what the next release would write, in a throwaway worktree of
HEAD. Preview only what’s committed: the worktree has only the
committed files (an uncommitted release-plz.toml change isn’t in it),
and release-plz stashes anything uncommitted it finds into the
repository’s shared stash, and leaves it there.
git worktree add /tmp/release-preview HEAD(cd /tmp/release-preview && SQLX_OFFLINE=true release-plz update)git -C /tmp/release-preview diff; git worktree remove --force /tmp/release-previewFuzzing
Section titled “Fuzzing”proptest checks properties on generated inputs; fuzz/ adds
coverage-guided fuzzing (cargo-fuzz, libFuzzer) where input comes from
outside, or where a mistake would weaken a guarantee:
| Target | What | Must hold |
|---|---|---|
secret_path |
SecretPath, Namespace (the AAD binds a path’s bytes) |
accepted exactly when canonical (restated independently), never rewritten; the namespace is the first segment; descendant_range holds exactly the paths is_under |
labels |
keys, values, key=value, changes |
accepted exactly per the documented rules, restated independently; a pair splits at the = and loses nothing |
policy_spec |
PolicySpec::validate, from JSON, TOML or the fields |
a valid policy keeps every limit; its canonical form (Policy::spec, what’s signed) is a fixed point and survives the JSON round trip |
policy_encoding |
the stored policies’ MAC messages | different rows (or sets) never encode alike, near-misses included (a field boundary moved, an item moved between lists) |
audit_verify |
ferritor audit verify on any bytes |
no panic; proven only if every chain is one a writer wrote (the seeds’) |
audit_tamper |
real logs from Chain, then edited (lines deleted, copied, swapped, inserted, cut, bits flipped) |
unedited: each chain judged as written; edited: proven only if still made of the genuine chains |
csi_yaml |
the CSI provider’s list parameters (csi::yaml: objects, templates) |
any text: a value or a refusal, never a panic, never past either size limit; any JSON within the limits (the lists the parameters took before YAML) parses to the same value |
crl_parse |
Crls::parse ([tls] crl): a CRL’s DER, the file’s text, or a CA certificate |
no panic; a file that loads has one CRL per client CA |
template |
the agent’s and the CSI provider’s templates (ferritor-agent’s template): any text, templates built from pieces, every filter on any value |
no panic; text without a placeholder comes back as it is; a built template parses back into its pieces and renders as its literals and filtered values; each filter accepts exactly what its rules allow, writes exactly encoded_len bytes (what a render reserves) and its output reads back as the value (dotenv through dotenvy itself); a refusal writes nothing |
The fuzz crate is its own workspace (fuzz/Cargo.toml, fuzz/Cargo.lock),
outside the main build. Its lockfile is the main one plus the fuzz crates,
so a target fuzzes the versions the server ships; CI fails if a crate both
name differs. After changing Cargo.lock (a cargo update), refresh it
the same way, not with a cargo update of its own:
cp Cargo.lock fuzz/Cargo.lock && cargo fetch --manifest-path fuzz/Cargo.tomlIt needs a nightly toolchain and cargo-fuzz:
cargo +nightly fuzz listSQLX_OFFLINE=true cargo +nightly fuzz run audit_verify fuzz/corpus/audit_verify fuzz/seeds/audit_verifySQLX_OFFLINE=true cargo +nightly fuzz run labels -- -max_total_time=60SQLX_OFFLINE=true cargo +nightly fuzz run <target> fuzz/artifacts/<target>/crash-… # replay a crash- Seeds and fixtures (
fuzz/seeds/,fuzz/fixtures/) are committed: genuine audit logs signed with the targets’ fixed test key, and a throwaway CA’s certificate with CRLs it signed (its key is discarded; no private key is checked in).cargo run --manifest-path fuzz/Cargo.toml --example seedsregenerates them all at once (a new CA each time, so the CRLs and the certificate always match). The corpus libFuzzer grows (fuzz/corpus/) and its crashes (fuzz/artifacts/) aren’t committed; CI keeps its corpus between runs in the Actions cache, and the daily run first shrinks it to the inputs that add coverage (cargo fuzz cmin <target>). - A crash is a bug or a wrong oracle: fix whichever it is, and turn the
input into a unit test in the crate (as
audit_chain::tests::damage_after_the_end_is_never_proven). - A new parser of outside input, or a new encoding a MAC or signature
covers, gets a target: a
[[bin]]infuzz/Cargo.tomlandfuzz/fuzz_targets/<name>.rs, asserting what must hold, not only that nothing panics; CI runs every targetcargo fuzz listnames.