5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/msf/core/db_manager/import/report.rb', line 5
def import_report(report, args, base_dir)
tmp = args[:ifd][:zip_tmp]
report_info = {}
report.elements.each do |e|
node_name = e.name
node_value = e.text
array_attrs = %w|addresses file-formats options sections|
if array_attrs.member? node_name
node_value = JSON.parse(node_value)
end
skip_nodes = %w|id workspace-id artifacts|
next if skip_nodes.member? node_name
report_info[node_name.parameterize.underscore.to_sym] = node_value
end
report_info[:workspace_id] = args[:workspace].id
report_id = report_report(report_info)
report.elements.at('artifacts').elements.each do |artifact|
artifact_opts = {}
artifact.elements.each do |attr|
skip_nodes = %w|id accessed-at|
next if skip_nodes.member? attr.name
symboled_attr = attr.name.parameterize.underscore.to_sym
artifact_opts[symboled_attr] = attr.text
end
artifact_opts[:report_id] = report_id
artifact_opts[:file_path].gsub!(/^\./, tmp)
msf_import_artifact(artifact_opts)
end
end
|