Repository navigation
feat(packaging): signed apt and yum repositories on Pages (#138) - #442
Merged
Merged
Conversation
`apt install objectfs` and `dnf install objectfs` work, which is the half of #138 part (c) that makes `apt upgrade` reach ObjectFS at all. pages.yml builds both repositories from the release assets on every deploy; two scripts, served at objectfs.io, add them. The two scripts do not offer the same guarantee, and the asymmetry is apt's and rpm's rather than ours. setup-repo-debian.sh writes a deb822 entry with Signed-By:, scoping the key to this repository; a key in /etc/apt/trusted.gpg.d — where apt-key add, which #138's text specifies, puts it — signs for every repository the machine reads. rpm has no equivalent: rpm --import is system-wide, gpgkey= creates no per-repository keyring, so on RHEL trusting this repository means trusting the key for everything. setup-repo-rhel.sh prints that before importing rather than papering over it. Both fail closed. No signing key at deploy time publishes no repository rather than an unsigned one, since an unsigned index fails at a user's apt update instead of in CI. Four defects found by installing from a real repository in a container, none reachable any other way: - nfpm builds unsigned rpms, so the first rockylinux:9 run downloaded the package and failed GPG check. apt needed no equivalent because InRelease covers the Packages indexes, which carry each .deb's checksum; rpm has no such chain and each package stands alone. - rpm -K exits 0 for an unsigned package — "digests OK" vs "digests signatures OK", both status 0 — so the assertion matches the text. - zypper reads /etc/zypp/repos.d, not /etc/yum.repos.d, so a yum-only script succeeds on openSUSE and configures nothing. - reprepro keeps one version per suite, which would have shipped a retention bound of five as a bound of one. Five documented one-liners were a 404 until the deploy served the scripts they name — worse than install.sh's year of the same, since these pipe into sudo bash. Both are now copied, byte-compared and in the paths filter: a stale installer installs an old binary, a stale setup script installs an old signing key, and that key stays trusted afterwards. Gated by internal/config/served_repositories_test.go and verified by mutation: 25 mutations each fail the intended test. Two found weaknesses in the gates themselves — an exit 1 assertion satisfied by an unrelated exit 1 in the same step, and two existing gates that matched one literal shell spelling and broke when a step became a loop over three files while their property still held. ci.yml gains repo-install, which builds the repositories from pages.yml's own extracted steps — so the copies cannot drift — and installs on ubuntu:24.04, rockylinux:9 and opensuse/leap:15.6, asserting a tampered index is refused on each. Every refusal has an untampered control, because the first two versions reported a pass for a check that had not run: apt reused cached lists and verified nothing, and dnf prints "Importing GPG key ..." on a good refresh, which the first grep took as evidence of a rejection.
A $GITHUB_ENV write takes effect in subsequent steps only, and repo-install set OBJECTFS_SIGNING_KEY_FILE and _ID there and then ran `make package-linux` in the same step. nfpm saw neither, and an unset key_file is not an error to nfpm — it skips signing — so the build printed four "created package" lines and produced an unsigned rpm. Caught by the job's own check, and note which half did the work: dist/objectfs-0.13.0-1.aarch64.rpm: digests OK Exit status 0, as it is for every unsigned package. This is the case the text assertion exists for. release.yml is unaffected: there the build is a separate step, so $GITHUB_ENV is the right mechanism. The new gate is conditional for that reason — it fires only on a step that both sets the variables and runs make, and it names both, since the first version named only the file and passed on a step exporting one of two.
The repo-install job runs pages.yml's own repository-building shell rather than a
second copy of it, extracted with python so an edit to the workflow is picked up
automatically. The extractor took the `run:` body and none of the YAML around it,
so the step's `env:` block was left behind — and REPO_KEEP, a plain literal there
that the step's summary reads, was unbound.
Under `set -u` that killed the script on its last line, after both repositories
had built and both signatures had verified: `repo-step.sh: line 163: REPO_KEEP:
unbound variable`. The substance of the step had all succeeded.
Carried across generally rather than by naming REPO_KEEP, since the gap is the
`env:` block and not that one variable. Only the plain literals: substituting a
`${{ secrets.* }}` expression would write its literal text into a shell variable,
which is worse than leaving it unset because then nothing would fail. Those are
exported by this job explicitly, with values a harness can have.
Two guards, because both halves can go quiet:
- The python side raises if it carries nothing. An indent or quoting change in
that block makes the regex match zero lines, which is the same outcome as not
having the loop and is invisible at the point of failure.
- The shell side checks every name pages.yml declares that the extracted script
still reads, against the environment the script will run in. `printenv`, not a
shell-variable test: the script is a subprocess, so a plain assignment here
would satisfy `${!v+x}` and still leave the child unbound. "Still reads" is
load-bearing — GH_TOKEN is in that block and is used only by the release
download the substitution removes.
Verified in a debian:12 container against the four locally built 0.13.0 packages:
189 lines and 1 literal env var extracted, both repositories signed and verified,
all seven expected artifacts present, and the summary block that died now renders
`retention: newest 5 release(s); carried 1`.
Both guards mutation-tested: dropping the carried export, reshaping the env
block's indent, unsetting a variable this shell supplies, and assigning one
without exporting it are each caught. A scan for other variables the script reads
and nothing sets found none, so REPO_KEEP was the only instance.
Refs #138
The previous commit's comments explained which env entries the extractor skips by naming them the obvious way, and that broke the workflow file: Actions interpolates expressions everywhere in a workflow, including inside what a shell would read as a comment, because the substitution happens before any shell exists. Neither the wildcard form nor the empty one parses, so the file failed and no job started. That failure has no local symptom and almost no remote one. check-yaml passed, shellcheck passed on the extracted step, the YAML was well-formed and the shell was correct. The run reports "This run likely failed because of a workflow file issue" with no job list, no log and no annotation -- `gh run view` prints that sentence and stops, and `gh pr checks` shows only the checks from other workflows. Fixed by taking the braces out of the prose, and in the one place the marker is genuinely needed -- the extractor tests for it, to skip the templated entries -- by building it from its halves at runtime. Gated by TestWorkflowExpressionsAreValid, which walks every workflow and requires that anything inside braces looks like an expression: non-empty, no wildcards, and starting from a known context, function, negation or literal. Deliberately not a parser; what has to be told apart is prose that happens to sit in braces from a real context reference, and the two are far apart. Four mutations, each caught: the exact wildcard comment that failed, the exact empty one, arbitrary prose in braces, and an unclosed opener. The floor of 50 checked expressions is against a counted 92 (ci 50, release 28, dependabot 9, pages 4, security 1), so the test going quiet is a failure rather than a pass. The misspell suppression is for GitHub's own spelling of a function name; verified it still fires without it, so it is not left over from something already fixed. Refs #138
All three are the same shape as the ones already in this entry: a mechanism that applies somewhere other than where it appears to. Two came out of running the job ($GITHUB_ENV applying to later steps only, so nfpm silently wrote an unsigned rpm; the extractor taking a step's shell without its env block), and the third came out of documenting the second, since workflow expressions are interpolated inside comments and a comment naming secrets.* fails the file before any job starts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the second half of #138 part (c).
apt install objectfsanddnf install objectfswork, which is what makesapt upgradereach ObjectFS at all.Two one-liners add the repositories;
pages.ymlbuilds and signs both from the release assets on every deploy. GitHub Pages hosts them — ~33 MB of packages per release against a 1 GB site cap, so a five-release retention bound is ~165 MB.The two scripts do not offer the same guarantee
setup-repo-debian.shwrites a deb822 entry withSigned-By:, which authorizes the key for this repository and no other. A key in/etc/apt/trusted.gpg.d— whereapt-key add, which #138's text specifies, puts it — is a valid signer for every repository the machine reads, Debian's ownopenssh-serverincluded.rpm has no equivalent.
rpm --importadds to a single system-wide keyring,gpgkey=in a.repofile creates no per-repository one, so trusting this repository on a RHEL-family machine means trusting the key for everything.setup-repo-rhel.shprints that before importing anything.Both fail closed: an index that does not verify is refused with no flag to proceed, and with no signing key at deploy time no repository is published rather than an unsigned one — an unsigned repository would fail at a user's
apt updateinstead of in CI.Four defects found by installing from a real repository in a container
None was reachable any other way.
rockylinux:9run downloaded the package and failed withError: GPG check FAILED. The deb had no such problem, and that is why only the rpm needs a signature block: apt'sInReleasesignature covers thePackagesindexes, which carry each.deb's checksum, so one signature at the top transitively covers the packages. rpm has no such chain.rpm -Kexits 0 for an unsigned package. Unsigned printsdigests OKand returns 0; signed printsdigests signatures OKand also returns 0. A status-only check passes for every unsigned package while reporting it verified a signature, so the assertion matches the text.zypperdoes not read/etc/yum.repos.d. A yum-only script succeeds on openSUSE and configures nothing — every step green,.repofile present, package not found.repreprokeeps one version per suite. Indexing five releases would have published one: a retention bound of five shipping as a bound of one.Five documented one-liners were a 404
The scripts were committed, reviewed and tested in three containers while
pages.ymlcopied onlyinstall.sh. Same defectinstall.shspent a year in, and worse — these pipe intosudo bash. Both are now copied, byte-compared and in the paths filter: a stale installer installs an old binary, a stale setup script installs an old signing key, and that key stays trusted after a later correct run.Verification
internal/config/served_repositories_test.gogates it, and 25 mutations each fail the intended test. Two found weaknesses in the gates rather than the code:exit 1assertion satisfied by an unrelatedexit 1elsewhere in the same step, so deleting the fail-closed guard still passed;cp scripts/install.sh _site/install.sh,run: make package-linux) that broke when the steps became a loop and a block scalar — property intact, spelling changed. Both now check the property.New
repo-installCI job builds the repositories frompages.yml's own extracted steps, so the two copies cannot drift, then installs onubuntu:24.04,rockylinux:9andopensuse/leap:15.6and asserts a tampered index is refused on each. Run locally in podman against all three images before pushing.Every refusal assertion has an untampered control, because the first two versions reported a pass for a check that had not run: apt reused cached lists and re-verified nothing, and dnf prints
Importing GPG key ...on a perfectly good refresh, which the first grep took as evidence of a rejection.One thing this needs from the repository owner
release.ymlnow fails closed withoutsecrets.GPG_SIGNING_KEY/secrets.GPG_PASSPHRASE, so the next release is blocked until those exist. Per the decision recorded earlier: a signing subkey (ASCII-armored) in an Actions secret, master key offline and never in CI, subkey expiry two years with rotation documented. The fingerprint placeholder indocs/index.mdis filled in with the first signed release — both scripts tell users to verify against that page.