Skip to content

fix(wsl): ssh-probe guard + harden Linux integration test auth#247

Merged
szymonos merged 2 commits into
mainfrom
rfr/lss-setup
May 2, 2026
Merged

fix(wsl): ssh-probe guard + harden Linux integration test auth#247
szymonos merged 2 commits into
mainfrom
rfr/lss-setup

Conversation

@szymonos

@szymonos szymonos commented May 2, 2026

Copy link
Copy Markdown
Owner

Summary

Two coordinated fixes on this branch:

1. Bug fix: Invoke-GhRepoClone ssh-probe guard for Windows hosts (dfb5943)

The SSH-first probe added in #246 calls bare ssh -T git@github.com from Invoke-GhRepoClone's begin block. With $ErrorActionPreference = 'Stop' and Windows PowerShell hosts where OpenSSH isn't on PATH, that throws and aborts wsl_setup.ps1 mid-pwsh provisioning at line 618 (Invoke-GhRepoClone -OrgRepo 'szymonos/ps-modules').

Fix: wrap the probe in Get-Command ssh -ErrorAction SilentlyContinue so the function silently falls back to HTTPS on hosts without ssh - matching pre-#246 behavior on Windows while keeping SSH preference on Linux/macOS hosts (where envy-nx normally runs and where this code path was originally validated).

2. CI infra: harden Linux integration test against api.github.com rate limit (97ddcdc)

The first attempt at this PR's integration test failed with "API rate limit exceeded" during oh-my-posh release lookup (log). This is a pre-existing flake unrelated to the WSL fix - the Docker build calls api.github.com unauthenticated, and shared GitHub Actions runner IPs routinely exhaust the 60/hr public quota.

Three coordinated changes:

  • .assets/docker/Dockerfile: accept ARG GITHUB_TOKEN, propagate inline into the su -c invocation (su -c clears env, so prefix-style env-var injection is the cleanest path).
  • .github/workflows/test_linux.yml: pass build-args: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} to the build-push step.
  • .assets/provision/source.sh:
    • get_gh_release_latest: fall back from gh auth token to ${GITHUB_TOKEN:-} so containerized runs without gh auth still authenticate.
    • install_github_release_user: broaden the prefix regex from ^gh[po]_ to ^(gh[a-z]_|github_pat_) so it accepts the ghs_ server-to-server token Actions auto-provides (the previous regex only matched ghp_/gho_).

Local Docker builds without --build-arg GITHUB_TOKEN remain functional (var stays empty, behavior matches pre-fix). The token does not leak beyond the runner since the test image uses push: false.

Test plan

  • pwsh parse-check on modules/InstallUtils/Functions/git.ps1
  • make lint clean
  • make test - 22 bats / 42 Pester, all green
  • Manual quoting trace verifying su -c arg expands $GITHUB_TOKEN from the build-arg while preserving deferred $HOME expansion
  • Linux integration test (label test:integration re-attached)
  • Manual: re-run failing wsl_setup.ps1 flow on a Windows host without OpenSSH installed - the Invoke-GhRepoClone -OrgRepo 'szymonos/ps-modules' call should now succeed via HTTPS

🤖 Generated with Claude Code

The SSH-first probe added in the envy-nx backport calls bare `ssh -T
git@github.com` from the begin block. With ErrorActionPreference=Stop
that throws on Windows PowerShell hosts where OpenSSH isn't on PATH,
aborting wsl_setup.ps1 partway through pwsh provisioning. Guard the
probe with Get-Command so we silently fall back to HTTPS - matching
the pre-backport behavior on Windows while keeping SSH-preference
on Linux/macOS.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@szymonos szymonos added the test:integration Trigger integration test (test_linux.yml) on this PR label May 2, 2026
@szymonos szymonos changed the title Post-merge follow-ups: WSL ssh-probe guard + provision helpers from envy-nx fix(wsl): guard ssh probe in Invoke-GhRepoClone for Windows hosts May 2, 2026
@szymonos szymonos removed the test:integration Trigger integration test (test_linux.yml) on this PR label May 2, 2026
The Linux integration test routinely fails on shared CI runner IPs with
"API rate limit exceeded" during oh-my-posh release lookup. Cause: the
get_gh_release_latest helper in source.sh hits api.github.com without a
token (it only consulted gh auth, which is empty in the container since
linux_setup.sh runs with --skip_gh_auth true). The unauthenticated 60/hr
per-IP quota on shared GitHub Actions runners is regularly exhausted.

Three coordinated changes:

1. .assets/docker/Dockerfile: accept ARG GITHUB_TOKEN, propagate it
   inline into the su -c invocation (su -c clears env, so prefix-style
   `GITHUB_TOKEN='...' linux_setup.sh ...` is the cleanest path).

2. .github/workflows/test_linux.yml: pass build-args
   GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} to docker/build-push-action.

3. .assets/provision/source.sh:
   - get_gh_release_latest: fall back from `gh auth token` to
     ${GITHUB_TOKEN:-} so containerized runs without gh-auth still
     authenticate.
   - install_github_release_user: broaden the prefix regex from
     `^gh[po]_` to `^(gh[a-z]_|github_pat_)` so it accepts the ghs_
     server-to-server token GitHub Actions auto-provides (the previous
     regex only matched ghp_/gho_ personal/OAuth tokens).

Local Docker builds without --build-arg GITHUB_TOKEN remain functional
(the var stays empty; behavior matches pre-fix). Token does not leak
beyond the runner since the test image uses push: false.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@szymonos szymonos changed the title fix(wsl): guard ssh probe in Invoke-GhRepoClone for Windows hosts fix(wsl): ssh-probe guard + harden Linux integration test auth May 2, 2026
@szymonos szymonos added the test:integration Trigger integration test (test_linux.yml) on this PR label May 2, 2026
@szymonos
szymonos merged commit e31c923 into main May 2, 2026
4 checks passed
@szymonos
szymonos deleted the rfr/lss-setup branch May 2, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:integration Trigger integration test (test_linux.yml) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant