gapic-common 1.4.0 → 1.4.1
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 +6 -0
- data/lib/gapic/common/version.rb +1 -1
- data/lib/gapic/rest/grpc_transcoder.rb +39 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11f04f82fc6e98e5ca24d814d6162d68681999b6a7f2305cc32c77c597db2a88
|
|
4
|
+
data.tar.gz: a36c758ffd65878ac9809c0ecfc515e2c6e0e817f5ad679e8574e5dbeb8a03f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8fb7d4c578dc4b44383ac18e33159fd824465e63df13b10ed2d2fe142c4a9743876d7a3a41cd00680dc3e44cab88f6d3d6185198a8b74a85ace1ff30ee6d9e4e
|
|
7
|
+
data.tar.gz: 3d508937a578e43a1fe8022557d08a7c01be477b9141a1d055c0d6a1df8e739eca0a9e2f14d178aa90c4b121d44dd12e437d73242250009916645948238af388
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
+
### 1.4.1 (2026-09-28)
|
|
4
|
+
|
|
5
|
+
#### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* validate path parameters and prevent traversal/injection in REST transcoder ([#67](https://github.com/googleapis/ruby-core-libraries/issues/67))
|
|
8
|
+
|
|
3
9
|
### 1.4.0 (2026-09-23)
|
|
4
10
|
|
|
5
11
|
#### Features
|
data/lib/gapic/common/version.rb
CHANGED
|
@@ -111,12 +111,14 @@ module Gapic
|
|
|
111
111
|
# @return [Hash{String, String}]
|
|
112
112
|
# Name to value hash of the variables for the uri template expansion.
|
|
113
113
|
# The values are percent-escaped with slashes potentially preserved.
|
|
114
|
+
# @raise [Gapic::Common::Error] If any parameter value fails path traversal or injection validation.
|
|
114
115
|
def bind_uri_values! http_binding, request_hash
|
|
115
116
|
http_binding.field_bindings.to_h do |field_binding|
|
|
116
117
|
field_path_camel = field_binding.field_path.split(".").map { |part| camel_name_for part }.join(".")
|
|
117
118
|
field_value = extract_scalar_value! request_hash, field_path_camel, field_binding.regex
|
|
118
119
|
|
|
119
120
|
if field_value
|
|
121
|
+
validate_field_binding! field_binding, field_value
|
|
120
122
|
field_value = field_value.split("/").map { |segment| percent_escape segment }.join("/")
|
|
121
123
|
end
|
|
122
124
|
|
|
@@ -124,6 +126,43 @@ module Gapic
|
|
|
124
126
|
end
|
|
125
127
|
end
|
|
126
128
|
|
|
129
|
+
# Validates a user-supplied parameter value bound to a standard (*) or path (**) URI template variable
|
|
130
|
+
# to prevent directory traversal exploits.
|
|
131
|
+
#
|
|
132
|
+
# @param field_binding [HttpBinding::FieldBinding] The field binding template metadata.
|
|
133
|
+
# @param field_value [String] The parameter value to validate.
|
|
134
|
+
# @raise [Gapic::Common::Error] If validation fails.
|
|
135
|
+
def validate_field_binding! field_binding, field_value
|
|
136
|
+
validate_path_binding! field_binding, field_value
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Validates standard (*) and path (**) parameters by ensuring that no segment in the parameter
|
|
140
|
+
# value is a directory traversal segment (. or ..).
|
|
141
|
+
#
|
|
142
|
+
# Validation Mechanism:
|
|
143
|
+
# 1. Splits the parameter value by slash (`/`) using `-1` limit to preserve all segments.
|
|
144
|
+
# 2. Checks each segment. If any segment matches `.` or `..`, it immediately raises
|
|
145
|
+
# a `Gapic::Common::Error`, aborting the request.
|
|
146
|
+
# 3. Empty segments (e.g. duplicate slashes `//` or trailing slashes `/`) are allowed
|
|
147
|
+
# by this validator and passed to the server, which handles normalization or returns 400.
|
|
148
|
+
#
|
|
149
|
+
# @param field_binding [HttpBinding::FieldBinding] The field binding template metadata.
|
|
150
|
+
# @param field_value [String] The parameter value to validate.
|
|
151
|
+
# @raise [Gapic::Common::Error] If validation fails.
|
|
152
|
+
def validate_path_binding! field_binding, field_value
|
|
153
|
+
segments = field_value.split("/", -1)
|
|
154
|
+
segments.each do |segment|
|
|
155
|
+
next unless [".", ".."].include? segment
|
|
156
|
+
if field_binding.preserve_slashes
|
|
157
|
+
raise ::Gapic::Common::Error,
|
|
158
|
+
"Value for #{field_binding.field_path} must not contain segments that are exactly '#{segment}'."
|
|
159
|
+
else
|
|
160
|
+
raise ::Gapic::Common::Error,
|
|
161
|
+
"Invalid value for #{field_binding.field_path} '#{segment}'."
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
127
166
|
# Percent-escapes a string.
|
|
128
167
|
# @param str [String] String to escape.
|
|
129
168
|
# @return [String] Escaped string.
|