Skip to content

fix(checks): report only org secrets the repo can actually read - #994

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-993
Aug 16, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-993

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

repo-secret-allowlist enumerated every org-level secret in the organization and flagged each one, without consulting whether that secret's visibility actually admits the repo being checked. On a repo where all ten org secrets are visibility: selected and none list it, the check reported all ten as "available to all workflows".

Nothing clears that. The repo is already at the tightest scoping GitHub offers — the secrets are not shared with it at all — so the only remaining lever is a secrets.allowed entry, whose documented meaning ("a deliberate acceptance that any workflow the repo runs can read that token") is false in that state, and which would mute those names permanently: if one were later shared with the repo, the sweep would stay silent about the one case it exists to catch.

It also penalized the grant it asks for. The check hints at admin:org to complete the sweep; granting it converted a pass into an unclearable FAIL, while the same ten secrets were equally unreachable before.

Solution

_list_org_secrets now takes the repo and returns only the org secrets that repo can read. It reads each secret's visibility alongside its name and drops:

  • selected whose /orgs/{org}/actions/secrets/{name}/repositories list omits the repo (paginated — an org sharing a secret past one page would otherwise look like it omits this one);
  • private when the repo is public;
  • all of them when the repo is private and the org is on GitHub Free, which serves org secrets to public repositories only.

The per-secret repositories endpoint needs admin:org, which the sweep already requires to enumerate org secrets at all, so no new scope is involved.

Filtering is deliberately one-directional: a secret whose reach can't be determined — the repositories list fails, the repo's visibility won't read, the plan field is absent — stays in the reported set. Under-reporting hides real exposure; over-reporting is only noise. _org_plan_is_free returns False on any read failure for the same reason.

check_secrets reads the same helper, so it gains the same correction: an org copy scoped away from the repo no longer gets named as the thing keeping its workflows running.

Testing

uv run pytest — 563 pass. Seven new cases in generator/tests/test_checks.py drive _list_org_secrets end-to-end through a fake gh serving the real endpoint shapes, rather than mocking the helper out. Four reproduced the reported FAIL before the fix: a selected secret omitting the repo, private against a public repo, a free-org private repo, and check_secrets naming an unreachable org copy. The other three pin the directions that must keep failing — selected including the repo, visibility: all, and a repositories lookup that errors.

Not covered

Pagination of the org secret listing itself is untouched — orgs/{org}/actions/secrets still reads one page, so an org with more secrets than a page holds under-reports. That is pre-existing and independent of visibility; separate change if it matters.

The free-plan rule rests on .plan.name, which GitHub returns only to org owners. For a non-owner token the field is absent and the rule simply doesn't fire, leaving the pre-fix behavior for visibility: all on a free org. selected and private are unaffected — they're filtered from data any admin:org token can read.


Closes #993 — automated triage

`repo-secret-allowlist` listed every org-level secret in the
organization, ignoring each secret's visibility scoping. A repo already
at the tightest scoping GitHub offers — the secret is not shared with it
at all — got a FAIL no repo-side change could clear, since the only lever
left, a `secrets.allowed` entry, would assert the opposite of the truth
and mute that name permanently.

Filter the org listing to what the repo can read: a `selected` secret
whose repository list omits it, a `private` secret against a public repo,
and any org secret against a private repo in a GitHub Free org are all
unreachable. Filtering is one-directional — a secret whose reach cannot
be determined stays reported, since under-reporting hides real exposure
while over-reporting is only noise.

Closes #993

@tend-agent tend-agent 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.

Two findings below, both mechanical. The PR is bot-authored, so I'll push them as a follow-up commit rather than leave one-click suggestions waiting on an author who won't return.

One thing I couldn't verify from CI: _org_secret_repos's docstring claims --paginate covers an org that shares a secret with more repos than one page holds. gh api --paginate follows Link headers, and I have no admin:org token here to confirm orgs/{org}/actions/secrets/{name}/repositories emits them. If it doesn't, the call silently stops at the default 30 and produces exactly the under-report the filter exists to prevent. -f per_page=100 would make the question moot; I've left it out rather than add a knob on a guess.

Comment thread generator/src/tend/checks.py Resolved
Comment thread generator/tests/test_checks.py Resolved
`full_name` comes back canonical while `repo` is whatever `--repo` was
given, so a casing difference made every `selected` org secret look
unshared and dropped it — the under-reporting direction `_list_org_secrets`
is written to avoid.

Also drops the dead non-visibility branch from the test helper: the org
secret listing has one reader and it always asks for `{name, visibility}`.
@tend-agent

Copy link
Copy Markdown
Collaborator Author

Both findings are on the branch as c22238b (case-folded membership test plus its own case, dead else arm dropped from the test helper); checks are green on that head.

On the open question from the review — whether --paginate actually covers orgs/{org}/actions/secrets/{name}/repositories, or silently stops at 30: the mechanism holds for this endpoint family. GitHub emits Link headers on the Actions total_count-envelope endpoints, and gh api --paginate --jq follows them across pages rather than parsing only the first:

$ gh api "repos/max-sixty/tend/actions/workflows" --jq '.total_count'
17
$ gh api "repos/max-sixty/tend/actions/workflows?per_page=2" --jq '.workflows[].name' | wc -l
2
$ gh api --paginate "repos/max-sixty/tend/actions/workflows?per_page=2" --jq '.workflows[].name' | wc -l
17

So no -f per_page=100 is needed to make the docstring's claim true — it would only cut request count, which isn't worth a knob.

What stays unverified is the specific endpoint: reading it needs admin:org, which no token in this repo's runs has, so the check above is same-family evidence rather than a direct test. If it ever turns out to be the one Actions endpoint without Link, the failure is the under-report the filter exists to prevent, so it's worth naming here rather than leaving in a docstring.

@max-sixty
max-sixty merged commit bd54905 into main Aug 16, 2026
6 checks passed
@max-sixty
max-sixty deleted the fix/issue-993 branch August 16, 2026 03:12
@max-sixty max-sixty mentioned this pull request Aug 16, 2026
max-sixty added a commit that referenced this pull request Aug 16, 2026
Bumps the generator to 0.1.18 and adds the CHANGELOG section the release
workflow publishes as the GitHub Release notes.

8 commits since 0.1.17. The two fixes: `repo-secret-allowlist` now
reports only the org secrets the repo can actually read, instead of
flagging every org secret as available to all workflows (#994); and both
halves of the 👀 reaction sit in one job on `tend-mention`, with a
paginated removal lookup (#990). Two bundled-skill changes go out with
them — `running-in-ci` scopes PR-description claims to the merge base
(#992), and tells a fork-PR session that no successor will pick up its
own review's findings (#985).

`uv run pytest` (564), the worker's vitest suite (31) and typecheck, and
`pre-commit run --all-files` all pass on the branch.

> _This was written by Claude Code on behalf of max-sixty_
dormouse-bot added a commit to diffplug/dormouse that referenced this pull request Aug 16, 2026
…n 0.1.18

The FAIL the section described is gone: max-sixty/tend#993 was fixed by
max-sixty/tend#994 and shipped in tend 0.1.18, which this repo picked up in
#380. Delete the section rather than rewriting it as history.
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Aug 17, 2026
Automated nightly regeneration of tend's workflow files, picking up tend
0.1.18.

**tend version:** 0.1.17 → 0.1.18

Notable changes:

- `tend-mention`: both halves of the 👀 reaction now live in the `handle`
job. Previously `verify` added the eyes and `handle` removed them, so a
burst of mentions on one thread could cancel a queued `handle` — which
allocates no runner and runs no steps, `always()` included — leaving the
reaction stranded (max-sixty/tend#990).
- `tend-review` / `tend-triage`: the eyes-removal lookup now paginates
(`--paginate`, `per_page=100`). A thread with more than 30 reactions
could push the bot's own eyes off the first page, so the removal
silently found nothing (max-sixty/tend#990).
- `tend check`: the secret audit now reports only org secrets this repo
can actually read, instead of every org secret (max-sixty/tend#994).
- `running-in-ci` skill: notes that fork PR reviews reach no successor
session, and scopes PR-description claims to the merge base
(max-sixty/tend#985, max-sixty/tend#992).

Full comparison:
max-sixty/tend@0.1.17...0.1.18

Co-authored-by: worktrunk-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tend check: repo-secret-allowlist reports org secrets that are not shared with the repo

2 participants