Skip to content

fix(core): bracket IPv6 bind addresses in forward arg and access URL#2449

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:fix-core-forward-ipv6-brackets/aw
Open

fix(core): bracket IPv6 bind addresses in forward arg and access URL#2449
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:fix-core-forward-ipv6-brackets/aw

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

Summary

ForwardSpec::parse supports IPv6 bind addresses (e.g. openshell forward ::1:8080, covered by an existing parse test), but two formatters emitted unbracketed output:

  • ssh_forward_arg() produced ::1:8080:127.0.0.1:8080, which OpenSSH misparses — the -L forward fails
  • access_url() produced http://::1:8080/, an invalid URL (RFC 3986 requires [::1]) printed verbatim to users

This PR supersedes #2409, which was auto-closed by the vouch-check workflow before I was vouched.

Related Issue

N/A — small fix found during code review. The same file already brackets IPv6 literals correctly in format_gateway_url; this applies the same logic to the forward spec.

Changes

  • Added a bracket_ipv6 helper (same condition as format_gateway_url) and used it in ssh_forward_arg() and access_url()
  • Extended forward_spec_ssh_forward_arg and forward_spec_access_url tests with ::1 cases

Testing

  • mise run pre-commit passes (mise unavailable in this environment; ran equivalent cargo fmt + cargo clippy -p openshell-core --all-targets — clean)
  • Unit tests added/updated (cargo test -p openshell-core forward_spec — 9 passed)
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

ForwardSpec::parse supports IPv6 binds (e.g. '::1:8080'), but
ssh_forward_arg emitted '::1:8080:127.0.0.1:8080', which OpenSSH
misparses, and access_url printed the invalid URL 'http://::1:8080/'.

Bracket IPv6 literals as OpenSSH and RFC 3986 require, matching the
bracketing logic already used by format_gateway_url, and extend the
existing forward spec tests with IPv6 cases.

Signed-off-by: Andrew White <andrewh@cdw.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

All contributors have signed the DCO ✍️ ✅
Posted by the DCO Assistant Lite bot.

@andrewwhitecdw

Copy link
Copy Markdown
Author

I have read the DCO document and I hereby sign the DCO.

@johntmyers johntmyers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

PR Review Status

Validation: This is a project-valid, concentrated core bug fix. It restores valid OpenSSH and URL formatting for an IPv6 bind address; PR #2409 was the same author's earlier submission and was closed only by the vouch gate.
Head SHA: bc87935b91607195c7c6b5e281a78e8b55b7cbc8

Review findings:

  • The focused implementation and regression tests are sound; no correctness or security defect was found.
  • The new helper leaves identical IPv6-bracketing logic in format_gateway_url(); the inline suggestion asks to consolidate that logic so the two paths cannot drift.
  • This changes direct user-visible forwarding behavior and printed access URLs. Please add an IPv6 example to the existing Port Forwarding section in docs/sandboxes/manage-sandboxes.mdx, including the bracketed http://[::1]:8000/ output. Existing navigation already covers that page, so docs/index.yml does not need to change.

Docs: missing for this direct UX change.

E2E/pipeline: deferred until review feedback is resolved.

Next state: gator:in-review


/// Bracket an IPv6 literal for use in `host:port` contexts (SSH `-L`
/// arguments and URLs); leave other addresses unchanged.
fn bracket_ipv6(addr: &str) -> String {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

Suggestion: format_gateway_url() still duplicates this exact IPv6-bracketing logic. Please have it call bracket_ipv6(host) as well so URL and forwarding behavior cannot drift. Its existing tests can remain unchanged.

@johntmyers johntmyers added the gator:in-review Gator is reviewing or awaiting PR review feedback label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gator:in-review Gator is reviewing or awaiting PR review feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants