Browse files

NmapUpload: detect if service information exists

And avoid parsing if no <service> node is present for a given <port>.

This commit closes #78

Kudos to @MrK
  • Loading branch information...
1 parent 34f7276 commit 34013fb22e11e5a6ae188689ef453eb1d6a51bbf @etdsoft etdsoft committed Jul 15, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 vendor/plugins/nmap_upload/lib/nmap_upload/filters.rb
View
12 vendor/plugins/nmap_upload/lib/nmap_upload/filters.rb
@@ -67,12 +67,12 @@ def self.import(params={})
host.each_port do |port|
port_info = ''
port_info << "\t\tPort ##{port.number}/#{port.protocol} is #{port.state} (#{port.reason})\n"
- srv = port.service_node
- port_info << "\t\t\tService: #{srv['name']}\n" if srv['name']
- port_info << "\t\t\tProduct: #{srv['product']}\n" if srv['product']
- port_info << "\t\t\tVersion: #{srv['version'] }\n" if srv['version']
- port_info << "\n"
-
+ if (srv = port.service_node)
+ port_info << "\t\t\tService: #{srv['name']}\n" if srv['name']
+ port_info << "\t\t\tProduct: #{srv['product']}\n" if srv['product']
+ port_info << "\t\t\tVersion: #{srv['version'] }\n" if srv['version']
+ port_info << "\n"
+ end
port_hash["#{port.number}/#{port.protocol}"] = port_info
host_info << port_info
end

0 comments on commit 34013fb

Please sign in to comment.