refactor note import into sep method
we will now be importing notes from multiple place within the XML document. the importing of notes has been refactored into a seperate method to be easily reused in this fashion MSP-12183bug/bundler_fix
parent
2389185376
commit
389bcbd343
|
@ -64,6 +64,30 @@ module Msf::DBManager::Import::MetasploitFramework::XML
|
|||
import_msf_xml(args.merge(:data => data))
|
||||
end
|
||||
|
||||
# Imports `Mdm::Note` objects from the XML element.
|
||||
#
|
||||
# @param note [REXML::Element] The Note element
|
||||
# @param allow_yaml [Boolean] whether to allow yaml
|
||||
# @param note_data [Hash] hash containing note attributes to be passed along
|
||||
# @return [void]
|
||||
def import_msf_note_element(note, allow_yaml, note_data={})
|
||||
note_data[:type] = nils_for_nulls(note.elements["ntype"].text.to_s.strip)
|
||||
note_data[:data] = nils_for_nulls(unserialize_object(note.elements["data"], allow_yaml))
|
||||
|
||||
if note.elements["critical"].text
|
||||
note_data[:critical] = true unless note.elements["critical"].text.to_s.strip == "NULL"
|
||||
end
|
||||
if note.elements["seen"].text
|
||||
note_data[:seen] = true unless note.elements["critical"].text.to_s.strip == "NULL"
|
||||
end
|
||||
%W{created-at updated-at}.each { |datum|
|
||||
if note.elements[datum].text
|
||||
note_data[datum.gsub("-","_")] = nils_for_nulls(note.elements[datum].text.to_s.strip)
|
||||
end
|
||||
}
|
||||
report_note(note_data)
|
||||
end
|
||||
|
||||
# Imports web_form element using {Msf::DBManager#report_web_form}.
|
||||
#
|
||||
# @param element [REXML::Element] web_form element.
|
||||
|
@ -280,21 +304,7 @@ module Msf::DBManager::Import::MetasploitFramework::XML
|
|||
note_data = {}
|
||||
note_data[:workspace] = wspace
|
||||
note_data[:host] = hobj
|
||||
note_data[:type] = nils_for_nulls(note.elements["ntype"].text.to_s.strip)
|
||||
note_data[:data] = nils_for_nulls(unserialize_object(note.elements["data"], allow_yaml))
|
||||
|
||||
if note.elements["critical"].text
|
||||
note_data[:critical] = true unless note.elements["critical"].text.to_s.strip == "NULL"
|
||||
end
|
||||
if note.elements["seen"].text
|
||||
note_data[:seen] = true unless note.elements["critical"].text.to_s.strip == "NULL"
|
||||
end
|
||||
%W{created-at updated-at}.each { |datum|
|
||||
if note.elements[datum].text
|
||||
note_data[datum.gsub("-","_")] = nils_for_nulls(note.elements[datum].text.to_s.strip)
|
||||
end
|
||||
}
|
||||
report_note(note_data)
|
||||
import_msf_note_element(note,allow_yaml,note_data)
|
||||
end
|
||||
|
||||
host.elements.each('tags/tag') do |tag|
|
||||
|
|
Loading…
Reference in New Issue