fog-aws 3.28.0 → 3.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b81862bafa0db522d573c2349e8505c3d66c3aeaae51a0c8daa2e6ba6bd1db8
4
- data.tar.gz: 4d4fac1aaffa73b888fca2c3b244a85c99d23fb288831947c3c8ffa3f0e7a23b
3
+ metadata.gz: e082ebe8e5a7cc585e85b6d2415306da6a2c0fec952ea3a62754dddfa82087d3
4
+ data.tar.gz: ac57b359e23b43ac11189ae93ee9f7eee31ac16b16d69ecc00f885b41f357105
5
5
  SHA512:
6
- metadata.gz: c1cd8afc6b7455b6392c55fd2483eb9ac2b0314e3ecd8757e46c3b7462ec9a7f90ab8058310d2ebdfa966e685b983ce7fd93ae834bb86ff44b2e7bac7022473d
7
- data.tar.gz: 640fb216fc8e201576b249aab161b1b6e125f1dc7f331f95c394b03f07b891c3e02ae5f75b344d3ecd4a19c0b912512904b48b6796b632b47d9e0cd271489e47
6
+ metadata.gz: b4e819ca80fc191bfd1a28888924a121f96e94e90315f2f62cc5b3c7702b810b9358ab6812c67c3d1dcf184ef673717030f3218a32f7c0e49a78c0cb4e89ebc8
7
+ data.tar.gz: 2959e61875371b8e0e06575855fa571669b477390c02c77515a1cba7c9f351b5ddd84865116d890b7a1be76ab91c5abf806aac5687345f167e1da2d9a396700f
data/CHANGELOG.md CHANGED
@@ -1,32 +1,65 @@
1
1
  # Changelog
2
2
 
3
- ## [v3.28.0](https://github.com/fog/fog-aws/tree/v3.28.0) (2024-10-14)
3
+ ## v3.33.0 (2025-08-27)
4
4
 
