Merge pull request 'CI: the VoelinProtocol deploy key lives for one trusted fetch step' (#2) from phase5/ci-deploy-key-hardening into main
CI / Linux checks (push) Successful in 32m20s

This commit was merged in pull request #2.
This commit is contained in:
Aleksey Selihov committed 2026-10-28 01:27:14 +00:00
commit b08bda599d
13 files changed
+719 -244

No files matched your search

+29 -131
View File
@@ -1,135 +1,21 @@
name: Linux checks name: Linux checks
description: Shared Linux validation for Gitea CI and release packaging. description: >
inputs: Linux validation for Gitea CI: formatting, Clippy, the build, the tests, the
protocol-deploy-key: dependency policy, the third-party notices and the release tooling tests. It
description: > runs after the job has fetched every dependency (the steps before it in
Private half of the read-only deploy key registered on the private .gitea/workflows/ci.yml: system packages, the Rust toolchain and `cargo fetch`
Voelin/VoelinProtocol repository (the repository secret with the read-only deploy key for the private VoelinProtocol repository) and
VOELIN_PROTOCOL_DEPLOY_KEY, passed in by the workflow: secrets are not has deleted the key (docs/ci.md, "VoelinProtocol access"). This action has no
visible inside a composite action). The action fails when it is empty. input and no secret, and every cargo command in it is --offline (or has
required: true CARGO_NET_OFFLINE set where a script or a plugin starts cargo): it needs no key
and cannot use one, so the build scripts, procedural macros and tests it runs
hold none.
runs: runs:
using: composite using: composite
steps: steps:
# The workspace depends on the private VoelinProtocol repository over SSH
# (docs/ci.md, "VoelinProtocol access"). First, so that a missing key fails
# in seconds and before anything runs cargo.
- name: Install the VoelinProtocol deploy key
# The key reaches this step through the environment only: never in the
# script text, never echoed, no `set -x`.
env:
PROTOCOL_DEPLOY_KEY: ${{ inputs.protocol-deploy-key }}
run: |
set -euo pipefail
umask 077
if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then
echo "::error::The VoelinProtocol deploy key is empty. Set the repository secret VOELIN_PROTOCOL_DEPLOY_KEY to the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access). Pull requests from forks get no secrets." >&2
exit 1
fi
for tool in ssh ssh-keygen; do
command -v "$tool" > /dev/null || {
echo "::error::The job image needs the OpenSSH client: $tool is missing." >&2
exit 1
}
done
ssh_dir="$HOME/.ssh"
key_file="$ssh_dir/voelin_protocol"
mkdir -p "$ssh_dir"
chmod 700 "$ssh_dir"
# Whatever the secret store did to the line ends and the final newline,
# OpenSSH needs LF lines, the BEGIN line first and a newline at the end.
printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' > "$key_file"
unset PROTOCOL_DEPLOY_KEY
chmod 600 "$key_file"
if ! public=$(ssh-keygen -y -f "$key_file" < /dev/null); then
rm -f "$key_file"
echo "::error::VOELIN_PROTOCOL_DEPLOY_KEY is not an unencrypted OpenSSH or PEM private key." >&2
exit 1
fi
# The fingerprint of the public half, to compare with the deploy key in
# the VoelinProtocol settings.
printf 'Deploy key installed: %s\n' "$(ssh-keygen -lf - <<< "$public")"
# The reviewed host key from the repository, never one fetched now.
known_hosts="$ssh_dir/known_hosts"
touch "$known_hosts"
chmod 600 "$known_hosts"
[[ -s "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts" ]] || {
echo "::error::.gitea/known_hosts is missing from the checkout." >&2
exit 1
}
while IFS= read -r line; do
case "$line" in '' | '#'*) continue ;; esac
grep -qxF -- "$line" "$known_hosts" || printf '%s\n' "$line" >> "$known_hosts"
done < "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts"
# Use this key, and only this one, for the Gitea server; fail rather than
# ask when its host key is unknown or changed. The block goes first: ssh
# takes the first value it finds for each option.
config="$ssh_dir/config"
marker="# VoelinProtocol deploy key (.gitea/actions/checks)"
touch "$config"
if ! grep -qxF -- "$marker" "$config"; then
{
cat << EOF
$marker
Host git.faumaray.com
User gitea
IdentityFile $key_file
IdentitiesOnly yes
UserKnownHostsFile $known_hosts
StrictHostKeyChecking yes
BatchMode yes
ConnectTimeout 30
EOF
cat "$config"
} > "$config.new"
mv "$config.new" "$config"
fi
chmod 600 "$config"
# Cargo's built-in git client (libgit2) cannot use IdentityFile; the
# system git runs ssh, which reads the config above. `-F` names it
# outright: ssh looks for ~/.ssh in the passwd entry's home directory, not
# in $HOME, and a job image may set the two apart.
{
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true"
echo "GIT_SSH_COMMAND=ssh -F '$config'"
} >> "$GITHUB_ENV"
shell: bash
- uses: ./.github/actions/system-deps
- name: Check read access to VoelinProtocol
# The first thing cargo does, with the same git and ssh configuration, so
# that a wrong key or a changed host key fails here with a clear message
# and not minutes later inside a cargo command.
run: |
set -euo pipefail
if ! GIT_TERMINAL_PROMPT=0 timeout 120 git ls-remote --exit-code \
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git HEAD > /dev/null; then
echo "::error::git cannot read Voelin/VoelinProtocol over SSH with the deploy key. 'Permission denied (publickey)' above: the key is not registered on that repository (or is not the one in VOELIN_PROTOCOL_DEPLOY_KEY). 'Host key verification failed': .gitea/known_hosts no longer matches the server (docs/ci.md, VoelinProtocol access)." >&2
exit 1
fi
echo "Voelin/VoelinProtocol is readable with the deploy key."
shell: bash
- name: Install pinned Rust toolchain
run: |
set -euo pipefail
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
export PATH="$CARGO_HOME/bin:$PATH"
if ! command -v rustup >/dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile minimal --default-toolchain none
fi
if [[ -f "$CARGO_HOME/env" ]]; then
# shellcheck source=/dev/null
source "$CARGO_HOME/env"
fi
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
rustup toolchain install
shell: bash
- name: rustfmt (own crates) - name: rustfmt (own crates)
env:
CARGO_NET_OFFLINE: "true"
run: | run: |
set -euo pipefail set -euo pipefail
packages=$(scripts/own-crates.sh) packages=$(scripts/own-crates.sh)
@@ -137,33 +23,45 @@ runs:
cargo fmt "${packages[@]}" --check cargo fmt "${packages[@]}" --check
shell: bash shell: bash
- name: clippy (own crates, deny warnings) - name: clippy (own crates, deny warnings)
env:
CARGO_NET_OFFLINE: "true"
run: | run: |
set -euo pipefail set -euo pipefail
packages=$(scripts/own-crates.sh) packages=$(scripts/own-crates.sh)
read -r -a packages <<< "$packages" read -r -a packages <<< "$packages"
cargo clippy "${packages[@]}" --all-targets --no-deps --locked -- -D warnings cargo clippy "${packages[@]}" --all-targets --no-deps --locked --offline -- -D warnings
shell: bash shell: bash
- name: clippy (workspace, report warnings) - name: clippy (workspace, report warnings)
run: cargo clippy --workspace --all-targets --locked run: cargo clippy --workspace --all-targets --locked --offline
shell: bash shell: bash
- name: Build - name: Build
run: cargo build --workspace --all-targets --locked run: cargo build --workspace --all-targets --locked --offline
shell: bash shell: bash
- name: Test (X11 enabled) - name: Test (X11 enabled)
run: | run: |
# DISPLAY is assigned by xvfb-run, then expanded by the inner shell. # DISPLAY is assigned by xvfb-run, then expanded by the inner shell.
# shellcheck disable=SC2016 # shellcheck disable=SC2016
xvfb-run -a bash -c 'VOELIN_X11_TEST_DISPLAY="$DISPLAY" cargo test --workspace --locked' xvfb-run -a bash -c 'VOELIN_X11_TEST_DISPLAY="$DISPLAY" cargo test --workspace --locked --offline'
shell: bash shell: bash
- name: Install cargo-deny and cargo-about - name: Install cargo-deny and cargo-about
# The only cargo commands here that go online: they download two tools from
# crates.io and build them. They read no manifest of this workspace and
# nothing in the job gives them a key.
run: | run: |
cargo install cargo-deny --locked --version 0.20.2 cargo install cargo-deny --locked --version 0.20.2
cargo install cargo-about --locked --version 0.9.2 --features cli cargo install cargo-about --locked --version 0.9.2 --features cli
shell: bash shell: bash
- name: Dependency policy - name: Dependency policy
# cargo-deny's own --offline would also stop it from fetching the RustSec
# advisory database, which the check needs (from github.com, no key).
# CARGO_NET_OFFLINE keeps only the `cargo metadata` it runs offline.
env:
CARGO_NET_OFFLINE: "true"
run: cargo deny --locked --workspace check run: cargo deny --locked --workspace check
shell: bash shell: bash
- name: Third-party notices - name: Third-party notices
env:
CARGO_NET_OFFLINE: "true"
run: scripts/notices.sh --check run: scripts/notices.sh --check
shell: bash shell: bash
- name: Release tooling regressions - name: Release tooling regressions
+4 -3
View File
@@ -4,7 +4,8 @@
# #
# Committed, never fetched while a job runs, so a CI or release build trusts the # Committed, never fetched while a job runs, so a CI or release build trusts the
# key reviewed here and not whatever answers on the network at that moment. # key reviewed here and not whatever answers on the network at that moment.
# Read by .gitea/actions/checks (appended to ~/.ssh/known_hosts) and COPYed by # Read in place by ssh (-o UserKnownHostsFile, in the command line that the fetch
# docker/*.Dockerfile and crates/voelin-gateway/Dockerfile. How to re-check it # step of .gitea/workflows/ci.yml gives git: nothing is appended to ~/.ssh) and
# and how to rotate it: docs/ci.md, "VoelinProtocol access". # COPYed by docker/*.Dockerfile and crates/voelin-gateway/Dockerfile. How to
# re-check it and how to rotate it: docs/ci.md, "VoelinProtocol access".
git.faumaray.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzZEz9JLrzk6oLiloSbueAN28vYL58Y/dTHBgRuBMMib9IJ1aDJShhr3kwC9sfOT0AzK0uwcMAqCAIkwJwttde8dIg0Mee0cmB/1JkoqFF4X3MUGD1r3nk8SSZNhIiPqo16hDF9Hf3FkovztIlBVntkyP9Iy9hYfP818Tiq3yRXROGdHjR7IfY4jR2QGfGrd/RtvPGExVqusxidy141240A8aRAwMFUqFdEvmXWjizrtCUqcrL/k1GEh0yJzbCdNOVUI6OuWd8tPluSBvmmeoNpKnCSl4Mkg36HObbOyrsme0asZqjcj0od65WYWApMPN0pUqhNu2CP83Nfor2VFwkdPRwe7cAZ0OD/8wyT6Hz5q1wWgf82y4tYDoDRYsd8JU86eebkJ07T5nCrEeC4Sj+qT4S5xv/kECAhxyP4QGnunORnY2fYsdNGzpPvbMN7gHe9UcIcQdOIgV3wrR1qpMVNcd8AEC2A3TRv/jzMCHSjmGGpgiy1Db2CZAjp5+PcjNmjvoPNN0NiA9X4rIVSeTfflWnDRmeNRJeZa73StjpU17EcAf97COUQPGWJQDgpJqINSpYU50fuaLBfzKnIRuiHjKQmyKe/zgRSmulnYFYM3AJfn8Ykg2VvkUQGvCt1+fqYiUa1iVFuwPP3ZigYF1mOZRpPnos5kaNmlB01q2sZw== git.faumaray.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzZEz9JLrzk6oLiloSbueAN28vYL58Y/dTHBgRuBMMib9IJ1aDJShhr3kwC9sfOT0AzK0uwcMAqCAIkwJwttde8dIg0Mee0cmB/1JkoqFF4X3MUGD1r3nk8SSZNhIiPqo16hDF9Hf3FkovztIlBVntkyP9Iy9hYfP818Tiq3yRXROGdHjR7IfY4jR2QGfGrd/RtvPGExVqusxidy141240A8aRAwMFUqFdEvmXWjizrtCUqcrL/k1GEh0yJzbCdNOVUI6OuWd8tPluSBvmmeoNpKnCSl4Mkg36HObbOyrsme0asZqjcj0od65WYWApMPN0pUqhNu2CP83Nfor2VFwkdPRwe7cAZ0OD/8wyT6Hz5q1wWgf82y4tYDoDRYsd8JU86eebkJ07T5nCrEeC4Sj+qT4S5xv/kECAhxyP4QGnunORnY2fYsdNGzpPvbMN7gHe9UcIcQdOIgV3wrR1qpMVNcd8AEC2A3TRv/jzMCHSjmGGpgiy1Db2CZAjp5+PcjNmjvoPNN0NiA9X4rIVSeTfflWnDRmeNRJeZa73StjpU17EcAf97COUQPGWJQDgpJqINSpYU50fuaLBfzKnIRuiHjKQmyKe/zgRSmulnYFYM3AJfn8Ykg2VvkUQGvCt1+fqYiUa1iVFuwPP3ZigYF1mOZRpPnos5kaNmlB01q2sZw==
+244 -9
View File
@@ -1,7 +1,22 @@
name: CI name: CI
# Linux checks for Gitea act_runner; runner setup and scope: docs/ci.md. # Linux checks for Gitea act_runner; runner setup and scope: docs/ci.md.
# Off for pushes and pull requests: run by hand only. # Runs on pushes to main and on pull requests (not when only docs or Markdown
# files change, apart from THIRD_PARTY_NOTICES.md), and by hand.
#
# The workspace depends on the private VoelinProtocol repository over SSH, so
# the job needs the read-only deploy key (the repository secret
# VOELIN_PROTOCOL_DEPLOY_KEY). The key exists for one step only: "Fetch the
# dependencies" runs `cargo fetch` with it, before any build script, procedural
# macro or test of the repository has run, and deletes it again. Everything after
# that (the composite action .gitea/actions/checks) runs `--offline` in a job that
# holds no key. docs/ci.md, "VoelinProtocol access", has the whole story; the
# order of the steps is part of it:
#
# 1. check that this job may hold the key (the runner, the pull request's head)
# 2. system packages and the Rust toolchain (no key yet)
# 3. install the key into a directory of its own, 4. fetch with it and delete it
# 5. delete it again whatever happened, 6. the checks, offline
on: on:
push: push:
branches: ["main"] branches: ["main"]
@@ -21,9 +36,8 @@ on:
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
# Cargo fetches the private VoelinProtocol dependency with the system git and # Cargo fetches the private VoelinProtocol dependency with the system git and
# ssh (docs/ci.md, "VoelinProtocol access"). The checks action exports this # ssh, whose command line the fetch step sets (docs/ci.md, "VoelinProtocol
# too; set here as well, it does not depend on the runner handing a composite # access"); Cargo's own git client could not use that key file.
# action's GITHUB_ENV on to the later steps.
CARGO_NET_GIT_FETCH_WITH_CLI: "true" CARGO_NET_GIT_FETCH_WITH_CLI: "true"
jobs: jobs:
@@ -31,14 +45,235 @@ jobs:
name: Linux checks name: Linux checks
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
timeout-minutes: 180 timeout-minutes: 180
env:
# 'yes' unless this run is a pull request whose head branch lives in
# another repository. For a pull request Gitea's event payload has
# github.event.pull_request.head.repo.full_name, the repository that holds
# the branch to be merged: this repository (equal to github.repository)
# for a branch pushed here, the fork's own name for a fork. Any other
# event (push, workflow_dispatch) has no pull request and the first
# operand is true at once. An absent or unequal name reads 'no', and the
# check below treats everything but 'yes' as no. The check asks the same
# question again in its script, from the head repository's name itself.
VOELIN_PR_HEAD_HERE: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'yes' || 'no' }}
defaults: defaults:
run: run:
shell: bash shell: bash
steps: steps:
- uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/checkout@v4
# A runner prints the `env:` of a step in the job log when the step starts,
# and the runner "gitea-runner-docker" v0.6.1 printed a multi-line secret
# there in clear (the deploy keys of all four repositories, 2026-10-27; they
# were rotated the next day). Both runners carry the same labels, so
# `runs-on` cannot keep the job off it. What the workflow can do is not to
# start the step that declares the secret on such a runner, and not to give
# the secret to a fork's pull request: this step decides, before any step
# names the secret, and writes the one positive flag that the key step asks
# for. Without the flag the job stops here: the key is not optional (nothing
# builds without voelin-identity), and a green job that checked nothing
# would be worse than a red one that says why.
- name: Check that this job may hold the VoelinProtocol deploy key
env:
# The oldest runner version known to mask a multi-line secret in the
# log. Lower it only after a canary secret has been shown masked on
# that runner (docs/ci.md, "VoelinProtocol access"). release.yml has
# the same line.
MIN_MASKING_RUNNER_VERSION: 3.1.0
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
run: |
set -euo pipefail
version="${GITEA_ACTIONS_RUNNER_VERSION:-}"
name="${RUNNER_NAME:-an unnamed runner}"
problems=()
masks=no
if [[ "$version" =~ ^v?([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
oldest="$(printf '%s\n%s\n' "$MIN_MASKING_RUNNER_VERSION" "${BASH_REMATCH[1]}" | sort -V | head -n 1)"
if [[ "$oldest" == "$MIN_MASKING_RUNNER_VERSION" ]]; then
masks=yes
echo "Runner $name reports version $version, which masks secrets in the log (at least $MIN_MASKING_RUNNER_VERSION)."
fi
fi
if [[ "$masks" != yes ]]; then
problems+=("the runner ($name) reports version '${version:-none}', and only a runner of version $MIN_MASKING_RUNNER_VERSION or newer is known to keep the deploy key out of the job log (gitea-runner-docker v0.6.1 printed it in clear). Run the job again: it may be given another runner")
fi
# The pull request's head. The job-level expression has answered in
# VOELIN_PR_HEAD_HERE; the answer is asked for again here, from the
# head repository's name and the repository's, so that a mistake in
# one of the two places does not hand the key to a fork's code. A pull
# request (any event whose name starts with pull_request, or any event
# that carries a head repository) passes only with a head repository
# that is named and is this repository.
head_here=yes
[[ "${VOELIN_PR_HEAD_HERE:-}" == yes ]] || head_here=no
case "${GITHUB_EVENT_NAME:-}" in
pull_request*) pull_request=yes ;;
*) pull_request=no ;;
esac
[[ -z "${PR_HEAD_REPO:-}" ]] || pull_request=yes
if [[ "$pull_request" == yes ]]; then
if [[ -z "${PR_HEAD_REPO:-}" || "$PR_HEAD_REPO" != "${GITHUB_REPOSITORY:-}" ]]; then
head_here=no
fi
fi
if [[ "$head_here" == yes ]]; then
if [[ "$pull_request" == yes ]]; then
echo "Event ${GITHUB_EVENT_NAME:-unknown}: the pull request's head is in $PR_HEAD_REPO, which is this repository, not a fork."
else
echo "Event ${GITHUB_EVENT_NAME:-unknown}: no pull request, the code is this repository's own."
fi
else
problems+=("the pull request's head repository is '${PR_HEAD_REPO:-unknown}', and this repository is ${GITHUB_REPOSITORY:-unknown}, so it is a fork's pull request (or the event did not say where the head is), and the key is not given to a fork's code. Push the branch to ${GITHUB_REPOSITORY:-this repository} to have it checked")
fi
if ((${#problems[@]})); then
for problem in "${problems[@]}"; do
echo "::error::The VoelinProtocol deploy key is not given to this job: $problem." >&2
done
echo "::error::The job stops here: the workspace cannot be built without the private VoelinProtocol repository (docs/ci.md, VoelinProtocol access)." >&2
exit 1
fi
echo "VOELIN_KEY_ALLOWED=yes" >> "$GITHUB_ENV"
# Native libraries and tools (apt), the same action as GitHub CI. The job
# image has git and the OpenSSH client; the key step checks for ssh.
- uses: ./.github/actions/system-deps
- name: Install pinned Rust toolchain
run: |
set -euo pipefail
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
export PATH="$CARGO_HOME/bin:$PATH"
if ! command -v rustup >/dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile minimal --default-toolchain none
fi
if [[ -f "$CARGO_HOME/env" ]]; then
# shellcheck source=/dev/null
source "$CARGO_HOME/env"
fi
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
rustup toolchain install
# The key, as late as it can be: after the packages and the toolchain have
# been installed, right before the one step that uses it.
- name: Install the VoelinProtocol deploy key
# Both lines below ask for the positive flag of the check above. On a
# runner that is not known to mask the secret (or whose expression context
# does not hold what an earlier step wrote to GITHUB_ENV) the flag reads
# empty: the step is not started, so it prints no header, and the
# expression is empty as well, in case a runner prints a header anyway.
# The key reaches the step through the environment only: never in the
# script text, never echoed, no `set -x`. A pull request from a fork gets
# no secrets from Gitea and fails the check above before it gets here.
if: env.VOELIN_KEY_ALLOWED == 'yes'
env:
PROTOCOL_DEPLOY_KEY: ${{ env.VOELIN_KEY_ALLOWED == 'yes' && secrets.VOELIN_PROTOCOL_DEPLOY_KEY || '' }}
run: |
set -euo pipefail
umask 077
if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then
echo "::error::The VoelinProtocol deploy key is empty. Set the repository secret VOELIN_PROTOCOL_DEPLOY_KEY to the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access)." >&2
exit 1
fi
for tool in ssh ssh-keygen; do
command -v "$tool" > /dev/null || {
echo "::error::The job image needs the OpenSSH client: $tool is missing." >&2
exit 1
}
done
[[ -s "$GITHUB_WORKSPACE/.gitea/known_hosts" ]] || {
echo "::error::.gitea/known_hosts is missing from the checkout." >&2
exit 1
}
# A directory of this job's own (mode 0700, a name that nothing else
# uses, so a host runner that keeps its temporary directory between
# jobs does not share it). On any way out of this step but the last
# line, the step removes it itself; the directory is left only for the
# fetch step, which removes it in turn. Its name goes to the later
# steps first, so that the cleanup step finds it even if this step is
# killed.
key_dir="$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/voelin-protocol-key.XXXXXX")"
installed=
trap '[[ -n "$installed" ]] || rm -rf "$key_dir"' EXIT
echo "VOELIN_PROTOCOL_KEY_DIR=$key_dir" >> "$GITHUB_ENV"
key_file="$key_dir/id"
# Whatever the secret store did to the line ends and the final newline,
# OpenSSH needs LF lines, the BEGIN line first and a newline at the end.
printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' > "$key_file"
unset PROTOCOL_DEPLOY_KEY
chmod 600 "$key_file"
if ! public=$(ssh-keygen -y -f "$key_file" < /dev/null); then
echo "::error::VOELIN_PROTOCOL_DEPLOY_KEY is not an unencrypted OpenSSH or PEM private key." >&2
exit 1
fi
# The fingerprint of the public half, to compare with the deploy key in
# the VoelinProtocol settings.
printf 'Deploy key installed: %s\n' "$(ssh-keygen -lf - <<< "$public")"
echo "VOELIN_PROTOCOL_KEY=installed" >> "$GITHUB_ENV"
installed=1
# The only step that uses the key, and the only place that sets
# GIT_SSH_COMMAND: not in GITHUB_ENV, so no later step has it.
- name: Fetch the dependencies with the deploy key
run: |
set -euo pipefail
if [[ "${VOELIN_PROTOCOL_KEY:-}" != installed || -z "${VOELIN_PROTOCOL_KEY_DIR:-}" ]]; then
echo "::error::The deploy key was not installed by the step before (the check at the start of the job or the key step did not pass its flag on)." >&2
exit 1
fi
key_dir="$VOELIN_PROTOCOL_KEY_DIR"
key_file="$key_dir/id"
# On every way out of this step, a failed fetch included.
trap 'rm -rf "$key_dir"' EXIT
[[ -f "$key_file" ]] || { echo "::error::The deploy key file is missing." >&2; exit 1; }
# The system git runs this ssh command, so the key and the host key are
# named outright and nothing in ~/.ssh or /etc/ssh is read: -F /dev/null
# leaves out every ssh config file, -i with IdentitiesOnly and no agent
# offers this one key, and the only host key accepted is the reviewed
# line in .gitea/known_hosts, never one fetched now (a changed or unknown
# host key fails rather than asks). The paths are absolute: Cargo runs
# git in its own directory under CARGO_HOME, not in the checkout.
export GIT_TERMINAL_PROMPT=0
export GIT_SSH_COMMAND="ssh -F /dev/null -i '$key_file' -o IdentitiesOnly=yes -o IdentityAgent=none -o UserKnownHostsFile='$GITHUB_WORKSPACE/.gitea/known_hosts' -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=yes -o BatchMode=yes -o ConnectTimeout=30"
# The first thing that touches the server with the key, so that a wrong
# key or a changed host key fails here with a clear message and not
# minutes later inside Cargo.
if ! timeout 120 git ls-remote --exit-code \
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git HEAD > /dev/null; then
echo "::error::git cannot read Voelin/VoelinProtocol over SSH with the deploy key. 'Permission denied (publickey)' above: the key is not registered on that repository (or is not the one in VOELIN_PROTOCOL_DEPLOY_KEY). 'Host key verification failed': .gitea/known_hosts no longer matches the server (docs/ci.md, VoelinProtocol access)." >&2
exit 1
fi
echo "Voelin/VoelinProtocol is readable with the deploy key."
# Cargo reads the manifests and Cargo.lock and downloads every package
# of the lock file (all targets: cargo deny and cargo about, later, read
# the whole graph). It runs no build script, procedural macro or test
# of the repository. Nothing else in the job needs the key: every later
# cargo command is --offline.
cargo fetch --locked
unset GIT_SSH_COMMAND
rm -rf "$key_dir"
[[ ! -e "$key_dir" ]] || { echo "::error::The deploy key could not be removed from the job." >&2; exit 1; }
echo "The deploy key is removed from the job."
# Whatever happened to the two steps above (a failed fetch, a key that was
# installed and never fetched with, a cancelled job), the key is gone before
# the checks start. Idempotent: the fetch step has already removed it.
- name: Delete the deploy key
if: always()
run: |
set -euo pipefail
key_dir="${VOELIN_PROTOCOL_KEY_DIR:-}"
if [[ -n "$key_dir" && -e "$key_dir" ]]; then
rm -rf "$key_dir"
[[ ! -e "$key_dir" ]] || { echo "::error::The deploy key could not be removed from the job." >&2; exit 1; }
echo "The deploy key is removed from the job."
else
echo "No deploy key is left in the job."
fi
{
echo "VOELIN_PROTOCOL_KEY_DIR="
echo "VOELIN_PROTOCOL_KEY="
} >> "$GITHUB_ENV"
# Formatting, Clippy, build, tests, dependency policy, notices: all
# offline, in a job that holds no key (docs/ci.md, "VoelinProtocol access").
- uses: ./.gitea/actions/checks - uses: ./.gitea/actions/checks
with:
# A repository secret is not visible inside the composite action, so
# it is passed in. Pull requests from forks get no secrets: the
# action then fails at once with a message that says so.
protocol-deploy-key: ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }}
+70 -12
View File
@@ -33,13 +33,56 @@ jobs:
# Remove only output owned by this workflow in its checkout. # Remove only output owned by this workflow in its checkout.
rm -rf dist rm -rf dist
# The workspace depends on the private VoelinProtocol repository over SSH # The workspace depends on the private VoelinProtocol repository over SSH
# (docs/ci.md, "VoelinProtocol access"). The Docker builds fetch it with # (docs/ci.md, "VoelinProtocol access"). The Docker builds fetch it with an
# this agent (`docker build --ssh default`): the key lives in the agent's # ssh-agent (`docker build --ssh default`): the key lives in the agent's
# memory, never on disk and never in an image layer. Stopped by the last # memory, never on disk and never in an image layer, and only the
# step; the lifetime below ends the key anyway if the runner dies first. # `cargo fetch` of each Dockerfile is given the agent (the build that
- name: Start ssh-agent with the VoelinProtocol deploy key # follows is --offline and has no ssh mount, so the build scripts and
# procedural macros run without the key). The agent is stopped by the step
# right after the last build, whatever the builds did; the lifetime below
# ends the key anyway if the runner dies first.
#
# A runner prints the `env:` of a step in the job log when the step starts,
# and the runner "gitea-runner-docker" v0.6.1 printed a multi-line secret
# there in clear (2026-10-27; the keys were rotated the next day). It
# carries the same labels as the release runner, so `runs-on` cannot keep
# the job off it: this step decides, before any step names the secret, and
# writes the one positive flag that the agent step asks for. Without the
# flag the job stops here (no package can be built without voelin-identity).
# ci.yml has the same step, with the check of a pull request's head repository
# that a release (tags and manual runs only) does not need.
- name: Check that this runner may hold the VoelinProtocol deploy key
env: env:
PROTOCOL_DEPLOY_KEY: ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }} # The oldest runner version known to mask a multi-line secret in the
# log. Lower it only after a canary secret has been shown masked on
# that runner (docs/ci.md, "VoelinProtocol access"). ci.yml has the
# same line.
MIN_MASKING_RUNNER_VERSION: 3.1.0
run: |
set -euo pipefail
version="${GITEA_ACTIONS_RUNNER_VERSION:-}"
name="${RUNNER_NAME:-an unnamed runner}"
if [[ "$version" =~ ^v?([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
oldest="$(printf '%s\n%s\n' "$MIN_MASKING_RUNNER_VERSION" "${BASH_REMATCH[1]}" | sort -V | head -n 1)"
if [[ "$oldest" == "$MIN_MASKING_RUNNER_VERSION" ]]; then
echo "Runner $name reports version $version, which masks secrets in the log (at least $MIN_MASKING_RUNNER_VERSION)."
echo "VOELIN_KEY_ALLOWED=yes" >> "$GITHUB_ENV"
exit 0
fi
fi
echo "::error::The VoelinProtocol deploy key is not given to this job: the runner ($name) reports version '${version:-none}', and only a runner of version $MIN_MASKING_RUNNER_VERSION or newer is known to keep the deploy key out of the job log (gitea-runner-docker v0.6.1 printed it in clear). Run the job again: it may be given another runner." >&2
echo "::error::The job stops here: no package can be built without the private VoelinProtocol repository (docs/ci.md, VoelinProtocol access)." >&2
exit 1
- name: Start ssh-agent with the VoelinProtocol deploy key
# Both lines below ask for the positive flag of the check above: on a
# runner that is not known to mask the secret (or whose expression context
# does not hold what an earlier step wrote to GITHUB_ENV) the step is not
# started and the expression is empty as well, in case a runner prints a
# header anyway. The key reaches the step through the environment only:
# never in the script text, never echoed, no `set -x`.
if: env.VOELIN_KEY_ALLOWED == 'yes'
env:
PROTOCOL_DEPLOY_KEY: ${{ env.VOELIN_KEY_ALLOWED == 'yes' && secrets.VOELIN_PROTOCOL_DEPLOY_KEY || '' }}
run: | run: |
set -euo pipefail set -euo pipefail
if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then
@@ -112,6 +155,27 @@ jobs:
DOCKER_BUILDKIT=1 docker build --ssh default -f crates/voelin-gateway/Dockerfile -t "tsgw:$version" -t tsgw:latest . DOCKER_BUILDKIT=1 docker build --ssh default -f crates/voelin-gateway/Dockerfile -t "tsgw:$version" -t tsgw:latest .
mkdir -p dist/gateway mkdir -p dist/gateway
docker save "tsgw:$version" tsgw:latest | gzip > dist/gateway/tsgw-image.tar.gz docker save "tsgw:$version" tsgw:latest | gzip > dist/gateway/tsgw-image.tar.gz
# Right after the builds, the only steps that use the agent, and whatever
# they did (a failed build, a cancelled job): the steps after this one
# (the artifact upload, the release draft with its token) have neither the
# key nor the socket.
- name: Stop the ssh-agent
if: always()
run: |
if [[ -n "${VOELIN_AGENT_STARTED:-}" && -n "${SSH_AGENT_PID:-}" ]]; then
if ssh-agent -k > /dev/null; then
echo "The ssh-agent with the deploy key is stopped."
else
echo "::warning::ssh-agent -k failed; the agent ends by itself when its lifetime (nine hours) is over." >&2
fi
else
echo "No ssh-agent of this job is running."
fi
{
echo "SSH_AUTH_SOCK="
echo "SSH_AGENT_PID="
echo "VOELIN_AGENT_STARTED="
} >> "$GITHUB_ENV"
- name: Collect packages and checksums - name: Collect packages and checksums
run: | run: |
set -euo pipefail set -euo pipefail
@@ -136,9 +200,3 @@ jobs:
# Gitea refuses secret names starting with GITEA_ or GITHUB_. # Gitea refuses secret names starting with GITEA_ or GITHUB_.
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: scripts/gitea-release.sh dist/release run: scripts/gitea-release.sh dist/release
- name: Stop the ssh-agent
if: always()
run: |
if [[ -n "${VOELIN_AGENT_STARTED:-}" && -n "${SSH_AGENT_PID:-}" ]]; then
ssh-agent -k > /dev/null || true
fi
+14
View File
@@ -240,6 +240,20 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
`Welcome`, `Server`, `Channel`, `Member` and the others whose secrets `Welcome`, `Server`, `Channel`, `Member` and the others whose secrets
VoelinProtocol lists) shows `<redacted>` in place of a password or a token, so VoelinProtocol lists) shows `<redacted>` in place of a password or a token, so
a log line or a failed test that prints one does not show it. a log line or a failed test that prints one does not show it.
- CI and the package builds give the VoelinProtocol deploy key only to the step
that fetches the sources. The CI job writes the key to a directory of its own
(no `~/.ssh` configuration), uses it for `cargo fetch` as `ssh -i` with the
committed host key, and deletes it right after and again in a step that always
runs; the formatting, Clippy, build, test and policy steps, which run the
repository's build scripts and tests, are `--offline` and run in a job without
the key. The Docker builds (Linux, Windows, Android and the gateway image)
fetch in a `RUN` with the ssh mount and build `--offline` without it, and the
release workflow stops its ssh-agent right after the last build. A job gives
the key only to a runner that reports version 3.1.0 or newer (the old runner
gitea-runner-docker v0.6.1 printed a multi-line secret in the job log; the
deploy key was replaced, id 7) and, on a pull request, only when its head
branch is in this repository; otherwise it stops with the reason. See
docs/ci.md, "VoelinProtocol access".
### Removed ### Removed
+8 -3
View File
@@ -17,13 +17,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends cmake git libas
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it): # `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
# the key stays in the agent and never reaches a layer. The host key is the # the key stays in the agent and never reaches a layer. The host key is the
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so # reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
# every cargo command needs this, although this crate does not use # the first cargo command needs this, although this crate does not use
# voelin-identity. # voelin-identity: the `cargo fetch` below, the only step that is given the agent.
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY . . COPY . .
# Only this step is given the agent, and it only fetches: no build script,
# procedural macro or test of the workspace runs in it. The build below has no
# ssh mount (so no agent socket and no key in reach of the code it compiles and
# runs) and is --offline, so it uses what this step fetched or fails.
RUN --mount=type=ssh,required=true \ RUN --mount=type=ssh,required=true \
cargo build --release --locked -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data cargo fetch --locked
RUN cargo build --release --locked --offline -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data
FROM gcr.io/distroless/cc-debian12:nonroot FROM gcr.io/distroless/cc-debian12:nonroot
COPY --from=build /tsgw /usr/local/bin/tsgw COPY --from=build /tsgw /usr/local/bin/tsgw
+15 -2
View File
@@ -90,13 +90,26 @@ WORKDIR /src
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it): # `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
# the key stays in the agent and never reaches a layer. The host key is the # the key stays in the agent and never reaches a layer. The host key is the
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so # reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
# every cargo command needs this (Gradle's cargo-ndk inherits the agent and the # the first cargo command needs this: the `cargo fetch` below, the only step
# variable below). # that is given the agent.
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY . . COPY . .
# Only this step is given the agent, and it only fetches (the packages of every
# target, so the Android ones too): no build script, procedural macro or test of
# the workspace runs in it. The build below has no ssh mount (so no agent socket
# and no key in reach of the code it compiles and runs).
RUN --mount=type=ssh,required=true \ RUN --mount=type=ssh,required=true \
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
cargo fetch --locked
# Gradle starts cargo-ndk, which starts cargo: the variable makes every one of
# them offline, as `--offline` does for the other Dockerfiles (the Gradle task
# is left as it is, because a developer's own build has network and no
# `cargo fetch`). The build uses what the step above fetched (the registry in
# the cache mount shared with it, the git checkout of VoelinProtocol in its
# layer) or fails.
ENV CARGO_NET_OFFLINE=true
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=voelin-target-android,target=/src/target \ --mount=type=cache,id=voelin-target-android,target=/src/target \
--mount=type=cache,id=voelin-gradle,target=/root/.gradle \ --mount=type=cache,id=voelin-gradle,target=/root/.gradle \
--mount=type=secret,id=keystore,required=false \ --mount=type=secret,id=keystore,required=false \
+11 -2
View File
@@ -45,14 +45,23 @@ WORKDIR /src
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it): # `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
# the key stays in the agent and never reaches a layer. The host key is the # the key stays in the agent and never reaches a layer. The host key is the
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so # reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
# every cargo command needs this. # the first cargo command needs this: the `cargo fetch` below, the only step
# that is given the agent.
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY . . COPY . .
# Only this step is given the agent, and it only fetches: no build script,
# procedural macro or test of the workspace runs in it. It shares the registry
# cache with the build below, which has no ssh mount (so no agent socket and no
# key in reach of the code it compiles and runs) and is --offline: it uses what
# this step fetched (the registry in the cache mount, the git checkout of
# VoelinProtocol in this step's layer) or fails.
RUN --mount=type=ssh,required=true \ RUN --mount=type=ssh,required=true \
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
cargo fetch --locked
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=voelin-target-linux,target=/src/target \ --mount=type=cache,id=voelin-target-linux,target=/src/target \
cargo build --release --locked -p voelin-ui -p voelin-gateway \ cargo build --release --locked --offline -p voelin-ui -p voelin-gateway \
&& scripts/package.sh linux /out && scripts/package.sh linux /out
FROM scratch AS artifacts FROM scratch AS artifacts
+12 -3
View File
@@ -98,15 +98,24 @@ WORKDIR /src
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it): # `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
# the key stays in the agent and never reaches a layer. The host key is the # the key stays in the agent and never reaches a layer. The host key is the
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so # reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
# every cargo command needs this. # the first cargo command needs this: the `cargo fetch` below, the only step
# that is given the agent.
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY . . COPY . .
# FFmpeg's LGPL DLLs go into the packages (scripts/fetch-ffmpeg-windows.sh). # Only this step is given the agent, and it only fetches (the packages of every
# target, so the Windows ones too): no build script, procedural macro or test of
# the workspace runs in it. The build below has no ssh mount (so no agent socket
# and no key in reach of the code it compiles and runs) and is --offline: it
# uses what this step fetched (the registry in the cache mount shared with it,
# the git checkout of VoelinProtocol in this step's layer) or fails.
RUN --mount=type=ssh,required=true \ RUN --mount=type=ssh,required=true \
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
cargo fetch --locked
# FFmpeg's LGPL DLLs go into the packages (scripts/fetch-ffmpeg-windows.sh).
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=voelin-target-windows,target=/src/target \ --mount=type=cache,id=voelin-target-windows,target=/src/target \
cargo build --release --locked --target x86_64-pc-windows-gnu -p voelin-ui \ cargo build --release --locked --offline --target x86_64-pc-windows-gnu -p voelin-ui \
&& scripts/fetch-ffmpeg-windows.sh /tmp/ffmpeg \ && scripts/fetch-ffmpeg-windows.sh /tmp/ffmpeg \
&& FFMPEG_DLL_DIR=/tmp/ffmpeg WINDOWS_TARGET=x86_64-pc-windows-gnu scripts/package.sh windows /out && FFMPEG_DLL_DIR=/tmp/ffmpeg WINDOWS_TARGET=x86_64-pc-windows-gnu scripts/package.sh windows /out
+15 -10
View File
@@ -86,7 +86,8 @@ The same with plain Docker, e.g. `docker build --ssh default -f docker/linux.Doc
**The builds need an ssh-agent that holds a key able to read the private **The builds need an ssh-agent that holds a key able to read the private
VoelinProtocol repository** ([below](#depending-on-voelinprotocol)): Cargo VoelinProtocol repository** ([below](#depending-on-voelinprotocol)): Cargo
fetches it inside the image, through the agent that `--ssh default` hands to the fetches it inside the image, through the agent that `--ssh default` hands to the
build. The key stays in the agent; it is not copied into the image or the build build, in a `RUN cargo fetch` of its own: the build after it has no agent and is
offline. The key stays in the agent; it is not copied into the image or the build
cache. `scripts/docker-build.sh` passes `--ssh default` itself and stops with a cache. `scripts/docker-build.sh` passes `--ssh default` itself and stops with a
message when `ssh-add -l` shows no agent or no key (`eval "$(ssh-agent -s)"`, message when `ssh-add -l` shows no agent or no key (`eval "$(ssh-agent -s)"`,
then `ssh-add` your key). The server's host key comes from then `ssh-add` your key). The server's host key comes from
@@ -183,15 +184,19 @@ set `net.git-fetch-with-cli = true` in `~/.cargo/config.toml`.
compiler (gcc or clang) and cmake. compiler (gcc or clang) and cmake.
`deny.toml` allows this one git source. `deny.toml` allows this one git source.
**CI and the Docker builds read it with a read-only SSH deploy key.** The key **CI and the Docker builds read it with a read-only SSH deploy key, and only to
is registered on VoelinProtocol and stored as the repository secret fetch.** The key is registered on VoelinProtocol and stored as the repository
`VOELIN_PROTOCOL_DEPLOY_KEY`; the Gitea workflows write it to `~/.ssh` (CI) or secret `VOELIN_PROTOCOL_DEPLOY_KEY`. The CI job writes it to a directory of its
load it into an ssh-agent (release builds), the server's host key comes from the own (nothing in `~/.ssh`), runs `cargo fetch --locked` with it as the one
committed `.gitea/known_hosts`, and Cargo is told to fetch with the system git `ssh -i` of that step, deletes it, and runs every later cargo command
(`CARGO_NET_GIT_FETCH_WITH_CLI=true`) because its built-in git client ignores `--offline`; the release builds load it into an ssh-agent, and each Dockerfile
`~/.ssh/config`. The Docker builds use the same key through gives the agent to a `RUN cargo fetch` only, the `cargo build --offline` after it
`docker build --ssh default` (see above). What was set up, how to re-check the has none. The server's host key comes from the committed `.gitea/known_hosts`, and
host key's fingerprint and what each failure means: Cargo is told to fetch with the system git (`CARGO_NET_GIT_FETCH_WITH_CLI=true`)
because its built-in git client cannot use a key file. The Docker builds use the
same key through `docker build --ssh default` (see above). What was set up, the
order of the steps, why a runner that may print the key does not get it, how to
re-check the host key's fingerprint and what each failure means:
[ci.md](ci.md#voelinprotocol-access). A runner of your own gets the same setup [ci.md](ci.md#voelinprotocol-access). A runner of your own gets the same setup
from the workflows; the alternative to a deploy key is an access token (rewrite from the workflows; the alternative to a deploy key is an access token (rewrite
the SSH URL to HTTPS with the SSH URL to HTTPS with
+284 -68
View File
@@ -2,8 +2,9 @@
GitHub Actions runs `.github/workflows/ci.yml`, including Linux checks, GitHub Actions runs `.github/workflows/ci.yml`, including Linux checks,
Windows and Android Clippy, and TeamSpeak integration smoke tests. Automatic Windows and Android Clippy, and TeamSpeak integration smoke tests. Automatic
runs are off: CI, the dependency audit and fuzzing run only by hand runs are off there: CI, the dependency audit and fuzzing run only by hand
(Actions → the workflow → Run workflow; the same on Gitea). Only the package (Actions → the workflow → Run workflow). On Gitea, CI also runs on pushes to
`main` and on pull requests ([Gitea Actions](#gitea-actions)). Only the package
builds run by themselves, on `v*` tags, and they run none of these checks. builds run by themselves, on `v*` tags, and they run none of these checks.
Both GitHub and Gitea provide release packaging; see [release.md](release.md) Both GitHub and Gitea provide release packaging; see [release.md](release.md)
and [building.md](building.md). and [building.md](building.md).
@@ -22,10 +23,18 @@ runtime performance has not been benchmarked for this change.
## Gitea Actions ## Gitea Actions
`.gitea/workflows/ci.yml` runs a single Linux job when dispatched by hand `.gitea/workflows/ci.yml` runs a single Linux job on pushes to `main`, on pull
(automatic runs on pushes and pull requests are off). requests (not when only `docs/` or Markdown files change, apart from
`THIRD_PARTY_NOTICES.md`) and when dispatched by hand.
The job runs: Before any check the job fetches every dependency with the read-only deploy key
with which Cargo reads the private VoelinProtocol repository, and deletes the key
again; the checks run `--offline`, in a job that holds no key
([VoelinProtocol access](#voelinprotocol-access)). The repository secret
`VOELIN_PROTOCOL_DEPLOY_KEY` is needed for it, and the job refuses a runner that
may print it and a fork's pull request.
The checks are:
- formatting and warnings-as-errors Clippy for our crates; - formatting and warnings-as-errors Clippy for our crates;
- workspace Clippy (vendored warnings are reported, compilation errors fail); - workspace Clippy (vendored warnings are reported, compilation errors fail);
@@ -64,8 +73,10 @@ the separate `release.yml` workflow below.
(`voelin-identity`, `voelin-proto` and `voelin-model` at its release tag, (`voelin-identity`, `voelin-proto` and `voelin-model` at its release tag,
over SSH), so the job needs read access to it and the server's SSH port. over SSH), so the job needs read access to it and the server's SSH port.
The workflows set that up themselves from a repository secret: The workflows set that up themselves from a repository secret:
[VoelinProtocol access](#voelinprotocol-access). A runner needs [VoelinProtocol access](#voelinprotocol-access). A runner needs nothing for
nothing for it beyond the network access and the image tools above. it beyond the network access and the image tools above, **and a version that
masks multi-line secrets in the job log** (3.1.0 or newer): the workflows do
not give the key to an older runner and fail the job instead.
4. Provision enough RAM, swap and free disk for a full Slint workspace build 4. Provision enough RAM, swap and free disk for a full Slint workspace build
plus cargo-deny/cargo-about compilation. These are large builds; monitor plus cargo-deny/cargo-about compilation. These are large builds; monitor
the first run and size the runner accordingly. The workflow limits Cargo the first run and size the runner accordingly. The workflow limits Cargo
@@ -91,8 +102,10 @@ the separate `release.yml` workflow below.
The workflow shares the repository's local system-dependencies action with The workflow shares the repository's local system-dependencies action with
GitHub CI and bootstraps rustup if absent, then installs the toolchain and GitHub CI and bootstraps rustup if absent, then installs the toolchain and
components pinned in `rust-toolchain.toml` (1.95: a channel change there is all components pinned in `rust-toolchain.toml` (1.95: a channel change there is all
the runner needs). Checkout uses a fully qualified GitHub action URL rather the runner needs); these are steps of `ci.yml`, and the composite action
than depending on the instance's action-source configuration. `.gitea/actions/checks` holds the checks that run after the fetch. Checkout uses
a fully qualified GitHub action URL rather than depending on the instance's
action-source configuration.
No GitHub cache/artifact service or reusable-workflow support is required. No GitHub cache/artifact service or reusable-workflow support is required.
The job does not need a Docker socket mounted inside its container; the The job does not need a Docker socket mounted inside its container; the
@@ -200,60 +213,145 @@ from the **private** repository `Voelin/VoelinProtocol`, as git dependencies ove
SSH, pinned by its release tag `v0.2.0` SSH, pinned by its release tag `v0.2.0`
([building.md](building.md#depending-on-voelinprotocol)). The tag is read over ([building.md](building.md#depending-on-voelinprotocol)). The tag is read over
the same SSH access as the commit it replaced (Cargo fetches it through the the same SSH access as the commit it replaced (Cargo fetches it through the
system `git`, like any ref), so the deploy key, the host key and the read check system `git`, like any ref). Cargo resolves the whole workspace before it builds
of the step below are as they were. Cargo resolves the anything, so *every* cargo command needs that access until the sources are on
whole workspace before it builds anything, so *every* cargo command needs disk: all of CI, all three package images and the gateway image (whose crate does
that access: all of CI, all three package images and the gateway image (whose not use `voelin-identity` itself). Without it the first cargo command fails with
crate does not use `voelin-identity` itself). Without it the first cargo `unknown SSH host key` (runs 1037 and 1050 did). The workflows therefore fetch
command fails with `unknown SSH host key` (runs 1037 and 1050 did). first, with the key, and build afterwards without it.
What is set up: What is set up:
- **The deploy key.** A read-only SSH deploy key is registered on - **The deploy key.** A read-only SSH deploy key is registered on
`Voelin/VoelinProtocol` (Settings → Deploy Keys, write access off). It has `Voelin/VoelinProtocol` (Settings → Deploy Keys, write access off; deploy key
no other use and no access to any other repository. Its private half is the **id 7**, "VoelinClient CI (read-only)", made on 2026-10-28,
repository secret **`VOELIN_PROTOCOL_DEPLOY_KEY`** of `Voelin/VoelinClient` `SHA256:TWpZx3NgSMKTBkNLfp0C+Q1/DPD0E44Gy+GiHwK/zpI`). It has no other use and no
(Settings → Actions → Secrets): the whole OpenSSH private key file, BEGIN access to any other repository. It replaced this repository's first deploy key
and END lines included, without a passphrase. To rotate it, make a new pair (the secret of 2026-10-24), which a job log had shown in clear
(`ssh-keygen -t ed25519 -N '' -C voelin-client-ci -f key`), register ([The key and the runners](#the-key-and-the-runners)); that key is deleted, and so
`key.pub` on VoelinProtocol, replace the secret with the contents of are the runs that printed it. The private half is the repository secret
`key`, run CI, then delete the old deploy key and `key`. **`VOELIN_PROTOCOL_DEPLOY_KEY`** of `Voelin/VoelinClient` (Settings → Actions →
- **CI** (`ci.yml`). The workflow hands the secret to the checks action as its Secrets): the whole OpenSSH private key file, BEGIN and END lines included,
input `protocol-deploy-key` (a repository secret is not visible inside a without a passphrase. The key step prints the public fingerprint on every run,
composite action). The action's first step fails at once, naming the secret, to compare with the Deploy Keys page of VoelinProtocol. To rotate it, make a
if the input is empty or is not a private key. Otherwise it writes the key to new pair (`ssh-keygen -t ed25519 -N '' -C voelin-client-ci -f key`), register
`~/.ssh/voelin_protocol` (mode 0600, `~/.ssh` 0700), appends the host key `key.pub` on VoelinProtocol, replace the secret with the contents of `key`, run
line to `~/.ssh/known_hosts`, writes a `Host git.faumaray.com` block to CI and look at the fingerprint the key step prints, then delete the old deploy
`~/.ssh/config` (`User gitea`, that `IdentityFile`, `IdentitiesOnly yes`, key and `key`. If the old key may have been seen, delete the runs that could
`StrictHostKeyChecking yes`) and exports `CARGO_NET_GIT_FETCH_WITH_CLI=true` have shown it and count the lines in the logs that remain
and `GIT_SSH_COMMAND` for the rest of the job (`ci.yml` sets the first one ([Looking at a run](#looking-at-a-run)).
in its own `env` as well). It prints only the key's - **CI** (`ci.yml`). In order; the key exists only between steps 3 and 4:
public fingerprint; the key is never echoed. After the system packages a 1. **Check that this job may hold the VoelinProtocol deploy key.** It reads
second step runs `git ls-remote` on VoelinProtocol, so a wrong key or host `GITEA_ACTIONS_RUNNER_VERSION`; a plain `X.Y.Z` (an optional leading `v`) of
key fails there, with the reason, and not inside a cargo command. The key `MIN_MASKING_RUNNER_VERSION` (3.1.0) or more passes the runner part. A lower
lives in the job container and goes with it. version, no version, or anything else (`3.1.0-rc1`) fails it. For a pull
- **Release** (`release.yml`). A step after checkout starts an `ssh-agent` on request it also asks whether the PR's head is in this repository (below). If
the release host, loads the key into it from stdin (it is never written to both hold it writes `VOELIN_KEY_ALLOWED=yes` to `GITHUB_ENV`; otherwise it
disk) and exports `SSH_AUTH_SOCK`; the agent forgets the key after nine prints each reason as an error and **fails the job**: the key is not optional
hours, and a last step, which also runs after a failure, stops it. The (nothing builds without `voelin-identity`), and a green job that checked
builds pass the agent on with `docker build --ssh default` nothing would be worse than a red one that says why. Run it again to be given
(`scripts/docker-build.sh` does it for the three packages; the gateway image another runner.
step does it itself). 2. The system packages (the `system-deps` action, apt) and the pinned Rust
- **The images.** Each cargo `RUN` of `docker/*.Dockerfile` and toolchain. No key yet.
`crates/voelin-gateway/Dockerfile` has `--mount=type=ssh,required=true`, so 3. **Install the VoelinProtocol deploy key.** The secret is the `env:` of this
the key exists only inside that step, through the agent socket, and never one step, through `${{ env.VOELIN_KEY_ALLOWED == 'yes' && secrets.VOELIN_PROTOCOL_DEPLOY_KEY || '' }}`,
reaches a layer, a build argument or the cache; a build without `--ssh` and the step has `if: env.VOELIN_KEY_ALLOWED == 'yes'`: both ask for the
stops there with `unset ssh forward key default`. The build stage copies positive flag, so a runner that is not trusted, or one whose expression
`.gitea/known_hosts` to `/etc/ssh/ssh_known_hosts` and sets the same context does not hold what an earlier step wrote to `GITHUB_ENV`, leaves the
`CARGO_NET_GIT_FETCH_WITH_CLI=true`; the toolchain stages install `git` and step not started and the variable empty. The script never prints the key and
`openssh-client`. has no `set -x`. It writes the key to `id` (mode 0600) in a directory of the
job's own, `mktemp -d "$RUNNER_TEMP/voelin-protocol-key.XXXXXX"` (mode 0700;
the name goes to `GITHUB_ENV` first so that the cleanup finds it even if this
step is killed), checks it with `ssh-keygen -y` and prints the fingerprint. From
the `mktemp` on, the step removes the directory itself on every way out but
the last line (an `EXIT` trap: a key that is not a key, a full disk, a
termination). It writes nothing to `~/.ssh`: no key file, no `known_hosts`,
no config block.
4. **Fetch the dependencies with the deploy key.** The only step that uses the
key, and the only one that sets `GIT_SSH_COMMAND` (not in `GITHUB_ENV`, so no
other step has it):
`ssh -F /dev/null -i <dir>/id -o IdentitiesOnly=yes -o IdentityAgent=none -o UserKnownHostsFile=<workspace>/.gitea/known_hosts -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=yes -o BatchMode=yes -o ConnectTimeout=30`.
`-F /dev/null` leaves out every ssh config file, the identity is that file and
nothing from an agent, and the host key accepted is the committed line and no
other (a changed or unknown host key fails rather than asks). The paths are
absolute because Cargo runs git in its own directory, not in the checkout.
The step runs `git ls-remote` on VoelinProtocol first, so a wrong key or host
key fails there, with the reason, and not inside Cargo; then
`cargo fetch --locked`, which downloads every package of `Cargo.lock` (all
targets, because cargo-deny and cargo-about read the whole graph) and runs **no
build script, procedural macro or test**; then it deletes the directory (on
every way out of the step, a failed fetch included) and checks that it is
gone.
5. **Delete the deploy key**, `if: always()`: removes the directory if it is
still there (the key step failed after creating it, the job was cancelled) and
says so, or says that none is left. It runs right after the fetch, so the
checks never start with a key in the job.
6. **The checks** (`.gitea/actions/checks`): formatting, Clippy, the build, the
tests under Xvfb, cargo-deny, the notices check and the release tooling tests.
The action has **no input and no secret**: the secret is never handed to the
steps that run the repository's build scripts and tests. Every cargo command
in it is `--offline` (with `--locked`), and the steps that start cargo through
a script or plugin (`scripts/own-crates.sh`, `cargo fmt`, `cargo deny`,
`scripts/notices.sh`) have `CARGO_NET_OFFLINE=true`. cargo-deny's own
`--offline` is not used: it would also stop it fetching the RustSec database
(from github.com, no key), which the check needs; the variable keeps its
`cargo metadata` offline and leaves the fetch alone. The only cargo commands
that go online are the two `cargo install` of cargo-deny and cargo-about, which
read no manifest of this workspace. A dependency added later that Cargo could
not get from `cargo fetch` fails these steps with an offline error instead of
waiting for an ssh key that is not there.
- **A fork's pull request.** A pull request gets the key only when its head branch
is in this repository. The job-level `env` of `ci.yml` asks
`github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository`:
Gitea's event payload names, in `pull_request.head.repo.full_name`, the repository
that holds the branch to be merged. That is `Voelin/VoelinClient` for a branch
pushed here and the fork's own name (`someone/VoelinClient`) for a fork; any other
event has no pull request, and the first operand is true. An absent or different
name reads `no`, and step 1 treats everything but `yes` as no (the same
fail-closed direction as the runner version). Step 1 also asks the question
again in its script, from the name itself: for a `pull_request` event (and for any
event that carries a head repository) it requires `PR_HEAD_REPO`, the same payload
field, to be non-empty and equal to `GITHUB_REPOSITORY`, so a mistake in the
expression or in the script alone does not hand the key to a fork's code. A fork's
pull request therefore fails at step 1 with the reason and the head repository's
name, without a key, as it failed before (at the empty secret). Gitea gives such a
run no secrets in any case; the check also keeps a same-looking head from being
trusted by accident. It does not make a same-repository branch safe: code of a
branch pushed here runs the build scripts and tests with no key (it is gone by
then), but a branch that changes the workflow itself is a change of the workflow
([below](#what-this-does-not-do)).
- **Release** (`release.yml`). A step after the checkout checks the runner as
step 1 above does (a release has no pull request). The step that starts an
`ssh-agent` on the release host has the same flag guard, loads the key into the
agent from stdin (it is never written to disk) and exports `SSH_AUTH_SOCK`; the
agent forgets the key after nine hours. The builds pass the agent on with
`docker build --ssh default` (`scripts/docker-build.sh` does it for the three
packages, the Android one twice, as the debug APK and as the signed release APK;
the gateway image step does it itself). A step directly after the last build,
`if: always()`, stops the agent and empties `SSH_AUTH_SOCK`, so the artifact
upload and the release draft have neither the key nor the socket.
- **The images.** In `docker/linux.Dockerfile`, `docker/windows.Dockerfile`,
`docker/android.Dockerfile` and `crates/voelin-gateway/Dockerfile` only a
`RUN cargo fetch --locked` has `--mount=type=ssh,required=true`; the build after
it has no ssh mount and is offline: `cargo build --release --locked --offline`
in three of them, `CARGO_NET_OFFLINE=true` in the Android one, whose Gradle task
starts cargo-ndk and cargo (the task itself is left as it is, because a
developer's own build has network and no `cargo fetch`). The key exists inside
the fetch only, through the agent socket, and never reaches a layer, a build
argument or the cache; the code that the build compiles and runs (build scripts,
procedural macros, Gradle) has no agent socket in reach. A build without `--ssh`
stops at the fetch with `unset ssh forward key default`. The build stage copies
`.gitea/known_hosts` to `/etc/ssh/ssh_known_hosts` and sets
`CARGO_NET_GIT_FETCH_WITH_CLI=true`; the images install `git` and `openssh-client`
in their build stage. The fetched git checkout of VoelinProtocol stays in the
layer of the fetch step, the registry in the cache mount that the build step
shares (the three package images; the gateway image has no cache mount, its
registry stays in the layer too).
- **Cargo uses the system git** (`CARGO_NET_GIT_FETCH_WITH_CLI=true`) because - **Cargo uses the system git** (`CARGO_NET_GIT_FETCH_WITH_CLI=true`) because
Cargo's built-in git client does not read `~/.ssh/config` (so it cannot use Cargo's built-in git client does not run `ssh -i` (so it cannot use a key file),
an `IdentityFile`), authenticates with an ssh-agent and checks the host authenticates with an ssh-agent and checks the host against `~/.ssh/known_hosts`
against `~/.ssh/known_hosts` and its own `net.ssh.known-hosts` setting. The and its own `net.ssh.known-hosts` setting. The system git runs the command in
system git runs `ssh`, which reads the config above (and `GIT_SSH_COMMAND`, so the same command serves the access check and Cargo.
`/etc/ssh/ssh_known_hosts` in the images), so the same files serve a plain
`git` call, Cargo and the access check.
- **The host key** is committed in [`.gitea/known_hosts`](../.gitea/known_hosts), - **The host key** is committed in [`.gitea/known_hosts`](../.gitea/known_hosts),
never fetched while a job runs. Gitea's built-in SSH server (`SSH-2.0-Go`) never fetched while a job runs. Gitea's built-in SSH server (`SSH-2.0-Go`)
offers an RSA host key only (`ssh-keyscan -t ed25519 git.faumaray.com` offers an RSA host key only (`ssh-keyscan -t ed25519 git.faumaray.com`
@@ -270,21 +368,135 @@ What is set up:
new `ssh-keyscan -t rsa` line and the date in `.gitea/known_hosts` and the new `ssh-keyscan -t rsa` line and the date in `.gitea/known_hosts` and the
fingerprint here, and commit all of it in one change. Until then a changed key fingerprint here, and commit all of it in one change. Until then a changed key
makes every job stop with `Host key verification failed`, which is the point. makes every job stop with `Host key verification failed`, which is the point.
VoelinGateWay, VoelinProtocol and VoelinServer keep the same line.
Pull requests from forks get no secrets: their CI run stops at the first step #### The key and the runners
with the message about the empty deploy key. Anyone who can change a workflow of
this repository, or run code in one of its jobs, can read the key; it can only Gitea has more than one runner with the same labels (`ubuntu-latest`,
read VoelinProtocol, and it is replaced as above. That is one more reason to `voelin-release`, `ubuntu-24.04`, `ubuntu-22.04`, `echoion-release-serial`), so
keep the CI runner isolated, as said above. `runs-on` cannot choose between them, and they do not log alike. A runner prints
the `env:` of a step in the job log when the step starts. "Perfrormance Runner"
(act_runner, reports `v3.1.0`, the one that is online) masks a multi-line secret
line by line (`***`). The runner **gitea-runner-docker v0.6.1 (id 1, offline on
2026-10-28) printed the whole private key in clear**, on one line with the line
ends shown as `\n`, in the logs of runs of this repository, of VoelinGateWay and of
VoelinServer on 2026-10-27. On 2026-10-28 every deploy key was rotated and the
runs that printed one were deleted.
What follows from it, in the workflows:
- **The key is not given to such a runner.** Step 1 of the job (and the check in
`release.yml`) writes the flag only for a runner whose reported version is
`MIN_MASKING_RUNNER_VERSION` (3.1.0, the oldest one seen masking) or more; for any
other the job fails there, before any step names the secret, and the key step is
not started. This is a gate on the version number and no test of masking: a
runner that reports 3.1.0 or more is trusted by its number, and a version
that a runner does not report is not trusted. It was **rehearsed** with a
stand-in for the runner (the step script with the reported version set to
`v0.6.1`, to nothing, to `3.0.9`, to `v3.1.0-rc1`, to `3.1` and to a word: the job
fails with the reason and no flag is written; `v3.1.0`, `3.1.0`, `v3.1.1`,
`v10.0.0` pass) and **has not been seen on gitea-runner-docker itself**, because
it is offline, and what that runner reports in `GITEA_ACTIONS_RUNNER_VERSION` is
not known. To let the gate admit an older runner, lower
`MIN_MASKING_RUNNER_VERSION` (in `ci.yml` and in `release.yml`) only after a
canary secret of several lines has been shown masked in the log of that runner.
- **The cause is the runner**, and the fix that covers every secret of every
repository is there: upgrade gitea-runner-docker to a version that masks
multi-line secrets, retire it, or register it with labels no workflow asks for.
- The log of a run that did hold the key shows the step headers with `***` for
each line of the secret; nothing else prints it.
#### What has been seen, and what has not
Seen on a real runner ("Perfrormance Runner", reports `v3.1.0`), by dispatching
`ci.yml` on the branch that introduced this order of steps:
- **Run 1226, the full path, green** (36 minutes). The check passes ("Runner …
reports version v3.1.0, which masks secrets in the log"; "Event
workflow_dispatch: no pull request"); the key step's header shows
`PROTOCOL_DEPLOY_KEY: ***` and one `***` for each further line of the key, and
prints `Deploy key installed: 256 SHA256:TWpZx3NgSMKTBkNLfp0C+Q1/DPD0E44Gy+GiHwK/zpI`
(deploy key id 7); the fetch step reads VoelinProtocol, runs `cargo fetch --locked`
(some eighteen seconds) and prints "The deploy key is removed from the job."; the
cleanup step prints "No deploy key is left in the job."; the checks run
`--offline`; the only `Updating crates.io index` after the fetch are the two
`cargo install` steps. The log of the job has no line with `PRIVATE KEY`.
- **Run 1225, the gate refusing, red by design.** A temporary commit raised
`MIN_MASKING_RUNNER_VERSION` to `99.0.0` (reverted by the next commit): the check
failed the job with "… the runner (Perfrormance Runner) reports version 'v3.1.0',
and only a runner of version 99.0.0 or newer …"; the system packages, the
toolchain, the key step, the fetch and the checks were not started and left no
line in the log (so the secret was named nowhere), the cleanup step ran and said
that no key is left, and the log has no `PRIVATE KEY` line and no mention of the
secret.
- Run 1224, of the same workflow as run 1226, was cancelled four minutes in, as
1225 was started on the same branch (a run started on a branch cancels the one
still running there, so dispatch the next only when the last has ended): the
key step, the fetch and the cleanup had run as in 1226 and the offline Clippy had
started. It shows nothing more.
Rehearsed with stand-ins, not seen on a runner: the runner check of `ci.yml` and of
`release.yml` for the reported versions above, and the pull request rule of
`ci.yml` (head repository empty, another one, equal to the repository, with the
expression's answer yes, no or missing: only equal and named passes); the key step
with a text that is no key, with an empty one and with a failing `GITHUB_ENV` (the
`EXIT` trap removes the directory) and with a key whose lines end in CR (it stays for
the fetch); the fetch step with a key that VoelinProtocol does not know (`Permission
denied (publickey)` from the server whose host key `.gitea/known_hosts` holds, the
directory removed by the step's trap); the cleanup step with and without a
directory; the ssh-agent step of `release.yml` with a key (the fingerprint, the
variables) and its stop step (the agent is gone, the variables are emptied).
Not seen: a job on gitea-runner-docker (offline; the gate is rehearsed with a
stand-in for the runner, above); a `pull_request` run, so neither the same-repository
head (`yes`) nor a fork's (`no`) has been read from a real event payload (the field
is the one that Gitea's API gives as `head.repo.full_name` of a pull request, which
reads `Voelin/VoelinClient` for a branch of this repository, and an absent field
fails closed); `release.yml` on a runner; the four Dockerfiles built (they pass
`docker build --check` with no warning, and the `cargo fetch` then `cargo build
--offline` split is that of VoelinGateWay's `docker/linux.Dockerfile`, which was
built with `docker build --ssh default`; the Android Gradle task with
`CARGO_NET_OFFLINE` has not been run). The first release or image build is the
check.
#### Looking at a run
The fingerprint of the key step, and the proof that no log holds a private key
(the job ids are in `GET .../actions/runs/<run id>/jobs`):
```sh
curl -s -H "Authorization: token $TOKEN" "https://git.faumaray.com/api/v1/repos/Voelin/VoelinClient/actions/jobs/<job id>/logs" | grep -c 'PRIVATE KEY' # 0
```
#### What this does not do
- Anyone who can change a workflow of this repository, or run code in one of its
jobs, can read the key: a branch pushed here that prints it in the key step, or
that lowers `MIN_MASKING_RUNNER_VERSION`, or that adds a step. The key can only
read VoelinProtocol and is replaced as above; keep the CI runner isolated, as said
above. What the hardening does is keep the *code* of a change (build scripts,
procedural macros, tests, tools installed by cargo) away from the key while the
workflow is the reviewed one.
- `cargo fetch` reads the checkout's `Cargo.toml` and `Cargo.lock` files,
`rust-toolchain.toml` and a `.cargo/config.toml` if there is one (there is none
at the root today), and runs the toolchain's `rustc -vV`. A branch that adds a
Cargo configuration with a `build.rustc` or `build.rustc-wrapper` program would
run it while the key exists. That is a change of the build configuration, to be
reviewed as one.
- The job token that `actions/checkout` leaves in the checkout's git configuration
is not touched by this.
If a run fails here: If a run fails here:
| Message | Cause | | Message | Cause |
|---|---| |---|---|
| `The VoelinProtocol deploy key is empty` | the secret is missing, empty or not visible (a fork's pull request) | | `The VoelinProtocol deploy key is not given to this job: the runner (…) reports version …` | the job landed on a runner that is not known to mask the key in the log (gitea-runner-docker v0.6.1, or one that reports no version): run it again |
| `… the pull request's head repository is '…'` | a fork's pull request, or an event that did not name the head: push the branch to this repository |
| `The VoelinProtocol deploy key is empty` | the secret is missing or empty |
| `… is not an unencrypted OpenSSH or PEM private key` | the secret holds something else, or a key with a passphrase | | `… is not an unencrypted OpenSSH or PEM private key` | the secret holds something else, or a key with a passphrase |
| `Permission denied (publickey)` in "Check read access to VoelinProtocol" | the key is valid but is not a deploy key of VoelinProtocol: compare the fingerprint "Deploy key installed" printed with the one in VoelinProtocol's deploy key settings | | `Permission denied (publickey)` in "Fetch the dependencies with the deploy key" | the key is valid but is not a deploy key of VoelinProtocol: compare the fingerprint "Deploy key installed" printed with the one in VoelinProtocol's deploy key settings |
| `Host key verification failed` | `.gitea/known_hosts` does not match the server: check as above before changing anything | | `Host key verification failed` | `.gitea/known_hosts` does not match the server: check as above before changing anything |
| an offline error ("no matching package", "can't update … in offline mode") in a check step | a dependency changed after the fetch, or `cargo fetch --locked` did not get something the checks need: fix the fetch step, do not give the checks a key |
| `unset ssh forward key default` | a Docker build ran without `--ssh default`: a plain `docker build` (`scripts/docker-build.sh` passes it itself and stops earlier when the agent has no key) | | `unset ssh forward key default` | a Docker build ran without `--ssh default`: a plain `docker build` (`scripts/docker-build.sh` passes it itself and stops earlier when the agent has no key) |
### Gitea release runner ### Gitea release runner
@@ -302,9 +514,13 @@ voelin-release:host
Provision Bash, Git, the OpenSSH client (`ssh-agent` and `ssh-add`), Node.js Provision Bash, Git, the OpenSSH client (`ssh-agent` and `ssh-add`), Node.js
20+, Python 3.11+, curl, tar, gzip and rootful Docker 23+ with BuildKit. Use 20+, Python 3.11+, curl, tar, gzip and rootful Docker 23+ with BuildKit. Use
**act_runner 0.2.7 or newer** (prefer the latest maintained release), or **a runner that reports 3.1.0 or newer** (the key gate refuses older ones;
gitea-runner 2+. Older act_runner does not provide 0.2.7 is only the artifact action's minimum; prefer the latest maintained
`ACTIONS_RESULTS_URL`, which the pinned artifact action needs. Register the release), or gitea-runner 2+. Older act_runner does not provide
`ACTIONS_RESULTS_URL`, which the pinned artifact action needs. The workflow also
gives the deploy key only to a runner that reports version 3.1.0 or newer in
`GITEA_ACTIONS_RUNNER_VERSION` ([VoelinProtocol access](#voelinprotocol-access)),
so on a lower one the release stops at its first check. Register the
runner against `https://git.faumaray.ru`, reachable from both the host and runner against `https://git.faumaray.ru`, reachable from both the host and
build containers. Gitea 1.25.4 provides the required artifact-v4 API. build containers. Gitea 1.25.4 provides the required artifact-v4 API.
The shared checks install native build dependencies The shared checks install native build dependencies
+10
View File
@@ -35,6 +35,16 @@ HTTPS and never uses GitHub's release API. On this instance the server URL
is `https://git.faumaray.ru`. No registry credentials are needed: the gateway is `https://git.faumaray.ru`. No registry credentials are needed: the gateway
image is attached as `tsgw-image.tar.gz`, not pushed to an OCI registry. image is attached as `tsgw-image.tar.gz`, not pushed to an OCI registry.
The builds also read the private VoelinProtocol repository
(`voelin-identity`, `voelin-proto`, `voelin-model`): the repository secret
`VOELIN_PROTOCOL_DEPLOY_KEY`, the read-only deploy key of that repository, is
loaded into an ssh-agent for the Docker builds, given to the `cargo fetch` of each
Dockerfile only, and the agent is stopped right after the last build
([ci.md](ci.md#voelinprotocol-access)). The workflow gives the key only to a
runner of version 3.1.0 or newer (an older one may print it in the job log) and
stops at that check otherwise; without the secret it stops at its ssh-agent step,
naming the secret.
Retries update only a matching **draft**, replacing same-named assets. Retries update only a matching **draft**, replacing same-named assets.
Published releases are not changed; a failed upload leaves a partial draft Published releases are not changed; a failed upload leaves a partial draft
for retry. Do not publish or modify a draft while the workflow runs. Gitea for retry. Do not publish or modify a draft while the workflow runs. Gitea
+3 -1
View File
@@ -10,7 +10,9 @@
# The workspace depends on the private VoelinProtocol repository, which the # The workspace depends on the private VoelinProtocol repository, which the
# build fetches over SSH with your ssh-agent (`docker build --ssh default`): # build fetches over SSH with your ssh-agent (`docker build --ssh default`):
# the agent must hold a key that can read it (docs/building.md, "Depending on # the agent must hold a key that can read it (docs/building.md, "Depending on
# VoelinProtocol"). The key stays in the agent, never in the image. # VoelinProtocol"). The key stays in the agent, never in the image, and only the
# Dockerfile's `cargo fetch` step is given the agent: the build after it is
# offline.
# #
# Behind an HTTPS proxy, HTTPS_PROXY/HTTP_PROXY/NO_PROXY are passed on to the # Behind an HTTPS proxy, HTTPS_PROXY/HTTP_PROXY/NO_PROXY are passed on to the
# build; a proxy on this machine's loopback is reached with host networking. # build; a proxy on this machine's loopback is reached with host networking.