Skip to content

Commit 6a4d63c

Browse files
committed
Drop explicit IPAddr to String coercion
MSP-12611
1 parent 11f9f15 commit 6a4d63c

File tree

32 files changed

+148
-148
lines changed

32 files changed

+148
-148
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ GIT
3333

3434
GIT
3535
remote: git://github.com/rapid7/metasploit_data_models.git
36-
revision: 28d2b7f40d9154f8a6a2005b33b9c54a74b59a08
36+
revision: caa8e1a64cd145b419cbbfb5a7dad3b75090e44e
3737
branch: staging/rails-4.0
3838
specs:
3939
metasploit_data_models (0.24.0.pre.rails.pre.4.0)

lib/msf/core/auxiliary/report.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def report_auth_info(opts={})
203203
port = opts[:service].port
204204
proto = opts[:service].proto
205205
service_name = opts[:service].name
206-
host = opts[:service].host.address.to_s
206+
host = opts[:service].host.address
207207
else
208208
port = opts.fetch(:port)
209209
service_name = opts.fetch(:sname, nil)

lib/msf/core/db_export.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def extract_web_site_info(report_file)
482482
end
483483

484484
site = e
485-
el = create_xml_element("host", site.service.host.address.to_s)
485+
el = create_xml_element("host", site.service.host.address)
486486
report_file.write(" #{el}\n")
487487

488488
el = create_xml_element("port", site.service.port)
@@ -509,7 +509,7 @@ def extract_web_info(report_file, tag, entries)
509509
el = create_xml_element("vhost", site.vhost)
510510
report_file.write(" #{el}\n")
511511

512-
el = create_xml_element("host", site.service.host.address.to_s)
512+
el = create_xml_element("host", site.service.host.address)
513513
report_file.write(" #{el}\n")
514514

515515
el = create_xml_element("port", site.service.port)

lib/msf/core/db_manager/service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ def report_service(opts)
6565

6666
if addr.kind_of? ::Mdm::Host
6767
host = addr
68-
addr = host.address.to_s
68+
addr = host.address
6969
else
7070
host = report_host(hopts)
7171
end
7272

7373
if opts[:port].to_i.zero?
74-
dlog("Skipping port zero for service '%s' on host '%s'" % [opts[:name],host.address.to_s])
74+
dlog("Skipping port zero for service '%s' on host '%s'" % [opts[:name],host.address])
7575
return nil
7676
end
7777

lib/msf/core/db_manager/web.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def report_web_site(opts)
242242
host.save!
243243
=end
244244

245-
vhost ||= host.address.to_s
245+
vhost ||= host.address
246246
site = ::Mdm::WebSite.where(vhost: vhost, service_id: serv[:id]).first_or_initialize
247247
site.options = opts[:options] if opts[:options]
248248

lib/msf/core/rpc/v10/rpc_db.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def rpc_create_credential(xopts)
128128
opts[:last_attempted_at] = opts[:last_attempted_at].to_datetime
129129
login = create_credential_login(opts)
130130

