diff --git a/codedeploy_agent.gemspec b/codedeploy_agent.gemspec index 4b9ab801..87ddaf3f 100644 --- a/codedeploy_agent.gemspec +++ b/codedeploy_agent.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'aws_codedeploy_agent' - spec.version = '1.7.0' + spec.version = '1.7.1' spec.summary = 'Packages AWS CodeDeploy agent libraries' spec.description = 'AWS CodeDeploy agent is responsible for doing the actual work of deploying software on an individual EC2 instance' spec.author = 'Amazon Web Services' @@ -13,13 +13,14 @@ Gem::Specification.new do |spec| spec.add_dependency('gli', '~> 2.21') spec.add_dependency('json_pure', '~> 1.6') - spec.add_dependency('archive-tar-minitar', '~> 0.5.2') + spec.add_dependency('minitar', '~> 0.6.1') spec.add_dependency('rubyzip', '~> 1.3.0') spec.add_dependency('logging', '~> 2.2') spec.add_dependency('aws-sdk-core', '~> 3') spec.add_dependency('aws-sdk-s3', '~> 1') spec.add_dependency('docopt', '~> 0.5.0') spec.add_dependency('concurrent-ruby', '~> 1.1.9') + spec.add_dependency('rexml', '~> 3.3.9') spec.add_development_dependency('rake', '~> 12.3.3') spec.add_development_dependency('rspec', '~> 3.2.0') diff --git a/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/deploy_control_endpoint.rb b/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/deploy_control_endpoint.rb index eff60a52..0388cbb6 100644 --- a/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/deploy_control_endpoint.rb +++ b/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/deploy_control_endpoint.rb @@ -1,4 +1,5 @@ require 'aws-sdk-core' +require 'json' module Aws module Plugins @@ -20,10 +21,29 @@ class DeployControlEndpoint < Seahorse::Client::Plugin if InstanceMetadata.imds_supported? region = InstanceMetadata.region domain = InstanceMetadata.domain + + if is_on_prem? + partitions_region_pattern = File.read(File.join(File.dirname(__FILE__), 'partition-region-pattern.json')) + partitions_region_pattern_hash = JSON.parse(partitions_region_pattern) + + unless partitions_region_pattern_hash.include?(domain) + raise "Unknown domain: #{domain}" + end + + known_region_pattern = partitions_region_pattern_hash[domain]["regionRegex"] + + unless region.match(known_region_pattern) + raise "Invalid region: #{region}" + end + end + + ProcessManager::Log.info("Creating client url from IMDS region and domain") else region = cfg.region domain = 'amazonaws.com' domain += '.cn' if region.split("-")[0] == 'cn' + + ProcessManager::Log.info("Creating client url from configurations") end url = "https://#{service}.#{region}.#{domain}" @@ -32,6 +52,10 @@ class DeployControlEndpoint < Seahorse::Client::Plugin ProcessManager::Log.info("CodeDeploy endpoint: #{url}") url end + + def self.is_on_prem? + return File.readable?(InstanceAgent::Config.config[:on_premises_config_file]) + end end end end diff --git a/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/partition-region-pattern.json b/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/partition-region-pattern.json new file mode 100644 index 00000000..eedffa08 --- /dev/null +++ b/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/partition-region-pattern.json @@ -0,0 +1,9 @@ +{ + "amazonaws.com": { + "regionRegex" : "^[0-9a-z-]{1,20}$" + }, + + "amazonaws.com.cn": { + "regionRegex" : "^cn\\-\\w+\\-\\d+$" + } +} \ No newline at end of file