Skip to content

Feat(forks): Require an expiring pool token #220

Closed

Description

Problem

#204's fork_pool_token is a classic token with the public_repo scope, of an account that belongs to the bot fork organisations. A classic token cannot be limited to organisations: it can write to every repository the account can, which includes the forks whose branches are the heads of Code Monkey's open pull requests. A leaked token could add commits there, and commits made through the API are signed by GitHub. Human approval, last-push approval and stale-review dismissal still stand between such a commit and a merge, but the exposure lasts as long as the token does, and a classic token may be created with no expiry.

check_token holds the scopes to public_repo alone and says nothing of expiry. GitHub reports a classic token's expiry in the GitHub-Authentication-Token-Expiration header of any API reply (for example 2027-01-18 10:39:33 UTC) and omits it for a token that never expires; checked on 22 November 2026 against GET /user.

Required behaviour

  1. check_token reads the header from the reply it already reads (gh api --include user).
  2. No expiry fails the job: "the fork pool token never expires; create it with an expiry", before any write.
  3. An expiry more than 90 days ahead fails the same way, naming the date, so the token is rotated at least that often.
  4. An expiry within 14 days passes with a ::warning naming the date, on every run, so the rotation is due before the job stops.
  5. A header the job cannot parse fails, as an absent scope header does.
  6. docs/DESIGN.md §10.6 (added by Feat(publish): Prepare forks in a separate job #204) and the README's rollout state the expiry rule and the rotation it implies.

Acceptance criteria

  • Tests in tests/test_fork_pool.py: no header, an unparsable one, and one more than 90 days ahead each fail before any write; one within 14 days warns and goes ahead; one in between passes silently; the scope check still runs and still refuses extra scopes.
  • uv run python -B -m unittest discover -s tests passes.
  • prek run --files <changed files> and the aislop gate report no findings.

Depends on

#204, which adds scripts/fork_pool.py.

Out of scope

  • Replacing the classic token with another kind of credential.
  • The App's own permissions (tracked separately).

Activity

  1. lf-releng-code-monkey-bot commented on Nov 23, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 An AI agent has proposed a change for this issue: pull request #232 (head 325ed9e). The Copilot review of it is clean. Checks failed on its head: Audit changes.

  2. lf-releng-code-monkey-bot commented on Nov 23, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 1: an AI agent revised pull request #232 (head 1a10fb6). Round 1 fixed the one failing check: Audit changes (aislop complexity/file-too-large on scripts/fork_pool.py, 445 lines, flagged above 441). - Moved the token check into a new scripts/pool_token.py that fork_pool.py imports (328 and 137 lines now). Behaviour has not changed. DESIGN.md §10.6 and its script table name the new module. The fix is amended into the Feat commit. - There were no review threads or maintainer comments. Copilot's review was clean. - No rebase: the base is still the default branch's head and the PR is mergeable. - Ran the unit tests (1719 OK), prek run --files over the changed files (all passed) and aislop scan (no diagnostics). It set out to fix the failing checks: Audit changes. The Copilot review of it is clean. An antagonistic review was requested from the review bot.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions