Skip to content

v2: download the simulator from the install with the PAT (ENG-1730) - #11

Merged
Adam Tauber (asciimoo) merged 4 commits into
mainfrom
adamtauber/eng-1730-require-a-pat-to-download-the-simulator-served-through-the-action-v2
Nov 2, 2026
Merged

Adam Tauber (asciimoo) merged 4 commits into
mainfrom
adamtauber/eng-1730-require-a-pat-to-download-the-simulator-served-through-the-action-v2

Conversation

@asciimoo

@asciimoo Adam Tauber (asciimoo) commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Linear: ENG-1730

What

v2 of the action downloads linro-simulator from the customer's install instead of anonymously from the Marketplace:

  • GET <server>/api/simulator/download/<version>/<os>-<arch>.tar.gz with token as Authorization: Bearer. The token goes to curl through a config on stdin, never argv.
  • The file is checked against the install's X-Linro-Sha256 header before it runs. This is a second check: the install already verifies the Marketplace's sha256 and cuts the transfer short on a mismatch. A missing header is refused.
  • Breaking: server and token are required on every run, dry runs included.
  • Breaking: marketplace-url is removed.
  • server must be https://, or plain http:// only to a loopback install, so the token never goes over the network in clear.
  • 401, 403, 404, 5xx and network failures each get their own message.
  • ca-cert now applies to the download too. The download trusts only that bundle, because it goes only to the install. The install step runs in working-directory, so the path resolves the same way as for the CLI.

README, CHANGELOG (new) and the product how-to say this is v2 and why. @v1 keeps downloading anonymously until the Marketplace enforces /artifacts.

CI without a secret

CI used to run on dry-run with no token at all. It now runs against testdata/stub-install.py, a loopback stand-in for the install's download route (bearer token, X-Linro-Sha256). The stand-in takes the tarball from the public Marketplace anonymously. Once /artifacts is enforced in production, CI breaks unless the stand-in gets a key or CI moves to a real install with a secret. New refusal cases:

  • dry run without a token
  • dry run without a server
  • a refused token
  • plain http to a non-loopback install
  • a sha256 mismatch
  • a missing sha256 header

Depends on

The service route in linro-io/service#424. An install without it answers 404. Do not release v2 until that route is deployed to the installs our callers use.

Releasing (not done here: no tag was created or moved)

After merge, from a machine on the IP allow list:

  1. Publish release v2.0.0 from main and move the CHANGELOG heading off "unreleased".
  2. Create the major tag: git tag v2 v2.0.0 && git push origin v2. release.yml only verifies the major tag, and it fails with "v2 does not exist" until this is done.
  3. Leave v1 where it is.

Then the callers move to @v2:

  • github-integration-test (pr-simulate-gateway.yaml:757, plus its own direct download around :213)
  • workflows (terragrunt-plan-apply.yml:1173)
  • simulator-demo (simulate.yaml:81,93, PR only)

Tested

I extracted the install step and ran it locally (macOS arm64) against the stand-in:

  • v0.2.1 and latest download, verify and run
  • wrong token → 401 message
  • empty token refused
  • http://example.com refused
  • bad sha → refused
  • no sha header → refused
  • v99.99.99 → 404 message

I could not run shellcheck locally; the CI lint job runs it.

🤖 Generated with Claude Code

The CLI now comes from <server>/api/simulator/download/... with the token as
a bearer, checked against the install's X-Linro-Sha256. server and token are
required on every run, dry runs included, and marketplace-url is removed.
CI runs against a loopback stand-in install, so it still needs no secret.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every ::error:: is also recorded in $RUNNER_TEMP/linro-simulation-error, and
CI checks each refusal failed for its own reason, so a stub failure cannot
pass for the sha256 check. version is validated against the install's
pattern before any request, and --retry-max-time bounds the whole download
at 10 minutes. The README says ca-cert replaces the system roots for the
download. Fixes actionlint's required-input findings and SC2129.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@asciimoo

Copy link
Copy Markdown
Contributor Author

Claude: what the cold review found and what changed (bc367f2)

  1. The refusals asserted only outcome == failure. Every ::error:: now also goes to $RUNNER_TEMP/linro-simulation-error. After each case, testdata/expect-refusal.sh asserts both the failure and the case's own reason, then clears the file. A stub 502 can no longer stand in for the sha256 check. All 11 cases pass on CI, each with its own reason (run 41422287186).
  2. version was not validated. It is now checked against the install's pattern (^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$, after stripping a leading v) before any request, with a clear error. A new CI case covers it.
  3. Retries were unbounded. --retry-max-time 600 now bounds the whole download, retries included, at 10 minutes.
  4. --cacert and upper-case HTTPS:// are left as they are. The README now says the download uses ca-cert instead of the system roots, so the bundle must hold the CA that signed the install's certificate. The CHANGELOG says the same.

The same push also fixes the earlier lint failure: actionlint's required-input errors (an absent input is now passed as "") and SC2129.

Mutation check: run locally against the stand-in, restored from memory, all 6 caught by the reason check:

  • sha256 comparison dropped
  • missing header accepted
  • version not validated
  • 401 not told apart
  • plain http allowed
  • token not sent

…adline (ENG-1730)

The loopback check matched a prefix, so http://127.0.0.1:80@evil.example sent
the token in clear to evil.example. server is now parsed: no user info,
query or fragment; plain http only for exactly 127.0.0.1, localhost or [::1]
with an optional port; https needs a host name. A loopback install is
fetched with --noproxy '*'. The download runs in a deadline loop that gives
each attempt the time left, so 10 minutes is one wall-clock bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (ENG-1730)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@asciimoo

Copy link
Copy Markdown
Contributor Author

Claude: what the Codex sweep of bc367f2 found and what changed (head 11167fd)

  1. MAJOR: the loopback check matched a prefix. http://127.0.0.1:80@attacker.example passed it, and curl then sent the PAT in clear to attacker.example. server is now parsed and its whole authority checked:
    • User info (@ in the authority), a query, a fragment, a backslash or whitespace is refused.
    • Plain http:// is allowed only for exactly 127.0.0.1, localhost or [::1] with an optional numeric port (^(127\.0\.0\.1|localhost|\[::1\])(:[0-9]{1,5})?$).
    • https:// needs a host-name-shaped authority with an optional port.
    • New CI refusals each assert their own reason: https://user@…, http://127.0.0.1:80@evil.example, http://localhost.evil.com, http://127.0.0.1.nip.io, http://[::1]@evil.example. All 16 refusal cases pass on run 41434955519.
  2. MAJOR: proxy variables applied to loopback. A loopback server is now fetched with --noproxy '*'. A new CI step sets http_proxy, HTTPS_PROXY and ALL_PROXY to a closed port and still downloads from the loopback stand-in, which shows the proxy was bypassed. The README says https downloads follow the runner's proxy settings, as before.
  3. Minor: the time bound was not one deadline. curl's --retry is replaced by a deadline loop with no timeout binary: each attempt gets --max-time of whatever time is left out of 10 minutes. Retries are for transient failures only (curl 7/28/52/55/56, HTTP 408/429/5xx), at most 4 attempts. Checked locally with the deadline set to 5 s against a server that accepts and never answers: the whole run ended at 5 s.

Mutation check: run locally against the stand-in, restored from memory, 10/10 caught:

  • the five earlier ones: sha comparison dropped, missing header accepted, version not validated, 401 not told apart, token not sent
  • user-info check dropped
  • loopback regex unanchored
  • plain http allowed to any host
  • https host not checked
  • --noproxy dropped (with proxy variables set)

Also in this push:

  • CI env names: the first CI run on this head failed to parse because the step set both http_proxy and HTTP_PROXY, and workflow env names are case-insensitive. Each variable is now set once.
  • Stand-in: the stand-in install answers 502 instead of crashing when its own Marketplace fetch fails.

No tag or release was made.

@asciimoo
Adam Tauber (asciimoo) marked this pull request as ready for review November 2, 2026 11:16
@asciimoo
Adam Tauber (asciimoo) merged commit 36003b7 into main Nov 2, 2026
6 checks passed
@asciimoo
Adam Tauber (asciimoo) deleted the adamtauber/eng-1730-require-a-pat-to-download-the-simulator-served-through-the-action-v2 branch November 2, 2026 12:49
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