Fixing: generated scenario.xml in projects are now re-runnable

This commit is contained in:
thomashaw
2017-04-12 20:28:38 +01:00
parent 07eaad8199
commit a62983a465
2 changed files with 16 additions and 27 deletions

View File

@@ -97,7 +97,7 @@ class Module
attr_flattened = {}
attributes.each do |key, array|
unless "#{key}" == 'module_type' || "#{key}" == 'conflict'
unless "#{key}" == 'module_type' || "#{key}" == 'conflict' || "#{key}" == 'default_input' || "#{key}" == 'requires'
# creates a valid regexp that can match the original module
attr_flattened["#{key}"] = Regexp.escape(array.join('~~~')).gsub(/\n\w*/, '.*').gsub(/\\ /, ' ').gsub(/~~~/, '|')
end

View File

@@ -50,46 +50,25 @@ class XmlScenarioGenerator
return
end
case selected_module.module_type
# FIXME: repetition of logic :-(
when 'vulnerability'
xml.vulnerability(selected_module.attributes_for_scenario_output) {
selected_module.received_inputs.each do |key,value|
xml.input({"into" => key}) {
xml.value value
}
end
insert_inputs_and_values(selected_module,xml)
}
when 'base'
xml.base(selected_module.attributes_for_scenario_output) {
selected_module.received_inputs.each do |key,value|
xml.input({"into" => key}) {
xml.value value
}
end
insert_inputs_and_values(selected_module,xml)
}
when 'build'
xml.build(selected_module.attributes_for_scenario_output) {
selected_module.received_inputs.each do |key,value|
xml.input({"into" => key}) {
xml.value value
}
end
insert_inputs_and_values(selected_module,xml)
}
when 'service'
xml.service(selected_module.attributes_for_scenario_output) {
selected_module.received_inputs.each do |key,value|
xml.input({"into" => key}) {
xml.value value
}
end
insert_inputs_and_values(selected_module,xml)
}
when 'utility'
xml.utility(selected_module.attributes_for_scenario_output) {
selected_module.received_inputs.each do |key,value|
xml.input({"into" => key}) {
xml.value value
}
end
insert_inputs_and_values(selected_module,xml)
}
when 'network'
xml.network(selected_module.attributes_for_scenario_output)
@@ -98,4 +77,14 @@ class XmlScenarioGenerator
# exit
end
end
def insert_inputs_and_values(selected_module, xml)
selected_module.received_inputs.each do |key, value|
xml.input({"into" => key}) {
value.each { |val|
xml.value val
}
}
end
end
end