Repository navigation
feat(gpg-key): add gpg-key list and add - #488
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Gitea returns no user ID of a GPG key, so each test key is marked by a private scratch repository it-run-<time>-gk<key ID>. A GPG key is deleted only when such a marker names its ID: on the test's cleanup, or for a marker older than two hours at the start of a later run, before the stale repository sweep deletes the marker.
q-horde
marked this pull request as ready for review
November 16, 2026 09:04
q-horde
marked this pull request as draft
November 16, 2026 09:10
Copia does not register GET /user/gpg_key_token, so gpg-key add drops --signature (Lead decision on QUB-1230) and no integration test adds a GPG key. Without one, the key fixture, its marker repositories and its sweep have nothing to guard. This reverts commit 64ada01.
Copia does not register GET /user/gpg_key_token (it answers Go's plain 404 page not found), so a token signature cannot be made. gpg-key add now sends the armored key only, like gh, and Gitea's 404 for a key without a verified email shows a hint to verify that email instead of Gitea's offer to sign the token.
The test adds no key: Copia adds only a key with a verified email of the account, which the tests never read.
q-horde
marked this pull request as ready for review
November 16, 2026 09:29
ReadAPIMessage reads at most 64 KiB of an error body and cuts the message to 512 bytes on a rune boundary, so a server cannot make copia-cli read or print an error of any size. FetchPages uses it for HTTPError.Message (security review QUB-1261, finding 3).
gpg-key add refused only PRIVATE KEY BLOCK, so an OpenSSH, PKCS#8, RSA or legacy PGP secret key passed. cmdutil.CheckArmor is an allowlist: every armor header must be the public key header, a header naming PRIVATE or SECRET is refused as a private key. A server message that holds 16 bytes in a row of the key material, compared without white space, is left out of the error (security review QUB-1261, findings 1 and 2).
Contributor
Author
This was referenced Nov 16, 2026
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.
Summary
Adds the
gpg-keycommand group withgpg-key listandgpg-key add, as in gh, on Gitea's/user/gpg_keysAPI, and marksgh ssh-keyandgh repo deploy-keyNone indocs/parity.md(app.copia.io has SSH disabled). Slice 1 of 4 of the keys-and-access epic (plan revision 2).Closes #482
Changes
gpg-key list(aliasls): every page ofGET /user/gpg_keys, gh's columns EMAIL, KEY ID, PUBLIC KEY, ADDED, EXPIRES,--json/--jq/--templatewith the API's field names.gpg-key add [<key-file>]:POST /user/gpg_keyswitharmored_public_key; duplicate key, not-armored and private key handled; Gitea's 404 for a key without a verified email gets a hint to verify that email; key content redacted from server messages.--signature(Lead decision on QUB-1230): app.copia.io does not registerGET /user/gpg_key_token(Go's plain-text404 page not found), so Gitea's signature route cannot be used. gh has no such flag either.cmdutil.HTTPErrorkeeps the API's message of a failed page (from closed PR feat(ssh-key): add ssh-key list and add #487).TestGPGKeyList_Runlists the account's keys (plain and--json). It adds no key: Copia adds only a key with a verified email of the account, which the tests never read.addis covered by unit tests. The marker-repository key fixture of 64ada01 is reverted (e5ce2af), since nothing adds a key.docs/parity.md(gpg-key section with the verified-email rule, ssh-key and deploy-key None, counts),docs/project-layout.md, sidebar,CLAUDE.mdcounts.Security review QUB-1261 (round 2)
cmdutil.CheckArmoris an allowlist. Every line holding-----BEGINmust be the public key header, and a header namingPRIVATEorSECRETis refused as a private key (OpenSSH, PKCS#8, RSA, legacy PGP secret, a private block after a public one), all before any request (5a5038b).cmdutil.ReadAPIMessagereads at most 64 KiB of an error body and cuts the message to 512 bytes;FetchPagesandgpg-key adduse it (fd3281e).Automated checks
horde-dev run go test ./...)horde-dev run golangci-lint run ./..., also with--build-tags=integration)horde-dev run go run script/gen-docs.goleaves no diff (manual pages are gitignored; the sidebar is updated by hand)User test
copia-cli gpg-key listprints your GPG keys;gpg --armor --export <ID> | copia-cli gpg-key add -adds a key whose email is verified on your account; a key without such an email fails with the hint to verify it.Notes for reviewer
The first integration run (actions run 43836533303) failed because
GET /user/gpg_key_tokenanswered 404 on Copia; that led to the decision above. Thetestjob's govulncheck step fails on GO-2026-6859 (net/http, fixed in go1.27.4) on every branch; PR #496 bumps Go.