feat: add downloadBaseURL, checksum, and downloadAuthToken inputs (closes Azure#206)#268
Open
benjaminbob21 wants to merge 1 commit into
Open
feat: add downloadBaseURL, checksum, and downloadAuthToken inputs (closes Azure#206)#268benjaminbob21 wants to merge 1 commit into
benjaminbob21 wants to merge 1 commit into
Conversation
5bc2efb to
d7e6712
Compare
d7e6712 to
4cce71c
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for downloading kubectl from custom/private mirrors by introducing a configurable download base URL, optional SHA256 verification, and optional bearer-token authentication. This extends the action’s download pipeline with additional URL validation and a “secure download” path intended to mitigate SSRF/token leakage risks when using non-default mirrors.
Changes:
- Add new action inputs:
downloadBaseURL,checksum,downloadAuthToken, and route downloads through mirror-aware logic. - Implement URL/version validation and a redirect-aware
secureDownload()path for custom mirrors, plus optional SHA256 verification. - Expand unit and integration tests to cover custom mirrors, redirects/SSRF guards, and checksum validation.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/run.ts |
Plumbs new inputs into version resolution and download/caching, adds checksum verification and token handling. |
src/run.test.ts |
Adds extensive test coverage for custom mirror behavior, URL/version validation, redirects, auth header stripping, and checksum checks. |
src/helpers.ts |
Introduces secureDownload, base URL/version validation helpers, and baseURL-aware URL construction for downloads/version discovery. |
package.json |
Adds @actions/http-client dependency used by secureDownload. |
package-lock.json |
Locks the newly added @actions/http-client dependency. |
action.yml |
Documents and exposes the new inputs to action consumers. |
.github/workflows/integration-tests.yml |
Adds an integration test validating checksum success and failure behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+77
to
+80
| if (status !== 200) { | ||
| response.message.resume() | ||
| throw new toolCache.HTTPError(status) | ||
| } |
Comment on lines
+131
to
+138
| // Scope the cache key per mirror so a binary cached from one source isn't silently reused for another. | ||
| const cacheKey = isDefaultBaseURL(baseURL) | ||
| ? version | ||
| : `${version}-${crypto | ||
| .createHash('sha256') | ||
| .update(normalizeBaseURL(baseURL)) | ||
| .digest('hex') | ||
| .slice(0, 12)}` |
Comment on lines
+96
to
+100
| const chunks: Buffer[] = [] | ||
| let received = 0 | ||
| for await (const chunk of response.message as AsyncIterable<Buffer>) { | ||
| received += chunk.length | ||
| if (received > SECURE_DOWNLOAD_MAX_BYTES) { |
| } | ||
| } | ||
|
|
||
| if (version.toLocaleLowerCase() === 'latest') { |
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.
Add downloadBaseURL, checksum, and downloadAuthToken inputs (closes #206)
Supports private kubectl mirrors (air-gapped / enterprise) with optional SHA256 verification and optional bearer-token auth for private artifact repositories. Default base URL is unchanged.
Security: https-only, blocks loopback/link-local/RFC1918 hosts, re-validates each redirect hop, strips the Authorization header on cross-origin redirects, masks the token via core.setSecret, and validates version format before any URL/path use.