securenative 0.1.17 → 0.1.18

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.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +5 -2
  3. data/.github/workflows/test.yml +5 -2
  4. data/.gitignore +3 -1
  5. data/Gemfile +5 -2
  6. data/Gemfile.lock +218 -10
  7. data/README.md +3 -3
  8. data/VERSION +1 -1
  9. data/lib/api_manager.rb +35 -0
  10. data/lib/config/configuration_builder.rb +30 -0
  11. data/lib/config/configuration_manager.rb +55 -0
  12. data/lib/config/securenative_options.rb +22 -0
  13. data/lib/context/hanami_context.rb +35 -0
  14. data/lib/context/rails_context.rb +41 -0
  15. data/lib/context/securenative_context.rb +67 -0
  16. data/lib/context/sinatra_context.rb +35 -0
  17. data/lib/enums/api_route.rb +6 -0
  18. data/lib/enums/event_types.rb +23 -0
  19. data/lib/enums/failover_strategy.rb +6 -0
  20. data/lib/enums/risk_level.rb +7 -0
  21. data/lib/errors/securenative_config_error.rb +4 -0
  22. data/lib/errors/securenative_http_error.rb +4 -0
  23. data/lib/errors/securenative_invalid_options_error.rb +4 -0
  24. data/lib/errors/securenative_invalid_uri_error.rb +4 -0
  25. data/lib/errors/securenative_parse_error.rb +4 -0
  26. data/lib/errors/securenative_sdk_Illegal_state_error.rb +4 -0
  27. data/lib/errors/securenative_sdk_error.rb +4 -0
  28. data/lib/event_manager.rb +156 -0
  29. data/lib/{securenative/event_options_builder.rb → event_options.rb} +5 -3
  30. data/lib/http/secure_native_http_response.rb +12 -0
  31. data/lib/http/securenative_http_client.rb +32 -0
  32. data/lib/{securenative/models → models}/client_token.rb +2 -0
  33. data/lib/{securenative/models → models}/device.rb +3 -1
  34. data/lib/models/event_options.rb +15 -0
  35. data/lib/models/request_context.rb +18 -0
  36. data/lib/models/request_options.rb +12 -0
  37. data/lib/models/sdk_event.rb +35 -0
  38. data/lib/models/user_traits.rb +13 -0
  39. data/lib/models/verify_result.rb +12 -0
  40. data/lib/securenative.rb +95 -0
  41. data/lib/utils/date_utils.rb +9 -0
  42. data/lib/{securenative/utils → utils}/encryption_utils.rb +1 -4
  43. data/lib/{securenative/utils → utils}/ip_utils.rb +7 -6
  44. data/lib/utils/request_utils.rb +54 -0
  45. data/lib/{securenative/logger.rb → utils/secure_native_logger.rb} +5 -3
  46. data/lib/{securenative/utils → utils}/signature_utils.rb +4 -2
  47. data/lib/utils/utils.rb +9 -0
  48. data/lib/{securenative/utils → utils}/version_utils.rb +3 -1
  49. data/{lib/securenative → out/production/securenative-ruby}/api_manager.rb +6 -5
  50. data/{lib/securenative → out/production/securenative-ruby}/config/configuration_builder.rb +7 -3
  51. data/{lib/securenative → out/production/securenative-ruby}/config/configuration_manager.rb +5 -3
  52. data/{lib/securenative → out/production/securenative-ruby}/config/securenative_options.rb +3 -1
  53. data/out/production/securenative-ruby/context/securenative_context.rb +40 -0
  54. data/out/production/securenative-ruby/enums/api_route.rb +6 -0
  55. data/out/production/securenative-ruby/enums/event_types.rb +23 -0
  56. data/out/production/securenative-ruby/enums/failover_strategy.rb +6 -0
  57. data/out/production/securenative-ruby/enums/risk_level.rb +7 -0
  58. data/out/production/securenative-ruby/errors/securenative_config_error.rb +4 -0
  59. data/out/production/securenative-ruby/errors/securenative_http_error.rb +4 -0
  60. data/out/production/securenative-ruby/errors/securenative_invalid_options_error.rb +4 -0
  61. data/out/production/securenative-ruby/errors/securenative_invalid_uri_error.rb +4 -0
  62. data/out/production/securenative-ruby/errors/securenative_parse_error.rb +4 -0
  63. data/out/production/securenative-ruby/errors/securenative_sdk_Illegal_state_error.rb +4 -0
  64. data/out/production/securenative-ruby/errors/securenative_sdk_error.rb +4 -0
  65. data/out/production/securenative-ruby/event_manager.rb +156 -0
  66. data/out/production/securenative-ruby/event_options.rb +32 -0
  67. data/{lib/securenative → out/production/securenative-ruby}/http/http_response.rb +3 -1
  68. data/out/production/securenative-ruby/http/securenative_http_client.rb +32 -0
  69. data/out/production/securenative-ruby/models/client_token.rb +12 -0
  70. data/out/production/securenative-ruby/models/device.rb +10 -0
  71. data/{lib/securenative → out/production/securenative-ruby}/models/event_options.rb +3 -1
  72. data/{lib/securenative → out/production/securenative-ruby}/models/request_context.rb +5 -2
  73. data/out/production/securenative-ruby/models/request_options.rb +12 -0
  74. data/{lib/securenative → out/production/securenative-ruby}/models/sdk_event.rb +11 -3
  75. data/{lib/securenative → out/production/securenative-ruby}/models/user_traits.rb +3 -1
  76. data/{lib/securenative → out/production/securenative-ruby}/models/verify_result.rb +3 -1
  77. data/{lib/securenative → out/production/securenative-ruby}/securenative.rb +24 -15
  78. data/out/production/securenative-ruby/utils/date_utils.rb +9 -0
  79. data/out/production/securenative-ruby/utils/encryption_utils.rb +35 -0
  80. data/out/production/securenative-ruby/utils/ip_utils.rb +23 -0
  81. data/{lib/securenative → out/production/securenative-ruby}/utils/request_utils.rb +5 -3
  82. data/out/production/securenative-ruby/utils/secure_native_logger.rb +44 -0
  83. data/out/production/securenative-ruby/utils/signature_utils.rb +16 -0
  84. data/out/production/securenative-ruby/utils/utils.rb +9 -0
  85. data/out/production/securenative-ruby/utils/version_utils.rb +12 -0
  86. data/out/test/securenative-ruby/spec_api_manager.rb +81 -0
  87. data/out/test/securenative-ruby/spec_context_builder.rb +69 -0
  88. data/out/test/securenative-ruby/spec_date_utils.rb +13 -0
  89. data/out/test/securenative-ruby/spec_encryption_utils.rb +26 -0
  90. data/out/test/securenative-ruby/spec_event_manager.rb +59 -0
  91. data/out/test/securenative-ruby/spec_helper.rb +20 -0
  92. data/out/test/securenative-ruby/spec_ip_utils.rb +41 -0
  93. data/out/test/securenative-ruby/spec_securenative.rb +65 -0
  94. data/out/test/securenative-ruby/spec_securenative_http_client.rb +23 -0
  95. data/out/test/securenative-ruby/spec_signature_utils.rb +18 -0
  96. data/securenative.gemspec +1 -1
  97. metadata +89 -42
  98. data/.travis.yml +0 -6
  99. data/lib/securenative/context/context_builder.rb +0 -59
  100. data/lib/securenative/context/securenative_context.rb +0 -14
  101. data/lib/securenative/enums/api_route.rb +0 -4
  102. data/lib/securenative/enums/event_types.rb +0 -21
  103. data/lib/securenative/enums/failover_strategy.rb +0 -4
  104. data/lib/securenative/enums/risk_level.rb +0 -5
  105. data/lib/securenative/event_manager.rb +0 -150
  106. data/lib/securenative/exceptions/securenative_config_exception.rb +0 -2
  107. data/lib/securenative/exceptions/securenative_http_exception.rb +0 -2
  108. data/lib/securenative/exceptions/securenative_invalid_options_exception.rb +0 -2
  109. data/lib/securenative/exceptions/securenative_invalid_uri_exception.rb +0 -2
  110. data/lib/securenative/exceptions/securenative_parse_exception.rb +0 -2
  111. data/lib/securenative/exceptions/securenative_sdk_Illegal_state_exception.rb +0 -2
  112. data/lib/securenative/exceptions/securenative_sdk_exception.rb +0 -2
  113. data/lib/securenative/http/securenative_http_client.rb +0 -30
  114. data/lib/securenative/models/request_options.rb +0 -10
  115. data/lib/securenative/securenative.iml +0 -9
  116. data/lib/securenative/utils/date_utils.rb +0 -7
  117. data/lib/securenative/utils/utils.rb +0 -9
@@ -1,4 +1,6 @@
1
- class EventOptionsBuilder
1
+ # frozen_string_literal: true
2
+
3
+ class EventOptions
2
4
  MAX_PROPERTIES_SIZE = 10
3
5
 
4
6
  def initialize(event_type, user_id, user_traits, user_name, email, phone, created_at, context, properties, timestamp)
@@ -22,9 +24,9 @@ class EventOptionsBuilder
22
24
 
23
25
  def build
24
26
  if !@event_options.properties.nil? && @event_options.properties.length > MAX_PROPERTIES_SIZE
25
- raise SecureNativeInvalidOptionsException('You can have only up to {} custom properties', MAX_PROPERTIES_SIZE)
27
+ raise SecureNativeInvalidOptionsError('You can have only up to {} custom properties', MAX_PROPERTIES_SIZE)
26
28
  end
27
29
 
28
30
  @event_options
29
31
  end
30
- end
32
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SecureNativeHttpResponse
4
+ attr_reader :ok, :status_code, :body
5
+ attr_writer :ok, :status_code, :body
6
+
7
+ def initialize(ok, status_code, body)
8
+ @ok = ok
9
+ @status_code = status_code
10
+ @body = body
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httpclient'
4
+
5
+ class SecureNativeHttpClient
6
+ AUTHORIZATION_HEADER = 'Authorization'
7
+ VERSION_HEADER = 'SN-Version'
8
+ USER_AGENT_HEADER = 'User-Agent'
9
+ USER_AGENT_HEADER_VALUE = 'SecureNative-python'
10
+ CONTENT_TYPE_HEADER = 'Content-Type'
11
+ CONTENT_TYPE_HEADER_VALUE = 'application/json'
12
+
13
+ def initialize(securenative_options)
14
+ @options = securenative_options
15
+ @client = HTTPClient.new
16
+ end
17
+
18
+ def _headers
19
+ {
20
+ CONTENT_TYPE_HEADER => CONTENT_TYPE_HEADER_VALUE,
21
+ USER_AGENT_HEADER => USER_AGENT_HEADER_VALUE,
22
+ VERSION_HEADER => VersionUtils.version,
23
+ AUTHORIZATION_HEADER => @options.api_key
24
+ }
25
+ end
26
+
27
+ def post(path, body)
28
+ url = "#{@options.api_url}/#{path}"
29
+ headers = _headers
30
+ @client.post(url, body, headers)
31
+ end
32
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ClientToken
2
4
  attr_reader :cid, :vid, :fp
