From be0e1a061a428d934d826d3b848ceb77e26add30 Mon Sep 17 00:00:00 2001 From: Sam Gunaratne Date: Wed, 2 Dec 2026 11:29:50 -0700 Subject: [PATCH 1/2] Bump addressable to 2.10.0 and pass docker host:port as authority addressable 2.10.0 validates the host component and rejects a colon outside an IP literal. DockerURIConverter passed "host:port" as host:, so converting any image reference with a registry port raised Addressable::URI::InvalidURIError, which fails the host:port examples in docker_uri_converter_spec.rb (and the dependabot bump in #5710). Pass the value as authority: instead, which accepts host[:port] and yields the same output on 2.9.2 and 2.10.0. Co-Authored-By: Claude Sonnet 5.5 --- Gemfile.lock | 2 +- lib/cloud_controller/diego/docker/docker_uri_converter.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 277733d13d4..fd39478a7b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,7 +32,7 @@ GEM securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) - addressable (2.9.2) + addressable (2.10.0) public_suffix (>= 2.0.2, < 8.0) ast (2.4.3) backport (1.2.0) diff --git a/lib/cloud_controller/diego/docker/docker_uri_converter.rb b/lib/cloud_controller/diego/docker/docker_uri_converter.rb index 9dfe71960ad..46988f5d061 100644 --- a/lib/cloud_controller/diego/docker/docker_uri_converter.rb +++ b/lib/cloud_controller/diego/docker/docker_uri_converter.rb @@ -10,7 +10,7 @@ def convert(docker_uri) # add tag or digest part as fragment to the uri, since ruby uri parser confuses with ':' # when it presented in path. We convert user's uri to, for example; # docker://docker.io/publish/ubuntu:latest -> docker://docker.io/publish/ubuntu#latest - Addressable::URI.new(scheme: 'docker', host: host, path: path, fragment: tag_digest).to_s + Addressable::URI.new(scheme: 'docker', authority: host, path: path, fragment: tag_digest).to_s end end end From c914f58fcaa2cafc58ef48689010a74cc0c8d75a Mon Sep 17 00:00:00 2001 From: Sam Gunaratne Date: Wed, 2 Dec 2026 14:02:05 -0700 Subject: [PATCH 2/2] Cover docker registry authority edge cases in DockerURIConverter spec Passing the registry as `authority:` changes behaviour for inputs the existing examples do not exercise. Pin the current behaviour for IPv6 literals, zero and zero-padded ports, non-numeric and empty ports, and userinfo. Co-Authored-By: Claude Sonnet 5.5 --- .../diego/docker/docker_uri_converter_spec.rb | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/spec/unit/lib/cloud_controller/diego/docker/docker_uri_converter_spec.rb b/spec/unit/lib/cloud_controller/diego/docker/docker_uri_converter_spec.rb index 9b963dc1a46..b0596de88d0 100644 --- a/spec/unit/lib/cloud_controller/diego/docker/docker_uri_converter_spec.rb +++ b/spec/unit/lib/cloud_controller/diego/docker/docker_uri_converter_spec.rb @@ -73,6 +73,54 @@ module VCAP::CloudController end end + context('and the host is an IPv6 literal with a port') do + let(:image_url) { '[::1]:5000/image' } + + it 'builds the correct rootFS path' do + expect(converter.convert(image_url)).to eq('docker://[::1]:5000/image') + end + end + + context('and the port is zero') do + let(:image_url) { 'example.com:0/image' } + + it 'drops the port' do + expect(converter.convert(image_url)).to eq('docker://example.com/image') + end + end + + context('and the port has leading zeros') do + let(:image_url) { 'example.com:05000/image' } + + it 'normalizes the port' do + expect(converter.convert(image_url)).to eq('docker://example.com:5000/image') + end + end + + context('and the port is not numeric') do + let(:image_url) { 'example.com:abc/image' } + + it 'raises an InvalidURIError' do + expect { converter.convert(image_url) }.to raise_error(Addressable::URI::InvalidURIError, /Invalid port number/) + end + end + + context('and the port is empty') do + let(:image_url) { 'example.com:/image' } + + it 'raises an InvalidURIError' do + expect { converter.convert(image_url) }.to raise_error(Addressable::URI::InvalidURIError, /Invalid port number/) + end + end + + context('and the registry contains userinfo') do + let(:image_url) { 'user:pass@example.com/image' } + + it 'keeps the userinfo in the rootFS path' do + expect(converter.convert(image_url)).to eq('docker://user:pass@example.com/image') + end + end + context('and user/image') do let(:image_url) { '10.244.2.6:8080/user/image' }