Skip to content

feat(coana): download the Coana CLI through SOCKET_COANA_MIRROR_URL - #1825

Draft
Oskar Haarklou Veileborg (BarrensZeppelin) wants to merge 1 commit into
v1.xfrom
oskar/rea-1377-let-customers-download-coana-components
Draft

Oskar Haarklou Veileborg (BarrensZeppelin) wants to merge 1 commit into
v1.xfrom
oskar/rea-1377-let-customers-download-coana-components

Conversation

@BarrensZeppelin

@BarrensZeppelin Oskar Haarklou Veileborg (BarrensZeppelin) commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

socket-cli's side of mirror support that Coana is also gaining for its own downloads.

Machines that can't reach storage.googleapis.com can mirror Coana's bucket, for example with an Artifactory generic remote repository with "Propagate Query Params" turned on, and set SOCKET_COANA_MIRROR_URL to it. socket-cli then downloads the cli component from the mirror:

  • The prefix 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.
  • The rewrite happens in requestArtifacts, so the URL requested anew after a 4xx is rewritten too.
  • A signed URL outside the bucket is refused, including one that climbs out with .. or %2e%2e. The error leaves out the signature.
  • A mirror URL that isn't https, or that has a query or fragment, is refused before the API is asked. The error leaves out the value, which may carry credentials. It is only checked when a download may be needed, so a warm cache never trips on it.
  • A failed download names the host it went to, so the mirror's host when one is set.

Coana inherits the variable through the user's environment and applies the same rule to its own analyzers and facts downloads, once the pinned Coana supports the variable.

Depends on a Coana version bump that supports the inherited SOCKET_COANA_MIRROR_URL.

Tests

New cases in src/utils/coana-release.test.mts mock the API and the download, and use an empty cache per test with the real cache script:

  • the rewrite keeps the signature;
  • the renewed URL after a 403 is rewritten;
  • the mirror's host is named in a download failure;
  • URLs outside the bucket are refused without showing their signature;
  • bad mirror values are refused without asking the API.

All 13 fail against the previous implementation.

Expected reviewer effort: High-level design decisions

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.
@jdalton

Copy link
Copy Markdown
Contributor

Love it Oskar Haarklou Veileborg (@BarrensZeppelin) ❤️ !

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants