The gitea role accepts a release only when it carries a valid signature by gitea_gpg_key_id or one of its subkeys, so an expired, revoked or replaced Gitea release key makes every install and update fail closed, without warning, on the day it happens. scripts/check_gitea_release_key.py reads the pins from the role defaults, fetches the release key into a throwaway keyring and only the .asc of the pinned release (never the binary), and fails when the primary key or a signing subkey expires within 60 days, is revoked or expired, or when a signature in the .asc is not by a valid signing key of the pinned key. Its docstring says what to do on a failure. The Gitea release key workflow runs it weekly, by hand, and on pull requests that change the role defaults or the check, so a gitea_version bump is checked against the new release's signature. It runs in the ci image at the pin of lint.yml; that image has gpgv but not gpg, so the job installs gpg and gpg-agent from the Ubuntu archive per run instead of making the check an image input. The tests that make keys skip without gpg, so the Lint job's unittest run (no gpg) still covers the parsing and rendering tests. The workflow pins the ci image, so it joins the pin consumers of check_image_versions.py and check_bot_pr_diff.py: Renovate's pin follow-up edits every workflow, and the bot-diff gate would otherwise refuse that pull request. The new workflow and script are on the molecule selector's IGNORED list, since no scenario reads them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
83 lines
4.1 KiB
YAML
83 lines
4.1 KiB
YAML
name: Gitea release key
|
|
|
|
# Early warning for the signature check of the gitea role: roles/gitea/tasks/download.yml
|
|
# accepts a release only when it carries a valid signature by gitea_gpg_key_id (or a subkey),
|
|
# so an expired, revoked or replaced Gitea release key makes every install and update fail
|
|
# closed. scripts/check_gitea_release_key.py reads the pins from roles/gitea/defaults/main.yml,
|
|
# fetches the key and the pinned release's .asc (never the binary) and fails when a key expires
|
|
# within 60 days, is revoked or expired, or did not sign the release. It checks the issuers and
|
|
# the key, not the signature itself (no binary), so a corrupt .asc still fails only in the role.
|
|
# What to do on a failure is in the script's docstring.
|
|
#
|
|
# Weekly, by hand, and on pull requests that change the pins (a Renovate bump of gitea_version
|
|
# is checked against the new release's signature) or the check itself. Runs only on the
|
|
# Collection's own runner. Read-only; no org secret, the only credential is the job token
|
|
# (secrets.GITHUB_TOKEN), which is read-only for a fork pull request. No pull_request_target.
|
|
# Not a required check: it depends on the key source and dl.gitea.com being reachable.
|
|
on: # yamllint disable-line rule:truthy
|
|
schedule:
|
|
# Every Monday at 06:00 UTC
|
|
- cron: "0 6 * * 1"
|
|
workflow_dispatch: {}
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- roles/gitea/defaults/main.yml
|
|
- scripts/check_gitea_release_key.py
|
|
- tests/scripts/test_check_gitea_release_key.py
|
|
- .gitea/workflows/gitea-release-key.yml
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# A newer push to the same pull request makes the running run obsolete; a scheduled or
|
|
# manual run on main keeps its own result.
|
|
concurrency:
|
|
group: gitea-release-key-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
check:
|
|
runs-on: kamino-docker
|
|
timeout-minutes: 10
|
|
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
|
|
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
|
|
container:
|
|
image: git.rkdr.net/mortis/ci:0.2.32@sha256:3282337dd3ccb20172e519d11fa996bfad2df09f3f5de14e2706d9d368af9923
|
|
steps:
|
|
# The container has no Node, so JavaScript actions such as actions/checkout
|
|
# cannot run; clone with git and the job token.
|
|
- name: Checkout the commit under test
|
|
env:
|
|
GIT_CONFIG_COUNT: "1"
|
|
GIT_CONFIG_KEY_0: http.extraheader
|
|
GIT_CONFIG_VALUE_0: "AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}"
|
|
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
REF: ${{ github.ref }}
|
|
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
|
run: |
|
|
git clone "$REPO_URL" .
|
|
# A clone has no refs/pull/*: fetch the run's ref when the sha is not on a branch.
|
|
git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; }
|
|
echo "Checked out $(git rev-parse HEAD)"
|
|
|
|
# The ci image has gpgv (apt's verifier) but not gpg: the check needs gpg to read the key
|
|
# and the signature packets, and the tests need gpg-agent to make throwaway keys. Installed
|
|
# per run from the image's own Ubuntu archive (apt verifies it) rather than baked in, so
|
|
# this check is not an input of the ci image. The tests skip their key cases without gpg,
|
|
# gpg-agent or gpgconf, so this step fails when any of the three is missing.
|
|
- name: Install gpg
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y -qq --no-install-recommends gpg gpg-agent
|
|
for c in gpg gpg-agent gpgconf; do command -v "$c" > /dev/null || { echo "::error::$c is missing"; exit 1; }; done
|
|
gpg --version | head -n1
|
|
|
|
# Offline, with throwaway keys: the check itself works before it judges the real key.
|
|
- name: Test the check
|
|
run: /opt/venv/bin/python3 -I tests/scripts/test_check_gitea_release_key.py
|
|
|
|
- name: Check the Gitea release key and the pinned release's signature
|
|
run: /opt/venv/bin/python3 -I scripts/check_gitea_release_key.py --window-days 60
|