Skip to content

Authenticate setup-cli release downloads with GH_TOKEN - #76428

Merged
pelikhan merged 5 commits into
mainfrom
copilot/fix-gh-token-downloads
Nov 10, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/fix-gh-token-downloads

Conversation

Copilot AI commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

setup-cli used GH_TOKEN for some API calls but not direct release downloads, leaving pinned binary and checksum requests anonymous. It now authenticates release lookups and downloads, while preserving anonymous access when the token is rejected.

  • Authenticated requests: Bash and PowerShell installers send the token with latest-release lookups, binaries, and checksums.
  • Anonymous fallback: After authenticated download retries fail, each installer warns and retries once without authentication. Bash does not use --location-trusted.
  • Docs and coverage: Clarifies GHES/GHE.com token behavior and adds tests for authenticated, anonymous, rejected-token, and latest-release requests.
curl "${AUTH_CURL_ARGS[@]}" -L -f -o "$destination" "$url"
# After authenticated retries fail:
curl -L -f -o "$destination" "$url"

Copilot AI and others added 2 commits November 10, 2026 06:52
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix GH_TOKEN usage in binary and checksums downloads Authenticate setup-cli release downloads with GH_TOKEN Nov 10, 2026
Copilot AI requested a review from pelikhan November 10, 2026 07:11
@github-actions

Copy link
Copy Markdown
Contributor

Category: bug | Risk: medium | Score: 59/100 (impact 29 + urgency 18 + quality 12) | Recommended action: batch_review | Notes: authenticates setup-cli release downloads using GH_TOKEN; security-adjacent dependency fetch hardening with moderate urgency.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~9 AIC · ⌖ ~2 AIC · ⊞ 15.8K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

Category: bug | Risk: medium | Score: 59/100 (impact 29 + urgency 18 + quality 12) | Recommended action: batch_review | Notes: authenticates setup-cli release downloads using GH_TOKEN; security-adjacent dependency download hardening with moderate urgency.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~9 AIC · ⌖ ~2 AIC · ⊞ 15.8K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

Category: bug | Risk: medium | Score: 59/100 (impact 29 + urgency 18 + quality 12) | Recommended action: batch_review | Notes: authenticates setup-cli release downloads with GH_TOKEN; security-adjacent hardening with moderate urgency.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~9 AIC · ⌖ ~2 AIC · ⊞ 15.8K · ◷

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Category: bug | Risk: medium | Score: 59/100 (impact 29 + urgency 18 + quality 12) | Recommended action: batch_review | Notes: authenticates setup-cli release downloads with GH_TOKEN; security-adjacent hardening with moderate urgency.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~9 AIC · ⌖ ~2 AIC · ⊞ 15.8K · ◷

@pelikhan
pelikhan marked this pull request as ready for review November 10, 2026 14:27
Copilot AI adaptive review requested due to automatic review settings November 10, 2026 14:27
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Specification Reviewer · gpt56 · ~2 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

Generated by PR Specification Reviewer for #76428

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt61 medium · ~4 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 181 · ◷

Generated by Ponytail Reviewer for #76428

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Code Quality Reviewer · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 8.5K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-10T14:35:00Z
review_event: COMMENT
top_themes: retry fallback diagnostics; authentication failure handling
files_reviewed: install-gh-aw.sh, install-gh-aw.ps1, actions/setup-cli/install.sh, actions/setup-cli/install.ps1, scripts/test-install-script.sh
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the installer authentication changes. One actionable diagnostics/retry issue was found; no blocking correctness or security issue was confirmed.

Highlights
  • Anonymous fallback is currently attempted for all authenticated download failures, including non-auth failures, and is reported as token rejection.
  • The specialist pass completed; its other candidates were discarded as out of scope, unchanged-line concerns, or insufficiently supported.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

Comment thread install-gh-aw.sh
fi
done

