Warn the user if there's a truncated nmap file.

git-svn-id: file:///home/svn/framework3/trunk@12704 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Tod Beardsley 2011-05-24 21:48:22 +00:00
parent 230295cc1b
commit 38504b39a8
1 changed files with 15 additions and 2 deletions

View File

@ -33,6 +33,7 @@ module Rex
@args = args @args = args
@db = db @db = db
@state = {} @state = {}
@state[:current_tag] = {}
@block = block if block @block = block if block
@report_data = {:wspace => args[:wspace]} @report_data = {:wspace => args[:wspace]}
super() super()
@ -113,6 +114,7 @@ module Rex
def start_element(name=nil,attrs=[]) def start_element(name=nil,attrs=[])
attrs = normalize_attrs(attrs) attrs = normalize_attrs(attrs)
block = @block block = @block
@state[:current_tag][name] = true
case name case name
when "host" when "host"
@state[:in_host] = true @state[:in_host] = true
@ -270,6 +272,7 @@ module Rex
# When we exit a tag, this is triggered. # When we exit a tag, this is triggered.
def end_element(name=nil) def end_element(name=nil)
block = @block block = @block
@state[:current_tag].delete name
case name case name
when "os" when "os"
collect_os_data collect_os_data
@ -299,7 +302,17 @@ module Rex
report_uptime(host_object) report_uptime(host_object)
report_traceroute(host_object) report_traceroute(host_object)
end end
@state = {} @state.delete_if {|k| k != :current_tag}
end
end
def end_document
block = @block
unless @state[:current_tag].empty?
missing_ends = @state[:current_tag].keys.map {|x| "'#{x}'"}.join(", ")
msg = "Warning, the provided file is incomplete, and there may be missing\n"
msg << "data. The following tags were not closed: #{missing_ends}."
db.emit(:warning,msg,&block)
end end
end end