capistrano / sshkit

A toolkit for deploying code and assets to servers in a repeatable, testable, reliable way.
MIT License
1.13k stars 253 forks source link

Handle unbracketed ipv6 addresses #538

Closed jeromedalbert closed 3 weeks ago

jeromedalbert commented 1 month ago

Fix for https://github.com/capistrano/sshkit/issues/537.

Solution

Notes

My previous solution tweaked the regex of the existing IPv6HostWithPortParser, but this resulted in a regression for local hostnames, so I am using Resolv::IPv6::Regex instead, which should prove more stable. I added an extra unit test to validate the local hostname scenario.

jeromedalbert commented 3 weeks ago

@mattbrictson Good point. Because the IPv6 parser still needs a high priority, we need a strict IPv6 regex. Resolv::IPv6::Regex seems to be the way to go, it is pretty involved in order to catch all the different IPv6 formats, so that should be plenty strict for our needs.

I have updated the PR and description accordingly, and added an extra unit test for the db:22 scenario you mentioned.