ssrfs-up 0.0.9 → 0.0.10

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: 2796b96f6866e077be5b51b71a5a65669ddc9ac4d80c064b6eb30f97ddd18c16
4
- data.tar.gz: becdfe1918143119606b1bfb3e2c3c0035933f767676f6e0970484505d6aa658
3
+ metadata.gz: 768f45bfa9082ab4ece48d30a884b82e0fd9e6ac747ccd022fde1b45d69b75f5
4
+ data.tar.gz: 933c09eb632bb41cb7664c0b57a4626f46a4ed53c1b83748e88c37a6c856a50a
5
5
  SHA512:
6
- metadata.gz: fbc1437a990864744db91c25fc094f3ff71a992922b2ea52d1683a90d197d43c8809dd76e2334722379e0ffe59dcb23f40e6ec26da1cbb6f3ec862ea65da47cd
7
- data.tar.gz: 5d064c5379a0c1ae44fb696e51dd865c55a0f84174c35417a5adc965a34cd7bf97ba2eac0019bcadaed929d6d2f1d2c3b320e68ad2e627e6ff1d2a989c105674
6
+ metadata.gz: fc7cdad51dd0a424164a6b6ea30e79078d82c8e5d94614e8c10d170fa32a37024e297991e34444fe215911980779404360bdabe7c12e5a055c62b94c1f2bfd7d
7
+ data.tar.gz: c1ba92689b2fda29d1fb345be58c766641b92d54aa001df7e29684d213c195b53d5389ffc9b1e70baa0c9e89547bb35d5244921a89a08fa080e793c0a3dc40b4
@@ -30,7 +30,7 @@ module OpenapiClient
30
30
  attr_accessor :timeout
31
31
 
32
32
  # a JSON object whose key/value pairs will be mapped to URL query parameters
33
- attr_accessor :_query_params
33
+ attr_accessor :params
34
34
 
35
35
  # a string representing the HTTP request or response body
36
36
  attr_accessor :body
@@ -53,10 +53,10 @@ module OpenapiClient
53
53
  :'secure' => :'secure',
54
54
  :'headers' => :'headers',
55
55
  :'timeout' => :'timeout',
56
- :'_query_params' => :'query-params',
56
+ :'params' => :'params',
57
57
  :'body' => :'body',
58
58
  :'sensitive' => :'sensitive',
59
- :'content_type' => :'content-type',
59
+ :'content_type' => :'content_type',
60
60
  :'redirect' => :'redirect',
61
61
  :'path' => :'path'
62
62
  }
@@ -75,7 +75,7 @@ module OpenapiClient
75
75
  :'secure' => :'Boolean',
76
76
  :'headers' => :'Object',
77
77
  :'timeout' => :'Integer',
78
- :'_query_params' => :'Object',
78
+ :'params' => :'Object',
79
79
  :'body' => :'String',
80
80
  :'sensitive' => :'Array<String>',
81
81
  :'content_type' => :'ContentType',
@@ -131,8 +131,8 @@ module OpenapiClient
131
131
  self.timeout = 10
132
132
  end
133
133
 
134
- if attributes.key?(:'_query_params')
135
- self._query_params = attributes[:'_query_params']
134
+ if attributes.key?(:'params')
135
+ self.params = attributes[:'params']
136
136
  end
137
137
 
138
138
  if attributes.key?(:'body')
@@ -188,8 +188,8 @@ module OpenapiClient
188
188
  invalid_properties.push('invalid value for "timeout", timeout cannot be nil.')
189
189
  end
190
190
 
191
- if @_query_params.nil?
192
- invalid_properties.push('invalid value for "_query_params", _query_params cannot be nil.')
191
+ if @params.nil?
192
+ invalid_properties.push('invalid value for "params", params cannot be nil.')
193
193
  end
194
194
 
195
195
  if @body.nil?
@@ -219,7 +219,7 @@ module OpenapiClient
219
219
  return false if @secure.nil?
220
220
  return false if @headers.nil?
221
221
  return false if @timeout.nil?
222
- return false if @_query_params.nil?
222
+ return false if @params.nil?
223
223
  return false if @body.nil?
224
224
  return false if @sensitive.nil?
225
225
  return false if @content_type.nil?
@@ -237,7 +237,7 @@ module OpenapiClient
237
237
  secure == o.secure &&
238
238
  headers == o.headers &&
239
239
  timeout == o.timeout &&
240
- _query_params == o._query_params &&
240
+ params == o.params &&
241
241
  body == o.body &&
242
242
  sensitive == o.sensitive &&
243
243
  content_type == o.content_type &&
@@ -254,7 +254,7 @@ module OpenapiClient
254
254
  # Calculates hash code according to all attributes.
255
255
  # @return [Integer] Hash code
256
256
  def hash
257
- [host, method, secure, headers, timeout, _query_params, body, sensitive, content_type, redirect, path].hash
257
+ [host, method, secure, headers, timeout, params, body, sensitive, content_type, redirect, path].hash
258
258
  end
259
259
 
260
260
  # Builds the object from hash
@@ -33,8 +33,8 @@ module OpenapiClient
33
33
  # Attribute mapping from ruby-style variable name to JSON key.
34
34
  def self.attribute_map
35
35
  {
36
- :'status_text' => :'status-text',
37
- :'status_code' => :'status-code',
36
+ :'status_text' => :'status_text',
37
+ :'status_code' => :'status_code',
38
38
  :'headers' => :'headers',
39
39
  :'body' => :'body',
40
40
  :'error' => :'error'
@@ -117,6 +117,10 @@ module OpenapiClient
117
117
  # @return Array for valid properties with the reasons
118
118
  def list_invalid_properties
119
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
+
120
124
  if @status_code.nil?
121
125
  invalid_properties.push('invalid value for "status_code", status_code cannot be nil.')
122
126
  end
@@ -139,6 +143,7 @@ module OpenapiClient
139
143
  # Check to see if the all the properties in the model are valid
140
144
  # @return true if the model is valid
141
145
  def valid?
146
+ return false if @status_text.nil?
142
147
  return false if @status_code.nil?
143
148
  return false if @headers.nil?
144
149
  return false if @body.nil?
@@ -30,8 +30,8 @@ module OpenapiClient
30
30
  # Attribute mapping from ruby-style variable name to JSON key.
31
31
  def self.attribute_map
32
32
  {
33
- :'status_text' => :'status-text',
34
- :'status_code' => :'status-code',
33
+ :'status_text' => :'status_text',
34
+ :'status_code' => :'status_code',
35
35
  :'headers' => :'headers',
36
36
  :'body' => :'body'
37
37
  }
@@ -100,6 +100,10 @@ module OpenapiClient
100
100
  # @return Array for valid properties with the reasons
101
101
  def list_invalid_properties
102
102
  invalid_properties = Array.new
103
+ if @status_text.nil?
104
+ invalid_properties.push('invalid value for "status_text", status_text cannot be nil.')
105
+ end
106
+
103
107
  if @status_code.nil?
104
108
  invalid_properties.push('invalid value for "status_code", status_code cannot be nil.')
105
109
  end
@@ -118,6 +122,7 @@ module OpenapiClient
118
122
  # Check to see if the all the properties in the model are valid
119
123
  # @return true if the model is valid
120
124
  def valid?
125
+ return false if @status_text.nil?
121
126
  return false if @status_code.nil?
122
127
  return false if @headers.nil?
123
128
  return false if @body.nil?
data/lib/ssrfs-up.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'aws-sdk-lambda'
2
2
  require 'uri'
3
+ require 'ssrfs-up/version'
4
+ require 'ostruct'
3
5
 
4
6
  # Common files
5
7
  require 'openapi_client/lib/openapi_client/api_client'
@@ -20,6 +22,18 @@ require 'openapi_client/lib/openapi_client/models/response_success'
20
22
  require 'openapi_client/lib/openapi_client/api/default_api'
21
23
 
22
24
  module SSRFsUp
25
+ class Configuration
26
+ attr_accessor :func_name, :invoke_type, :log_type, :region, :test
27
+
28
+ def initialize
29
+ @func_name = 'sec-czi-sec-ssrfs-up'
30
+ @invoke_type = 'RequestResponse'
31
+ @log_type = 'None'
32
+ @region = 'us-west-2'
33
+ @test = false
34
+ end
35
+ end
36
+
23
37
  class << self
24
38
  attr_accessor :config, :client
25
39
 
@@ -33,7 +47,7 @@ module SSRFsUp
33
47
 
34
48
  def configure
35
49
  yield(configuration)
36
- @client = Aws::Lambda::Client.new(region: configuration.region)
50
+ @client = Aws::Lambda::Client.new({ region: configuration.region, stub_responses: configuration.test })
37
51
  end
38
52
 
39
53
  # These methods take a string like "www.google.com" or "https://google.com" and parse
@@ -71,13 +85,12 @@ module SSRFsUp
71
85
  invoke(host, opts)
72
86
  end
73
87
 
74
- private
75
-
76
88
  # parseAsUri takes an ambiguous string and sets the appropriate options based
77
89
  # on if it can be parsed as URI object. If it can't, then the string is assumed
78
90
  # to be a hostname only.
79
91
  def parseAsUri(uri = '')
80
- opts = { 'host' => uri }
92
+ splits = uri.split '/'
93
+ opts = { 'host' => splits[0] }
81
94
  u = URI(uri)
82
95
  # if the scheme was present, we can parse most of the options from the URI.
83
96
  # otherwise, we can assume the URI was an actual hostname
@@ -85,16 +98,17 @@ module SSRFsUp
85
98
  opts['secure'] = !(u.scheme == 'http')
86
99
  opts['host'] = u.host
87
100
  opts['path'] = u.path unless u.path == ''
88
- opts['_query_params'] = CGI.parse(u.query) unless u.query.nil?
101
+ opts['params'] = CGI.parse(u.query) unless u.query.nil?
89
102
  end
90
103
  opts
91
104
  end
92
105
 
93
- # TODO: log errors to CloudWatch
94
- def logError(e = nil)
95
- puts e
106
+ def toOpenAPIClient(opts = {})
107
+ OpenapiClient::Request.new(opts).to_hash
96
108
  end
97
109
 
110
+ private
111
+
98
112
  # invoke invokes the lambda with the provided arguments. It handles all lambda
99
113
  # related errors so developers should assume the data they receive back is straight
100
114
  # from the server they are speaking to.
@@ -106,31 +120,20 @@ module SSRFsUp
106
120
  log_type: configuration.log_type,
107
121
  payload: payload(opts)
108
122
  })
123
+
109
124
  if resp['status_code'] == 200
110
- JSON.parse(resp&.payload&.string)
125
+ OpenStruct.new(JSON.parse(resp&.payload&.string))
111
126
  else
112
- { body: '', status_code: resp[status_code], status_text: '500 Error with proxy' }
127
+ OpenStruct.new({ body: '', status_code: resp[status_code], status_text: '500 Error with proxy' })
113
128
  end
114
129
  rescue StandardError => e
115
- logError(e)
116
- { body: '', status_code: 500, status_text: e.to_s }
130
+ OpenStruct.new({ body: '', status_code: 500, status_text: e.to_s })
117
131
  end
118
132
 
119
133
  # payload builds an API client Request object with the proper defaults and
120
134
  # returns its JSON serialization.
121
135
  def payload(opts = {})
122
- OpenapiClient::Request.new(opts).to_hash.to_json
123
- end
124
-
125
- class Configuration
126
- attr_accessor :func_name, :invoke_type, :log_type, :region
127
-
128
- def initialize
129
- @func_name = 'testproxy'
130
- @invoke_type = 'RequestResponse'
131
- @log_type = 'None'
132
- @region = 'us-west-2'
133
- end
136
+ toOpenAPIClient(opts).to_json
134
137
  end
135
138
  end
136
139
  end
@@ -0,0 +1,3 @@
1
+ module SSRFsUp
2
+ VERSION = '0.0.10'.freeze
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssrfs-up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Heath
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-10 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-lambda
@@ -50,6 +50,48 @@ dependencies:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 1.0.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ - !ruby/object:Gem::Dependency
68
+ name: pry
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: rake
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
53
95
  - !ruby/object:Gem::Dependency
54
96
  name: rspec
55
97
  requirement: !ruby/object:Gem::Requirement
@@ -71,8 +113,9 @@ dependencies:
71
113
  - !ruby/object:Gem::Version
72
114
  version: 3.6.0
73
115
  description: A gem that simplifies connecting to out AWS Lambda used to proxy requests.
74
- Make your third-party requests secure by default. For additional docs, see https://github.com/chanzuckerberg/ssrf-proxy
75
- email: jheath@chanzuckerberg.com
116
+ Make your third-party requests secure by default.
117
+ email:
118
+ - jheath@chanzuckerberg.com
76
119
  executables: []
77
120
  extensions: []
78
121
  extra_rdoc_files: []
@@ -91,10 +134,12 @@ files:
91
134
  - lib/openapi_client/lib/openapi_client/models/response_success.rb
92
135
  - lib/openapi_client/lib/openapi_client/version.rb
93
136
  - lib/ssrfs-up.rb
94
- homepage: https://github.com/chanzuckerberg/SSRFs-Up/
137
+ - lib/ssrfs-up/version.rb
138
+ homepage: https://github.com/chanzuckerberg/ssrf-proxy
95
139
  licenses:
96
140
  - MIT
97
- metadata: {}
141
+ metadata:
142
+ homepage_uri: https://github.com/chanzuckerberg/ssrf-proxy
98
143
  post_install_message:
99
144
  rdoc_options: []
100
145
  require_paths:
@@ -103,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
148
  requirements:
104
149
  - - ">="
105
150
  - !ruby/object:Gem::Version
106
- version: '0'
151
+ version: 2.3.0
107
152
  required_rubygems_version: !ruby/object:Gem::Requirement
108
153
  requirements:
109
154
  - - ">="