Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "android-upstream-audit",
"version": "1.0.0",
"version": "1.1.0",
Comment thread
DmitriyG1 marked this conversation as resolved.
Resolved
"description": "Manually started audit of an Android project's Kotlin/Android toolchain against what was published upstream: Kotlin, AGP, Google Play requirements, Android API levels, AndroidX and Jetpack Compose.",
"author": {
"name": "KODE LLC",
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this plugin. Versions follow [Semantic Versioning](https://semver.org):
a major version means you have to act after updating, and that is said in the entry.

## 1.1.0 — 2026-11-17

- The skill no longer reads `GITHUB_TOKEN`. Install and authenticate `gh` (`gh auth login`) for
authenticated GitHub requests; `gh` reads `GH_TOKEN` / `GITHUB_TOKEN` itself. Without `gh` the
audit asks GitHub unauthenticated (60 requests an hour), and the report says so.
- `gh` installed but not logged in no longer fails every GitHub call: the audit falls back to
unauthenticated curl and says why.
- No format change; no `--init` needed after updating.

## 1.0.0 — 2026-11-16

First public release as a Claude Code plugin.
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ people, never by the audit.

### GitHub access

GitHub allows 60 unauthenticated API requests an hour; a large project can need more.
GitHub allows 60 unauthenticated API requests an hour. That is usually enough for a run; a
large project, or several runs an hour from one network, can need more.

- **`gh` installed** — requests go through `gh api`, authenticated however you logged in
(`gh auth login`). The audit never sees the token.
- **No `gh`** — requests go through `curl`. If the `GITHUB_TOKEN` environment variable is set,
the audit reads it and sends it **only** to `api.github.com` as the `Authorization` header; it
is never written to a file or a report. Without it, requests are unauthenticated and the report
says so.
- **`gh` installed and logged in** — requests go through `gh api`, authenticated however you
logged in (`gh auth login`). The audit never sees the token.
- **No `gh`, or `gh` not logged in** — requests go through `curl`, unauthenticated: 60 requests
an hour. The report says so.

Installing and authenticating `gh` is the recommended way. A future version will stop reading
`GITHUB_TOKEN` and use `gh` as the only authenticated path.
Installing and authenticating `gh` is the recommended way. The audit never reads a token itself;
`gh` reads `GH_TOKEN` / `GITHUB_TOKEN` on its own, so a CI job with only a token gets
authenticated requests by installing `gh`.

## Things to know

Expand Down
10 changes: 6 additions & 4 deletions skills/android-upstream-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ with `cases.md`, `slice-format.md` and `digest.md` read at the step that needs t
- **A git checkout** with an `origin` remote that has the base branch.
- **Python 3.9 or later**, standard library only (the `python3` of macOS works), plus `curl` and
`git`.
- **`gh`, recommended.** Without it the GitHub API is asked through curl: 60 requests an
hour, or more with `GITHUB_TOKEN` set. The report then says so in the upkeep line.
- **`gh`, recommended.** Install it and run `gh auth login` for authenticated requests. Without
it, or with `gh` not logged in, the GitHub API is asked through curl, unauthenticated: 60 requests an hour, usually enough
for a run; a large project can need more. The report then says so in the upkeep line.
- Network access to `api.deps.dev`, `api.github.com`, the project's Maven repositories and the
documentation sites.

Expand Down Expand Up @@ -138,8 +139,9 @@ decisions.txt is written only by people, config.json only by --init; a run reads
## The scripts

All in `scripts/`, standard library Python plus `curl` and `git`. `gh` is used for the GitHub
API when installed; without it the scripts use curl, unauthenticated (60 requests an hour,
enough for a run) or with `GITHUB_TOKEN`, and the digest's upkeep line says so.
API when installed, authenticated however `gh` is; without it the scripts use curl,
unauthenticated (60 requests an hour, usually enough for a run; a large project can need more),
and the digest's upkeep line says so.

| Script | Role | What it does |
|---|---|---|
Expand Down
4 changes: 2 additions & 2 deletions skills/android-upstream-audit/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ serialization), for every pin with a suffix or on a pre-release, and for the `re
`config.json`; head commits for its `commits` and for the upstream of each vendored artifact.
A pin deps.dev links to no repository is printed as `PIN WITHOUT REPOSITORY`. AndroidX pins
are not: AndroidX has no GitHub releases, so they share one `ANDROIDX PINS` line, and a pin
that matters is read on its group's release-notes page. Without `gh`
the script asks GitHub through curl and says so on its first line.
that matters is read on its group's release-notes page. Without `gh`, or with `gh` not logged
in, the script asks GitHub through curl and says so on its first line.

What its output is for:

Expand Down
2 changes: 1 addition & 1 deletion skills/android-upstream-audit/scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

def curl(url: str, path: str | None = None, headers: list[str] | None = None) -> str | None:
"""Downloads with curl, not urllib: the system Python may ship without CA certificates.
Headers go through stdin, so a token never shows in the process list."""
Headers go through stdin (`-H @-`), not the command line."""
cmd = ['curl', '-sSL', '--fail', '--max-time', '90', '-A', 'android-upstream-audit/1.0', url]
if path:
cmd += ['-o', path]
Expand Down
27 changes: 19 additions & 8 deletions skills/android-upstream-audit/scripts/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
4. config.json against the project: a vendored artifact it does not name
(UNCONFIGURED VENDORED), and an entry for a path the build no longer uses (STALE CONFIG).

GitHub is asked through `gh` when it is installed, otherwise through curl (unauthenticated,
60 requests an hour, or with GITHUB_TOKEN). `--out` writes releases.json for slice.py.
GitHub is asked through `gh` when it is installed and logged in, otherwise through curl,
unauthenticated (60 requests an hour). `--out` writes releases.json for slice.py.
`--body` prints the notes of one release. Anything published on or after `--since`
(default: the previous run's start) is marked NEW.
"""
Expand Down Expand Up @@ -57,7 +57,21 @@


def github_client():
return 'gh' if shutil.which('gh') else 'curl'
"""('gh', None) when gh is installed and logged in to github.com, else ('curl', why).
A gh that is not logged in fails every call, while curl still has 60 an hour. Only the exit
code of `gh auth status` is used: its output names the account and a masked token."""
if not shutil.which('gh'):
return 'curl', ('gh is not installed; unauthenticated, 60 requests an hour; '
'install gh and run `gh auth login` for more')
try:
r = subprocess.run(['gh', 'auth', 'status', '--hostname', 'github.com'],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=30)
except (OSError, subprocess.TimeoutExpired):
return 'curl', '`gh auth status` failed; unauthenticated, 60 requests an hour'
if r.returncode != 0:
return 'curl', ('gh is installed but not logged in; unauthenticated, 60 requests an hour; '
'run `gh auth login` for more')
return 'gh', None


def github(path, client):
Expand All @@ -67,8 +81,6 @@ def github(path, client):
raise RuntimeError((r.stderr or r.stdout).strip().split('\n')[0])
Comment thread
DmitriyG1 marked this conversation as resolved.
Resolved
return json.loads(r.stdout)
headers = ['Accept: application/vnd.github+json']
if os.environ.get('GITHUB_TOKEN'):
headers.append(f"Authorization: Bearer {os.environ['GITHUB_TOKEN']}")
return json.loads(common.curl('https://api.github.com/' + path, headers=headers))


Expand Down Expand Up @@ -417,7 +429,7 @@ def main():
p.add_argument('--since')
p.add_argument('--body', metavar='OWNER/REPO@TAG', help='print the notes of one GitHub release')
args = p.parse_args()
client = github_client()
client, why = github_client()

if args.body:
repo, _, tag = args.body.partition('@')
Expand All @@ -435,8 +447,7 @@ def main():
if client == 'gh':
print('## GitHub API client: gh')
else:
print('## GitHub API client: curl — gh is not installed; install gh for authenticated requests '
f"({'GITHUB_TOKEN is set' if os.environ.get('GITHUB_TOKEN') else 'unauthenticated, 60 requests an hour'})")
print(f'## GitHub API client: curl — {why}')

checked = [e for e in entries if e['version']]
unique = sorted({e['coord'] for e in checked})
Expand Down
2 changes: 1 addition & 1 deletion skills/android-upstream-audit/scripts/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def upkeep_line(out):
if q.get('sources_failed'):
parts.append(f"{q['sources_failed']} sources failed")
if q.get('github_client') == 'curl':
parts.append('GitHub queried with curl, gh is not installed — install gh for authenticated requests')
parts.append('GitHub queried with curl, unauthenticated (60 requests an hour) — install and authenticate gh')
if q.get('dependencies_not_checked'):
parts.append(f"{len(q['dependencies_not_checked'])} dependencies not checked")
if (q.get('resolved_versions') or {}).get('status') in ('failed', 'timeout'):
Expand Down
44 changes: 44 additions & 0 deletions skills/android-upstream-audit/scripts/tests/test_releases.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""releases.py: dependency entries, version comparison, failed calls."""
import json
import os
import subprocess
import tempfile
import unittest
from unittest import mock

import fixtures # noqa: F401 (puts the scripts on sys.path)
import common # noqa: E402
Expand Down Expand Up @@ -271,6 +273,48 @@ def test_github_through_curl_without_gh(self):
self.assertEqual(calls[0][0], 'https://api.github.com/repos/google/ksp/releases?per_page=5')
self.assertIn('Accept: application/vnd.github+json', calls[0][1])

def test_gh_is_used_only_when_it_is_logged_in(self):
calls = []

def auth_status(returncode):
def run(cmd, **kwargs):
calls.append((cmd, kwargs))
if returncode is None:
raise subprocess.TimeoutExpired(cmd, kwargs.get('timeout'))
return subprocess.CompletedProcess(cmd, returncode)
return run

with mock.patch.object(releases.shutil, 'which', return_value=None):
client, why = releases.github_client()
self.assertEqual((client, calls), ('curl', []))
self.assertIn('gh is not installed', why)

for returncode, expected, reason in [(0, 'gh', None), (1, 'curl', 'gh is installed but not logged in'),
(None, 'curl', '`gh auth status` failed')]:
with self.subTest(returncode=returncode):
calls.clear()
with mock.patch.object(releases.shutil, 'which', return_value='/usr/bin/gh'), \
mock.patch.object(releases.subprocess, 'run', auth_status(returncode)):
client, why = releases.github_client()
self.assertEqual(client, expected)
if reason:
self.assertIn(reason, why)
self.assertIn('60 requests an hour', why)
else:
self.assertIsNone(why)
cmd, kwargs = calls[0]
self.assertEqual(cmd, ['gh', 'auth', 'status', '--hostname', 'github.com'])
# Its output names the account and a masked token: never read, never printed.
self.assertEqual((kwargs['stdout'], kwargs['stderr']), (subprocess.DEVNULL, subprocess.DEVNULL))

def test_curl_sends_no_authorization_even_with_github_token(self):
Comment thread
DmitriyG1 marked this conversation as resolved.
Resolved
calls = []
fake_curl = lambda url, path=None, headers=None: calls.append(headers) or '[]' # noqa: E731
with mock.patch.object(common, 'curl', fake_curl), \
mock.patch.dict(os.environ, {'GITHUB_TOKEN': 'test-token'}):
releases.github('repos/google/ksp/releases?per_page=5', 'curl')
self.assertEqual(calls, [['Accept: application/vnd.github+json']])


if __name__ == '__main__':
unittest.main()
3 changes: 2 additions & 1 deletion skills/android-upstream-audit/scripts/tests/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ def test_what_a_run_could_not_see_reaches_upkeep_and_coverage(self):
self.assertEqual(code, 0, out)
upkeep = next(line for line in out.splitlines() if line.startswith('upkeep line:'))
for phrase in ['feed gap in Kotlin blog (12 days)', 'Android blog feed silent for 72 days',
'GitHub queried with curl, gh is not installed', '1 dependencies not checked',
'GitHub queried with curl, unauthenticated (60 requests an hour) — install and authenticate gh',
'1 dependencies not checked',
'2 build-facts problems']:
self.assertIn(phrase, upkeep)
for coverage_line in ['- com.example:sdk 1.0 — needs credentials [x:1]',
Expand Down