if [ "${#AUTH_CURL_ARGS[@]}" -gt 0 ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The anonymous fallback is attempted for every failure after the authenticated retries, not just an authentication rejection, so a nonexistent asset, outage, timeout, or DNS failure incurs another request and is misreported as a rejected token.

💡 Restrict the fallback to authentication failures

Capture the HTTP status (for example with curl -w) and retry without AUTH_CURL_ARGS only for 401/403, or use a neutral warning that accurately covers non-auth failures. This avoids extra traffic and makes installer diagnostics trustworthy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the fallback warning to describe the actual authenticated download failure without assuming the token was rejected. Commit: fc79c12e.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd. The auth change and anonymous fallback look correct, and the bash path has solid test coverage. The remaining items are small and non-blocking.

📋 Key Themes & Highlights

Key Themes

  • Misleading PowerShell checksum output: the skip warning prints before the anonymous retry, so a successful retry still reports that verification is skipped (inline).
  • Swallowed errors: both PowerShell anonymous fallbacks use empty catch blocks (inline).
  • Misleading token-rejected wording: it fires on any authenticated failure, not only on rejected tokens (inline).
  • PowerShell test gap: scripts/test-install-script.ps1 covers only the GH_TOKEN header on the release list and the pinned path. It does not exercise the anonymous fallback for binary or checksum downloads, or the latest lookup auth. The bash fixture covers all of these, so the PowerShell fallback is the untested side. Add fixture cases, or note that it is untested.

Positive Highlights

  • ✅ The anonymous fallback runs only when a token is set, so no-token behaviour is unchanged.
  • ✅ No --location-trusted is used, and the test script rejects it.
  • ✅ The bash fixture asserts per-request auth, exhausted authenticated retries, and a single anonymous retry.
  • ✅ install-gh-aw.sh and .ps1 are mirrored into actions/setup-cli/, and the copies are identical.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~10 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

Comment thread install-gh-aw.ps1
if (-not $checksumsDownloaded -and $env:GH_TOKEN) {
Write-WarningMessage "GitHub token was rejected; retrying checksums download without authentication."
try {
Invoke-WebRequest -Uri $ChecksumsURL -Headers $AnonymousHeaders -OutFile $ChecksumsPath -TimeoutSec 60 | Out-Null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/diagnosing-bugs] The skip warning at line 430 is printed on the third failed attempt, before this anonymous retry runs. If the retry succeeds, the output still says checksum verification will be skipped. Print that warning only when $checksumsDownloaded is still false after this fallback.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved the checksum failure and skip-verification warnings until after the anonymous retry, so they’re emitted only if it also fails. Commit: fc79c12e.

Comment thread install-gh-aw.ps1
Invoke-WebRequest -Uri $Url -Headers $AnonymousHeaders -OutFile $DestinationPath -TimeoutSec 120 | Out-Null
Write-Success "Binary downloaded successfully"
return $true
} catch {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/diagnosing-bugs] The empty catch discards the anonymous retry exception, so the caller only sees the generic download failure and the root cause is lost. Log the exception message with Write-WarningMessage so a future regression can be diagnosed.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The anonymous binary retry catch now reports the exception message with Write-WarningMessage. Commit: fc79c12e.

Comment thread install-gh-aw.sh Outdated
done

if [ "${#AUTH_CURL_ARGS[@]}" -gt 0 ]; then
print_warning "GitHub token was rejected; retrying binary download without authentication."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/diagnosing-bugs] This warning says the token was rejected for any failure after the authenticated retries, including network errors and timeouts, so it misreports the cause. With curl -f, exit code 22 means an HTTP error, so check for that before using the rejection wording, or use neutral text such as authenticated download failed, retrying anonymously. The same wording appears at line 554 and in install-gh-aw.ps1 at line 275.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed the fallback warning to neutral wording that remains accurate for network and HTTP failures. Commit: fc79c12e.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The installer exposes GH_TOKEN in curl’s command-line arguments, allowing other local users on shared Linux runners with readable /proc entries to steal the credential.

4 open issues
What changed in this PR

Updates setup-cli and the standalone installers to authenticate release requests with GH_TOKEN, while retaining anonymous fallback for failed asset downloads.

Changes:

  • Authenticates Bash latest-release lookups, binary downloads, and checksum downloads.
  • Adds anonymous download retries to Bash and PowerShell installers.
  • Expands Bash authentication coverage and documents token behavior across GitHub instances.
