bugfix: some data was copied by reference rather than by value in the select_modules function, causing edits of the available_modules rather than a copy. Used duplicate() for a deep object copy instead of .clone.

This commit is contained in:
thomashaw
2020-01-17 16:26:10 +00:00
parent 5e81edb231
commit 5b7c79cc72

View File

@@ -87,7 +87,7 @@ class System
def replace_datastore_ips(options)
begin
if options[:ip_ranges] and $datastore['IP_addresses'] and !$datastore['replaced_ranges']
unused_opts_ranges = options[:ip_ranges].clone
unused_opts_ranges = duplicate(options[:ip_ranges])
option_range_map = {} # k = ds_range, v = opts_range
new_ip_addresses = []
@@ -142,7 +142,7 @@ class System
def select_modules(module_type, required_attributes, available_modules, previously_selected_modules, unique_id, write_outputs_to, write_to_module_with_id, received_inputs, default_inputs_literals, write_to_datastore, received_datastores, write_module_path_to_datastore)
default_modules_to_add = []
search_list = available_modules.clone
search_list = duplicate(available_modules)
# shuffle order of available vulnerabilities
search_list.shuffle!
@@ -180,7 +180,7 @@ class System
Print.err 'Could not find a matching module. Please check the scenario specification'
else
# use from the top of the randomised list
selected = search_list[0].clone
selected = duplicate(search_list[0])
Print.verbose "Selecting module: #{selected.printable_name}"
# propagate module relationships established when the filter was created