From 29a63f302f9aebcd3d24fd200909b30259bc958e Mon Sep 17 00:00:00 2001 From: sjanusz-r7 Date: Tue, 15 Jul 2025 21:03:59 +0100 Subject: [PATCH 1/2] Add ip is_name test --- spec/rex/socket_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/rex/socket_spec.rb b/spec/rex/socket_spec.rb index 12137b2..6c047b6 100644 --- a/spec/rex/socket_spec.rb +++ b/spec/rex/socket_spec.rb @@ -370,6 +370,13 @@ described_class.is_name?(try) end + context 'with an ip address' do + let(:try) { '192.168.1.1' } + it 'should return false' do + expect(name).to eq false + end + end + context 'with a hostname' do let(:try) { "localhost" } it "should return true" do From 7f3cda8438493987f726296953210c8f8dac6dae Mon Sep 17 00:00:00 2001 From: sjanusz-r7 Date: Tue, 15 Jul 2025 21:20:19 +0100 Subject: [PATCH 2/2] is_name? returns false if value is ip address --- lib/rex/socket.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rex/socket.rb b/lib/rex/socket.rb index cee793e..97bc776 100644 --- a/lib/rex/socket.rb +++ b/lib/rex/socket.rb @@ -133,7 +133,7 @@ def self.support_ipv6? # Determine whether this is a valid DNS name without trying to resolve it # def self.is_name?(name) - return false if name.length > 253 + return false if name.length > 253 || name =~ MATCH_IPV4 || name =~ MATCH_IPV6 name.delete_suffix('.') =~ MATCH_DNS_NAME ? (name =~ /\s/).nil? : false end