5
- [Full Changelog](https://github.com/fog/fog-aws/compare/v3.27.0...v3.28.0)
5
+ Closed issues:
6
+
7
+ - Add support for ListObjectsV2 [\#741](https://github.com/fog/fog-aws/issues/741)
8
+
9
+
10
+ Merged pull requests:
11
+
12
+ - Update base64 requirement from ~\> 0.2.0 to \>= 0.2, \< 0.4 [\#743](https://github.com/fog/fog-aws/pull/743) ([dependabot[bot]](https://github.com/apps/dependabot))
13
+ - Fix #741 Added list objects v2 api support [\#744](https://github.com/fog/fog-aws/pull/744)
14
+ - Update rubyzip requirement from ~\> 2.4.1 to ~\> 3.0.0 [\#746](https://github.com/fog/fog-aws/pull/746) ([dependabot[bot]](https://github.com/apps/dependabot))
15
+ - storage headers should be rejected in a case-insensitive way [\#747](https://github.com/fog/fog-aws/pull/747)
16
+
17
+ ## [v3.32.0](https://github.com/fog/fog-aws/tree/v3.32.0) (2025-05-27)
18
+
19
+ [Full Changelog](https://github.com/fog/fog-aws/compare/v3.31.0...v3.32.0)
6
20
 
7
21
  **Closed issues:**
8
22
 
9
- - SES needs to support AWS SigV4 [\#726](https://github.com/fog/fog-aws/issues/726)
23
+ - Add ability to specify s3 restore object tier in post\_object\_restore [\#740](https://github.com/fog/fog-aws/issues/740)
10
24
 
11
25
  **Merged pull requests:**
12
26
 
13
- - Update SES to use AWS SigV4 [\#727](https://github.com/fog/fog-aws/pull/727) ([ohookins](https://github.com/ohookins))
27
+ - Add ability to specify s3 restore object tier in post\_object\_restore [\#742](https://github.com/fog/fog-aws/pull/742) ([Ankk98](https://github.com/Ankk98))
28
+
29
+ ## [v3.31.0](https://github.com/fog/fog-aws/tree/v3.31.0) (2025-04-21)
14
30
 
15
- ## [v3.27.0](https://github.com/fog/fog-aws/tree/v3.27.0) (2024-09-16)
31
+ [Full Changelog](https://github.com/fog/fog-aws/compare/v3.30.0...v3.31.0)
32
+
33
+ **Closed issues:**
34
+
35
+ - Compute.describe\_instance\_status\(\) fails [\#734](https://github.com/fog/fog-aws/issues/734)
36
+
37
+ **Merged pull requests:**
38
+
39
+ - Fix Compute.describe\_instance\_status parser [\#735](https://github.com/fog/fog-aws/pull/735) ([kitherill](https://github.com/kitherill))
40
+ - Update rubyzip requirement from ~\> 2.3.0 to ~\> 2.4.1 [\#733](https://github.com/fog/fog-aws/pull/733) ([dependabot[bot]](https://github.com/apps/dependabot))
41
+
42
+ ## [v3.30.0](https://github.com/fog/fog-aws/tree/v3.30.0) (2024-12-17)
43
+
44
+ [Full Changelog](https://github.com/fog/fog-aws/compare/v3.29.0...v3.30.0)
45
+
46
+ **Closed issues:**
16
47
 
17
- [Full Changelog](https://github.com/fog/fog-aws/compare/v3.26.0...v3.27.0)
48
+ - Support S3 FIPS endpoints, disable S3 Transfer Acceleration in GovCloud or FIPS mode [\#729](https://github.com/fog/fog-aws/issues/729)
18
49
 
19
50
  **Merged pull requests:**
20
51
 
21
- - avoid merging connection value from headers when saving files [\#725](https://github.com/fog/fog-aws/pull/725) ([geemus](https://github.com/geemus))
52
+ - Bump fog/.github from 1.4.0 to 1.5.0 [\#732](https://github.com/fog/fog-aws/pull/732) ([dependabot[bot]](https://github.com/apps/dependabot))
53
+ - kms additions [\#731](https://github.com/fog/fog-aws/pull/731) ([geemus](https://github.com/geemus))
54
+ - Support FIPS endpoints, disable S3 Transfer Acceleration in GovCloud [\#730](https://github.com/fog/fog-aws/pull/730) ([matt-domsch-sp](https://github.com/matt-domsch-sp))
22
55
 
23
- ## [v3.26.0](https://github.com/fog/fog-aws/tree/v3.26.0) (2024-09-10)
56
+ ## [v3.29.0](https://github.com/fog/fog-aws/tree/v3.29.0) (2024-10-25)
24
57
 
25
- [Full Changelog](https://github.com/fog/fog-aws/compare/v3.25.0...v3.26.0)
58
+ [Full Changelog](https://github.com/fog/fog-aws/compare/v3.28.0...v3.29.0)
26
59
 
27
60
  **Merged pull requests:**
28
61
 
29
- - Support AWS\_ENDPOINT\_URL\_STS environment variable [\#724](https://github.com/fog/fog-aws/pull/724) ([stanhu](https://github.com/stanhu))
62
+ - fallback to excon 1.0+ error retry error settings [\#728](https://github.com/fog/fog-aws/pull/728) ([geemus](https://github.com/geemus))
30
63
 
31
64
 
32
65
 
data/fog-aws.gemspec CHANGED
@@ -25,11 +25,11 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'bundler'
26
26
  spec.add_development_dependency 'github_changelog_generator', '~> 1.16'
27
27
  spec.add_development_dependency 'rake', '>= 12.3.3'
28
- spec.add_development_dependency 'rubyzip', '~> 2.3.0'
28
+ spec.add_development_dependency 'rubyzip', '~> 3.0.0'
29
29
  spec.add_development_dependency 'shindo', '~> 0.3'
30
30
 
31
- spec.add_dependency 'base64', '~> 0.2.0'
32
- spec.add_dependency 'fog-core', '~> 2.1'
31
+ spec.add_dependency 'base64', '>= 0.2', '< 0.4'
32
+ spec.add_dependency 'fog-core', '~> 2.6'
33
33
  spec.add_dependency 'fog-json', '~> 1.1'
34
34
  spec.add_dependency 'fog-xml', '~> 0.1'
35
35
 
data/lib/fog/aws/kms.rb CHANGED
@@ -20,6 +20,9 @@ module Fog
20
20
  request :list_keys
21
21
  request :create_key
22
22
  request :describe_key
23
+ request :get_public_key
24
+ request :schedule_key_deletion
25
+ request :sign
23
26
 
24
27
  model_path 'fog/aws/models/kms'
25
28
  model :key
@@ -30,7 +33,8 @@ module Fog
30
33
  @data ||= Hash.new do |hash, region|
31
34
  hash[region] = Hash.new do |region_hash, access_key|
32
35
  region_hash[access_key] = {
33
- :keys => {},
36
+ keys: {},
37
+ pkeys: {}
34
38
  }
35
39
  end
36
40
  end
@@ -281,7 +281,7 @@ module Fog
281
281
  merge_attributes(data.body)
282
282
  else
283
283
  data = service.put_object(directory.key, key, body, options)
284
- merge_attributes(data.headers.reject {|key, value| ['Connection', 'Content-Length', 'Content-Type'].include?(key)})
284
+ merge_attributes(data.headers.reject {|key, value| ['connection', 'content-length', 'content-type'].include?(key.downcase)})
285
285
  end
286
286
  self.etag = self.etag.gsub('"','') if self.etag
287
287
  self.content_length = Fog::Storage.get_body_size(body)
@@ -4,7 +4,7 @@ module Fog
4
4
  module Compute
5
5
  class DescribeInstanceStatus < Fog::Parsers::Base
6
6
  def new_instance!
7
- @instance = { 'instanceState' => {}, 'systemStatus' => { 'details' => [] }, 'instanceStatus' => { 'details' => [] }, 'eventsSet' => [] }
7
+ @instance = { 'instanceState' => {}, 'systemStatus' => { 'details' => [] }, 'instanceStatus' => { 'details' => [] }, 'attachedEbsStatus' => { 'details' => [] }, 'eventsSet' => [] }
8
8
  end
9
9
 
10
10
  def new_item!
@@ -31,6 +31,8 @@ module Fog
31
31
  @inside = :instanceState
32
32
  when 'instanceStatus'
33
33
  @inside = :instanceStatus
34
+ when 'attachedEbsStatus'
35
+ @inside = :attachedEbsStatus
34
36
  when 'eventsSet'
35
37
  @inside = :eventsSet
36
38
  end
@@ -43,13 +45,13 @@ module Fog
43
45
  @instance[name] = value
44
46
  when 'nextToken', 'requestId'
45
47
  @response[name] = value
46
- when 'systemStatus', 'instanceState', 'instanceStatus', 'eventsSet'
48
+ when 'systemStatus', 'instanceState', 'instanceStatus', 'attachedEbsStatus', 'eventsSet'
47
49
  @inside = nil
48
50
  when 'item'
49
51
  case @inside
50
52
  when :eventsSet
51
53
  @instance['eventsSet'] << @item
52
- when :systemStatus, :instanceStatus
54
+ when :systemStatus, :instanceStatus, :attachedEbsStatus
53
55
  @instance[@inside.to_s]['details'] << @item
54
56
  when nil
55
57
  @response['instanceStatusSet'] << @instance
@@ -17,9 +17,9 @@ module Fog
17
17
 
18
18
  def end_element(name)
19
19
  case name
20
- when 'KeyUsage', 'AWSAccountId', 'Description', 'KeyId', 'Arn'
20
+ when 'Arn', 'AWSAccountId', 'Description', 'KeyId', 'KeySpec', 'KeyState', 'KeyUsage'
21
21
  @key[name] = value
22
- when 'CreationDate'
22
+ when 'CreationDate', 'DeletionDate'
23
23
  @key[name] = Time.parse(value)
24
24
  when 'Enabled'
25
25
  @key[name] = (value == 'true')
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module KMS
5
+ class GetPublicKey < Fog::Parsers::Base
6
+ def reset
7
+ @response = {}
8
+ end
9
+
10
+ def start_element(name, attrs = [])
11
+ super
12
+ case name
13
+ when 'EncryptionAlgorithms', 'KeyAgreementAlgorithms', 'SigningAlgorithms'
14
+ @response[name] = []
15
+ end
16
+ end
17
+
18
+ def end_element(name)
19
+ case name
20
+ when 'KeyId', 'KeySpec', 'KeyUsage', 'PublicKey'
21
+ @response[name] = value
22
+ when 'EncryptionAlgorithms', 'KeyAgreementAlgorithms', 'SigningAlgorithms'
23
+ @response[name] << value
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module KMS
5
+ class ScheduleKeyDeletion < Fog::Parsers::Base
6
+ def reset
7
+ @response = {}
8
+ end
9
+
10
+ def start_element(name, attrs = [])
11
+ super
12
+ end
13
+
14
+ def end_element(name)
15
+ case name
16
+ when 'DeletionDate'
17
+ @response[name] = Time.parse(value)
18
+ when 'KeyId', 'KeyState'
19
+ @response[name] = value
20
+ when 'PendingWindowInDays'
21
+ @response[name] = value.to_i
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module KMS
5
+ class Sign < Fog::Parsers::Base
6
+ def reset
7
+ @response = {}
8
+ end
9
+
10
+ def start_element(name, attrs = [])
11
+ super
12
+ end
13
+
14
+ def end_element(name)
15
+ case name
16
+ when 'KeyId', 'Signature', 'SigningAlgorithm'
17
+ @response[name] = value
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,66 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module Storage
5
+ class ListObjectsV2 < Fog::Parsers::Base
6
+ # Initialize parser state
7
+ def initialize
8
+ super
9
+ @common_prefix = {}
10
+ @object = { 'Owner' => {} }
11
+ reset
12
+ end
13
+
14
+ def reset
15
+ @object = { 'Owner' => {} }
16
+ @response = { 'Contents' => [], 'CommonPrefixes' => [] }
17
+ end
18
+
19
+ def start_element(name, attrs = [])
20
+ super
21
+ case name
22
+ when 'CommonPrefixes'
23
+ @in_common_prefixes = true
24
+ end
25
+ end
26
+
27
+ def end_element(name)
28
+ case name
29
+ when 'CommonPrefixes'
30
+ @in_common_prefixes = false
31
+ when 'Contents'
32
+ @response['Contents'] << @object
33
+ @object = { 'Owner' => {} }
34
+ when 'DisplayName', 'ID'
35
+ @object['Owner'][name] = value
36
+ when 'ETag'
37
+ @object[name] = value.gsub('"', '') if value != nil
38
+ when 'IsTruncated'
39
+ if value == 'true'
40
+ @response['IsTruncated'] = true
41
+ else
42
+ @response['IsTruncated'] = false
43
+ end
44
+ when 'LastModified'
45
+ @object['LastModified'] = Time.parse(value)
46
+ when 'ContinuationToken', 'NextContinuationToken', 'Name', 'StartAfter'
47
+ @response[name] = value
48
+ when 'MaxKeys', 'KeyCount'
49
+ @response[name] = value.to_i
50
+ when 'Prefix'
51
+ if @in_common_prefixes
52
+ @response['CommonPrefixes'] << value
53
+ else
54
+ @response[name] = value
55
+ end
56
+ when 'Size'
57
+ @object['Size'] = value.to_i
58
+ when 'Delimiter', 'Key', 'StorageClass'
59
+ @object[name] = value
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -2,61 +2,99 @@ module Fog
2
2
  module AWS
3
3
  class KMS
4
4
  class Real
5
- DEFAULT_KEY_POLICY = <<-JSON
6
- {
7
- "Version": "2012-10-17",
8
- "Id": "key-default-1",
9
- "Statement": [
10
- {
11
- "Sid": "Enable IAM User Permissions",
12
- "Effect": "Allow",
13
- "Principal": {
14
- "AWS": "arn:aws:iam::915445820265:root"
15
- },
16
- "Action": "kms:*",
17
- "Resource": "*"
18
- }
19
- ]
20
- }
21
- JSON
22
-
23
5
  require 'fog/aws/parsers/kms/describe_key'
24
6
 
25
- def create_key(policy = nil, description = nil, usage = "ENCRYPT_DECRYPT")
26
- request(
27
- 'Action' => 'CreateKey',
28
- 'Description' => description,
29
- 'KeyUsage' => usage,
30
- 'Policy' => policy,
31
- :parser => Fog::Parsers::AWS::KMS::DescribeKey.new
32
- )
7
+ # Create Key
8
+ #
9
+ # ==== Parameters
10
+ # * options<~Hash>:
11
+ # * 'Description'<~String>:
12
+ # * 'KeyUsage'<~String>:
13
+ # * 'Policy'<~String>:
14
+ # * ... (see docs from see also)
15
+ #
16
+ # === Returns
17
+ #
18
+ # ==== See Also
19
+ # https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateKey.html
20
+ def create_key(*args)
21
+ options = Fog::AWS::KMS.parse_create_key_args(args)
22
+ request({
23
+ 'Action' => 'CreateKey',
24
+ :parser => Fog::Parsers::AWS::KMS::DescribeKey.new
25
+ }.merge!(options))
33
26
  end
34
27
  end
35
28
 
36
29
  class Mock
37
- def create_key(policy = nil, description = nil, usage = "ENCRYPT_DECRYPT")
30
+ def create_key(*args)
31
+ options = Fog::AWS::KMS.parse_create_key_args(args)
32
+
38
33
  response = Excon::Response.new
39
34
  key_id = UUID.uuid
40
35
  key_arn = Fog::AWS::Mock.arn("kms", self.account_id, "key/#{key_id}", @region)
41
36
 
42
37
  key = {
43
- "KeyUsage" => usage,
44
- "AWSAccountId" => self.account_id,
45
- "KeyId" => key_id,
46
- "Description" => description,
47
- "CreationDate" => Time.now,
48
- "Arn" => key_arn,
49
- "Enabled" => true,
50
- }
38
+ 'Arn' => key_arn,
39
+ 'AWSAccountId' => self.account_id,
40
+ 'CreationDate' => Time.now.utc,
41
+ 'DeletionDate' => nil,
42
+ 'Description' => nil,
43
+ 'Enabled' => true,
44
+ 'KeyId' => key_id,
45
+ 'KeySpec' => 'SYMMETRIC_DEFAULT',
46
+ 'KeyState' => 'Enabled',
47
+ 'KeyUsage' => 'ENCRYPT_DECRYPT',
48
+ 'Policy' => nil
49
+ }.merge!(options)
51
50
 
52
51
  # @todo use default policy
53
52
 
54
53
  self.data[:keys][key_id] = key
55
54
 
56
- response.body = { "KeyMetadata" => key }
55
+ klass, arg = {
56
+ 'ECC_NIST_P256' => [OpenSSL::PKey::EC, 'prime256v1'],
57
+ 'ECC_NIST_P384' => [OpenSSL::PKey::EC, 'secp384r1'],
58
+ 'ECC_NIST_P521' => [OpenSSL::PKey::EC, 'secp521r1'],
59
+ 'ECC_SECG_P256K1' => [OpenSSL::PKey::EC, 'secp256k1'],
60
+ 'RSA_2048' => [OpenSSL::PKey::RSA, 2048],
61
+ 'RSA_3072' => [OpenSSL::PKey::RSA, 3072],
62
+ 'RSA_4096' => [OpenSSL::PKey::RSA, 4096]
63
+ }[key['KeySpec']]
64
+ raise "Unknown or not-yet-implemented #{key['KeySpec']} KeySpec for kms create_key mocks" unless klass
65
+
66
+ self.data[:pkeys][key_id] = klass.generate(arg)
67
+
68
+ response.body = { 'KeyMetadata' => key }
57
69
  response
58
70
  end
59
71
  end
72
+
73
+ # previous args (policy, description, usage) was deprecated in favor of a hash of options
74
+ def self.parse_create_key_args(args)
75
+ case args.size
76
+ when 0
77
+ {}
78
+ when 1
79
+ if args[0].is_a?(Hash)
80
+ args[0]
81
+ else
82
+ Fog::Logger.deprecation("create_key with distinct arguments is deprecated, use options hash instead [light_black](#{caller.first})[/]")
83
+ {
84
+ 'Policy' => args[0]
85
+ }
86
+ end
87
+ when 2, 3
88
+ Fog::Logger.deprecation("create_key with distinct arguments is deprecated, use options hash instead [light_black](#{caller.first})[/]")
89
+ {
90
+ 'Policy' => args[0],
91
+ 'Description' => args[1],
92
+ 'KeyUsage' => args[2] || 'ENCRYPT_DECRYPT'
93
+ }
94
+ else
95
+ raise "Unknown argument style: #{args.inspect}, use options hash instead."
96
+ end
97
+ end
60
98
  end
61
99
  end
62
100
  end
@@ -0,0 +1,35 @@
1
+ module Fog
2
+ module AWS
3
+ class KMS
4
+ class Real
5
+ require 'fog/aws/parsers/kms/get_public_key'
6
+
7
+ def get_public_key(identifier, grant_tokens = nil)
8
+ request(
9
+ 'Action' => 'GetPublicKey',
10
+ 'GrantTokens' => grant_tokens,
11
+ 'KeyId' => identifier,
12
+ :parser => Fog::Parsers::AWS::KMS::GetPublicKey.new
13
+ )
14
+ end
15
+ end
16
+
17
+ class Mock
18
+ def get_public_key(identifier, _grant_tokens = [])
19
+ response = Excon::Response.new
20
+ key = self.data[:keys][identifier]
21
+ pkey = self.data[:pkeys][identifier]
22
+
23
+ response.body = {
24
+ 'KeyId' => key['Arn'],
25
+ 'KeyUsage' => key['KeyUsage'],
26
+ 'KeySpec' => key['KeySpec'],
27
+ 'PublicKey' => Base64.strict_encode64(pkey.public_to_der),
28
+ 'SigningAlgorithms' => key['SigningAlgorithms']
29
+ }
30
+ response
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -2,7 +2,6 @@ module Fog
2
2
  module AWS
3
3
  class KMS
4
4
  class Real
5
-
6
5
  require 'fog/aws/parsers/kms/list_keys'
7
6
 
8
7
  def list_keys(options={})
@@ -43,9 +42,9 @@ module Fog
43
42
  key_set = if marker
44
43
  self.data[:markers][marker] || []
45
44
  else
46
- self.data[:keys].inject([]) { |r,(k,v)|
47
- r << { "KeyId" => k, "KeyArn" => v["Arn"] }
48
- }
45
+ self.data[:keys].inject([]) do |r, (k, v)|
46
+ r << { 'KeyArn' => v['Arn'], 'KeyId' => k }
47
+ end
49
48
  end
50
49
 
51
50
  keys = if limit
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module AWS
3
+ class KMS
4
+ class Real
5
+ require 'fog/aws/parsers/kms/schedule_key_deletion'
6
+
7
+ def schedule_key_deletion(identifier, pending_window_in_days)
8
+ request(
9
+ 'Action' => 'ScheduleKeyDeletion',
10
+ 'KeyId' => identifier,
11
+ 'PendingWindowInDays' => pending_window_in_days,
12
+ :parser => Fog::Parsers::AWS::KMS::ScheduleKeyDeletion.new
13
+ )
14
+ end
15
+ end
16
+
17
+ class Mock
18
+ def schedule_key_deletion(identifier, pending_window_in_days)
19
+ response = Excon::Response.new
20
+ key = self.data[:keys][identifier]
21
+
22
+ key['DeletionDate'] = Time.now + (60 * 60 * 24 * pending_window_in_days)
23
+ key['Enabled'] = false
24
+ key['KeyState'] = 'PendingDeletion'
25
+
26
+ response.body = {
27
+ 'DeletionDate' => key['DeletionDate'],
28
+ 'KeyId' => key['KeyId'],
29
+ 'KeyState' => key['KeyState'],
30
+ 'PendingWindowInDays' => pending_window_in_days
31
+ }
32
+ response
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,62 @@
1
+ module Fog
2
+ module AWS
3
+ class KMS
4
+ class Real
5
+ require 'fog/aws/parsers/kms/sign'
6
+
7
+ # Sign
8
+ #
9
+ # ==== Parameters
10
+ # * identifier<~String>: id, arn, alias name, or alias arn for key to sign with
11
+ # * message<~String>: base64 encoded message to sign
12
+ #
13
+ # === Returns
14
+ # * response<~Excon::Response>:
15
+ #
16
+ # ==== See Also
17
+ # https://docs.aws.amazon.com/kms/latest/APIReference/API_Sign.html
18
+ #
19
+ def sign(identifier, message, algorithm, options = {})
20
+ request({
21
+ 'Action' => 'Sign',
22
+ 'KeyId' => identifier,
23
+ 'Message' => message,
24
+ 'SigningAlgorithm' => algorithm,
25
+ :parser => Fog::Parsers::AWS::KMS::Sign.new
26
+ }.merge!(options))
27
+ end
28
+ end
29
+
30
+ class Mock
31
+ def sign(identifier, message, algorithm, options = {})
32
+ response = Excon::Response.new
33
+ pkey = self.data[:pkeys][identifier]
34
+ unless pkey
35
+ response.status = 404
36
+ raise(Excon::Errors.status_error({ expects: 200 }, response))
37
+ end
38
+
39
+ data = Base64.decode64(message)
40
+
41
+ # FIXME: SM2 support?
42
+ sha = "SHA#{algorithm.split('_SHA_').last}"
43
+ signopts = {}
44
+ signopts[:rsa_padding_mode] = 'pss' if algorithm.start_with?('RSASSA_PSS')
45
+
46
+ signature = if options['MessageType'] == 'DIGEST'
47
+ pkey.sign_raw(sha, data, signopts)
48
+ else
49
+ pkey.sign(sha, data, signopts)
50
+ end
51
+
52
+ response.body = {
53
+ 'KeyId' => identifier,
54
+ 'Signature' => Base64.strict_encode64(signature),
55
+ 'SigningAlgorithm' => algorithm
56
+ }
57
+ response
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,129 @@
1
+ module Fog
2
+ module AWS
3
+ class Storage
4
+ class Real
5
+ require 'fog/aws/parsers/storage/list_objects_v2'
6
+
7
+ # List information about objects in an S3 bucket using ListObjectsV2
8
+ #
9
+ # @param bucket_name [String] name of bucket to list object keys from
10
+ # @param options [Hash] config arguments for list. Defaults to {}.
11
+ # @option options delimiter [String] causes keys with the same string between the prefix
12
+ # value and the first occurrence of delimiter to be rolled up
13
+ # @option options continuation-token [String] continuation token from a previous request
14
+ # @option options fetch-owner [Boolean] specifies whether to return owner information
15
+ # @option options max-keys [Integer] limits number of object keys returned
16
+ # @option options prefix [String] limits object keys to those beginning with its value
17
+ # @option options start-after [String] starts listing after this specified key
18
+ #
19
+ # @return [Excon::Response] response:
20
+ # * body [Hash]:
21
+ # * Delimiter [String] - Delimiter specified for query
22
+ # * IsTruncated [Boolean] - Whether or not the listing is truncated
23
+ # * ContinuationToken [String] - Token specified in the request
24
+ # * NextContinuationToken [String] - Token to use in subsequent requests
25
+ # * KeyCount [Integer] - Number of keys returned
26
+ # * MaxKeys [Integer] - Maximum number of keys specified for query
27
+ # * Name [String] - Name of the bucket
28
+ # * Prefix [String] - Prefix specified for query
29
+ # * StartAfter [String] - StartAfter specified in the request
30
+ # * CommonPrefixes [Array] - Array of strings for common prefixes
31
+ # * Contents [Array]:
32
+ # * ETag [String] - Etag of object
33
+ # * Key [String] - Name of object
34
+ # * LastModified [String] - Timestamp of last modification of object
35
+ # * Owner [Hash]:
36
+ # * DisplayName [String] - Display name of object owner
37
+ # * ID [String] - Id of object owner
38
+ # * Size [Integer] - Size of object
39
+ # * StorageClass [String] - Storage class of object
40
+ #
41
+ # @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
42
+
43
+ def list_objects_v2(bucket_name, options = {})
44
+ unless bucket_name
45
+ raise ArgumentError.new('bucket_name is required')
46
+ end
47
+
48
+ # Add list-type=2 to indicate ListObjectsV2
49
+ options = options.merge('list-type' => '2')
50
+
51
+ request({
52
+ :expects => 200,
53
+ :headers => {},
54
+ :bucket_name => bucket_name,
55
+ :idempotent => true,
56
+ :method => 'GET',
57
+ :parser => Fog::Parsers::AWS::Storage::ListObjectsV2.new,
58
+ :query => options
59
+ })
60
+ end
61
+ end
62
+
63
+ class Mock # :nodoc:all
64
+ def list_objects_v2(bucket_name, options = {})
65
+ prefix = options['prefix']
66
+ continuation_token = options['continuation-token']
67
+ delimiter = options['delimiter']
68
+ max_keys = options['max-keys']
69
+ start_after = options['start-after']
70
+ fetch_owner = options['fetch-owner']
71
+ common_prefixes = []
72
+
73
+ unless bucket_name
74
+ raise ArgumentError.new('bucket_name is required')
75
+ end
76
+
77
+ response = Excon::Response.new
78
+ if bucket = self.data[:buckets][bucket_name]
79
+ contents = bucket[:objects].values.map(&:first).sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
80
+ (prefix && object['Key'][0...prefix.length] != prefix) ||
81
+ (start_after && object['Key'] <= start_after) ||
82
+ (continuation_token && object['Key'] <= continuation_token) ||
83
+ (delimiter && object['Key'][(prefix ? prefix.length : 0)..-1].include?(delimiter) \
84
+ && common_prefixes << object['Key'].sub(/^(#{prefix}[^#{delimiter}]+.).*/, '\1')) ||
85
+ object.key?(:delete_marker)
86
+ end.map do |object|
87
+ data = object.reject {|key, value| !['ETag', 'Key', 'StorageClass'].include?(key)}
88
+ data.merge!({
89
+ 'LastModified' => Time.parse(object['Last-Modified']),
90
+ 'Owner' => fetch_owner ? bucket['Owner'] : nil,
91
+ 'Size' => object['Content-Length'].to_i
92
+ })
93
+ data
94
+ end
95
+
96
+ max_keys = max_keys || 1000
97
+ size = [max_keys, 1000].min
98
+ truncated_contents = contents[0...size]
99
+ next_token = truncated_contents.size != contents.size ? truncated_contents.last['Key'] : nil
100
+
101
+ response.status = 200
102
+ common_prefixes_uniq = common_prefixes.uniq
103
+ response.body = {
104
+ 'CommonPrefixes' => common_prefixes_uniq,
105
+ 'Contents' => truncated_contents,
106
+ 'IsTruncated' => truncated_contents.size != contents.size,
107
+ 'ContinuationToken' => continuation_token,
108
+ 'NextContinuationToken' => next_token,
109
+ 'KeyCount' => truncated_contents.size + common_prefixes_uniq.size,
110
+ 'MaxKeys' => max_keys,
111
+ 'Name' => bucket['Name'],
112
+ 'Prefix' => prefix,
113
+ 'StartAfter' => start_after
114
+ }
115
+ if max_keys && max_keys < response.body['Contents'].length
116
+ response.body['IsTruncated'] = true
117
+ response.body['Contents'] = response.body['Contents'][0...max_keys]
118
+ response.body['KeyCount'] = response.body['Contents'].size + response.body['CommonPrefixes'].size
119
+ end
120
+ else
121
+ response.status = 404
122
+ raise(Excon::Errors.status_error({:expects => 200}, response))
123
+ end
124
+ response
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -6,7 +6,9 @@ module Fog
6
6
  #
7
7
  # @param bucket_name [String] Name of bucket containing object
8
8
  # @param object_name [String] Name of object to restore
9
- # @option days [Integer] Number of days to restore object for. Defaults to 100000 (a very long time)
9
+ # @param options [Hash] Optional parameters
10
+ # @option options [Integer] :days Number of days to restore object for. Defaults to 100000 (a very long time)
11
+ # @option options [String] :tier Glacier retrieval tier. Can be 'Standard', 'Bulk', or 'Expedited'
10
12
  #
11
13
  # @return [Excon::Response] response:
12
14
  # * status [Integer] 200 (OK) Object is previously restored
@@ -15,11 +17,24 @@ module Fog
15
17
  #
16
18
  # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPOSTrestore.html
17
19
  #
18
- def post_object_restore(bucket_name, object_name, days = 100000)
20
+ def post_object_restore(bucket_name, object_name, options = {})
19
21
  raise ArgumentError.new('bucket_name is required') unless bucket_name
20
22
  raise ArgumentError.new('object_name is required') unless object_name
21
23
 
22
- data = '<RestoreRequest xmlns="http://s3.amazonaws.com/doc/2006-3-01"><Days>' + days.to_s + '</Days></RestoreRequest>'
24
+ unless options.is_a?(Hash)
25
+ Fog::Logger.deprecation("post_object_restore with a bare days parameter is deprecated, use post_object_restore(bucket_name, object_name, :days => days) instead [light_black](#{caller.first})[/]")
26
+ options = { :days => options }
27
+ end
28
+
29
+ days = options[:days] || 100000
30
+ tier = options[:tier]
31
+
32
+ data = '<RestoreRequest xmlns="http://s3.amazonaws.com/doc/2006-03-01/">'
33
+ data += '<Days>' + days.to_s + '</Days>'
34
+ if tier
35
+ data += '<GlacierJobParameters><Tier>' + tier + '</Tier></GlacierJobParameters>'
36
+ end
37
+ data += '</RestoreRequest>'
23
38
 
24
39
  headers = {}
25
40
  headers['Content-MD5'] = Base64.encode64(OpenSSL::Digest::MD5.digest(data)).strip
@@ -39,7 +54,12 @@ module Fog
39
54
  end
40
55
 
41
56
  class Mock # :nodoc:all
42
- def post_object_restore(bucket_name, object_name, days = 100000)
57
+ def post_object_restore(bucket_name, object_name, options = {})
58
+ unless options.is_a?(Hash)
59
+ Fog::Logger.deprecation("post_object_restore with a bare days parameter is deprecated, use post_object_restore(bucket_name, object_name, :days => days) instead [light_black](#{caller.first})[/]")
60
+ options = { :days => options }
61
+ end
62
+
43
63
  response = get_object(bucket_name, object_name)
44
64
  response.body = nil
45
65
  response
@@ -7,6 +7,8 @@ module Fog
7
7
 
8
8
  DEFAULT_REGION = 'us-east-1'
9
9
  ACCELERATION_HOST = 's3-accelerate.amazonaws.com'
10
+ AWS_FIPS_REGIONS = %w(us-east-1 us-east-2 us-west-1 us-west-2 us-gov-east-1 us-gov-west-1 ca-central-1 ca-west-1).freeze
11
+ AWS_GOVCLOUD_REGIONS = %w(us-gov-east-1 us-gov-west-1).freeze
10
12
 
11
13
  DEFAULT_SCHEME = 'https'
12
14
  DEFAULT_SCHEME_PORT = {
@@ -16,10 +18,7 @@ module Fog
16
18
 
17
19
  DEFAULT_CONNECTION_OPTIONS = {
18
20
  retry_limit: 5,
19
- retry_interval: 1,
20
- retry_errors: [
21
- Excon::Error::Timeout, Excon::Error::Socket, Excon::Error::Server
22
- ]
21
+ retry_interval: 1
23
22
  }
24
23
 
25
24
  MIN_MULTIPART_CHUNK_SIZE = 5242880
@@ -27,9 +26,12 @@ module Fog
27
26
 
28
27
  VALID_QUERY_KEYS = %w[
29
28
  acl
29
+ continuation-token
30
30
  cors
31
31
  delete
32
+ fetch-owner
32
33
  lifecycle
34
+ list-type
33
35
  location
34
36
  logging
35
37
  notification
@@ -43,6 +45,7 @@ module Fog
43
45
  response-content-type
44
46
  response-expires
45
47
  restore
48
+ start-after
46
49
  tagging
47
50
  torrent
48
51
  uploadId
@@ -103,6 +106,7 @@ module Fog
103
106
  request :head_object_url
104
107
  request :initiate_multipart_upload
105
108
  request :list_multipart_uploads
109
+ request :list_objects_v2
106
110
  request :list_parts
107
111
  request :post_object_hidden_fields
108
112
  request :post_object_restore
@@ -261,13 +265,17 @@ module Fog
261
265
  end
262
266
 
263
267
  def region_to_host(region=nil)
264
- case region.to_s
265
- when DEFAULT_REGION, ''
266
- 's3.amazonaws.com'
267
- when %r{\Acn-.*}
268
- "s3.#{region}.amazonaws.com.cn"
268
+ if ENV['AWS_USE_FIPS_ENDPOINT'] == 'true' && AWS_FIPS_REGIONS.include?(region)
269
+ "s3-fips.#{region}.amazonaws.com" # https://aws.amazon.com/compliance/fips/
269
270
  else
270
- "s3.#{region}.amazonaws.com"
271
+ case region.to_s
272
+ when DEFAULT_REGION, ''
273
+ 's3.amazonaws.com'
274
+ when %r{\Acn-.*}
275
+ "s3.#{region}.amazonaws.com.cn"
276
+ else
277
+ "s3.#{region}.amazonaws.com"
278
+ end
271
279
  end
272
280
  end
273
281
 
@@ -581,6 +589,13 @@ module Fog
581
589
  @port = options[:port] || DEFAULT_SCHEME_PORT[@scheme]
582
590
  end
583
591
 
592
+ # GovCloud doesn't support S3 Transfer Acceleration https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-s3.html
593
+ # S3 Transfer Acceleration doesn't support FIPS endpoints. When both fog_aws_accelerate=true and AWS_USE_FIPS_ENDPOINT=true, don't use Accelerate.
594
+ if @acceleration && (AWS_GOVCLOUD_REGIONS.include?(@region) || ENV['AWS_USE_FIPS_ENDPOINT'] == 'true')
595
+ Fog::Logger.warning("fog: S3 Transfer Acceleration is not available in GovCloud regions or when AWS_USE_FIPS_ENDPOINT=true. Disabling acceleration.")
596
+ @acceleration = false
597
+ end
598
+
584
599
  @host = ACCELERATION_HOST if @acceleration
585
600
  setup_credentials(options)
586
601
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AWS
3
- VERSION = '3.28.0'.freeze
3
+ VERSION = '3.33.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.28.0
4
+ version: 3.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
8
8
  - Wesley Beary
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-10-14 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
@@ -59,14 +58,14 @@ dependencies:
59
58
  requirements:
60
59
  - - "~>"
61
60
  - !ruby/object:Gem::Version
62
- version: 2.3.0
61
+ version: 3.0.0
63
62
  type: :development
64
63
  prerelease: false
65
64
  version_requirements: !ruby/object:Gem::Requirement
66
65
  requirements:
67
66
  - - "~>"
68
67
  - !ruby/object:Gem::Version
69
- version: 2.3.0
68
+ version: 3.0.0
70
69
  - !ruby/object:Gem::Dependency
71
70
  name: shindo
72
71
  requirement: !ruby/object:Gem::Requirement
@@ -85,30 +84,36 @@ dependencies:
85
84
  name: base64
86
85
  requirement: !ruby/object:Gem::Requirement
87
86
  requirements:
88
- - - "~>"
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0.2'
90
+ - - "<"
89
91
  - !ruby/object:Gem::Version
90
- version: 0.2.0
92
+ version: '0.4'
91
93
  type: :runtime
92
94
  prerelease: false
93
95
  version_requirements: !ruby/object:Gem::Requirement
94
96
  requirements:
95
- - - "~>"
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0.2'
100
+ - - "<"
96
101
  - !ruby/object:Gem::Version
97
- version: 0.2.0
102
+ version: '0.4'
98
103
  - !ruby/object:Gem::Dependency
99
104
  name: fog-core
100
105
  requirement: !ruby/object:Gem::Requirement
101
106
  requirements:
102
107
  - - "~>"
103
108
  - !ruby/object:Gem::Version
104
- version: '2.1'
109
+ version: '2.6'
105
110
  type: :runtime
106
111
  prerelease: false
107
112
  version_requirements: !ruby/object:Gem::Requirement
108
113
  requirements:
109
114
  - - "~>"
110
115
  - !ruby/object:Gem::Version
111
- version: '2.1'
116
+ version: '2.6'
112
117
  - !ruby/object:Gem::Dependency
113
118
  name: fog-json
114
119
  requirement: !ruby/object:Gem::Requirement
@@ -614,7 +619,10 @@ files:
614
619
  - lib/fog/aws/parsers/iam/upload_server_certificate.rb
615
620
  - lib/fog/aws/parsers/iam/upload_signing_certificate.rb
616
621
  - lib/fog/aws/parsers/kms/describe_key.rb
622
+ - lib/fog/aws/parsers/kms/get_public_key.rb
617
623
  - lib/fog/aws/parsers/kms/list_keys.rb
624
+ - lib/fog/aws/parsers/kms/schedule_key_deletion.rb
625
+ - lib/fog/aws/parsers/kms/sign.rb
618
626
  - lib/fog/aws/parsers/lambda/base.rb
619
627
  - lib/fog/aws/parsers/rds/authorize_db_security_group_ingress.rb
620
628
  - lib/fog/aws/parsers/rds/base.rb
@@ -745,6 +753,7 @@ files:
745
753
  - lib/fog/aws/parsers/storage/get_service.rb
746
754
  - lib/fog/aws/parsers/storage/initiate_multipart_upload.rb
747
755
  - lib/fog/aws/parsers/storage/list_multipart_uploads.rb
756
+ - lib/fog/aws/parsers/storage/list_objects_v2.rb
748
757
  - lib/fog/aws/parsers/storage/list_parts.rb
749
758
  - lib/fog/aws/parsers/storage/upload_part_copy_object.rb
750
759
  - lib/fog/aws/parsers/sts/assume_role.rb
@@ -1236,7 +1245,10 @@ files:
1236
1245
  - lib/fog/aws/requests/kinesis/split_shard.rb
1237
1246
  - lib/fog/aws/requests/kms/create_key.rb
1238
1247
  - lib/fog/aws/requests/kms/describe_key.rb
1248
+ - lib/fog/aws/requests/kms/get_public_key.rb
1239
1249
  - lib/fog/aws/requests/kms/list_keys.rb
1250
+ - lib/fog/aws/requests/kms/schedule_key_deletion.rb
1251
+ - lib/fog/aws/requests/kms/sign.rb
1240
1252
  - lib/fog/aws/requests/lambda/add_permission.rb
1241
1253
  - lib/fog/aws/requests/lambda/create_event_source_mapping.rb
1242
1254
  - lib/fog/aws/requests/lambda/create_function.rb
@@ -1414,6 +1426,7 @@ files:
1414
1426
  - lib/fog/aws/requests/storage/head_object_url.rb
1415
1427
  - lib/fog/aws/requests/storage/initiate_multipart_upload.rb
1416
1428
  - lib/fog/aws/requests/storage/list_multipart_uploads.rb
1429
+ - lib/fog/aws/requests/storage/list_objects_v2.rb
1417
1430
  - lib/fog/aws/requests/storage/list_parts.rb
1418
1431
  - lib/fog/aws/requests/storage/post_object_hidden_fields.rb
1419
1432
  - lib/fog/aws/requests/storage/post_object_restore.rb
@@ -1458,7 +1471,6 @@ licenses:
1458
1471
  - MIT
1459
1472
  metadata:
1460
1473
  changelog_uri: https://github.com/fog/fog-aws/blob/master/CHANGELOG.md
1461
- post_install_message:
1462
1474
  rdoc_options: []
1463
1475
  require_paths:
1464
1476
  - lib
@@ -1473,8 +1485,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1473
1485
  - !ruby/object:Gem::Version
1474
1486
  version: '0'
1475
1487
  requirements: []
1476
- rubygems_version: 3.5.18
1477
- signing_key:
1488
+ rubygems_version: 3.7.1
1478
1489
  specification_version: 4
1479
1490
  summary: Module for the 'fog' gem to support Amazon Web Services.
1480
1491
  test_files: []