fix(skills-sync): authenticate via credential helper, guarantee clone cleanup - #124
Merged
Merged
Conversation
…clone cleanup The clone URL embedded ORG_PAT directly (visible in argv and stored as the clone's origin), and the mktemp consumer clone leaked on every failure and early-exit path — only the success path removed it. Extract skills_sync_credential_helper (a git credential helper that reads GH_TOKEN from its own environment, never a URL or argument) and skills_sync_run_repo (a per-repo function whose RETURN trap removes its mktemp clone on every exit path) into sourceable libs, and add regression coverage for both properties using stubbed git/gh. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
bketelsen
marked this pull request as ready for review
August 25, 2026 01:03
bketelsen
added a commit
that referenced
this pull request
Aug 25, 2026
#124 changed scripts/lib/skills-sync-repo.sh to clone and push as `git -c credential.helper=<helper> <subcommand> ...`. The hermetic harness's fake git only recognised `clone` as $1, so the real github.com URL passed straight through to the real binary and CI's docs-gate failed both tests with an authentication error. - Locate the subcommand by skipping `-c <value>` pairs and flags (the same detection test/sync-skills-run-repo.test.mjs uses), and rewrite the frostyard clone URL by pattern rather than by argv position. - Accept the credential-helper prefix on the asserted push line. - Carry the sibling test's rsync fallback so the harness stays runnable in sandboxes without a system rsync. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ORG_PATdirectly (https://x-access-token:${GH_TOKEN}@github.com/...), leaving the secret in the clone's storedoriginURL and in a raw process argument.mktempconsumer clone leaked on every exit path except success: clone failure, an unknown skill, containment failure, and any git/PR failure allcontinued orexited without removing it.Change
scripts/lib/skills-sync-auth.sh:skills_sync_credential_helper— a git credential helper (git-credential(1)) that readsGH_TOKENfrom its own process environment when git invokes it. The template string contains the literal characters$GH_TOKEN, never the token's value, so neither the clone'soriginURL, argv, nor the clone's.git/configever holds the secret.scripts/lib/skills-sync-repo.sh:skills_sync_run_repo— the per-repo clone/mirror/PR orchestration, now a single function whosemktempclone is bound to atrap ... RETURN, guaranteeing removal on every return path (clone failure, unknown skill, containment failure, git/PR failure, and success).scripts/sync-skills.shnow just parses the config and callsskills_sync_run_repoper repo — same branch name, target repos, token permissions, and PR semantics as before (verbatim log messages, PR title/body, and force-push behavior preserved).Test plan
test/sync-skills-auth.test.mjs(new): the credential helper never contains a literal token, and wired up via a realgit credential fillit correctly resolvesGH_TOKENfrom the environment.test/sync-skills-run-repo.test.mjs(new): with stubbedgit/gh(no network, no GitHub mutation), the mktemp clone directory is removed after — success, clone failure, push failure, an unknown skill, and a containment escape.npm run verify— 33/33 tests pass (node --test test/*.test.mjs, plus docs/organization/script-syntax gates).Risk tier: 2 — security-sensitive automation script and its git-credential handling change; no product surface, no new permissions.