3
5
  attr_writer :cid, :vid, :fp
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Device
2
4
  attr_reader :device_id
3
5
  attr_writer :device_id
@@ -5,4 +7,4 @@ class Device
5
7
  def initialize(device_id)
6
8
  @device_id = device_id
7
9
  end
8
- end
10
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class EventOptions
4
+ attr_reader :event, :user_id, :user_traits, :context, :properties, :timestamp
5
+ attr_writer :event, :user_id, :user_traits, :context, :properties, :timestamp
6
+
7
+ def initialize(event: nil, user_id: nil, user_traits: nil, context: nil, properties: nil, timestamp: nil)
8
+ @event = event
9
+ @user_id = user_id
10
+ @user_traits = user_traits
11
+ @context = context
12
+ @properties = properties
13
+ @timestamp = timestamp
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RequestContext
4
+ attr_reader :cid, :vid, :fp, :ip, :remote_ip, :headers, :url, :http_method
5
+ attr_writer :cid, :vid, :fp, :ip, :remote_ip, :headers, :url, :http_method
6
+
7
+ def initialize(cid: nil, vid: nil, fp: nil, ip: nil, remote_ip: nil, headers: nil, url: nil, http_method: nil)
8
+ @cid = cid
9
+ @vid = vid
10
+ @fp = fp
11
+ @ip = ip
12
+ @remote_ip = remote_ip
13
+ @headers = headers
14
+ @url = url
15
+ @method = http_method
16
+ end
17
+ end
18
+
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RequestOptions
4
+ attr_reader :url, :body, :retry_sending
5
+ attr_writer :url, :body, :retry_sending
6
+
7
+ def initialize(url, body, retry_sending)
8
+ @url = url
9
+ @body = body
10
+ @retry_sending = retry_sending
11
+ end
12
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'context/securenative_context'
4
+ require 'utils/encryption_utils'
5
+
6
+ class SDKEvent
7
+ attr_reader :context, :rid, :event_type, :user_id, :user_traits, :request, :timestamp, :properties
8
+ attr_writer :context, :rid, :event_type, :user_id, :user_traits, :request, :timestamp, :properties
9
+
10
+ def initialize(event_options, securenative_options)
11
+ @context = if !event_options.context.nil?
12
+ event_options.context
13
+ else
14
+ SecureNativeContext.default_context_builder
15
+ end
16
+
17
+ client_token = EncryptionUtils.decrypt(@context.client_token, securenative_options.api_key)
18
+
19
+ @rid = SecureRandom.uuid.to_str
20
+ @event_type = event_options.event
21
+ @user_id = event_options.user_id
22
+ @user_traits = event_options.user_traits
23
+ @request = RequestContext(client_token ? client_token.cid : '', client_token ? client_token.vid : '',
24
+ client_token ? client_token.fp : '', @context.ip,
25
+ @context.remote_ip, @context.headers, @context.url, @context.http_method)
26
+
27
+ @timestamp = DateUtils.to_timestamp(event_options.timestamp)
28
+ @properties = event_options.properties
29
+ end
30
+
31
+ def to_s
32
+ "context: #{@context}, rid: #{@rid}, event_type: #{@event_type}, user_id: #{@user_id},
33
+ user_traits: #{@user_traits}, request: #{@request}, timestamp: #{@timestamp}, properties: #{@properties}"
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UserTraits
4
+ attr_reader :name, :email, :phone, :created_at
5
+ attr_writer :name, :email, :phone, :created_at
6
+
7
+ def initialize(name: nil, email: nil, phone: nil, created_at: nil)
8
+ @name = name
9
+ @email = email
10
+ @created_at = created_at
11
+ @phone = phone
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class VerifyResult
4
+ attr_reader :risk_level, :score, :triggers
5
+ attr_writer :risk_level, :score, :triggers
6
+
7
+ def initialize(risk_level: nil, score: nil, triggers: nil)
8
+ @risk_level = risk_level
9
+ @score = score
10
+ @triggers = triggers
11
+ end
12
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'utils/secure_native_logger'
4
+ require 'utils/signature_utils'
5
+ require 'utils/utils'
6
+ require 'errors/securenative_sdk_error'
7
+ require 'errors/securenative_sdk_Illegal_state_error'
8
+ require 'errors/securenative_config_error'
9
+ require 'enums/failover_strategy'
10
+ require 'config/configuration_builder'
11
+ require 'event_manager'
12
+ require 'api_manager'
13
+
14
+ class SecureNative
15
+ attr_reader :options
16
+
17
+ def initialize(options)
18
+ @securenative = nil
19
+ raise SecureNativeSDKError, 'You must pass your SecureNative api key' if Utils.null_or_empty?(options.api_key)
20
+
21
+ @options = options
22
+ @event_manager = EventManager.new(@options)
23
+
24
+ @event_manager.start_event_persist unless @options.api_url.nil?
25
+
26
+ @api_manager = ApiManager.new(@event_manager, @options)
27
+ SecureNativeLogger.init_logger(@options.log_level)
28
+ end
29
+
30
+ def self.init_with_options(options)
31
+ if @securenative.nil?
32
+ @securenative = SecureNative.new(options)
33
+ @securenative
34
+ else
35
+ SecureNativeLogger.debug('This SDK was already initialized.')
36
+ raise SecureNativeSDKError, 'This SDK was already initialized.'
37
+ end
38
+ end
39
+
40
+ def self.init_with_api_key(api_key)
41
+ raise SecureNativeConfigError, 'You must pass your SecureNative api key' if Utils.null_or_empty?(api_key)
42
+
43
+ if @securenative.nil?
44
+ options = ConfigurationBuilder.new(api_key: api_key)
45
+ @securenative = SecureNative.new(options)
46
+ @securenative
47
+ else
48
+ SecureNativeLogger.debug('This SDK was already initialized.')
49
+ raise SecureNativeSDKError, 'This SDK was already initialized.'
50
+ end
51
+ end
52
+
53
+ def self.init
54
+ options = ConfigurationManager.load_config
55
+ init_with_options(options)
56
+ end
57
+
58
+ def self.instance
59
+ raise SecureNativeSDKIllegalStateError if @securenative.nil?
60
+
61
+ @securenative
62
+ end
63
+
64
+ def self.config_builder(api_key: nil, api_url: 'https://api.securenative.com/collector/api/v1', interval: 1000,
65
+ max_events: 1000, timeout: 1500, auto_send: true, disable: false, log_level: 'FATAL',
66
+ fail_over_strategy: FailOverStrategy::FAIL_OPEN)
67
+ ConfigurationBuilder.new(api_key: api_key, api_url: api_url, interval: interval, max_events: max_events,
68
+ timeout: timeout, auto_send: auto_send, disable: disable, log_level: log_level,
69
+ fail_over_strategy: fail_over_strategy)
70
+ end
71
+
72
+ def self.context_builder(client_token: nil, ip: nil, remote_ip: nil, headers: nil, url: nil, http_method: nil, body: nil)
73
+ SecureNativeContext.new(client_token: client_token, ip: ip, remote_ip: remote_ip, headers: headers,
74
+ url: url, http_method: http_method, body: body)
75
+ end
76
+
77
+ def track(event_options)
78
+ @api_manager.track(event_options)
79
+ end
80
+
81
+ def verify(event_options)
82
+ @api_manager.verify(event_options)
83
+ end
84
+
85
+ def self._flush
86
+ @securenative = nil
87
+ end
88
+
89
+ def verify_request_payload(request)
90
+ request_signature = request.header[SignatureUtils.SIGNATURE_HEADER]
91
+ body = request.body
92
+
93
+ SignatureUtils.valid_signature?(@options.api_key, body, request_signature)
94
+ end
95
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DateUtils
4
+ def self.to_timestamp(date)
5
+ return Time.now.strftime('%Y-%m-%dT%H:%M:%S%Z') if date.nil?
6
+
7
+ Time.parse(date).iso8601
8
+ end
9
+ end
@@ -11,9 +11,6 @@ class EncryptionUtils
11
11
  cipher.padding = 0
