mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-21 11:18:06 +00:00
Fixing: generated scenario.xml in projects are now re-runnable
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user