workato-connector-sdk 1.3.8 → 1.3.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab098bba65e812d5ec811d584358c98d6d51e42433019af516a7cff3d1817e1d
4
- data.tar.gz: 4433f811d9d144826a40868958a4c783fd18ab6834b230b5332d0b7fc7f6dfac
3
+ metadata.gz: dc61d331c5e90aefecdbb3f336ae69937bb29b68f7bd7719d81bcdb5c3c86bd9
4
+ data.tar.gz: b229cca847d63f6e209f84d10e82aa63fda5b87408f4af80c0c5608f2bc42654
5
5
  SHA512:
6
- metadata.gz: bded379a7c421201fb92a51db40cc7b4d14e35f84c28bfd42cb26259aba4d1e1f0e99c49793ea84df2dc4adce0564e643aa01f5bc2b42990ee66a5a4fd58efbb
7
- data.tar.gz: bec9736d31ebf8d492924e54e3b4e255d6672a6eb059dfcdcb604d968c876bddfd9512d553aff5a6b01bb36c9025d1496b0062315381b97f4130cfe71efa51a3
6
+ metadata.gz: 5c235fca45159067ee8a175893692d739b4ad484f25538a6791e2a4f09fec895e719b6cbfb2159be790427f29226cea9be018d460679cafff1aa81416d9f8e14
7
+ data.tar.gz: 95d48a7b47e8dde25b95491594914a1f3a4e932c92edbaa94c98f6a80621b4c536b259465f46af21f5d634a1a18c021b9453e4b44b9f0ea0522a13db9a239ad7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.8
1
+ 1.3.9
@@ -14,6 +14,8 @@ module Workato
14
14
 
15
15
  InvalidDefinitionError = Class.new(Error)
16
16
 
17
+ InvalidURIError = Class.new(Error)
18
+
17
19
  class UnexpectedMethodDefinitionError < InvalidDefinitionError
18
20
  attr_reader :name
19
21
  attr_reader :definition
@@ -21,12 +21,14 @@ module Workato
21
21
 
22
22
  using BlockInvocationRefinements
23
23
 
24
+ ALLOWED_URI_TYPES = [URI::Generic, String].freeze
25
+ private_constant :ALLOWED_URI_TYPES
26
+
24
27
  def initialize(uri, method: 'GET', connection: nil, action: nil)
25
28
  super(nil)
26
29
  @uri = uri
27
30
  @method = method
28
31
  @connection = connection
29
- @base_uri = connection&.base_uri(connection&.settings || {})
30
32
  @action = action
31
33
  @headers = {}
32
34
  @case_sensitive_headers = {}
@@ -273,6 +275,8 @@ module Workato
273
275
  begin
274
276
  request = RestClientRequest.new(rest_request_params)
275
277
  response = execute_request(request)
278
+ rescue URI::InvalidURIError => e
279
+ Kernel.raise(InvalidURIError, e.message)
276
280
  rescue RestClient::Unauthorized => e
277
281
  Kernel.raise e unless @digest_auth
278
282
 
@@ -331,8 +335,18 @@ module Workato
331
335
  end
332
336
 
333
337
  def build_url
334
- uri = if @base_uri
335
- merge_uris(@base_uri, @uri)
338
+ uri = if (base_uri = @connection&.base_uri)
339
+ unless valid_uri?(@uri)
340
+ raise_invalid_uri_error(
341
+ "Expected String or URI as request URL, got: #{@uri.class.name}"
342
+ )
343
+ end
344
+ unless valid_uri?(base_uri)
345
+ raise_invalid_uri_error(
346
+ "Expected String or URI as output of base_uri lambda, got: #{base_uri.class.name}"
347
+ )
348
+ end
349
+ merge_uris(base_uri, @uri)
336
350
  else
337
351
  URI.parse(@uri)
338
352
  end
@@ -357,6 +371,14 @@ module Workato
357
371
  uri.to_s
358
372
  end
359
373
 
374
+ def valid_uri?(path)
375
+ ALLOWED_URI_TYPES.any? { |type| path.is_a?(type) }
376
+ end
377
+
378
+ def raise_invalid_uri_error(message)
379
+ Kernel.raise(InvalidURIError, message)
380
+ end
381
+
360
382
  def merge_uris(uri1, uri2)
361
383
  (uri1.is_a?(::String) ? URI.parse(uri1) : uri1).merge(uri2)
362
384
  end
@@ -549,6 +571,23 @@ module Workato
549
571
  net.extra_chain_cert = ssl_extra_chain_cert if ssl_extra_chain_cert
550
572
  net
551
573
  end
574
+
575
+ private
576
+
577
+ def parse_url_with_auth!(url)
578
+ # Fix Ruby 2.7 vs 3.0 incompatibility
579
+ # In ruby 2.7 URI.parse("http:///foo/bar").hostname returns nil
580
+ # In ruby 3.0 URI.parse("http:///foo/bar").hostname returns ""
581
+ uri = URI.parse(url)
582
+
583
+ if uri.hostname.nil? || uri.hostname.empty?
584
+ raise URI::InvalidURIError, "bad URI(no host provided): #{url}"
585
+ end
586
+
587
+ super
588
+ rescue ArgumentError => e
589
+ raise URI::InvalidURIError, "Invalid URL: #{e.message}"
590
+ end
552
591
  end
553
592
 
554
593
  private_constant :RestClientRequest
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workato-connector-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: 1.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Abolmasov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-30 00:00:00.000000000 Z
11
+ date: 2023-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport