Warn the user if there's a truncated nmap file.
git-svn-id: file:///home/svn/framework3/trunk@12704 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
230295cc1b
commit
38504b39a8
|
@ -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()
|
||||||
|
@ -106,13 +107,14 @@ module Rex
|
||||||
end
|
end
|
||||||
return attr_pairs
|
return attr_pairs
|
||||||
end
|
end
|
||||||
|
|
||||||
# Triggered every time a new element is encountered. We keep state
|
# Triggered every time a new element is encountered. We keep state
|
||||||
# ourselves with the @state variable, turning things on when we
|
# ourselves with the @state variable, turning things on when we
|
||||||
# get here (and turning things off when we exit in end_element()).
|
# get here (and turning things off when we exit in end_element()).
|
||||||
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue