diff --git a/foo.rb b/foo.rb new file mode 100644 index 0000000000000..8e47a921d93de --- /dev/null +++ b/foo.rb @@ -0,0 +1,33 @@ +# Usage: +# terraform output | ruby foo.rb "TEST_SUBDOMAIN" + +require 'json' +require 'yaml' + +terraform_output = JSON.parse(STDIN.read, symbolize_names: true) +lab_cucumber_targets = terraform_output[:lab_cucumber_targets][:value] +test_subdomain = ARGV[0] + +# Names from: https://github.com/rapid7/pro/blob/4cb5d12469405b124c0ce3d1f818e95b20ddac3d/ui/features/support/aws_lab_config.yml#L6 +templates = [ + { alias: 'winm3', search_prefix: 'metasploitable3-win2k8-' }, + { alias: 'linm3', search_prefix: 'metasploitable3-ub1404-' }, + { alias: 'windows_server_2022_domain_controller', search_prefix: 'mspro-test-active_directory-w22std' }, +] +result = templates.each_with_object({}) do |template, acc| + lab_cucumber_target = lab_cucumber_targets.find do |lab_target_name, config| + lab_target_name.start_with?(template[:search_prefix]) + end + raise "Did not find matching cucumber lab target #{template}" unless lab_cucumber_target + name, config = lab_cucumber_target + + acc[template[:alias]] = { + template: name, + name: "#{name}.#{test_subdomain}", + path: "#{name}.#{test_subdomain}", + instance_id: config[:instance_id], + private_ip: config[:private_ip] + } +end + +puts result.to_yaml diff --git a/lib/msf/core/thread_manager.rb b/lib/msf/core/thread_manager.rb index 7fe59f501805e..9bc89ae37ca6f 100644 --- a/lib/msf/core/thread_manager.rb +++ b/lib/msf/core/thread_manager.rb @@ -111,16 +111,6 @@ def spawn(name, crit, *args, &block) error: e ) raise e - ensure - if framework.db && framework.db.active && framework.db.is_local? - # NOTE: despite the Deprecation Warning's advice, this should *NOT* - # be ApplicationRecord.connection.close which causes unrelated - # threads to raise ActiveRecord::StatementInvalid exceptions at - # some point in the future, presumably due to the pool manager - # believing that the connection is still usable and handing it out - # to another thread. - ::ApplicationRecord.connection_pool.release_connection - end end end else