ssrfs-up-v2 0.21.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,381 @@
1
+ =begin
2
+ #SSRF Forwarder
3
+
4
+ #This is an API that forwards request on behalf of other services.
5
+
6
+ The version of the OpenAPI document: 1.0.0-oas3-oas3-oas3
7
+ Contact: jheath@chanzuckerberg.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ class Request
18
+ # the destination host of the request to be made
19
+ attr_accessor :host
20
+
21
+ attr_accessor :method
22
+
23
+ # boolean to indicate if the request should be made over HTTPS or not; default is secure
24
+ attr_accessor :secure
25
+
26
+ # any custom headers that should also be forwarded with the request
27
+ attr_accessor :headers
28
+
29
+ # a timeout length in seconds for the HTTP request to return; default is 10 seconds
30
+ attr_accessor :timeout
31
+
32
+ # a JSON object whose key/value pairs will be mapped to URL query parameters
33
+ attr_accessor :params
34
+
35
+ # a string representing the HTTP request or response body
36
+ attr_accessor :body
37
+
38
+ # any sensitive keys that are used in URL parameters or in the HTTP body; keys marked as sensitive will be automatically scubbed
39
+ attr_accessor :sensitive
40
+
41
+ attr_accessor :content_type
42
+
43
+ attr_accessor :redirect
44
+
45
+ # the path in the URL from the host; query parameters should not be included here
46
+ attr_accessor :path
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'host' => :'host',
52
+ :'method' => :'method',
53
+ :'secure' => :'secure',
54
+ :'headers' => :'headers',
55
+ :'timeout' => :'timeout',
56
+ :'params' => :'params',
57
+ :'body' => :'body',
58
+ :'sensitive' => :'sensitive',
59
+ :'content_type' => :'content_type',
60
+ :'redirect' => :'redirect',
61
+ :'path' => :'path'
62
+ }
63
+ end
64
+
65
+ # Returns all the JSON keys this model knows about
66
+ def self.acceptable_attributes
67
+ attribute_map.values
68
+ end
69
+
70
+ # Attribute type mapping.
71
+ def self.openapi_types
72
+ {
73
+ :'host' => :'String',
74
+ :'method' => :'Method',
75
+ :'secure' => :'Boolean',
76
+ :'headers' => :'Object',
77
+ :'timeout' => :'Integer',
78
+ :'params' => :'Object',
79
+ :'body' => :'String',
80
+ :'sensitive' => :'Array<String>',
81
+ :'content_type' => :'ContentType',
82
+ :'redirect' => :'Redirect',
83
+ :'path' => :'String'
84
+ }
85
+ end
86
+
87
+ # List of attributes with nullable: true
88
+ def self.openapi_nullable
89
+ Set.new([
90
+ ])
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ if (!attributes.is_a?(Hash))
97
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Request` initialize method"
98
+ end
99
+
100
+ # check to see if the attribute exists and convert string to symbol for hash key
101
+ attributes = attributes.each_with_object({}) { |(k, v), h|
102
+ if (!self.class.attribute_map.key?(k.to_sym))
103
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Request`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
104
+ end
105
+ h[k.to_sym] = v
106
+ }
107
+
108
+ if attributes.key?(:'host')
109
+ self.host = attributes[:'host']
110
+ end
111
+
112
+ if attributes.key?(:'method')
113
+ self.method = attributes[:'method']
114
+ else
115
+ self.method = 'GET'
116
+ end
117
+
118
+ if attributes.key?(:'secure')
119
+ self.secure = attributes[:'secure']
120
+ else
121
+ self.secure = true
122
+ end
123
+
124
+ if attributes.key?(:'headers')
125
+ self.headers = attributes[:'headers']
126
+ end
127
+
128
+ if attributes.key?(:'timeout')
129
+ self.timeout = attributes[:'timeout']
130
+ else
131
+ self.timeout = 10
132
+ end
133
+
134
+ if attributes.key?(:'params')
135
+ self.params = attributes[:'params']
136
+ end
137
+
138
+ if attributes.key?(:'body')
139
+ self.body = attributes[:'body']
140
+ else
141
+ self.body = ''
142
+ end
143
+
144
+ if attributes.key?(:'sensitive')
145
+ if (value = attributes[:'sensitive']).is_a?(Array)
146
+ self.sensitive = value
147
+ end
148
+ end
149
+
150
+ if attributes.key?(:'content_type')
151
+ self.content_type = attributes[:'content_type']
152
+ else
153
+ self.content_type = 'application/json'
154
+ end
155
+
156
+ if attributes.key?(:'redirect')
157
+ self.redirect = attributes[:'redirect']
158
+ end
159
+
160
+ if attributes.key?(:'path')
161
+ self.path = attributes[:'path']
162
+ else
163
+ self.path = ''
164
+ end
165
+ end
166
+
167
+ # Show invalid properties with the reasons. Usually used together with valid?
168
+ # @return Array for valid properties with the reasons
169
+ def list_invalid_properties
170
+ invalid_properties = Array.new
171
+ if @host.nil?
172
+ invalid_properties.push('invalid value for "host", host cannot be nil.')
173
+ end
174
+
175
+ if @method.nil?
176
+ invalid_properties.push('invalid value for "method", method cannot be nil.')
177
+ end
178
+
179
+ if @secure.nil?
180
+ invalid_properties.push('invalid value for "secure", secure cannot be nil.')
181
+ end
182
+
183
+ if @headers.nil?
184
+ invalid_properties.push('invalid value for "headers", headers cannot be nil.')
185
+ end
186
+
187
+ if @timeout.nil?
188
+ invalid_properties.push('invalid value for "timeout", timeout cannot be nil.')
189
+ end
190
+
191
+ if @params.nil?
192
+ invalid_properties.push('invalid value for "params", params cannot be nil.')
193
+ end
194
+
195
+ if @body.nil?
196
+ invalid_properties.push('invalid value for "body", body cannot be nil.')
197
+ end
198
+
199
+ if @sensitive.nil?
200
+ invalid_properties.push('invalid value for "sensitive", sensitive cannot be nil.')
201
+ end
202
+
203
+ if @content_type.nil?
204
+ invalid_properties.push('invalid value for "content_type", content_type cannot be nil.')
205
+ end
206
+
207
+ if @path.nil?
208
+ invalid_properties.push('invalid value for "path", path cannot be nil.')
209
+ end
210
+
211
+ invalid_properties
212
+ end
213
+
214
+ # Check to see if the all the properties in the model are valid
215
+ # @return true if the model is valid
216
+ def valid?
217
+ return false if @host.nil?
218
+ return false if @method.nil?
219
+ return false if @secure.nil?
220
+ return false if @headers.nil?
221
+ return false if @timeout.nil?
222
+ return false if @params.nil?
223
+ return false if @body.nil?
224
+ return false if @sensitive.nil?
225
+ return false if @content_type.nil?
226
+ return false if @path.nil?
227
+ true
228
+ end
229
+
230
+ # Checks equality by comparing each attribute.
231
+ # @param [Object] Object to be compared
232
+ def ==(o)
233
+ return true if self.equal?(o)
234
+ self.class == o.class &&
235
+ host == o.host &&
236
+ method == o.method &&
237
+ secure == o.secure &&
238
+ headers == o.headers &&
239
+ timeout == o.timeout &&
240
+ params == o.params &&
241
+ body == o.body &&
242
+ sensitive == o.sensitive &&
243
+ content_type == o.content_type &&
244
+ redirect == o.redirect &&
245
+ path == o.path
246
+ end
247
+
248
+ # @see the `==` method
249
+ # @param [Object] Object to be compared
250
+ def eql?(o)
251
+ self == o
252
+ end
253
+
254
+ # Calculates hash code according to all attributes.
255
+ # @return [Integer] Hash code
256
+ def hash
257
+ [host, method, secure, headers, timeout, params, body, sensitive, content_type, redirect, path].hash
258
+ end
259
+
260
+ # Builds the object from hash
261
+ # @param [Hash] attributes Model attributes in the form of hash
262
+ # @return [Object] Returns the model itself
263
+ def self.build_from_hash(attributes)
264
+ new.build_from_hash(attributes)
265
+ end
266
+
267
+ # Builds the object from hash
268
+ # @param [Hash] attributes Model attributes in the form of hash
269
+ # @return [Object] Returns the model itself
270
+ def build_from_hash(attributes)
271
+ return nil unless attributes.is_a?(Hash)
272
+ attributes = attributes.transform_keys(&:to_sym)
273
+ self.class.openapi_types.each_pair do |key, type|
274
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
275
+ self.send("#{key}=", nil)
276
+ elsif type =~ /\AArray<(.*)>/i
277
+ # check to ensure the input is an array given that the attribute
278
+ # is documented as an array but the input is not
279
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
280
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
281
+ end
282
+ elsif !attributes[self.class.attribute_map[key]].nil?
283
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
284
+ end
285
+ end
286
+
287
+ self
288
+ end
289
+
290
+ # Deserializes the data based on type
291
+ # @param string type Data type
292
+ # @param string value Value to be deserialized
293
+ # @return [Object] Deserialized data
294
+ def _deserialize(type, value)
295
+ case type.to_sym
296
+ when :Time
297
+ Time.parse(value)
298
+ when :Date
299
+ Date.parse(value)
300
+ when :String
301
+ value.to_s
302
+ when :Integer
303
+ value.to_i
304
+ when :Float
305
+ value.to_f
306
+ when :Boolean
307
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
308
+ true
309
+ else
310
+ false
311
+ end
312
+ when :Object
313
+ # generic object (usually a Hash), return directly
314
+ value
315
+ when /\AArray<(?<inner_type>.+)>\z/
316
+ inner_type = Regexp.last_match[:inner_type]
317
+ value.map { |v| _deserialize(inner_type, v) }
318
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
319
+ k_type = Regexp.last_match[:k_type]
320
+ v_type = Regexp.last_match[:v_type]
321
+ {}.tap do |hash|
322
+ value.each do |k, v|
323
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
324
+ end
325
+ end
326
+ else # model
327
+ # models (e.g. Pet) or oneOf
328
+ klass = OpenapiClient.const_get(type)
329
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
330
+ end
331
+ end
332
+
333
+ # Returns the string representation of the object
334
+ # @return [String] String presentation of the object
335
+ def to_s
336
+ to_hash.to_s
337
+ end
338
+
339
+ # to_body is an alias to to_hash (backward compatibility)
340
+ # @return [Hash] Returns the object in the form of hash
341
+ def to_body
342
+ to_hash
343
+ end
344
+
345
+ # Returns the object in the form of hash
346
+ # @return [Hash] Returns the object in the form of hash
347
+ def to_hash
348
+ hash = {}
349
+ self.class.attribute_map.each_pair do |attr, param|
350
+ value = self.send(attr)
351
+ if value.nil?
352
+ is_nullable = self.class.openapi_nullable.include?(attr)
353
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
354
+ end
355
+
356
+ hash[param] = _to_hash(value)
357
+ end
358
+ hash
359
+ end
360
+
361
+ # Outputs non-array value in the form of hash
362
+ # For object, use to_hash. Otherwise, just return the value
363
+ # @param [Object] value Any valid value
364
+ # @return [Hash] Returns the value in the form of hash
365
+ def _to_hash(value)
366
+ if value.is_a?(Array)
367
+ value.compact.map { |v| _to_hash(v) }
368
+ elsif value.is_a?(Hash)
369
+ {}.tap do |hash|
370
+ value.each { |k, v| hash[k] = _to_hash(v) }
371
+ end
372
+ elsif value.respond_to? :to_hash
373
+ value.to_hash
374
+ else
375
+ value
376
+ end
377
+ end
378
+
379
+ end
380
+
381
+ end
@@ -0,0 +1,299 @@
1
+ =begin
2
+ #SSRF Forwarder
3
+
4
+ #This is an API that forwards request on behalf of other services.
5
+
6
+ The version of the OpenAPI document: 1.0.0-oas3-oas3-oas3
7
+ Contact: jheath@chanzuckerberg.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ class Response
18
+ # the status text string from an HTTP response
19
+ attr_accessor :status_text
20
+
21
+ # the numbered status code from an HTTP response
22
+ attr_accessor :status_code
23
+
24
+ # any custom headers that should also be forwarded with the request
25
+ attr_accessor :headers
26
+
27
+ # a string representing the HTTP request or response body
28
+ attr_accessor :body
29
+
30
+ # error message
31
+ attr_accessor :error
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'status_text' => :'status_text',
37
+ :'status_code' => :'status_code',
38
+ :'headers' => :'headers',
39
+ :'body' => :'body',
40
+ :'error' => :'error'
41
+ }
42
+ end
43
+
44
+ # Returns all the JSON keys this model knows about
45
+ def self.acceptable_attributes
46
+ attribute_map.values
47
+ end
48
+
49
+ # Attribute type mapping.
50
+ def self.openapi_types
51
+ {
52
+ :'status_text' => :'String',
53
+ :'status_code' => :'Integer',
54
+ :'headers' => :'Object',
55
+ :'body' => :'String',
56
+ :'error' => :'String'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ ])
64
+ end
65
+
66
+ # List of class defined in allOf (OpenAPI v3)
67
+ def self.openapi_all_of
68
+ [
69
+ :'ResponseError',
70
+ :'ResponseSuccess'
71
+ ]
72
+ end
73
+
74
+ # Initializes the object
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ def initialize(attributes = {})
77
+ if (!attributes.is_a?(Hash))
78
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Response` initialize method"
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!self.class.attribute_map.key?(k.to_sym))
84
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ end
86
+ h[k.to_sym] = v
87
+ }
88
+
89
+ if attributes.key?(:'status_text')
90
+ self.status_text = attributes[:'status_text']
91
+ else
92
+ self.status_text = ''
93
+ end
94
+
95
+ if attributes.key?(:'status_code')
96
+ self.status_code = attributes[:'status_code']
97
+ else
98
+ self.status_code = 200
99
+ end
100
+
101
+ if attributes.key?(:'headers')
102
+ self.headers = attributes[:'headers']
103
+ end
104
+
105
+ if attributes.key?(:'body')
106
+ self.body = attributes[:'body']
107
+ else
108
+ self.body = ''
109
+ end
110
+
111
+ if attributes.key?(:'error')
112
+ self.error = attributes[:'error']
113
+ end
114
+ end
115
+
116
+ # Show invalid properties with the reasons. Usually used together with valid?
117
+ # @return Array for valid properties with the reasons
118
+ def list_invalid_properties
119
+ invalid_properties = Array.new
120
+ if @status_text.nil?
121
+ invalid_properties.push('invalid value for "status_text", status_text cannot be nil.')
122
+ end
123
+
124
+ if @status_code.nil?
125
+ invalid_properties.push('invalid value for "status_code", status_code cannot be nil.')
126
+ end
127
+
128
+ if @headers.nil?
129
+ invalid_properties.push('invalid value for "headers", headers cannot be nil.')
130
+ end
131
+
132
+ if @body.nil?
133
+ invalid_properties.push('invalid value for "body", body cannot be nil.')
134
+ end
135
+
136
+ if @error.nil?
137
+ invalid_properties.push('invalid value for "error", error cannot be nil.')
138
+ end
139
+
140
+ invalid_properties
141
+ end
142
+
143
+ # Check to see if the all the properties in the model are valid
144
+ # @return true if the model is valid
145
+ def valid?
146
+ return false if @status_text.nil?
147
+ return false if @status_code.nil?
148
+ return false if @headers.nil?
149
+ return false if @body.nil?
150
+ return false if @error.nil?
151
+ true
152
+ end
153
+
154
+ # Checks equality by comparing each attribute.
155
+ # @param [Object] Object to be compared
156
+ def ==(o)
157
+ return true if self.equal?(o)
158
+ self.class == o.class &&
159
+ status_text == o.status_text &&
160
+ status_code == o.status_code &&
161
+ headers == o.headers &&
162
+ body == o.body &&
163
+ error == o.error
164
+ end
165
+
166
+ # @see the `==` method
167
+ # @param [Object] Object to be compared
168
+ def eql?(o)
169
+ self == o
170
+ end
171
+
172
+ # Calculates hash code according to all attributes.
173
+ # @return [Integer] Hash code
174
+ def hash
175
+ [status_text, status_code, headers, body, error].hash
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def self.build_from_hash(attributes)
182
+ new.build_from_hash(attributes)
183
+ end
184
+
185
+ # Builds the object from hash
186
+ # @param [Hash] attributes Model attributes in the form of hash
187
+ # @return [Object] Returns the model itself
188
+ def build_from_hash(attributes)
189
+ return nil unless attributes.is_a?(Hash)
190
+ attributes = attributes.transform_keys(&:to_sym)
191
+ self.class.openapi_types.each_pair do |key, type|
192
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
193
+ self.send("#{key}=", nil)
194
+ elsif type =~ /\AArray<(.*)>/i
195
+ # check to ensure the input is an array given that the attribute
196
+ # is documented as an array but the input is not
197
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
198
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
199
+ end
200
+ elsif !attributes[self.class.attribute_map[key]].nil?
201
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
202
+ end
203
+ end
204
+
205
+ self
206
+ end
207
+
208
+ # Deserializes the data based on type
209
+ # @param string type Data type
210
+ # @param string value Value to be deserialized
211
+ # @return [Object] Deserialized data
212
+ def _deserialize(type, value)
213
+ case type.to_sym
214
+ when :Time
215
+ Time.parse(value)
216
+ when :Date
217
+ Date.parse(value)
218
+ when :String
219
+ value.to_s
220
+ when :Integer
221
+ value.to_i
222
+ when :Float
223
+ value.to_f
224
+ when :Boolean
225
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
226
+ true
227
+ else
228
+ false
229
+ end
230
+ when :Object
231
+ # generic object (usually a Hash), return directly
232
+ value
233
+ when /\AArray<(?<inner_type>.+)>\z/
234
+ inner_type = Regexp.last_match[:inner_type]
235
+ value.map { |v| _deserialize(inner_type, v) }
236
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
237
+ k_type = Regexp.last_match[:k_type]
238
+ v_type = Regexp.last_match[:v_type]
239
+ {}.tap do |hash|
240
+ value.each do |k, v|
241
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
242
+ end
243
+ end
244
+ else # model
245
+ # models (e.g. Pet) or oneOf
246
+ klass = OpenapiClient.const_get(type)
247
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
248
+ end
249
+ end
250
+
251
+ # Returns the string representation of the object
252
+ # @return [String] String presentation of the object
253
+ def to_s
254
+ to_hash.to_s
255
+ end
256
+
257
+ # to_body is an alias to to_hash (backward compatibility)
258
+ # @return [Hash] Returns the object in the form of hash
259
+ def to_body
260
+ to_hash
261
+ end
262
+
263
+ # Returns the object in the form of hash
264
+ # @return [Hash] Returns the object in the form of hash
265
+ def to_hash
266
+ hash = {}
267
+ self.class.attribute_map.each_pair do |attr, param|
268
+ value = self.send(attr)
269
+ if value.nil?
270
+ is_nullable = self.class.openapi_nullable.include?(attr)
271
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
272
+ end
273
+
274
+ hash[param] = _to_hash(value)
275
+ end
276
+ hash
277
+ end
278
+
279
+ # Outputs non-array value in the form of hash
280
+ # For object, use to_hash. Otherwise, just return the value
281
+ # @param [Object] value Any valid value
282
+ # @return [Hash] Returns the value in the form of hash
283
+ def _to_hash(value)
284
+ if value.is_a?(Array)
285
+ value.compact.map { |v| _to_hash(v) }
286
+ elsif value.is_a?(Hash)
287
+ {}.tap do |hash|
288
+ value.each { |k, v| hash[k] = _to_hash(v) }
289
+ end
290
+ elsif value.respond_to? :to_hash
291
+ value.to_hash
292
+ else
293
+ value
294
+ end
295
+ end
296
+
297
+ end
298
+
299
+ end