Skip to content

feat(cortex): add the cortex formula and a private-release download strategy - #3

Closed
todie wants to merge 1 commit into
mainfrom
pkg-lead/cortex-formula
Closed

todie wants to merge 1 commit into
mainfrom
pkg-lead/cortex-formula

Conversation

@todie

@todie todie commented Oct 22, 2026

Copy link
Copy Markdown
Member

The tap's first private tool: cortex v1.0.0-rc.46, plus a vendored download strategy for private GitHub release assets. paas reviews and merges. The cortex lane is copied through the advisor.

The token is not here and is not needed to review this. Acceptance with the real read-only installer token (github-installer-readonly) runs separately, once Christian has minted it.

Change

  • lib/github_private_release_download_strategy.rb, a CurlDownloadStrategy subclass:
    1. It parses the owner, repo, tag and asset name from the formula's browser URL (https://github.com/<owner>/<repo>/releases/download/<tag>/<asset>).
    2. It calls GET /repos/<owner>/<repo>/releases/tags/<tag> and picks the asset by its exact name. It doesn't use latest, which skips prereleases.
    3. It calls GET /repos/<owner>/<repo>/releases/assets/<id> with Accept: application/octet-stream.
    • Where the token goes: HOMEBREW_GITHUB_API_TOKEN reaches curl only through a header file: --header @<file>, mode 0600, deleted after use.
      • Homebrew's own headers: option would put the value on curl's argv, so it isn't used. A value on argv shows in a process list and in the command line Homebrew prints when curl fails.
      • The token is never part of a URL.
    • No unauthenticated HEAD probe of the private URL: resolve_url_basename_time_file_size is local.
    • Before any network call, it fails if no token is set, and it refuses to run with HOMEBREW_CURL_VERBOSE or HOMEBREW_CURLRC set, since curl's verbose mode, or options a curlrc can add, print request headers.
    • The sha256 stays enforced: Homebrew verifies it after the strategy returns.
  • Formula/cortex.rb covers darwin and musl, on x86_64 and aarch64.
    • Each sha256 equals GitHub's own asset digest; all four were checked.
    • The version (1.0.0-rc.46) is parsed from the URL. An explicit version would be redundant, as audit --strict says.
    • license :cannot_represent: cortex's LICENSE is proprietary ("All rights reserved").
    • Test: cortex --version contains cortex 1.0.0-rc.46. The binary prints cortex 1.0.0-rc.46 (f207b86).
  • README.md: cortex's brew line and mise line (mise use github:cerebral-work/cortex@v1.0.0-rc.46).
    • It also covers private-tool setup: the token goes in the environment (HOMEBREW_GITHUB_API_TOKEN for brew, GITHUB_TOKEN for mise), never on a command line.
    • Pin a tag: mise's latest skips prereleases.

Proof without the token (pinned homebrew/brew@sha256:b0072bfd…, Homebrew 4.6.20, curl 7.81.0)

  • No token: install rc 1, "cortex is private: set HOMEBREW_GITHUB_API_TOKEN to a read-only token". The failure happens before any network call.
  • HOMEBREW_CURL_VERBOSE=1: install rc 1, "unset HOMEBREW_CURL_VERBOSE and HOMEBREW_CURLRC; they would print the token".
  • A canary token (a marker string, not a secret), with brew install --verbose --debug and a loop snapshotting every process's command line:
    • GitHub answers "Bad credentials", rc 1.
    • The loop captured the strategy's curl command lines: 4,267 with the API URL and 4,270 with --header @….
    • Canary hits: 0 on brew's argv, in brew's output, in its cache, temp and log directories. 0 header files left.
    • Positive control: the same loop and grep caught a canary placed on a plain curl's argv, 45 hits.
  • Cross-host redirect: a local 302 from 127.0.0.1 to localhost. curl given --header @file sent Authorization to the first host only; the redirect target got the Accept header and no Authorization. GitHub's asset redirect is likewise cross-host (API host to the signed asset host).
  • Tempfile creates the header file 0600.
  • Style and audit: brew style unsigned-gg/unsigned gives 2 files, no offenses. brew audit --strict --tap unsigned-gg/unsigned gives rc 0.

Expected red, not a defect

  • This tap's CI installs every formula. Without the token as a repo secret, the cortex install fails with the no-token message above. Adding that secret is paas's follow-up; this PR adds no secret.
  • brew audit --online would probe the url and homepage anonymously, and a private repo answers 404.

Not yet tested (needs the token)

  • The authenticated download, install and brew test, and the mise github: install. The tarball nests the binary under one top-level directory; brew handles that, and mise must find cortex inside it.
  • That will run in a throwaway container with a 0600 --env-file, shredded afterwards. The token is never read or printed. A run with the token unset is the negative control.

Refs OPS-1744

…trategy

cortex's release assets are in a private repository. The tap gains
lib/github_private_release_download_strategy.rb, which downloads them
through GitHub's release-asset API with HOMEBREW_GITHUB_API_TOKEN:
- the token reaches curl only through a 0600 header file (--header
  @file) that is deleted after use: never on argv, never in a URL;
- the release is looked up by tag and the asset by exact name, then
  fetched with Accept: application/octet-stream; curl does not resend
  the header after the cross-host redirect to the signed asset URL;
- no unauthenticated HEAD probe of the private URL;
- it fails before any network call without a token, and refuses to
  run with HOMEBREW_CURL_VERBOSE or HOMEBREW_CURLRC, which can print
  request headers.

Formula/cortex.rb installs cortex v1.0.0-rc.46 (darwin and musl, both
architectures); each sha256 equals GitHub's asset digest. The licence
is proprietary, so license :cannot_represent. The README gains cortex's
brew and mise lines and the private-tool setup.

Refs OPS-1744
@todie

todie commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

Superseded by cerebral-work/homebrew-cerebral#4, the canonical tap for cortex now (Christian, 2026-10-24: "homebrew-cerebral; move the release formula there"). #4 carries this PR's private-release download strategy unchanged, cortex at v1.0.0-rc.47 on all four platforms (this PR was rc.46), antikithera v0.3.0, and tap CI that can fail. homebrew-unsigned keeps herdr (and kd).

@todie todie closed this Oct 24, 2026
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.

1 participant