Skip to content

mitm: address remaining review on #151#152

Merged
dangtony98 merged 3 commits intomainfrom
mitm/post-151-cleanup
May 6, 2026
Merged

mitm: address remaining review on #151#152
dangtony98 merged 3 commits intomainfrom
mitm/post-151-cleanup

Conversation

@dangtony98
Copy link
Copy Markdown
Contributor

Summary

Three findings from the post-merge review on #151 that landed after the squash:

  • Banner host (cmd/run.go:149): hardcoded 127.0.0.1 in the "routing HTTP/HTTPS through MITM proxy" banner while augmentEnvWithMITM derives the host from --address. Misleading on remote vault deploys. Extracted resolveMITMHost(addr) so banner and env-var path share one source.
  • IPv6 test naming (internal/mitm/forward_test.go): TestMITMForwardIPv6LiteralCanonicalises was named for the no-port canonicalisation branch, but the request URL carries an explicit port — net.SplitHostPort succeeds in the old code and the buggy fallback is never taken. The assertion actually verifies the Host-header port-preservation fix. Renamed to TestMITMForwardIPv6PreservesHostHeader and rewrote the comment to match.
  • Dead instruction files: only persistent_instructions_admin.txt is //go:embed-ed; both invite-redeem paths in handle_agents.go hardcode persistentInstructionsAdmin regardless of role. The other four files (persistent_instructions_member.txt, persistent_instructions_proxy.txt, persistent_agent_instructions.txt, instructions.txt) shipped on disk but never reached any agent. Doc cross-syncs kept repainting them. Deleted.

Plus a small /simplify follow-up tightening the resolveMITMHost doc comment.

Test plan

  • go build ./...
  • go test ./cmd/... ./internal/mitm/... ./internal/server/...

dangtony98 added 2 commits May 5, 2026 20:10
Three findings from the post-merge review pass:

1. cmd/run.go:149 hardcoded 127.0.0.1 in the "routing HTTP/HTTPS through
   MITM proxy" banner while augmentEnvWithMITM derives the actual host
   from the parsed --address. With a remote vault server the banner
   misled operators debugging proxy connectivity. Extracted
   resolveMITMHost(addr) so both the env-var path and the banner pull
   from the same source.

2. internal/mitm/forward_test.go:601 was named
   TestMITMForwardIPv6LiteralCanonicalises but the request line carries
   an explicit port — net.SplitHostPort succeeds in the old code, the
   buggy double-bracket fallback is never taken, and what the assertion
   actually verifies is the Host-header port-preservation fix. Renamed
   to TestMITMForwardIPv6PreservesHostHeader and rewrote the comment to
   match. End-to-end coverage of the no-port canonicalisation branch
   would need to bind port 80 on ::1, which is impractical for CI.

3. Only persistent_instructions_admin.txt is //go:embed-ed in
   handle_agents.go; both invite-redeem paths hardcode
   persistentInstructionsAdmin for every redeeming agent regardless of
   role. The other four files (persistent_instructions_member.txt,
   persistent_instructions_proxy.txt, persistent_agent_instructions.txt,
   instructions.txt) shipped on disk but never reached any agent. Doc
   cross-syncs kept repainting them. Deleted.
/simplify finding: the comment narrated the change ("Single source of
truth for both the env-var path and the operator-facing banner") rather
than describing the function contract. Trimmed to purpose + fallback
behaviour, dropped the call-site enumeration that would go stale on
the next caller.
@infisical-review-police
Copy link
Copy Markdown

💬 Discussion in Slack: #pr-review-agent-vault-152-mitm-address-remaining-review-on-151

Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel.

Comment thread cmd/run.go
Comment thread internal/mitm/forward_test.go Outdated
Address review on #152:

- BuildProxyEnv composed HTTPS_PROXY/HTTP_PROXY via fmt.Sprintf("%s:%d",
  host, port). For IPv6 --address (e.g. http://[::1]:14321), resolveMITMHost
  returns the bare "::1" (url.Hostname strips brackets), so the proxy URL
  came out as "https://tok:v@::1:14322" — net.SplitHostPort rejects the
  authority as "too many colons", failing every outbound request from the
  child agent. Switch to net.JoinHostPort for both env.go:49 and the
  cosmetic banner at run.go:149.
- forward_test.go inline comment for TestMITMForwardIPv6PreservesHostHeader
  still claimed the URL was the no-port form; it actually carries an
  explicit ephemeral port. Realigned with the new outer docstring.

https://claude.ai/code/session_011CrrNcAGDQvCLgvj79Cui2
@dangtony98 dangtony98 merged commit 07c1460 into main May 6, 2026
9 checks passed
@dangtony98 dangtony98 deleted the mitm/post-151-cleanup branch May 6, 2026 04:17
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