Repository navigation
Feat(forks): Require an expiring pool token - #232
ModeSevenIndustrialSolutions merged 2 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the token-expiry enforcement change.
No open issues 🎉
What changed in this PR
Adds expiry enforcement for the classic fork pool token, addressing #220 and limiting how long a leaked credential remains usable.
Changes:
- Rejects missing, unreadable, or more-than-90-day expiries before fork operations; warns when 14 days or less remain.
- Adds expiry validation tests while preserving scope-check coverage.
- Documents token creation limits and rotation guidance.
| File | Description |
|---|---|
| tests/test_fork_pool.py | Tests expiry failures, warnings, silent acceptance, and early stopping. |
| scripts/fork_pool.py | Reads the expiry header and enforces expiry limits and warnings. |
| README.md | Adds rollout guidance for token expiry and rotation. |
| docs/DESIGN.md | Explains expiry safeguards, rotation, and failure handling. |
Review effort: Balanced
The fork pool token is a classic token, which may be created with no expiry and can write to every repository its account can. Pin the expiry rule before it exists: no expiry header, an unparsable one or one more than 90 days ahead fails before any fork is read; one within 14 days warns and goes ahead; one in between passes silently. The existing scope tests now carry a valid expiry, so they show the scope check still refuses extra scopes once the expiry passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
The fork pool token is a classic token, which cannot be limited to organisations and may be created with no expiry; a leaked one could add API-signed commits to the forks that head open pull requests for as long as it lives. check_token now reads GitHub-Authentication-Token-Expiration from the reply it already reads. No header, an unparsable one, or an expiry more than 90 days ahead fails the job before any write, naming the date; an expiry 14 days away or less passes with a warning on every run, so the rotation falls due before the job stops. The scope check runs first and is unchanged. DESIGN.md section 10.6, its failure-mode row and the README state the rule and the rotation it implies. The token check moves from fork_pool.py into a new pool_token.py, which fork_pool.py imports. Review round 1: the aislop gate failed the Audit changes job with complexity/file-too-large on fork_pool.py (445 lines, flagged above 441); the split leaves it at 328 lines and pool_token.py at 139, with no change in behaviour. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
325ed9e to
1a10fb6
Compare
There was a problem hiding this comment.
🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.
The change appears sound: expiry checks enforce the documented policy before fork operations, and the module extraction preserves existing scope validation. No actionable defects found in the reviewed diff.
Antagonistic round 1 of 3.
Automated antagonistic review by lf-releng-antagonistic-review-bot[bot] using model gpt-6-astra; see the run. This is not a human review and never an approval: a maintainer must still review and approve this pull request.
55f2c8c
into
lfreleng-actions:main
Closes #220
Authored by an AI agent; human review required
claude-opus-5.5via GitHub Copilot CLI0e1191599bebbf5ceae7a25c724cd76a00875a39uv run ruff format scripts/pool_token.py scripts/fork_pool.pyuv run ruff check scripts/pool_token.py scripts/fork_pool.pyuv run python -B -m unittest discover -s testsAISLOP_NO_TELEMETRY=1 aislop scan --json .AISLOP_NO_TELEMETRY=1 prek run --files README.md docs/DESIGN.md scripts/fork_pool.py scripts/pool_token.py tests/test_fork_pool.pyAISLOP_NO_TELEMETRY=1 prek run --files README.md docs/DESIGN.md scripts/fork_pool.py scripts/pool_token.py tests/test_fork_pool.pyThe
github-code-monkey-botworkflow opened this pull request.Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.
Round 1 of revision, on its base. It set out to fix the failing checks: Audit changes.
Requires the fork pool token to expire, as #220 asks.
check_tokenreadsGitHub-Authentication-Token-Expirationfrom thegh api --include userreply it already reads. A missing header, one it cannot parse, or an expiry more than 90 days ahead fails the forks job before any write and names the date. An expiry 14 days away or less passes, with a::warningon every run. The scope check runs first and has not changed. DESIGN.md §10.6, its failure-mode row and the README state the rule and the rotation it implies.Commits:
Test(forks): Add expected-fail token expiry tests: covers no header, an unparsable one, more than 90 days ahead, within 14 days, an expiry in between, and extra scopes still refused.Feat(forks): Require an expiring pool token: the check, the docs, and the test markers removed.This round
The
Audit changesjob failed the aislop gate withcomplexity/file-too-largeonscripts/fork_pool.py. The expiry check had grown that file to 445 lines, and aislop flags anything above 441. The token check (token_identity,check_expiry,check_token,PoolErrorand their constants) now lives in a newscripts/pool_token.py, whichfork_pool.pyimports. That leavesfork_pool.pyat 328 lines andpool_token.pyat 137. Behaviour has not changed. DESIGN.md §10.6 and its script table name the new module. The fix is amended into the Feat commit, and the branch stays on its original base.Checks run
uv run python -B -m unittest discover -s tests: 1719 tests, OKprek run --files <the five changed files>: every hook passed, aislop includedaislop scan --json .: no diagnosticsuv run ruff …exited 2 because ruff is not in the project's uv environment. The prekruffandruff formathooks ran in its place and passed.For the reviewer
PoolErrormoved topool_token.pyalong with the check that raises it.fork_pool.pyre-imports it, so its callers and the tests still usefork_pool.PoolErrorandfork_pool.check_token.