12
12
 
13
13
  if text.size % BLOCK_SIZE != 0
14
- logger = Logger.new(STDOUT)
15
- logger.level = Logger::WARN
16
- logger.fatal('data not multiple of block length')
17
14
  return nil
18
15
  end
19
16
 
@@ -35,4 +32,4 @@ class EncryptionUtils
35
32
  rv = cipher.update(s) + cipher.final
36
33
  rv.strip
37
34
  end
38
- end
35
+ end
@@ -1,10 +1,11 @@
1
- class IpUtils
2
- VALID_IPV4_PATTERN = '(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])'.freeze
3
- VALID_IPV6_PATTERN = '([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}'.freeze
1
+ # frozen_string_literal: true
2
+
3
+ require "resolv"
4
4
 
5
+ class IpUtils
5
6
  def self.ip_address?(ip_address)
6
- return true if IpUtils.VALID_IPV4_PATTERN.match(ip_address)
7
- return true if IpUtils.VALID_IPV6_PATTERN.match(ip_address)
7
+ return true if ip_address =~ Resolv::IPv4::Regex
8
+ return true if ip_address =~ Resolv::IPv6::Regex
8
9
 
9
10
  false
10
11
  end
@@ -19,4 +20,4 @@ class IpUtils
19
20
  def self.loop_back?(ip_address)
