Skip to content

Commit 5ce886c

Browse files
committed
Land rapid7#7490, xml importer fingerprinting fixed
2 parents c83474e + 56d5c49 commit 5ce886c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/msf/core/db_manager/import.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,21 @@ def emit(sym,data,&block)
8686
# is unknown.
8787
def import(args={}, &block)
8888
wspace = args[:wspace] || args['wspace'] || workspace
89+
preserve_hosts = args[:task].options["DS_PRESERVE_HOSTS"] if args[:task].present? && args[:task].options.present?
8990
wspace.update_attribute(:import_fingerprint, true)
91+
existing_host_ids = wspace.hosts.map(&:id)
9092
data = args[:data] || args['data']
9193
ftype = import_filetype_detect(data)
9294
yield(:filetype, @import_filedata[:type]) if block
9395
self.send "import_#{ftype}".to_sym, args, &block
94-
wspace.hosts.each(&:normalize_os)
96+
if preserve_hosts
97+
new_host_ids = Mdm::Host.where(workspace: wspace).map(&:id)
98+
(new_host_ids - existing_host_ids).each do |id|
99+
Mdm::Host.where(id: id).first.normalize_os
100+
end
101+
else
102+
Mdm::Host.where(workspace: wspace).each(&:normalize_os)
103+
end
95104
wspace.update_attribute(:import_fingerprint, false)
96105
end
97106

0 commit comments

Comments
 (0)