Repository navigation
feat(coana): download the Coana CLI through SOCKET_COANA_MIRROR_URL - #1825
Conversation
Machines that can't reach storage.googleapis.com can mirror Coana's bucket, for example with an Artifactory remote repository, and set SOCKET_COANA_MIRROR_URL to it. Each signed URL for the cli component then has its https://storage.googleapis.com/socket-coana-cli/ prefix replaced with the mirror's URL, keeping the signature, including the URL requested anew after a 4xx. Coana, which inherits the variable, follows the same rule for its own components. A signed URL outside the bucket is refused rather than fetched from GCS. A mirror URL that isn't https, or that has a query or fragment, is refused before the API is asked, without echoing the value. socket-cli downloads over https only, so unlike Coana it doesn't accept an http mirror.
|
Love it Oskar Haarklou Veileborg (@BarrensZeppelin) ❤️ ! |
Parse the signed URL once into a URL, and have the mirror rule throw its errors so that the existing catch reports them as failures to get the Coana CLI. installComponent takes the request function instead of the org slug and mirror rule. The tests share one tarball fixture and API response.
PR SummaryMedium Risk Overview In Docs (README, CHANGELOG) document the variable. Reviewed by Cursor Bugbot for commit fbe7a91. Configure here. |
Jeppe Fredsgaard Blaabjerg (jfblaa)
left a comment
There was a problem hiding this comment.
Works with the Coana 15.15.12 pin now on v1.x. A few comments, mostly small; the download timeout is the one I would most like to see handled.
Parse SOCKET_COANA_MIRROR_URL and rewrite the signed URL only after the resolved version missed the cache, so a stale value or a URL outside the bucket no longer breaks a run that needs no download. An invalid value is an InputError. Downloads get a 60 s inactivity timeout, so a stalled mirror can't hang the run, and a failed download names the host it went to.
Jeppe Fredsgaard Blaabjerg (jfblaa)
left a comment
There was a problem hiding this comment.
Thanks, all addressed. Small thing: the "Depends on a Coana version bump" line in the description can go, since Coana 15.15.12 is on v1.x now.
1413d21
into
v1.x
* Download the Coana CLI through SOCKET_COANA_MIRROR_URL When SOCKET_COANA_MIRROR_URL is set, the signed URL's prefix https://storage.googleapis.com/socket-coana-cli/ is replaced with the mirror's URL, keeping the query that holds the signature. The value is read only after a cache miss. Signed URLs outside the bucket and invalid values are refused without showing the signature or the value, and download errors name the host without credentials. Port of SocketDev/socket-cli#1825. Unlike the Node CLI, http mirrors are accepted, as in Coana. * Correct two comments on the mirror download * Ride the unreleased 2.15.10 instead of bumping to 2.15.11
Summary
socket-cli's side of mirror support that Coana is also gaining for its own downloads.
Machines that can't reach
storage.googleapis.comcan mirror Coana's bucket, for example with an Artifactory generic remote repository with "Propagate Query Params" turned on, and setSOCKET_COANA_MIRROR_URLto it. socket-cli then downloads theclicomponent from the mirror:https://storage.googleapis.com/socket-coana-cli/of the signed URL is replaced with the mirror's URL, with a/appended when it lacks one. The query string, which holds the signature, is kept...or%2e%2e. The error leaves out the signature.InputError. The error leaves out the value, which may carry credentials.Coana inherits the variable through the user's environment and applies the same rule to its own
analyzersandfactsdownloads, once the pinned Coana supports the variable. Coana also accepts an http mirror; socket-cli refuses one, becauseapiFetchspeaks only https.Depends on a Coana version bump that supports the inherited
SOCKET_COANA_MIRROR_URL.Tests
New cases in
src/utils/coana-release.test.mtsmock the API and the download, and use an empty cache per test with the real cache script:All but the last fail against the previous implementation.
Expected reviewer effort: High-level design decisions