131-
ret[:host] = login.service.host.address.to_s,
131+
ret[:host] = login.service.host.address,
132132
ret[:sname] = login.service.name
133133
ret[:status] = login.status
134134
end
@@ -157,7 +157,7 @@ def rpc_creds(xopts)
157157
sname = ''
158158
unless cred.logins.empty?
159159
login = cred.logins.first
160-
host = login.service.host.address.to_s
160+
host = login.service.host.address
161161
sname = login.service.name.to_s if login.service.name.present?
162162
port = login.service.port.to_i
163163
proto = login.service.proto.to_s
@@ -192,7 +192,7 @@ def rpc_hosts(xopts)
192192
wspace.hosts.where(conditions).offset(offset).order(:address).limit(limit).each do |h|
193193
host = {}
194194
host[:created_at] = h.created_at.to_i
195-
host[:address] = h.address.to_s
195+
host[:address] = h.address
196196
host[:mac] = h.mac.to_s
197197
host[:name] = h.name.to_s
198198
host[:state] = h.state.to_s
@@ -228,7 +228,7 @@ def rpc_services( xopts)
228228
wspace.services.includes(:host).where(conditions).offset(offset).limit(limit).each do |s|
229229
service = {}
230230
host = s.host
231-
service[:host] = host.address.to_s || "unknown"
231+
service[:host] = host.address || "unknown"
232232
service[:created_at] = s[:created_at].to_i
233233
service[:updated_at] = s[:updated_at].to_i
234234
service[:port] = s[:port]
@@ -267,7 +267,7 @@ def rpc_vulns(xopts)
267267
vuln[:proto] = nil
268268
end
269269
vuln[:time] = v.created_at.to_i
270-
vuln[:host] = v.host.address.to_s || nil
270+
vuln[:host] = v.host.address || nil
271271
vuln[:name] = v.name
272272
vuln[:refs] = reflist.join(',')
273273
ret[:vulns] << vuln
@@ -365,7 +365,7 @@ def rpc_get_host(xopts)
365365
if(h)
366366
host = {}
367367
host[:created_at] = h.created_at.to_i
368-
host[:address] = h.address.to_s
368+
host[:address] = h.address
369369
host[:mac] = h.mac.to_s
370370
host[:name] = h.name.to_s
371371
host[:state] = h.state.to_s
@@ -433,7 +433,7 @@ def rpc_get_service(xopts)
433433
services.each do |s|
434434
service = {}
435435
host = s.host
436-
service[:host] = host.address.to_s || "unknown"
436+
service[:host] = host.address || "unknown"
437437
service[:created_at] = s[:created_at].to_i
438438
service[:updated_at] = s[:updated_at].to_i
439439
service[:port] = s[:port]
@@ -482,7 +482,7 @@ def rpc_get_note(xopts)
482482
notes.each do |n|
483483
note = {}
484484
host = n.host
485-
note[:host] = host.address.to_s || "unknown"
485+
note[:host] = host.address || "unknown"
486486
if n.service
487487
note[:port] = n.service.port
488488
note[:proto] = n.service.proto
@@ -508,7 +508,7 @@ def rpc_get_client(xopts)
508508
if(c)
509509
client = {}
510510
host = c.host
511-
client[:host] = host.address.to_s
511+
client[:host] = host.address
512512
client[:created_at] = c.created_at.to_i
513513
client[:updated_at] = c.updated_at.to_i
514514
client[:ua_string] = c.ua_string.to_s
@@ -567,7 +567,7 @@ def rpc_notes(xopts)
567567
note[:time] = n.created_at.to_i
568568
note[:host] = ""
569569
note[:service] = ""
570-
note[:host] = n.host.address.to_s if(n.host)
570+
note[:host] = n.host.address if(n.host)
571571
note[:service] = n.service.name || n.service.port if(n.service)
572572
note[:type ] = n.ntype.to_s
573573
note[:data] = n.data.inspect
@@ -641,7 +641,7 @@ def rpc_del_vuln(xopts)
641641
deleted = []
642642
vulns.each do |v|
643643
dent = {}
644-
dent[:address] = v.host.address.to_s if v.host
644+
dent[:address] = v.host.address if v.host
645645
dent[:port] = v.service.port if v.service
646646
dent[:proto] = v.service.proto if v.service
647647
dent[:name] = v.name
@@ -709,7 +709,7 @@ def rpc_del_note(xopts)
709709
deleted = []
710710
notes.each do |n|
711711
dent = {}
712-
dent[:address] = n.host.address.to_s if n.host
712+
dent[:address] = n.host.address if n.host
713713
dent[:port] = n.service.port if n.service
714714
dent[:proto] = n.service.proto if n.service
715715
dent[:ntype] = n.ntype
@@ -766,7 +766,7 @@ def rpc_del_service(xopts)
766766
deleted = []
767767
services.each do |s|
768768
dent = {}
769-
dent[:address] = s.host.address.to_s
769+
dent[:address] = s.host.address
770770
dent[:port] = s.port
771771
dent[:proto] = s.proto
772772
deleted << dent
@@ -798,7 +798,7 @@ def rpc_del_host(xopts)
798798
end
799799
deleted = []
800800
hosts.each do |h|
801-
deleted << h.address.to_s
801+
deleted << h.address
802802
h.destroy
803803
end
804804

@@ -828,7 +828,7 @@ def rpc_events(xopts)
828828