20
21
  IPAddr.new(ip_address).loopback?
21
22
  end
22
- end
23
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RequestUtils
4
+ SECURENATIVE_COOKIE = '_sn'
5
+ SECURENATIVE_HEADER = 'x-securenative'
6
+
7
+ def self.get_secure_header_from_request(headers)
8
+ begin
9
+ return headers[SECURENATIVE_HEADER] unless headers.nil?
10
+ rescue StandardError
11
+ []
12
+ end
13
+ []
14
+ end
15
+
16
+ def self.get_client_ip_from_request(request)
17
+ begin
18
+ return request.ip unless request.ip.nil?
19
+ rescue NoMethodError
20
+ end
21
+
22
+ begin
23
+ x_forwarded_for = request.env['HTTP_X_FORWARDED_FOR']
24
+ return x_forwarded_for unless x_forwarded_for.nil?
25
+ rescue NoMethodError
26
+ begin
27
+ x_forwarded_for = request['HTTP_X_FORWARDED_FOR']
28
+ return x_forwarded_for unless x_forwarded_for.nil?
29
+ rescue NoMethodError
30
+ end
31
+ end
32
+
33
+ begin
34
+ x_forwarded_for = request.env['REMOTE_ADDR']
35
+ return x_forwarded_for unless x_forwarded_for.nil?
36
+ rescue NoMethodError
37
+ begin
38
+ x_forwarded_for = request['REMOTE_ADDR']
39
+ return x_forwarded_for unless x_forwarded_for.nil?
40
+ rescue NoMethodError
41
+ end
42
+ end
43
+
44
+ ''
45
+ end
46
+
47
+ def self.get_remote_ip_from_request(request)
48
+ begin
49
+ request.remote_ip
50
+ rescue NoMethodError
51
+ ''
52
+ end
53
+ end
54
+ end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
 
3
- class Logger
5
+ class SecureNativeLogger
4
6
  @logger = Logger.new(STDOUT)
5
7
 
6
- def self.init_logger(level)
8
+ def self.init_logger(level = 'DEBUG')
7
9
  @logger.level = case level
8
10
  when 'WARN'
9
11
  Logger::WARN
@@ -39,4 +41,4 @@ class Logger
39
41
  def self.error(msg)
40
42
  @logger.error(msg)
41
43
  end
42
- end
44
+ end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'openssl'
2
4
 
3
5
  class SignatureUtils
4
- SIGNATURE_HEADER = 'x-securenative'.freeze
6
+ SIGNATURE_HEADER = 'x-securenative'
5
7
 
6
8
  def self.valid_signature?(api_key, payload, header_signature)
7
9
  key = api_key.encode('utf-8')
@@ -11,4 +13,4 @@ class SignatureUtils
11
13
  rescue StandardError
12
14
  false
13
15
  end
14
- end
16
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Utils
4
+ def self.null_or_empty?(string)
5
+ return true if !string || string.empty? || string.nil?
6
+
7
+ false
8
+ end
9
+ end