File Description
scripts/​test-install-script.sh Adds authenticated, anonymous, rejected-token, and latest-release cases.
install-gh-aw.sh Adds authenticated release requests and anonymous download fallback.
install-gh-aw.ps1 Adds anonymous retries for binary and checksum downloads.
actions/​setup-cli/​README.md Explains download authentication and GHES/GHE.com token behavior.
actions/​setup-cli/​install.sh Mirrors the standalone Bash installer changes.
actions/​setup-cli/​install.ps1 Mirrors the standalone PowerShell fallback changes.
actions/​setup-cli/​action.yml Updates the token input description to include release downloads.
.changeset/​patch-authenticated-setup-cli-downloads.md Records the authentication changes for a patch release.

Review effort: Max (auto)

Comment thread install-gh-aw.sh
if [ -n "${GH_TOKEN:-}" ]; then
AUTHORIZATION_HEADER="Authorization: Bearer "
AUTHORIZATION_HEADER+="$GH_TOKEN"
AUTH_CURL_ARGS=(-H "$AUTHORIZATION_HEADER")
Comment thread install-gh-aw.sh
FALLBACK_CHECKSUMS_URL=""
if [ "$VERSION" = "latest" ]; then
if LATEST_RELEASE_RESPONSE=$(curl -sLf --connect-timeout 15 --max-time 30 "https://api.github.com/repos/$REPO/releases/latest"); then
if LATEST_RELEASE_RESPONSE=$(curl -sLf --connect-timeout 15 --max-time 30 "${AUTH_CURL_ARGS[@]}" "https://api.github.com/repos/$REPO/releases/latest"); then
FIXTURE_REJECT_AUTH="$reject_auth" \
FIXTURE_REQUEST_LOG="$case_root/requests" \
FIXTURE_LATEST="$case_root/latest.json" \
GH_TOKEN="$([ "$case_name" = channel-page-and-semver ] && echo test-token || echo "$gh_token")" \
Comment on lines +477 to +480
[ "$(awk -F '\t' '$1 ~ /\/download\/v0[.]37[.]18\/linux-amd64$/ && $2 == "authenticated" { count++ } END { print count+0 }' "$case_root/requests")" -eq 3 ] ||
fail "binary did not exhaust authenticated retries"
[ "$(awk -F '\t' '$1 ~ /\/download\/v0[.]37[.]18\/linux-amd64$/ && $2 == "anonymous" { count++ } END { print count+0 }' "$case_root/requests")" -eq 1 ] ||
fail "binary did not retry anonymously once"
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (install-gh-aw.sh:510): address unresolved feedback - Review comment
  3. Review (install-gh-aw.ps1:442): address unresolved feedback - Review comment
  4. Review (install-gh-aw.ps1:280): address unresolved feedback - Review comment
  5. Review (install-gh-aw.sh:511): address unresolved feedback - Review comment

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "62f98f69ad1d3483a223e395873d887d9731acd0",
  "kind": "requested",
  "schema_version": "1",
  "state": "4abba2516c00260e755192ef4c81eefc045d1f2459e24272c514290af795c956",
  "work": [
    "0805a68bef3f9901737eccb5266c4e4353355b4ef56a59249dd9e550fc148c72",
    "17f29de159c89322705bfa6825b6b0dc538a501449017ae61baf6d2dc8560165",
    "604ea0cc9c4d87c3fd81446c99877bf0c3ca8302ec5a29a56780f95aed69b93e",
    "ad83d803e327a8a8d0eff17296ce86fa6b81a621f87a418644958cf1a223a55f"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

Copilot AI and others added 2 commits November 10, 2026 15:21
…downloads

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI requested a review from gh-aw-bot November 10, 2026 15:29
@pelikhan
pelikhan merged commit ec58846 into main Nov 10, 2026
88 checks passed
@pelikhan
pelikhan deleted the copilot/fix-gh-token-downloads branch November 10, 2026 15:56
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install-gh-aw.sh / setup-cli: send GH_TOKEN with the binary and checksums downloads, not only the releases API

4 participants