829829
wspace.events.offset(offset).limit(limit).each do |e|
830830
event = {}
831-
event[:host] = e.host.address.to_s if(e.host)
831+
event[:host] = e.host.address if(e.host)
832832
event[:created_at] = e.created_at.to_i
833833
event[:updated_at] = e.updated_at.to_i
834834
event[:name] = e.name
@@ -873,7 +873,7 @@ def rpc_loots(xopts)
873873
ret[:loots] = []
874874
wspace.loots.offset(offset).limit(limit).each do |l|
875875
loot = {}
876-
loot[:host] = l.host.address.to_s if(l.host)
876+
loot[:host] = l.host.address if(l.host)
877877
loot[:service] = l.service.name || l.service.port if(l.service)
878878
loot[:ltype] = l.ltype
879879
loot[:ctype] = l.content_type
@@ -928,7 +928,7 @@ def rpc_get_vuln(xopts)
928928
vulns.each do |v|
929929
vuln= {}
930930
host= v.host
931-
vuln[:host] = host.address.to_s || "unknown"
931+
vuln[:host] = host.address || "unknown"
932932
if v.service
933933
vuln[:port] = v.service.port
934934
vuln[:proto] = v.service.proto
@@ -963,7 +963,7 @@ def rpc_clients(xopts)
963963

964964
wspace.clients.includes(:host).where(conditions).offset(offset).limit(limit).each do |c|
965965
client = {}
966-
client[:host] = c.host.address.to_s if c.host
966+
client[:host] = c.host.address if c.host
967967
client[:ua_string] = c.ua_string
968968
client[:ua_name] = c.ua_name
969969
client[:ua_ver] = c.ua_ver
@@ -1007,7 +1007,7 @@ def rpc_del_client(xopts)
10071007
deleted = []
10081008
clients.each do |c|
10091009
dent = {}
1010-
dent[:address] = c.host.address.to_s
1010+
dent[:address] = c.host.address
10111011
dent[:ua_string] = c.ua_string
10121012
deleted << dent
10131013
c.destroy

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,7 @@ def option_values_target_addrs
31173117
hosts = {}
31183118
framework.db.each_service(framework.db.workspace) do |service|
31193119
if (service.port == mport)
3120-
hosts[ service.host.address.to_s ] = true
3120+
hosts[ service.host.address ] = true
31213121
end
31223122
end
31233123

@@ -3128,7 +3128,7 @@ def option_values_target_addrs
31283128
# List all hosts in the database
31293129
else
31303130
framework.db.each_host(framework.db.workspace) do |host|
3131-
res << host.address.to_s
3131+
res << host.address
31323132
end
31333133
end
31343134

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def cmd_hosts(*args)
411411
host_ranges.each do |range|
412412
range.each do |address|
413413
host = framework.db.find_or_create_host(:host => address)
414-
print_status("Time: #{host.created_at} Host: host=#{host.address.to_s}")
414+
print_status("Time: #{host.created_at} Host: host=#{host.address}")
415415
end
416416
end
417417
return
@@ -483,7 +483,7 @@ def cmd_hosts(*args)
483483

484484
tbl << columns
485485
if set_rhosts
486-
addr = (host.scope ? host.address.to_s + '%' + host.scope : host.address.to_s)
486+
addr = (host.scope ? host.address + '%' + host.scope : host.address)
487487
rhosts << addr
488488
end
489489
if mode == [:delete]
@@ -634,7 +634,7 @@ def cmd_services(*args)
634634
info[:name] = names.first.downcase if names and names.first
635635

636636
svc = framework.db.find_or_create_service(info)
637-
print_status("Time: #{svc.created_at} Service: host=#{svc.host.address.to_s} port=#{svc.port} proto=#{svc.proto} name=#{svc.name}")
637+
print_status("Time: #{svc.created_at} Service: host=#{svc.host.address} port=#{svc.port} proto=#{svc.proto} name=#{svc.name}")
638638
end
639639
end
640640
return
@@ -665,10 +665,10 @@ def cmd_services(*args)
665665
)
666666
end
667667

