Skip to content

Download the Coana CLI through SOCKET_COANA_MIRROR_URL - #486

Merged
Oskar Haarklou Veileborg (BarrensZeppelin) merged 3 commits into
mainfrom
oskar/rea-1377-let-customers-download-coana-components
Dec 4, 2026
Merged

Oskar Haarklou Veileborg (BarrensZeppelin) merged 3 commits into
mainfrom
oskar/rea-1377-let-customers-download-coana-components

Conversation

@BarrensZeppelin

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

Copy link
Copy Markdown
Member

socket-python-cli's side of mirror support for Coana's downloads, following socket-cli's SocketDev/socket-cli#1825.

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. The 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 value is read, and the URL rewritten, only once a download is certain: after the resolved version missed the cache. A warm cache never trips on a stale value. The URL requested anew after a 4xx is rewritten too.
  • A signed URL outside the bucket is refused, including one with a . or .. segment, percent-encoded or not. The error leaves out the signature.
  • A mirror URL that isn't http(s), or that has a query, fragment or invalid port, is refused. The error leaves out the value, which may carry credentials.
  • A download that fails with an error status names the host, without credentials. raise_for_status is no longer used, since its message shows the whole URL.

Unlike socket-cli, http mirrors are accepted, as in Coana: requests speaks both.

The pinned Coana 15.15.12 already honours the inherited variable for its analyzers and facts downloads. The variable isn't documented in docs/ yet, since the feature isn't GA.

Known gap, unchanged by this PR: a connection, TLS or proxy error from requests still shows the request path and signature (not credentials) in its message.

Why?

Customers whose CI runners can't reach storage.googleapis.com can't download Coana since the CLI started downloading it from GCS.

Tests

New cases in tests/unit/test_reachability.py mock the Socket API and the download, and use an empty cache per test with the real cache script:

  • the rewrite keeps the signature, for https and http mirrors, with and without a trailing / and with credentials;
  • the renewed URL after a 403 is rewritten;
  • the mirror's host, without credentials, is named for an error status and for a refused renewed URL;
  • URLs outside the bucket are refused without showing their signature;
  • bad mirror values are refused before any download, without showing them;
  • a bad mirror value and a URL outside the bucket are ignored when a range resolves to a cached version.

Public Changelog

  • Set SOCKET_COANA_MIRROR_URL to download the reachability engine through a mirror of storage.googleapis.com/socket-coana-cli.

Expected reviewer effort: High-level design decisions

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

cursor Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes reachability engine download paths and URL validation; wrong mirror config could block --reach, but default behavior is unchanged when the env var is unset.

Overview
Release 2.15.11 adds SOCKET_COANA_MIRROR_URL so CI environments blocked from storage.googleapis.com can fetch the Coana reachability CLI from a mirror (e.g. Artifactory) instead of GCS directly.

In reachability.py, downloads rewrite signed URLs by swapping the https://storage.googleapis.com/socket-coana-cli/ prefix for the mirror base while keeping the signature query. Mirror config is read only when a real download is needed (cache hits are unchanged). Invalid mirror values and signed URLs outside the expected bucket are rejected with errors that omit credentials and signatures; failed downloads report the host only, not the full URL.

Unit tests cover URL rewriting, retry after 4xx, validation edge cases, and cached-version behavior.

Reviewed by Cursor Bugbot for commit 08d2f8e. Configure here.

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.

🎉

@BarrensZeppelin
Oskar Haarklou Veileborg (BarrensZeppelin) merged commit eb4ae61 into main Dec 4, 2026
34 checks passed
@BarrensZeppelin
Oskar Haarklou Veileborg (BarrensZeppelin) deleted the oskar/rea-1377-let-customers-download-coana-components branch December 4, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants