Skip to content

feat(scan): attach the developer's SSH keys for private module fetches - #194

Merged
liamcervante merged 2 commits into
mainfrom
feat/fetch-auth-options
Jul 27, 2026
Merged

feat(scan): attach the developer's SSH keys for private module fetches#194
liamcervante merged 2 commits into
mainfrom
feat/fetch-auth-options

Conversation

@liamcervante

Copy link
Copy Markdown
Collaborator

Prepares the CLI for the parser's move to an in-process getter (grabber). grabber's SSH system fallback only consults the ssh-agent, so a developer whose key lives in ~/.ssh but isn't loaded into an agent would lose access to private git-over-ssh modules. This reads those on-disk keys and passes them explicitly as FetchAuth on GenericOptions.

SSH keys are the only thing the CLI needs to set — HTTPS credentials (keychain / store / netrc via git credential fill), ~/.ssh/known_hosts verification, and the agent are all still covered by grabber's system fallback on a dev machine.

Changes

  • internal/scanner.ResolveSSHFetchAuth builds FetchAuth.ssh_keys from either an explicit list (--ssh-key-file / INFRACOST_CLI_SSH_KEY_FILE, comma-separated) or, when unset, the standard ~/.ssh default key files (id_rsa, id_ecdsa, id_ed25519, …). Passphrase-protected and unreadable keys are skipped with a warning/debug log — they remain resolvable via the agent.
  • Keys travel with an empty host (offered as defaults for any host). Combined with grabber's key→agent fallback this never suppresses the agent: the on-disk key is tried first, the agent is the fallback.
  • Wired on every fetch-capable command — scan, price, policies — and the MCP scan/price tools (via cfg). The --ssh-key-file flag is registered on scan and price (mirroring --currency); the env var flows to all of them through cfg.

Notes

Checklist

The parser is moving to an in-process getter (grabber) whose SSH system
fallback only consults the ssh-agent, so a key sitting in ~/.ssh that
isn't loaded into an agent would stop working for private git-over-ssh
modules. Read the developer's on-disk keys and pass them as typed
FetchAuth on GenericOptions so they authenticate explicitly.

- Scan the standard ~/.ssh default key files, or an explicit list from
  the --ssh-key-file flag / INFRACOST_CLI_SSH_KEY_FILE env. Passphrase-
  protected and unreadable keys are skipped (the agent covers those).
- Keys travel with an empty host (offered as defaults for any host);
  grabber still falls back to the agent, so this never suppresses agent
  identities.
- Wired on every fetch-capable command (scan, price, policies) and the
  MCP scan/price tools via cfg. HTTPS creds, known_hosts and the agent
  stay covered by grabber's system fallback, so only SSH keys are set.

Requires the proto FetchAuth options (proto pin bumped here).
@liamcervante
liamcervante force-pushed the feat/fetch-auth-options branch from 6c928c3 to d9665c3 Compare July 24, 2026 12:27
@liamcervante
liamcervante marked this pull request as ready for review July 24, 2026 15:18
@liamcervante
liamcervante requested a review from a team July 24, 2026 15:18
@liamcervante
liamcervante merged commit e0a4505 into main Jul 27, 2026
5 checks passed
@liamcervante
liamcervante deleted the feat/fetch-auth-options branch July 27, 2026 16:32
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