mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
da68e5d67e |
feat(cosign): GitHub, CI's artifacts, the app's token, the config, the state and the lock
What devvm-cosign reads and writes, below its run: - github.go, actions.go: every GitHub call goes through Client: releases listed, read one, by its tag, a draft made, an upload streamed from a file with the SHA-256 of the bytes it sent, a delete, a publish, the tap's contents; and the Actions API's runs of a workflow file, a run's artifacts by name and an artifact's zip, which redirects to storage that never gets the token. CI's token can only read the repo, so CI hands its build over this way, and only the co-signer makes and publishes releases. - Lists are read a page at a time until a page holds only entries the caller is done with, newest first as GitHub lists them, so years of releases and bases never stop a run; ten pages it isn't done with are an error, never a list cut short. Every entry of a page is asked about (every), never stopping at the first that isn't done, so a caller that counts what it's asked, as init does, sees the whole page. - TagRef: what a tag names now, so a release is published only while its tag names the tag object the rebuild checked; Latest: GitHub's latest release, which /releases/latest/download/ serves. - artifact.go: an artifact downloaded into the co-signer's stage folder, capped, checked against GitHub's digest, and unzipped with nothing but a flat list of regular files, each named as a manifest names a file, stored or deflated, written new (O_EXCL), each no larger than its header says, within the artifact's bounds, and hashed as written. - app.go: the GitHub App's installation token (RS256 JWT), now asking for actions: read beside contents: write, on the two repos alone. - config.go: release_workflow and [base]'s workflow and max_snapshot_days; notify, the maintainer's command for a failed run; build_dir, the folder the builds' containers write, apart from state_dir, which they can't reach, neither in the other; ReadConfig, without the keys, for retry and ack; and the key files read from systemd's credentials folder ($CREDENTIALS_DIRECTORY) by their own names, where systemd's system manager makes them root's, mode 0440, with an ACL for the service's user, so there only others' bits are refused. A kind with no keys at all, as before the release keys are made, is refused by name, pointing at github-setup.md's step 1, so the co-signer doesn't start without them. - state.go: a ledger for each kind: what it signed, the drafts it made, what it published, each refusal with how often it was retried, each alert with how often it was acked, and the CI runs it signed; releases also record the SHA-256 of each file kept for the tap and each tag object checked. The state's watermark, the highest release ID GitHub showed at init, and the drafts there were then, and the alerts on what isn't one of its own: a release someone else published since, by <tag>#<ID>, and a tap formula it didn't write. A save is refused when it drops or changes an entry or counts one back, and writeWhole now syncs the folder after the rename, so a crash can't lose the record of a version made before its signature is uploaded. - lock_unix.go: one run at a time, unchanged. - forbidigo's exclusions now name their files: the web for github.go and app.go, Flock for lock_unix.go, so a second client or lock elsewhere in the package still fails the lint. Tests: the fake GitHub serves workflow runs and artifacts and makes drafts; TestUnzip (a folder, a path, a parent, a dot file, a link, a file twice, too many, a size that lies, not a zip, a file already there), TestFetchArtifact, TestClientReleasesAndRuns, TestReleasesPaged (1,100 settled releases read in two pages), TestLedger, TestStateNeverBackwards (drafts, publishes, kept files, alerts and refusals counted back), TestConfigCredentials, TestConfigRefused (the build folder in the state folder or the reverse). Reverted once each to see the test fail: the paging's stop (TestReleasesPaged), the credentials folder (TestConfigCredentials), the lint's scope (an http.Client in another file fails forbidigo). The folder's fsync was checked with strace on Fedora: openat of the folder and fsync right after the rename. The state also counts each manifest's failed builds in a row (Refusal.Failed, Ledger.failed): the third, maxBuildFailures, refuses it as a mismatch does, with its cause (Why), and the count alone may go back, as a lower one only builds more. And it records GitHub's latest release at init (InitLatest), which a save may never change. TestStateNeverBackwards covers both. Co-Authored-By: Claude Opus 5.5 <[email protected]> |