Skip to content

Repair and validate the AUR key before using it - #227

Merged
jeremy merged 1 commit into
mainfrom
aur-key-install
Aug 20, 2026
Merged

Repair and validate the AUR key before using it#227
jeremy merged 1 commit into
mainfrom
aur-key-install

Conversation

@jeremy

@jeremy jeremy commented Aug 20, 2026

Copy link
Copy Markdown
Member

The v0.1.1 `Publish to AUR` leg failed all three attempts before touching the AUR: `Load key "/home/runner/.ssh/aur": invalid format` → `Permission denied (publickey)`. That's the secret not surviving paste, not an outage — and it filed the outage issue (#217) anyway. We've hit this repeatedly across the CLIs (CRLF, dropped trailing newline, key flattened onto one line with literal `\n`).

`scripts/install-ssh-key.sh` writes a key from `$SSH_KEY` to a path, repairing those shapes (CR removal, surrounding blank lines/trailing whitespace, exactly one trailing newline, `\n` expansion only when the key arrived on a single line), then proves it loads with `ssh-keygen -y`. On refusal it prints a shape diagnosis (`lines=N header=ok|missing|PUBLIC-KEY footer=ok|missing had-CR had-literal-backslash-n no-trailing-newline`) and never key material. `tests/e2e/install_ssh_key.bats` covers each repair and refusal.

Workflows: both `release.yml` and `aur-publish.yml` install the key through it in a named `Install AUR key` step, so a bad secret fails there with the diagnosis. `release.yml`'s outage issue is now scoped to the publish step's outcome, matching `aur-publish.yml`.

RELEASING.md: set the secret from the file (`gh secret set AUR_KEY --env release < keyfile`), never a paste.

After merge: dispatch `Publish to AUR` with `0.1.1` — either the repair makes the existing secret work, or the diagnosis names what's wrong with it.


Summary by cubic

Fail fast on malformed AUR SSH keys and avoid false “AUR outage” reports. Previously we wrote AUR_KEY directly, got “invalid format” → “Permission denied (publickey)”, and filed an outage; now we normalize and verify the key before publish.

  • Introduces scripts/install-ssh-key.sh: reads $SSH_KEY, repairs common paste damage (CRLF, missing trailing newline, single-line with literal "\n", surrounding blanks/whitespace), enforces 0600, and verifies load with ssh-keygen -y. On refusal, emits a shape diagnosis without printing key material.

  • Updates .github/workflows/aur-publish.yml and release.yml to add a named “Install AUR key” step that maps AUR_KEY$SSH_KEY, installs the key, and only then runs publish. Failure notification in release.yml is now scoped to the publish step outcome.

  • Adds tests/e2e/install_ssh_key.bats to cover each repair path, refusal paths, permissions, and cleanup.

  • Updates RELEASING.md to set AUR_KEY from the key file, not a paste: gh secret set AUR_KEY --env release < ~/.ssh/aur_hey_cli.

  • Rollout

    • After merge, dispatch “Publish to AUR” for 0.1.1. If the installer fails, re-save AUR_KEY from the key file using the command above and retry.

Written for commit 0973dad. Summary will update on new commits.

Review in cubic

The v0.1.1 AUR publish failed all three attempts with ssh's
'invalid format' / 'Permission denied (publickey)' — a secret that did
not survive paste, not an AUR outage — and filed the outage issue for it.
This has recurred across our CLIs (CRLF, dropped trailing newline,
flattened lines). scripts/install-ssh-key.sh repairs those shapes,
proves the key loads with ssh-keygen -y before anything authenticates,
and on refusal diagnoses the shape without printing key material. Both
the release job and the recovery dispatch install the key through it in
a named step, and release.yml's outage issue is now scoped to the
publish step like aur-publish.yml's already was.
@jeremy
jeremy requested a review from a team as a code owner August 20, 2026 22:17
Copilot AI balanced review requested due to automatic review settings August 20, 2026 22:17
@jeremy
jeremy enabled auto-merge (rebase) August 20, 2026 22:17
@github-actions

Copy link
Copy Markdown

Sensitive Change Detection (shadow mode)

This PR modifies control-plane files:

  • .github/workflows/aur-publish.yml
  • .github/workflows/release.yml

Shadow mode — this check is informational only. When activated, changes to these paths will require approval from a maintainer.

@jeremy
jeremy merged commit 4a1e356 into main Aug 20, 2026
24 checks passed
@jeremy
jeremy deleted the aur-key-install branch August 20, 2026 22:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds robust AUR SSH-key normalization and validation before publishing.

Changes:

  • Repairs common secret formatting damage and validates keys.
  • Adds Bats coverage for repair and rejection cases.
  • Prevents invalid keys from triggering outage notifications.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/install-ssh-key.sh Normalizes, validates, and securely installs SSH keys.
tests/e2e/install_ssh_key.bats Tests key repair, validation, and cleanup behavior.
.github/workflows/release.yml Validates the AUR key before release publishing.
.github/workflows/aur-publish.yml Validates the key in manual recovery publishing.
RELEASING.md Documents safe AUR secret configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

assert_installed() {
[[ "$status" -eq 0 ]]
[[ -f "$DEST" ]]
[[ "$(stat -c %a "$DEST")" == "600" ]]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0973dad624

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

assert_installed() {
[[ "$status" -eq 0 ]]
[[ -f "$DEST" ]]
[[ "$(stat -c %a "$DEST")" == "600" ]]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use portable stat syntax for the mode assertion

On macOS, where the documented Bats runner explicitly supports brew install bats-core and contains macOS-specific sysctl/rush handling, BSD stat does not support GNU's -c option. Consequently, every new key-installation test fails inside assert_installed even when the script works correctly. Use a GNU/BSD fallback such as the one already present in scripts/check-size-budget.sh.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants