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,306 @@
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
+ module OpenapiClient
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
66
+ # details will be logged with `logger.debug` (see the `logger` attribute).
67
+ # Default to false.
68
+ #
69
+ # @return [true, false]
70
+ attr_accessor :debugging
71
+
72
+ # Defines the logger used for debugging.
73
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
74
+ #
75
+ # @return [#debug]
76
+ attr_accessor :logger
77
+
78
+ # Defines the temporary folder to store downloaded files
79
+ # (for API endpoints that have file response).
80
+ # Default to use `Tempfile`.
81
+ #
82
+ # @return [String]
83
+ attr_accessor :temp_folder_path
84
+
85
+ # The time limit for HTTP request in seconds.
86
+ # Default to 0 (never times out).
87
+ attr_accessor :timeout
88
+
89
+ # Set this to false to skip client side validation in the operation.
90
+ # Default to true.
91
+ # @return [true, false]
92
+ attr_accessor :client_side_validation
93
+
94
+ ### TLS/SSL setting
95
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
96
+ # Default to true.
97
+ #
98
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
99
+ #
100
+ # @return [true, false]
101
+ attr_accessor :ssl_verify
102
+
103
+ ### TLS/SSL setting
104
+ # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
105
+ #
106
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
107
+ #
108
+ attr_accessor :ssl_verify_mode
109
+
110
+ ### TLS/SSL setting
111
+ # Set this to customize the certificate file to verify the peer.
112
+ #
113
+ # @return [String] the path to the certificate file
114
+ attr_accessor :ssl_ca_file
115
+
116
+ ### TLS/SSL setting
117
+ # Client certificate file (for client certificate)
118
+ attr_accessor :ssl_client_cert
119
+
120
+ ### TLS/SSL setting
121
+ # Client private key file (for client certificate)
122
+ attr_accessor :ssl_client_key
123
+
124
+ ### Proxy setting
125
+ # HTTP Proxy settings
126
+ attr_accessor :proxy
127
+
128
+ # Set this to customize parameters encoder of array parameter.
129
+ # Default to nil. Faraday uses NestedParamsEncoder when nil.
130
+ #
131
+ # @see The params_encoder option of Faraday. Related source code:
132
+ # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
133
+ attr_accessor :params_encoder
134
+
135
+
136
+ attr_accessor :inject_format
137
+
138
+ attr_accessor :force_ending_format
139
+
140
+ def initialize
141
+ @scheme = 'https'
142
+ @host = 'ssrf.czisec.com'
143
+ @base_path = ''
144
+ @server_index = 0
145
+ @server_operation_index = {}
146
+ @server_variables = {}
147
+ @server_operation_variables = {}
148
+ @api_key = {}
149
+ @api_key_prefix = {}
150
+ @client_side_validation = true
151
+ @ssl_verify = true
152
+ @ssl_verify_mode = nil
153
+ @ssl_ca_file = nil
154
+ @ssl_client_cert = nil
155
+ @ssl_client_key = nil
156
+ @middlewares = []
157
+ @request_middlewares = []
158
+ @response_middlewares = []
159
+ @timeout = 60
160
+ # return data as binary instead of file
161
+ @return_binary_data = false
162
+ @params_encoder = nil
163
+ @debugging = false
164
+ @inject_format = false
165
+ @force_ending_format = false
166
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
167
+
168
+ yield(self) if block_given?
169
+ end
170
+
171
+ # The default Configuration object.
172
+ def self.default
173
+ @@default ||= Configuration.new
174
+ end
175
+
176
+ def configure
177
+ yield(self) if block_given?
178
+ end
179
+
180
+ def scheme=(scheme)
181
+ # remove :// from scheme
182
+ @scheme = scheme.sub(/:\/\//, '')
183
+ end
184
+
185
+ def host=(host)
186
+ # remove http(s):// and anything after a slash
187
+ @host = host.sub(/https?:\/\//, '').split('/').first
188
+ end
189
+
190
+ def base_path=(base_path)
191
+ # Add leading and trailing slashes to base_path
192
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
193
+ @base_path = '' if @base_path == '/'
194
+ end
195
+
196
+ # Returns base URL for specified operation based on server settings
197
+ def base_url(operation = nil)
198
+ index = server_operation_index.fetch(operation, server_index)
199
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
200
+
201
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
202
+ end
203
+
204
+ # Gets API key (with prefix if set).
205
+ # @param [String] param_name the parameter name of API key auth
206
+ def api_key_with_prefix(param_name, param_alias = nil)
207
+ key = @api_key[param_name]
208
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
209
+ if @api_key_prefix[param_name]
210
+ "#{@api_key_prefix[param_name]} #{key}"
211
+ else
212
+ key
213
+ end
214
+ end
215
+
216
+ # Gets Basic Auth token string
217
+ def basic_auth_token
218
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
219
+ end
220
+
221
+ # Returns Auth Settings hash for api client.
222
+ def auth_settings
223
+ {
224
+ }
225
+ end
226
+
227
+ # Returns an array of Server setting
228
+ def server_settings
229
+ [
230
+ {
231
+ url: "https://ssrf.czisec.com",
232
+ description: "No description provided",
233
+ }
234
+ ]
235
+ end
236
+
237
+ def operation_server_settings
238
+ {
239
+ }
240
+ end
241
+
242
+ # Returns URL based on server settings
243
+ #
244
+ # @param index array index of the server settings
245
+ # @param variables hash of variable and the corresponding value
246
+ def server_url(index, variables = {}, servers = nil)
247
+ servers = server_settings if servers == nil
248
+
249
+ # check array index out of bound
250
+ if (index < 0 || index >= servers.size)
251
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
252
+ end
253
+
254
+ server = servers[index]
255
+ url = server[:url]
256
+
257
+ return url unless server.key? :variables
258
+
259
+ # go through variable and assign a value
260
+ server[:variables].each do |name, variable|
261
+ if variables.key?(name)
262
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
263
+ url.gsub! "{" + name.to_s + "}", variables[name]
264
+ else
265
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
266
+ end
267
+ else
268
+ # use default value
269
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
270
+ end
271
+ end
272
+
273
+ url
274
+ end
275
+
276
+ # Adds middleware to the stack
277
+ def use(*middleware)
278
+ @middlewares << middleware
279
+ end
280
+
281
+ # Adds request middleware to the stack
282
+ def request(*middleware)
283
+ @request_middlewares << middleware
284
+ end
285
+
286
+ # Adds response middleware to the stack
287
+ def response(*middleware)
288
+ @response_middlewares << middleware
289
+ end
290
+
291
+ # Set up middleware on the connection
292
+ def configure_middleware(connection)
293
+ @middlewares.each do |middleware|
294
+ connection.use(*middleware)
295
+ end
296
+
297
+ @request_middlewares.each do |middleware|
298
+ connection.request(*middleware)
299
+ end
300
+
301
+ @response_middlewares.each do |middleware|
302
+ connection.response(*middleware)
303
+ end
304
+ end
305
+ end
306
+ end
@@ -0,0 +1,40 @@
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 ContentType
18
+ APPLICATION_JSON = "application/json".freeze
19
+ TEXT_HTML = "text/html".freeze
20
+ TEXT_PLAIN = "text/plain".freeze
21
+ APPLICATION_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded".freeze
22
+ MULTIPART_FORM_DATA = "multipart/form-data".freeze
23
+
24
+ # Builds the enum from string
25
+ # @param [String] The enum value in the form of the string
26
+ # @return [String] The enum value
27
+ def self.build_from_hash(value)
28
+ new.build_from_hash(value)
29
+ end
30
+
31
+ # Builds the enum from string
32
+ # @param [String] The enum value in the form of the string
33
+ # @return [String] The enum value
34
+ def build_from_hash(value)
35
+ constantValues = ContentType.constants.select { |c| ContentType::const_get(c) == value }
36
+ raise "Invalid ENUM value #{value} for class #ContentType" if constantValues.empty?
37
+ value
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
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 Method
18
+ GET = "GET".freeze
19
+ PUT = "PUT".freeze
20
+ POST = "POST".freeze
21
+ PATCH = "PATCH".freeze
22
+ DELETE = "DELETE".freeze
23
+
24
+ # Builds the enum from string
25
+ # @param [String] The enum value in the form of the string
26
+ # @return [String] The enum value
27
+ def self.build_from_hash(value)
28
+ new.build_from_hash(value)
29
+ end
30
+
31
+ # Builds the enum from string
32
+ # @param [String] The enum value in the form of the string
33
+ # @return [String] The enum value
34
+ def build_from_hash(value)
35
+ constantValues = Method.constants.select { |c| Method::const_get(c) == value }
36
+ raise "Invalid ENUM value #{value} for class #Method" if constantValues.empty?
37
+ value
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,243 @@
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
+ # option to configure how the service should handle HTTP responses with redirects
18
+ class Redirect
19
+ attr_accessor :follow
20
+
21
+ attr_accessor :follow_limit
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'follow' => :'follow',
27
+ :'follow_limit' => :'follow-limit'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'follow' => :'Boolean',
40
+ :'follow_limit' => :'Integer'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Redirect` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Redirect`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'follow')
66
+ self.follow = attributes[:'follow']
67
+ else
68
+ self.follow = true
69
+ end
70
+
71
+ if attributes.key?(:'follow_limit')
72
+ self.follow_limit = attributes[:'follow_limit']
73
+ else
74
+ self.follow_limit = 3
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ if @follow.nil?
83
+ invalid_properties.push('invalid value for "follow", follow cannot be nil.')
84
+ end
85
+
86
+ if @follow_limit.nil?
87
+ invalid_properties.push('invalid value for "follow_limit", follow_limit cannot be nil.')
88
+ end
89
+
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ return false if @follow.nil?
97
+ return false if @follow_limit.nil?
98
+ true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ follow == o.follow &&
107
+ follow_limit == o.follow_limit
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Integer] Hash code
118
+ def hash
119
+ [follow, follow_limit].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def self.build_from_hash(attributes)
126
+ new.build_from_hash(attributes)
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def build_from_hash(attributes)
133
+ return nil unless attributes.is_a?(Hash)
134
+ attributes = attributes.transform_keys(&:to_sym)
135
+ self.class.openapi_types.each_pair do |key, type|
136
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
137
+ self.send("#{key}=", nil)
138
+ elsif type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :Time
159
+ Time.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ # models (e.g. Pet) or oneOf
190
+ klass = OpenapiClient.const_get(type)
191
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
218
+ hash[param] = _to_hash(value)
219
+ end
220
+ hash
221
+ end
222
+
223
+ # Outputs non-array value in the form of hash
224
+ # For object, use to_hash. Otherwise, just return the value
225
+ # @param [Object] value Any valid value
226
+ # @return [Hash] Returns the value in the form of hash
227
+ def _to_hash(value)
228
+ if value.is_a?(Array)
229
+ value.compact.map { |v| _to_hash(v) }
230
+ elsif value.is_a?(Hash)
231
+ {}.tap do |hash|
232
+ value.each { |k, v| hash[k] = _to_hash(v) }
233
+ end
234
+ elsif value.respond_to? :to_hash
235
+ value.to_hash
236
+ else
237
+ value
238
+ end
239
+ end
240
+
241
+ end
242
+
243
+ end