Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# cargo-audit configuration. Every ignored advisory needs a reason and an exit
# condition; revisit them whenever dependencies or the toolchain change.
[advisories]
ignore = [
# rsa (Marvin attack). Listed in Cargo.lock only because sqlx-macros-core
# declares optional MySQL support; it is never compiled
# (`cargo tree -i rsa` prints nothing). Remove with the sqlx 0.9 upgrade.
"RUSTSEC-2023-0071",
# libsqlite3-sys bundles SQLite < 3.54 (stale page-cache bytes when an
# attacker-written database and -wal file are opened together). SQLite is
# only used for local development and tests, on files the service creates
# itself. The fix needs sqlx 0.9, which requires Rust 1.94; this workspace
# is pinned to Rust 1.93.1 to match SendBox. Remove when the toolchain moves.
"RUSTSEC-2026-0459",
]
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git/
.github/
.env
target/
logs/
docs/
*.db
*.db-shm
*.db-wal
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copy to `.env` and adjust. These are local development examples, not secrets.

# docker compose (see docs/development.md)
POSTGRES_DB=sendbox_fleet
POSTGRES_USER=sendbox_fleet
POSTGRES_PASSWORD=local-dev-only-change-me
FLEET_PORT=8080
FLEET_LOG_LEVEL=info
FLEET_LOG_RETENTION_DAYS=30

# Running the binary directly with SQLite (export these in your shell)
# FLEET_DATABASE_URL=sqlite://sendbox-fleet.db?mode=rwc
# FLEET_BIND=127.0.0.1:8080
# FLEET_LOG_DIR=./logs
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
# Keeps the sendbox-governance contract on the latest sendbox `main` commit.
# See docs/contract.md.
- package-ecosystem: cargo
directory: /
schedule:
interval: daily
allow:
- dependency-name: sendbox-governance
commit-message:
prefix: "Bump contract"
111 changes: 111 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
checks:
name: Format, lint, and test (SQLite)
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Install the pinned toolchain
run: rustc --version --verbose

- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3

- name: Check formatting
run: cargo fmt --all -- --check

- name: Run Clippy
run: cargo clippy --locked --workspace --all-targets -- -D warnings

- name: Run tests
run: cargo test --locked --workspace

postgres:
name: Migrations and server (PostgreSQL)
runs-on: ubuntu-24.04
timeout-minutes: 30
services:
postgres:
image: postgres:18.7-alpine3.24@sha256:b6972e1115a4ff8eba5d7f7d19184926d1e16d7d1136ae1e1a7ebf286da0f015
env:
POSTGRES_DB: sendbox_fleet_test
POSTGRES_USER: sendbox_fleet
# Ephemeral, job-local database reachable only from this runner.
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U sendbox_fleet -d sendbox_fleet_test"
--health-interval 5s
--health-timeout 5s
--health-retries 12
env:
FLEET_TEST_DATABASE_URL: postgres://sendbox_fleet@localhost:5432/sendbox_fleet_test
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Install the pinned toolchain
run: rustc --version --verbose

- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3

- name: Run migration tests against PostgreSQL
run: cargo test --locked --workspace --test migrations -- --test-threads=1

- name: Start the server against PostgreSQL and stop it gracefully
env:
FLEET_DATABASE_URL: ${{ env.FLEET_TEST_DATABASE_URL }}
FLEET_LOG_DIR: ${{ runner.temp }}/fleet-logs
run: |
cargo build --locked --bin sendbox-fleet
./target/debug/sendbox-fleet &
server=$!
for _ in $(seq 1 30); do
curl --fail --silent http://127.0.0.1:8080/readyz >/dev/null && break
sleep 1
done
curl --fail --silent --show-error http://127.0.0.1:8080/readyz
status=$(curl --silent --output /dev/null --write-out '%{http_code}' \
--request POST http://127.0.0.1:8080/v1/authorize)
test "$status" = 401
kill -TERM "$server"
wait "$server"
ls -l "$FLEET_LOG_DIR"/sendbox-fleet.*.log

audit:
name: Dependency audit
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: taiki-e/install-action@ab49d3c64680143e184118bed66a46419fc15519 # v2.90.5
with:
tool: cargo-audit@0.23.0

- name: Audit Cargo.lock
run: cargo audit --deny warnings
28 changes: 28 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Dependabot auto-merge

on: pull_request

permissions:
contents: read

jobs:
contract-pin:
name: Auto-merge sendbox-governance pin updates
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'mbianchidev/sendbox-fleet'
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: write
pull-requests: write
steps:
- name: Read Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0

# Branch protection holds the merge until every required CI job passes.
- name: Enable auto-merge
if: steps.metadata.outputs.dependency-names == 'sendbox-governance'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Contributing

1. Read [docs/architecture.md](docs/architecture.md) and the
[threat model](docs/threat-model.md); changes must keep the trust boundaries
(no provider credentials in this service, bearer-only authentication,
workload-supplied identity never authoritative).
2. Contract types come from `sendbox-governance`. Change them in the sendbox
repository first, then update the pin ([docs/contract.md](docs/contract.md)).
3. Schema changes need matching PostgreSQL and SQLite migrations and a test.
4. Before opening a pull request, run the checks in
[docs/development.md](docs/development.md#checks). CI runs the same
commands plus PostgreSQL and `cargo audit` jobs.
5. Use synthetic data in tests and examples; never commit real credentials,
tokens, or personal data.
Loading