Phase 1: app, Kanidm login, people, passports, addresses, audit log
visa.buildfor.life keeps the immigration records of the foreigners B4L looks after. This first phase is the base the deadlines and extension packs build on (docs/PLAN.md, phases 2 to 7). - One Rust binary (axum 0.8, minijinja, sqlx on PostgreSQL) with its templates, static files and migrations compiled in. - Login through Kanidm (OpenID Connect with PKCE and a nonce, ES256), client visa-web, group visa; sessions in PostgreSQL keyed by the SHA-256 of the cookie. VISA_INSECURE_NO_LOGIN=1 for loopback development only. - Same-site check and form token on every POST; a CSP without inline script or style; security headers. - People: list with filter, page, create, edit, archive, restore. - Passports from the machine-readable zone with check digits (ICAO 9303 TD3); expiry warnings at 12 and 6 months. - Addresses in Thailand in the order Thai forms use, with the house master and the TM.30 receipt. - Append-only audit log of every view and change, with the names of the changed fields but never their values (PDPA); the Activity page. - Invented demo people (visa seed-demo, refused when login is on). - 40 tests: unit tests, pages with demo data, the forms, the audit log and the whole login against a fake OpenID provider. - CI: gitleaks over the history, fmt, clippy and the tests against PostgreSQL 18; the pre-commit secret scan.
This commit is contained in:
commit
2e009700a9
56 files changed
+11193
No files matched your search
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Secret scan for CI (copy to .gitea/scripts/gitleaks.sh): gitleaks over the
|
||||
# whole history of every branch the checkout has, with .gitleaks.toml and
|
||||
# .gitleaksignore. A full scan of a few hundred commits takes about a second,
|
||||
# so every push checks every commit. Exit 1 on a finding; --redact keeps the
|
||||
# value out of the log. Bump VERSION and SHA256 together (checksums.txt of
|
||||
# the release, line for linux_x64.tar.gz).
|
||||
set -euo pipefail
|
||||
VERSION=8.30.1
|
||||
SHA256=551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb # linux_x64
|
||||
dir=$(mktemp -d)
|
||||
tarball="gitleaks_${VERSION}_linux_x64.tar.gz"
|
||||
curl -fsSL --retry 3 -o "$dir/$tarball" \
|
||||
"https://github.com/gitleaks/gitleaks/releases/download/v${VERSION}/${tarball}"
|
||||
echo "$SHA256 $dir/$tarball" | sha256sum -c --quiet -
|
||||
tar -xzf "$dir/$tarball" -C "$dir" gitleaks
|
||||
"$dir/gitleaks" git . --redact --no-banner --verbose --exit-code 1 \
|
||||
--log-opts="--all"
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# CI: install the given Rust toolchain (with clippy and rustfmt) through
|
||||
# rustup and make it the default. Installs rustup and a C compiler first when
|
||||
# the job image has none (ring compiles C).
|
||||
# bash .gitea/scripts/rust-toolchain.sh 1.98.1
|
||||
set -euo pipefail
|
||||
tc=${1:?toolchain, e.g. 1.98.1}
|
||||
need=()
|
||||
command -v cc >/dev/null || need+=(gcc libc6-dev)
|
||||
command -v curl >/dev/null || need+=(curl ca-certificates)
|
||||
if [ ${#need[@]} -gt 0 ]; then
|
||||
SUDO=$(command -v sudo || true)
|
||||
$SUDO apt-get update -qq
|
||||
$SUDO apt-get install -y -qq "${need[@]}"
|
||||
fi
|
||||
if ! command -v rustup >/dev/null && [ ! -x "$HOME/.cargo/bin/rustup" ]; then
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none
|
||||
fi
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
[ -n "${GITHUB_PATH:-}" ] && echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
rustup toolchain install "$tc" --profile minimal -c clippy -c rustfmt
|
||||
rustup default "$tc"
|
||||
rustc --version
|
||||
cargo --version
|
||||
@@ -0,0 +1,81 @@
|
||||
# visa CI on git.b4l.co.th (Gitea Actions).
|
||||
#
|
||||
# leaks: gitleaks over the whole history on every push and pull request
|
||||
# (.gitea/scripts/gitleaks.sh, rules in .gitleaks.toml). The pull
|
||||
# request trigger covers AGit pull requests, whose commits arrive
|
||||
# without a branch push. The pre-commit hook in .githooks/ scans the
|
||||
# staged changes before they leave a computer.
|
||||
# check: cargo fmt, clippy and the tests against a throwaway PostgreSQL 18,
|
||||
# the version on cnx01 (each #[sqlx::test] creates its own database).
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_INCREMENTAL: "0"
|
||||
RUST_TOOLCHAIN: "1.98.1"
|
||||
|
||||
jobs:
|
||||
leaks:
|
||||
name: secret scan
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: gitleaks
|
||||
run: bash .gitea/scripts/gitleaks.sh
|
||||
|
||||
check:
|
||||
name: fmt, clippy, tests
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18
|
||||
env:
|
||||
POSTGRES_USER: visa
|
||||
POSTGRES_PASSWORD: visa-ci
|
||||
POSTGRES_DB: visa
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U visa"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 20
|
||||
env:
|
||||
DATABASE_URL: postgres://visa:visa-ci@postgres:5432/visa
|
||||
# the tests wait on the database more than on the CPU
|
||||
RUST_TEST_THREADS: "16"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Rust toolchain
|
||||
run: bash .gitea/scripts/rust-toolchain.sh "$RUST_TOOLCHAIN"
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry/index
|
||||
~/.cargo/registry/cache
|
||||
~/.cargo/git/db
|
||||
target
|
||||
key: check-${{ runner.os }}-${{ env.RUST_TOOLCHAIN }}-${{ hashFiles('Cargo.lock') }}
|
||||
restore-keys: check-${{ runner.os }}-${{ env.RUST_TOOLCHAIN }}-
|
||||
|
||||
- name: Format
|
||||
run: cargo fmt --all --check
|
||||
|
||||
- name: Clippy
|
||||
run: cargo clippy --all-targets --locked -- -D warnings
|
||||
|
||||
- name: Tests
|
||||
run: cargo test --locked
|
||||
Reference in new issue
Block a user