aws-sdk-sqs 1.71.0 → 1.72.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-sqs/client.rb +1 -1
- data/lib/aws-sdk-sqs/plugins/md5s.rb +84 -35
- data/lib/aws-sdk-sqs.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc33461fcd4ab13322dca0464f15da04a78ecc9a7f35a0019d528486f815d80
|
4
|
+
data.tar.gz: 12e287ef33fdf91219e1fd26749c758667302b234d7a8ef17ab6d88d56003e76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6b3398c64232fb1d2b608d899e5a51989cbb02a15bcb0429ccc167ce20a2d4616195bfa8035ee8e1d77192b4fba33bcccb861e62cbafb2242280cf1a717d68f
|
7
|
+
data.tar.gz: 6feb77d8953a9fec2461122819de5fd44b3c12a48e10a864a05db92e0a6dec7425e24aea353f0f0b3e09fcb6335bcfa4c7b0724c65951e918cd2a7b3faa67874
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.72.0
|
data/lib/aws-sdk-sqs/client.rb
CHANGED
@@ -6,7 +6,6 @@ module Aws
|
|
6
6
|
module SQS
|
7
7
|
module Plugins
|
8
8
|
class Md5s < Seahorse::Client::Plugin
|
9
|
-
|
10
9
|
# @api private
|
11
10
|
class Handler < Seahorse::Client::Handler
|
12
11
|
def call(context)
|
@@ -26,16 +25,17 @@ module Aws
|
|
26
25
|
'String' => 1,
|
27
26
|
'Binary' => 2,
|
28
27
|
'Number' => 1
|
29
|
-
}
|
28
|
+
}.freeze
|
30
29
|
|
31
|
-
DATA_TYPE = /\A(String|Binary|Number)(\..+)?\z
|
30
|
+
DATA_TYPE = /\A(String|Binary|Number)(\..+)?\z/.freeze
|
32
31
|
|
33
32
|
NORMALIZED_ENCODING = Encoding::UTF_8
|
34
33
|
|
35
34
|
def validate_send_message(context, response)
|
36
35
|
body = context.params[:message_body]
|
37
36
|
attributes = context.params[:message_attributes]
|
38
|
-
|
37
|
+
system_attributes = context.params[:message_system_attributes]
|
38
|
+
validate_single_message(body, attributes, system_attributes, response)
|
39
39
|
end
|
40
40
|
|
41
41
|
def validate_send_message_batch(context, response)
|
@@ -43,63 +43,87 @@ module Aws
|
|
43
43
|
id = entry[:id]
|
44
44
|
body = entry[:message_body]
|
45
45
|
attributes = entry[:message_attributes]
|
46
|
+
system_attributes = entry[:message_system_attributes]
|
46
47
|
message_response = response.successful.select { |r| r.id == id }[0]
|
47
48
|
unless message_response.nil?
|
48
|
-
validate_single_message(body, attributes, message_response)
|
49
|
+
validate_single_message(body, attributes, system_attributes, message_response)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
|
-
def validate_single_message(body, attributes, response)
|
54
|
+
def validate_single_message(body, attributes, system_attributes, response)
|
54
55
|
validate_body(body, response)
|
55
56
|
unless attributes.nil? || attributes.empty?
|
56
57
|
validate_attributes(attributes, response)
|
57
58
|
end
|
59
|
+
unless system_attributes.nil? || system_attributes.empty?
|
60
|
+
validate_system_attributes(system_attributes, response)
|
61
|
+
end
|
58
62
|
end
|
59
63
|
|
60
64
|
def validate_body(body, response)
|
61
65
|
calculated_md5 = md5_of_message_body(body)
|
62
66
|
returned_md5 = response.md5_of_message_body
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
return unless calculated_md5 != returned_md5
|
68
|
+
|
69
|
+
error_message = mismatch_error_message(
|
70
|
+
'message body',
|
71
|
+
calculated_md5,
|
72
|
+
returned_md5,
|
73
|
+
response
|
74
|
+
)
|
75
|
+
raise Aws::Errors::ChecksumError, error_message
|
71
76
|
end
|
72
77
|
|
73
78
|
def validate_attributes(attributes, response)
|
74
79
|
calculated_md5 = md5_of_message_attributes(attributes)
|
75
80
|
returned_md5 = response.md5_of_message_attributes
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
return unless returned_md5 != calculated_md5
|
82
|
+
|
83
|
+
error_message = mismatch_error_message(
|
84
|
+
'message attributes',
|
85
|
+
calculated_md5,
|
86
|
+
returned_md5,
|
87
|
+
response
|
88
|
+
)
|
89
|
+
raise Aws::Errors::ChecksumError, error_message
|
90
|
+
end
|
91
|
+
|
92
|
+
def validate_system_attributes(system_attributes, response)
|
93
|
+
calculated_md5 = md5_of_message_system_attributes(system_attributes)
|
94
|
+
returned_md5 = response.md5_of_message_system_attributes
|
95
|
+
return unless returned_md5 != calculated_md5
|
96
|
+
|
97
|
+
error_message = mismatch_error_message(
|
98
|
+
'message system attributes',
|
99
|
+
calculated_md5,
|
100
|
+
returned_md5,
|
101
|
+
response
|
102
|
+
)
|
103
|
+
raise Aws::Errors::ChecksumError, error_message
|
84
104
|
end
|
85
105
|
|
86
106
|
def md5_of_message_body(message_body)
|
87
107
|
OpenSSL::Digest::MD5.hexdigest(message_body)
|
88
108
|
end
|
89
109
|
|
110
|
+
# MD5 of Message Attributes and System Attributes are effectively
|
111
|
+
# the same calculation. However, keeping these as two methods because
|
112
|
+
# they are modeled as two different shapes.
|
113
|
+
###
|
90
114
|
def md5_of_message_attributes(message_attributes)
|
91
|
-
encoded = {
|
115
|
+
encoded = {}
|
92
116
|
message_attributes.each do |name, attribute|
|
93
117
|
name = name.to_s
|
94
118
|
encoded[name] = String.new
|
95
119
|
data_type_without_label = DATA_TYPE.match(attribute[:data_type])[1]
|
96
120
|
encoded[name] << encode_length_and_bytes(name) <<
|
97
|
-
|
98
|
-
|
121
|
+
encode_length_and_bytes(attribute[:data_type]) <<
|
122
|
+
[TRANSPORT_TYPE_ENCODINGS[data_type_without_label]].pack('C')
|
99
123
|
|
100
|
-
if attribute[:string_value]
|
124
|
+
if !attribute[:string_value].nil?
|
101
125
|
encoded[name] << encode_length_and_string(attribute[:string_value])
|
102
|
-
elsif attribute[:binary_value]
|
126
|
+
elsif !attribute[:binary_value].nil?
|
103
127
|
encoded[name] << encode_length_and_bytes(attribute[:binary_value])
|
104
128
|
end
|
105
129
|
end
|
@@ -110,6 +134,30 @@ module Aws
|
|
110
134
|
OpenSSL::Digest::MD5.hexdigest(buffer)
|
111
135
|
end
|
112
136
|
|
137
|
+
def md5_of_message_system_attributes(message_system_attributes)
|
138
|
+
encoded = {}
|
139
|
+
message_system_attributes.each do |name, attribute|
|
140
|
+
name = name.to_s
|
141
|
+
encoded[name] = String.new
|
142
|
+
data_type_without_label = DATA_TYPE.match(attribute[:data_type])[1]
|
143
|
+
encoded[name] << encode_length_and_bytes(name) <<
|
144
|
+
encode_length_and_bytes(attribute[:data_type]) <<
|
145
|
+
[TRANSPORT_TYPE_ENCODINGS[data_type_without_label]].pack('C')
|
146
|
+
|
147
|
+
if !attribute[:string_value].nil?
|
148
|
+
encoded[name] << encode_length_and_string(attribute[:string_value])
|
149
|
+
elsif !attribute[:binary_value].nil?
|
150
|
+
encoded[name] << encode_length_and_bytes(attribute[:binary_value])
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
buffer = encoded.keys.sort.reduce(String.new) do |string, name|
|
155
|
+
string << encoded[name]
|
156
|
+
end
|
157
|
+
OpenSSL::Digest::MD5.hexdigest(buffer)
|
158
|
+
end
|
159
|
+
###
|
160
|
+
|
113
161
|
def encode_length_and_string(string)
|
114
162
|
string = String.new(string)
|
115
163
|
string.encode!(NORMALIZED_ENCODING)
|
@@ -117,7 +165,7 @@ module Aws
|
|
117
165
|
end
|
118
166
|
|
119
167
|
def encode_length_and_bytes(bytes)
|
120
|
-
[bytes.bytesize, bytes].pack('L>a*'
|
168
|
+
[bytes.bytesize, bytes].pack('L>a*')
|
121
169
|
end
|
122
170
|
|
123
171
|
def mismatch_error_message(section, local_md5, returned_md5, response)
|
@@ -154,13 +202,14 @@ not match.
|
|
154
202
|
end
|
155
203
|
|
156
204
|
def add_handlers(handlers, config)
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
205
|
+
return unless config.verify_checksums
|
206
|
+
|
207
|
+
handlers.add(
|
208
|
+
Handler,
|
209
|
+
priority: 10,
|
210
|
+
step: :validate,
|
211
|
+
operations: %i[send_message send_message_batch]
|
212
|
+
)
|
164
213
|
end
|
165
214
|
end
|
166
215
|
end
|
data/lib/aws-sdk-sqs.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-sqs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.72.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|