Skip to content

fix(scripts): stop reading github_token, use gh only - #3

Merged
DmitriyG1 merged 4 commits into
mainfrom
fix/no-github-token
Nov 17, 2026
Merged

DmitriyG1 merged 4 commits into
mainfrom
fix/no-github-token

Conversation

@DmitriyG1

@DmitriyG1 DmitriyG1 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • releases.py: on the curl path (no gh), github() no longer reads GITHUB_TOKEN or sends an Authorization header. The client status line says the requests are unauthenticated (60 an hour) and how to get more. The docstring is updated to match.
  • New test: on the curl path no Authorization header is sent, even with GITHUB_TOKEN set.
  • github_client(): gh is used only when gh auth status --hostname github.com succeeds (exit code only; its output is discarded). A gh that is installed but not logged in failed every call; now the run falls back to unauthenticated curl and the status line says why. Tests for each case.
  • Digest upkeep line on the curl path: unauthenticated (60 requests an hour) — install and authenticate gh.
  • Root and skill README.md: gh installed and authenticated → authenticated requests; no gh → unauthenticated, 60 an hour, and the report says so. gh reads GH_TOKEN / GITHUB_TOKEN itself; the skill never does.
  • Release 1.1.0: plugin.json version and CHANGELOG.md. No format change, no --init needed.

Why

The skill read a credential from the user's environment, against AGENTS.md Security rules ("read, collect, print or send credentials, tokens…"). It is also a point the Claude plugin directory holds for review, and something every user has to decide to trust. gh already honours GH_TOKEN / GITHUB_TOKEN, and GitHub Actions runners ship it, so nothing real is lost.

Testing

  • python3 -m unittest discover skills/android-upstream-audit/scripts/tests: 89 tests, OK on every commit (Gradle test skipped locally; the init script did not change, CI runs it). Both new tests failed before their fix.

  • claude plugin validate . --profile directory: passed.

  • Real gh: logged in → gh; with an empty GH_CONFIG_DIR and no token → curl, "gh is installed but not logged in".

  • Smoke test: with gh hidden from PATH and GITHUB_TOKEN=x, github_client() returns curl and a real request to api.github.com succeeds unauthenticated. Before the fix, the bogus token would have caused a 401.

  • Control run on nowinandroid (/android-upstream-audit with claude --plugin-dir on this branch): report header Skill: 1.1.0; releases.py 128 calls through gh, 0 failed; 26 pages, 0 failed; no GitHub note in the upkeep line.

  • releases.py --out on nowinandroid in the three client cases:

    Case First line of releases.py github_client Calls ok / failed 401 403
    gh installed and logged in GitHub API client: gh gh 128 / 0 0 0
    gh installed, not logged in (empty GH_CONFIG_DIR, no token) curl — gh is installed but not logged in; unauthenticated, 60 requests an hour; run gh auth login for more curl 128 / 0 0 0
    no gh on PATH, GITHUB_TOKEN=bogus curl — gh is not installed; unauthenticated, 60 requests an hour; install gh and run gh auth login for more curl 128 / 0 0 0

    No 401 with a bogus GITHUB_TOKEN: the token is not sent. The two unauthenticated runs used 18 of GitHub's 60 requests an hour (about 9 a run; the rest of the 128 calls go to deps.dev and Maven repositories), so 60 is enough for a project of this size.

  • Agent: Claude Code (Claude Opus 5.5).

A CI check that forbids GITHUB_TOKEN in skills/ is left for the planned skill-specific checks.

🤖 Generated with Claude Code

@DmitriyG1 DmitriyG1 added the ai AI-assisted change label Nov 17, 2026
@DmitriyG1
DmitriyG1 marked this pull request as draft November 17, 2026 17:44

@DmitriyG1 DmitriyG1 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review of the three commits against main (/code-review medium). The fix does what it says: releases.py no longer reads GITHUB_TOKEN, and the new test fails without it.

Severity:
🔴 a required check can pass while the thing it checks is broken; fix before merging
🟠 wrong behavior in a narrower case; fix in this PR
🟢 minor or already decided/tracked; no change needed now

🔴: none.

Two findings are on files this PR does not touch, so they are here instead of inline:

  • 🟢 skills/android-upstream-audit/scripts/common.py:36: the curl() docstring still says "Headers go through stdin, so a token never shows in the process list", but no caller sends a token any more. Stale; a reader could take it as an invitation to add an Authorization header back. Cheap to reword in this PR.
  • 🟢 skills/android-upstream-audit/scripts/common.py:37: the User-Agent is hard-coded as android-upstream-audit/1.0, so 1.1.0 identifies itself as 1.0. common.skill_version() already exists. Unrelated to the token; separate fix.

Comment thread skills/android-upstream-audit/README.md Resolved
Comment thread .claude-plugin/plugin.json Resolved
@DmitriyG1
DmitriyG1 force-pushed the fix/no-github-token branch 4 times, most recently from 8665819 to 5c34017 Compare November 17, 2026 18:21
DmitriyG1 and others added 4 commits November 17, 2026 22:26
Without gh, releases.py asked GitHub through curl and sent GITHUB_TOKEN
from the environment as an Authorization header. The skill must not read
credentials (AGENTS.md, Security rules). gh is now the only authenticated
way to GitHub; without it curl runs unauthenticated (60 requests an hour)
and the client status line says so. gh reads GH_TOKEN / GITHUB_TOKEN
itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github_client() chose gh whenever it was on PATH. A gh that is not
logged in fails every `gh api` call, so the run got no GitHub data at
all, while unauthenticated curl still has 60 requests an hour. Check
`gh auth status --hostname github.com` (its exit code only; the output
names the account and a masked token) and fall back to curl, saying why
on the client status line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The skill no longer reads GITHUB_TOKEN. Say that gh, installed and
authenticated, gives authenticated requests, and that without it the
audit asks GitHub unauthenticated (60 requests an hour) and the report
says so. Drop the note about a future version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DmitriyG1
DmitriyG1 marked this pull request as ready for review November 17, 2026 19:24
@DmitriyG1 DmitriyG1 self-assigned this Nov 17, 2026
@DmitriyG1
DmitriyG1 merged commit af73710 into main Nov 17, 2026
4 checks passed
@DmitriyG1
DmitriyG1 deleted the fix/no-github-token branch November 17, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai AI-assisted change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant