ssrfs-up 0.0.12 → 0.0.13

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: c061f769418e088e103c3ba1327cf855fdbd53fe33497b81d50959674a3838d8
4
- data.tar.gz: b0bd761fee8012ba56712c68323b732cc8ae29f05d32efb6caf33dae870580e3
3
+ metadata.gz: 65b5eb9f58b692e95c449880172276f8b749734d70e6152589d952df09be65e3
4
+ data.tar.gz: 50ebf7be670a30131bb44a6359d216e66b153899bd7db89429cd9e15744457bd
5
5
  SHA512:
6
- metadata.gz: e7e69b1729f872607dfc9be6917642522c5eb4f0db100c494196b0ccfeb898079cd0a11f3b8ef85df9e6aa8651f07f376a3df24f2f936c8aeeccd8678b824dd3
7
- data.tar.gz: 31b69a4f3fd9d3d41c8e4cfb49b557f6096769ab8fc586f36cf666af636fbb12a17597a1ed121cdb0d97aec3306d73152530bf64c68902aac43c5b145a6021b5
6
+ metadata.gz: f1ca68a924ad437d0ec6acad7a81060fb582928568dd32b32f7be336ea6777063637c9706041698f92f9499e9b9b3c2069fe6ba8c4ec539c6811a63f74124fa2
7
+ data.tar.gz: 629ad3d4e3af052dc3f8c7f2c9117b2cb55086c5dc99e2c31eb4ba778e4ba67a6e2d49648c5c0619d873fd19005971b78fac2aa6bc21a59d6a19eaac8d800a5b
data/lib/ssrfs-up.rb CHANGED
@@ -21,12 +21,16 @@ require 'openapi_client/lib/openapi_client/models/response_success'
21
21
  # APIs
22
22
  require 'openapi_client/lib/openapi_client/api/default_api'
23
23
 
24
+ ##
25
+ # This module contains the AWS lambda client and helper methods to easily
26
+ # make requests to it. All methods take a hostname or URI and a hash or options
27
+ # for the request.
24
28
  module SSRFsUp
25
29
  class Configuration
26
30
  attr_accessor :func_name, :invoke_type, :log_type, :region, :test
27
31
 
28
32
  def initialize
29
- @func_name = 'sec-czi-sec-ssrfs-up'
33
+ @func_name = 'arn:aws:lambda:us-west-2:871040364337:function:sec-czi-sec-ssrfs-up'
30
34
  @invoke_type = 'RequestResponse'
31
35
  @log_type = 'None'
32
36
  @region = 'us-west-2'
@@ -37,55 +41,57 @@ module SSRFsUp
37
41
  class << self
38
42
  attr_accessor :config, :client
39
43
 
40
- def configuration
41
- @config ||= Configuration.new
42
- end
43
-
44
- def client
45
- @client ||= Aws::Lambda::Client.new(region: configuration.region)
46
- end
47
-
48
- def configure
49
- yield(configuration)
50
- @client = Aws::Lambda::Client.new({ region: configuration.region, stub_responses: configuration.test })
51
- end
52
-
53
44
  # These methods take a string like "www.google.com" or "https://google.com" and parse
54
45
  # the respective parameters from the string to make the request. If only a hostname
55
46
  # is provided, the default options are applied. A hash of options can also be
56
- # supplied to configure the request.
47
+ # supplied to configure the request. The set of options can be found at
48
+ # https://github.com/chanzuckerberg/SSRFs-Up/blob/0e18fd30bee3f2b99ff4bc512cb967b83e8d9dcb/openapi.yaml#L97-L119
49
+ def do(method, host, opts = {})
50
+ case method.downcase
51
+ when 'get'
52
+ get(host, opts)
53
+ when 'put'
54
+ put(host, opts)
55
+ when 'post'
56
+ post(host, opts)
57
+ when 'patch'
58
+ patch(host, opts)
59
+ when 'delete'
60
+ delete(host, opts)
61
+ end
62
+ end
57
63
 
58
- # get makes a get request through the proxy.
64
+ # convenience method for making a GET request with do.
59
65
  def get(host, opts = {})
60
66
  opts['method'] = 'GET'
61
67
  invoke(host, opts)
62
68
  end
63
69
 
64
- # put makes a put request through the proxy.
70
+ # convenience method for making a PUT request with do.
65
71
  def put(host, opts = {})
66
72
  opts['method'] = 'PUT'
67
73
  invoke(host, opts)
68
74
  end
69
75
 
70
- # post makes a post request through the proxy.
76
+ # convenience method for making a POST request with do.
71
77
  def post(host, opts = {})
72
78
  opts['method'] = 'POST'
73
79
  invoke(host, opts)
74
80
  end
75
81
 
76
- # patch makes a patch request through the proxy.
82
+ # convenience method for making a patch request with do.
77
83
  def patch(host, opts = {})
78
84
  opts['method'] = 'PATCH'
79
85
  invoke(host, opts)
80
86
  end
81
87
 
82
- # delete makes a delete request through the proxy.
88
+ # convenience method for making a DELETE request with do.
83
89
  def delete(host, opts = {})
84
90
  opts['method'] = 'DELETE'
85
91
  invoke(host, opts)
86
92
  end
87
93
 
88
- # parseAsUri takes an ambiguous string and sets the appropriate options based
94
+ # takes an ambiguous string or URI and sets the appropriate options based
89
95
  # on if it can be parsed as URI object. If it can't, then the string is assumed
90
96
  # to be a hostname only.
91
97
  def parseAsUri(uri = '')
@@ -104,13 +110,28 @@ module SSRFsUp
104
110
  opts
105
111
  end
106
112
 
113
+ # converts a hash of options to a valid OpenapiClient Request so that it
114
+ # can be properly consumed by the lambda.
107
115
  def toOpenAPIClient(opts = {})
108
116
  OpenapiClient::Request.new(opts).to_hash
109
117
  end
110
118
 
111
- private
119
+ # configures the SSRFsUp module and recreates the AWS Lambda Client from
120
+ # the updated configuration.
121
+ def configure
122
+ yield(configuration)
123
+ @client = Aws::Lambda::Client.new({ region: configuration.region, stub_responses: configuration.test })
124
+ end
125
+
126
+ def configuration
127
+ @config ||= Configuration.new
128
+ end
129
+
130
+ def client
131
+ @client ||= Aws::Lambda::Client.new(region: configuration.region)
132
+ end
112
133
 
113
- # invoke invokes the lambda with the provided arguments. It handles all lambda
134
+ # invokes the lambda with the provided arguments. It handles all lambda
114
135
  # related errors so developers should assume the data they receive back is straight
115
136
  # from the server they are speaking to.
116
137
  def invoke(host = nil, opts = {})
@@ -1,3 +1,3 @@
1
1
  module SSRFsUp
2
- VERSION = '0.0.12'.freeze
2
+ VERSION = '0.0.13'.freeze
3
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.12
4
+ version: 0.0.13
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-13 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-lambda