668-
columns = [host.address.to_s] + col_names.map { |n| service[n].to_s || "" }
668+
columns = [host.address] + col_names.map { |n| service[n].to_s || "" }
669669
tbl << columns
670670
if set_rhosts
671-
addr = (host.scope ? host.address.to_s + '%' + host.scope : host.address.to_s )
671+
addr = (host.scope ? host.address + '%' + host.scope : host.address )
672672
rhosts << addr
673673
end
674674

@@ -789,12 +789,12 @@ def cmd_vulns(*args)
789789
next unless ports.empty? or ports.include? vuln.service.port
790790
# Same for service names
791791
next unless svcs.empty? or svcs.include?(vuln.service.name)
792-
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address.to_s} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
792+
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
793793

794794
else
795795
# This vuln has no service, so it can't match
796796
next unless ports.empty? and svcs.empty?
797-
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address.to_s} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
797+
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
798798
end
799799
if set_rhosts
800800
addr = (host.scope ? host.address + '%' + host.scope : host.address)
@@ -1079,11 +1079,11 @@ def creds_search(*args)
10791079
# the user-supplied RangeWalker, then we don't have any reason to
10801080
# print it out. However, we treat the absence of ranges as meaning
10811081
# all hosts.
1082-
if host_ranges.present? && !host_ranges.any? { |range| range.include?(login.service.host.address.to_s) }
1082+
if host_ranges.present? && !host_ranges.any? { |range| range.include?(login.service.host.address) }
10831083
next
10841084
end
1085-
row = [ login.service.host.address.to_s ]
1086-
rhosts << login.service.host.address.to_s
1085+
row = [ login.service.host.address ]
1086+
rhosts << login.service.host.address
10871087
if login.service.name.present?
10881088
row << "#{login.service.port}/#{login.service.proto} (#{login.service.name})"
10891089
else
@@ -1250,7 +1250,7 @@ def cmd_notes(*args)
12501250
break if not host
12511251
note = framework.db.find_or_create_note(:host => host, :type => type, :data => data)
12521252
break if not note
1253-
print_status("Time: #{note.created_at} Note: host=#{host.address.to_s} type=#{note.ntype} data=#{note.data}")
1253+
print_status("Time: #{note.created_at} Note: host=#{host.address} type=#{note.ntype} data=#{note.data}")
12541254
}
12551255
}
12561256
return
@@ -1317,9 +1317,9 @@ def cmd_notes(*args)
13171317
msg = "Time: #{note.created_at} Note:"
13181318
if (note.host)
13191319
host = note.host
1320-
msg << " host=#{note.host.address.to_s}"
1320+
msg << " host=#{note.host.address}"
13211321
if set_rhosts
1322-
addr = (host.scope ? host.address.to_s + '%' + host.scope : host.address.to_s )
1322+
addr = (host.scope ? host.address + '%' + host.scope : host.address )
13231323
rhosts << addr
13241324
end
13251325
end
@@ -1475,7 +1475,7 @@ def cmd_loot(*args)
14751475
)
14761476
end
14771477
row = []
1478-
row.push( (loot.host ? loot.host.address.to_s : "") )
1478+
row.push( (loot.host ? loot.host.address : "") )
14791479
if (loot.service)
14801480
svc = (loot.service.name ? loot.service.name : "#{loot.service.port}/#{loot.service.proto}")
14811481
row.push svc

lib/rex/parser/burp_session_nokogiri.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def report_web_host_info
155155
return unless @state[:uri].kind_of? URI::HTTP
156156
return unless @state[:web_site].service.host.name.to_s.empty?
157157
host_info = {:workspace => @args[:wspace]}
158-
host_info[:address] = @state[:web_site].service.host.address.to_s
158+
host_info[:address] = @state[:web_site].service.host.address
159159
host_info[:name] = @state[:uri].host
160160
report_db(:host, host_info)
161161
end

modules/auxiliary/analyze/jtr_oracle_fast.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def crack(format)
5151
print_error("Unable to read #{myloot.path} \n #{e}")
5252
end
5353
oracle_array.each do |row|
54-
hashlist.write("#{row[0]}:#{row[1]}:#{myloot.host.address.to_s}:#{myloot.service.port}\n")
54+
hashlist.write("#{row[0]}:#{row[1]}:#{myloot.host.address}:#{myloot.service.port}\n")
5555
end
5656
end
5757
hashlist.close

0 commit comments

Comments
 (0)