truemail 2.3.3 → 2.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{circle.yml → .circleci/config.yml} +37 -19
- data/.codeclimate.yml +1 -1
- data/.reek.yml +9 -8
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +65 -0
- data/Gemfile.lock +37 -36
- data/README.md +111 -26
- data/lib/truemail/configuration.rb +19 -24
- data/lib/truemail/core.rb +5 -2
- data/lib/truemail/log/serializer/base.rb +17 -8
- data/lib/truemail/log/serializer/validator_text.rb +3 -3
- data/lib/truemail/validate/mx_blacklist.rb +26 -0
- data/lib/truemail/validate/smtp.rb +1 -1
- data/lib/truemail/validator.rb +6 -2
- data/lib/truemail/version.rb +1 -1
- data/truemail.gemspec +11 -11
- metadata +36 -42
data/lib/truemail/core.rb
CHANGED
@@ -24,8 +24,10 @@ module Truemail
|
|
24
24
|
REGEX_DOMAIN_PATTERN = /(?=\A.{4,255}\z)(\A#{REGEX_DOMAIN}\z)/.freeze
|
25
25
|
REGEX_DOMAIN_FROM_EMAIL = /\A.+@(.+)\z/.freeze
|
26
26
|
REGEX_SMTP_ERROR_BODY_PATTERN = /(?=.*550)(?=.*(user|account|customer|mailbox)).*/i.freeze
|
27
|
-
|
28
|
-
|
27
|
+
REGEX_IP_ADDRESS = /((1\d|[1-9]|2[0-4])?\d|25[0-5])(\.\g<1>){3}/.freeze
|
28
|
+
REGEX_IP_ADDRESS_PATTERN = /\A#{REGEX_IP_ADDRESS}\z/.freeze
|
29
|
+
REGEX_PORT_NUMBER = /6553[0-5]|655[0-2]\d|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3}/.freeze
|
30
|
+
REGEX_DNS_SERVER_ADDRESS_PATTERN = /\A#{REGEX_IP_ADDRESS}(:#{REGEX_PORT_NUMBER})?\z/.freeze
|
29
31
|
end
|
30
32
|
|
31
33
|
module Dns
|
@@ -46,6 +48,7 @@ module Truemail
|
|
46
48
|
require_relative '../truemail/validate/domain_list_match'
|
47
49
|
require_relative '../truemail/validate/regex'
|
48
50
|
require_relative '../truemail/validate/mx'
|
51
|
+
require_relative '../truemail/validate/mx_blacklist'
|
49
52
|
require_relative '../truemail/validate/smtp'
|
50
53
|
require_relative '../truemail/validate/smtp/response'
|
51
54
|
require_relative '../truemail/validate/smtp/request'
|
@@ -6,6 +6,14 @@ module Truemail
|
|
6
6
|
class Base
|
7
7
|
require 'json'
|
8
8
|
|
9
|
+
CONFIGURATION_ARRAY_ATTRS = %i[
|
10
|
+
validation_type_by_domain
|
11
|
+
whitelisted_domains
|
12
|
+
blacklisted_domains
|
13
|
+
blacklisted_mx_ip_addresses
|
14
|
+
dns
|
15
|
+
].freeze
|
16
|
+
CONFIGURATION_REGEX_ATTRS = %i[email_pattern smtp_error_body_pattern].freeze
|
9
17
|
DEFAULT_GEM_VALUE = 'default gem value'
|
10
18
|
|
11
19
|
def self.call(executor_instance)
|
@@ -30,22 +38,22 @@ module Truemail
|
|
30
38
|
|
31
39
|
alias warnings errors
|
32
40
|
|
33
|
-
|
41
|
+
Truemail::Log::Serializer::Base::CONFIGURATION_ARRAY_ATTRS.each do |method|
|
34
42
|
define_method(method) do
|
35
|
-
|
36
|
-
return if
|
37
|
-
|
43
|
+
executor_configuration_attr = executor_configuration.public_send(method)
|
44
|
+
return if executor_configuration_attr.empty?
|
45
|
+
executor_configuration_attr
|
38
46
|
end
|
39
47
|
end
|
40
48
|
|
41
|
-
|
49
|
+
Truemail::Log::Serializer::Base::CONFIGURATION_REGEX_ATTRS.each do |method|
|
42
50
|
define_method(method) do
|
43
|
-
|
51
|
+
executor_configuration_attr = executor_configuration.public_send(method)
|
44
52
|
default_pattern = Truemail::RegexConstant.const_get(
|
45
53
|
(method.eql?(:email_pattern) ? :regex_email_pattern : :regex_smtp_error_body_pattern).upcase
|
46
54
|
)
|
47
|
-
return Truemail::Log::Serializer::Base::DEFAULT_GEM_VALUE if
|
48
|
-
|
55
|
+
return Truemail::Log::Serializer::Base::DEFAULT_GEM_VALUE if executor_configuration_attr.eql?(default_pattern)
|
56
|
+
executor_configuration_attr
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
@@ -55,6 +63,7 @@ module Truemail
|
|
55
63
|
whitelist_validation: executor_configuration.whitelist_validation,
|
56
64
|
whitelisted_domains: whitelisted_domains,
|
57
65
|
blacklisted_domains: blacklisted_domains,
|
66
|
+
blacklisted_mx_ip_addresses: blacklisted_mx_ip_addresses,
|
58
67
|
dns: dns,
|
59
68
|
not_rfc_mx_lookup_flow: executor_configuration.not_rfc_mx_lookup_flow,
|
60
69
|
smtp_fail_fast: executor_configuration.smtp_fail_fast,
|
@@ -19,9 +19,9 @@ module Truemail
|
|
19
19
|
def data_composer(enumerable_object)
|
20
20
|
enumerable_object.inject([]) do |formatted_data, (key, value)|
|
21
21
|
data =
|
22
|
-
case
|
23
|
-
when
|
24
|
-
when
|
22
|
+
case value
|
23
|
+
when ::Hash then "\n#{printer(value)}"
|
24
|
+
when ::Array then value.join(', ')
|
25
25
|
else value
|
26
26
|
end
|
27
27
|
formatted_data << "#{key.to_s.tr('_', ' ')}: #{data}".chomp << "\n"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Truemail
|
4
|
+
module Validate
|
5
|
+
class MxBlacklist < Truemail::Validate::Base
|
6
|
+
ERROR = 'blacklisted mx server ip address'
|
7
|
+
|
8
|
+
def run
|
9
|
+
return false unless Truemail::Validate::Mx.check(result)
|
10
|
+
return true if success(not_blacklisted_mail_servers?)
|
11
|
+
add_error(Truemail::Validate::MxBlacklist::ERROR)
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def blacklisted_ip?
|
18
|
+
->(mail_server) { configuration.blacklisted_mx_ip_addresses.include?(mail_server) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def not_blacklisted_mail_servers?
|
22
|
+
mail_servers.none?(&blacklisted_ip?)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -13,7 +13,7 @@ module Truemail
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def run
|
16
|
-
return false unless Truemail::Validate::
|
16
|
+
return false unless Truemail::Validate::MxBlacklist.check(result)
|
17
17
|
establish_smtp_connection
|
18
18
|
return true if success(success_response?)
|
19
19
|
result.smtp_debug = smtp_results
|
data/lib/truemail/validator.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Truemail
|
4
4
|
class Validator < Truemail::Executor
|
5
5
|
RESULT_ATTRS = %i[success email domain mail_servers errors smtp_debug configuration].freeze
|
6
|
-
VALIDATION_TYPES = %i[regex mx smtp].freeze
|
6
|
+
VALIDATION_TYPES = %i[regex mx mx_blacklist smtp].freeze
|
7
7
|
|
8
8
|
Result = ::Struct.new(*RESULT_ATTRS, keyword_init: true) do
|
9
9
|
def initialize(mail_servers: [], errors: {}, **args)
|
@@ -27,7 +27,7 @@ module Truemail
|
|
27
27
|
|
28
28
|
def run
|
29
29
|
Truemail::Validate::DomainListMatch.check(result)
|
30
|
-
result_not_changed? ? Truemail::Validate.const_get(validation_type
|
30
|
+
result_not_changed? ? Truemail::Validate.const_get(constantize(validation_type)).check(result) : update_validation_type
|
31
31
|
logger&.push(self)
|
32
32
|
self
|
33
33
|
end
|
@@ -43,6 +43,10 @@ module Truemail
|
|
43
43
|
result.configuration.validation_type_by_domain[domain] || current_validation_type
|
44
44
|
end
|
45
45
|
|
46
|
+
def constantize(symbol)
|
47
|
+
symbol.capitalize.to_s.gsub(/_[a-z]/, &:upcase).tr('_', '').to_sym
|
48
|
+
end
|
49
|
+
|
46
50
|
def update_validation_type
|
47
51
|
@validation_type = result.success ? :whitelist : :blacklist
|
48
52
|
end
|
data/lib/truemail/version.rb
CHANGED
data/truemail.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ['admin@bestweb.com.ua']
|
12
12
|
|
13
13
|
spec.summary = %(truemail)
|
14
|
-
spec.description = %(Configurable framework agnostic plain Ruby email validator. Verify email via Regex, DNS and
|
14
|
+
spec.description = %(Configurable framework agnostic plain Ruby email validator. Verify email via Regex, DNS, SMTP and even more.)
|
15
15
|
|
16
16
|
spec.homepage = 'https://github.com/truemail-rb/truemail'
|
17
17
|
spec.license = 'MIT'
|
@@ -33,21 +33,21 @@ Gem::Specification.new do |spec|
|
|
33
33
|
|
34
34
|
spec.add_runtime_dependency 'simpleidn', '~> 0.2.1'
|
35
35
|
|
36
|
-
spec.add_development_dependency 'bundler', '~>
|
36
|
+
spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.20'
|
37
37
|
spec.add_development_dependency 'bundler-audit', '~> 0.8.0'
|
38
|
-
spec.add_development_dependency 'dns_mock', '~> 1.
|
39
|
-
spec.add_development_dependency 'faker', '~> 2.
|
38
|
+
spec.add_development_dependency 'dns_mock', '~> 1.3'
|
39
|
+
spec.add_development_dependency 'faker', '~> 2.18'
|
40
40
|
spec.add_development_dependency 'fasterer', '~> 0.9.0'
|
41
41
|
spec.add_development_dependency 'json_matchers', '~> 0.11.1'
|
42
|
-
spec.add_development_dependency 'overcommit', '~> 0.
|
42
|
+
spec.add_development_dependency 'overcommit', '~> 0.58.0'
|
43
43
|
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
44
44
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.3'
|
45
|
-
spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.
|
45
|
+
spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.4'
|
46
46
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
47
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
48
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.
|
49
|
-
spec.add_development_dependency 'rubocop-rspec', '~> 2.
|
47
|
+
spec.add_development_dependency 'rubocop', '~> 1.16', '>= 1.16.1'
|
48
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.11', '>= 1.11.3'
|
49
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.4'
|
50
50
|
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
51
|
-
spec.add_development_dependency 'truemail-rspec', '~> 0.
|
52
|
-
spec.add_development_dependency 'webmock', '~> 3.
|
51
|
+
spec.add_development_dependency 'truemail-rspec', '~> 0.6'
|
52
|
+
spec.add_development_dependency 'webmock', '~> 3.13'
|
53
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: truemail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Trotsenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simpleidn
|
@@ -30,14 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.2'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.2.20
|
34
37
|
type: :development
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
43
|
+
version: '2.2'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.2.20
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: bundler-audit
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,34 +64,28 @@ dependencies:
|
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: 1.2.1
|
67
|
+
version: '1.3'
|
65
68
|
type: :development
|
66
69
|
prerelease: false
|
67
70
|
version_requirements: !ruby/object:Gem::Requirement
|
68
71
|
requirements:
|
69
72
|
- - "~>"
|
70
73
|
- !ruby/object:Gem::Version
|
71
|
-
version: '1.
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: 1.2.1
|
74
|
+
version: '1.3'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: faker
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '2.
|
81
|
+
version: '2.18'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '2.
|
88
|
+
version: '2.18'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: fasterer
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,14 +120,14 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0.
|
123
|
+
version: 0.58.0
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0.
|
130
|
+
version: 0.58.0
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: pry-byebug
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,7 +171,7 @@ dependencies:
|
|
171
171
|
version: '6.0'
|
172
172
|
- - ">="
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version: 6.0.
|
174
|
+
version: 6.0.4
|
175
175
|
type: :development
|
176
176
|
prerelease: false
|
177
177
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -181,7 +181,7 @@ dependencies:
|
|
181
181
|
version: '6.0'
|
182
182
|
- - ">="
|
183
183
|
- !ruby/object:Gem::Version
|
184
|
-
version: 6.0.
|
184
|
+
version: 6.0.4
|
185
185
|
- !ruby/object:Gem::Dependency
|
186
186
|
name: rspec
|
187
187
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,54 +202,54 @@ dependencies:
|
|
202
202
|
requirements:
|
203
203
|
- - "~>"
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
version: '1.
|
205
|
+
version: '1.16'
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 1.
|
208
|
+
version: 1.16.1
|
209
209
|
type: :development
|
210
210
|
prerelease: false
|
211
211
|
version_requirements: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: '1.
|
215
|
+
version: '1.16'
|
216
216
|
- - ">="
|
217
217
|
- !ruby/object:Gem::Version
|
218
|
-
version: 1.
|
218
|
+
version: 1.16.1
|
219
219
|
- !ruby/object:Gem::Dependency
|
220
220
|
name: rubocop-performance
|
221
221
|
requirement: !ruby/object:Gem::Requirement
|
222
222
|
requirements:
|
223
223
|
- - "~>"
|
224
224
|
- !ruby/object:Gem::Version
|
225
|
-
version: '1.
|
225
|
+
version: '1.11'
|
226
226
|
- - ">="
|
227
227
|
- !ruby/object:Gem::Version
|
228
|
-
version: 1.
|
228
|
+
version: 1.11.3
|
229
229
|
type: :development
|
230
230
|
prerelease: false
|
231
231
|
version_requirements: !ruby/object:Gem::Requirement
|
232
232
|
requirements:
|
233
233
|
- - "~>"
|
234
234
|
- !ruby/object:Gem::Version
|
235
|
-
version: '1.
|
235
|
+
version: '1.11'
|
236
236
|
- - ">="
|
237
237
|
- !ruby/object:Gem::Version
|
238
|
-
version: 1.
|
238
|
+
version: 1.11.3
|
239
239
|
- !ruby/object:Gem::Dependency
|
240
240
|
name: rubocop-rspec
|
241
241
|
requirement: !ruby/object:Gem::Requirement
|
242
242
|
requirements:
|
243
243
|
- - "~>"
|
244
244
|
- !ruby/object:Gem::Version
|
245
|
-
version: '2.
|
245
|
+
version: '2.4'
|
246
246
|
type: :development
|
247
247
|
prerelease: false
|
248
248
|
version_requirements: !ruby/object:Gem::Requirement
|
249
249
|
requirements:
|
250
250
|
- - "~>"
|
251
251
|
- !ruby/object:Gem::Version
|
252
|
-
version: '2.
|
252
|
+
version: '2.4'
|
253
253
|
- !ruby/object:Gem::Dependency
|
254
254
|
name: simplecov
|
255
255
|
requirement: !ruby/object:Gem::Requirement
|
@@ -270,42 +270,37 @@ dependencies:
|
|
270
270
|
requirements:
|
271
271
|
- - "~>"
|
272
272
|
- !ruby/object:Gem::Version
|
273
|
-
version: '0.
|
273
|
+
version: '0.6'
|
274
274
|
type: :development
|
275
275
|
prerelease: false
|
276
276
|
version_requirements: !ruby/object:Gem::Requirement
|
277
277
|
requirements:
|
278
278
|
- - "~>"
|
279
279
|
- !ruby/object:Gem::Version
|
280
|
-
version: '0.
|
280
|
+
version: '0.6'
|
281
281
|
- !ruby/object:Gem::Dependency
|
282
282
|
name: webmock
|
283
283
|
requirement: !ruby/object:Gem::Requirement
|
284
284
|
requirements:
|
285
285
|
- - "~>"
|
286
286
|
- !ruby/object:Gem::Version
|
287
|
-
version: '3.
|
288
|
-
- - ">="
|
289
|
-
- !ruby/object:Gem::Version
|
290
|
-
version: 3.12.2
|
287
|
+
version: '3.13'
|
291
288
|
type: :development
|
292
289
|
prerelease: false
|
293
290
|
version_requirements: !ruby/object:Gem::Requirement
|
294
291
|
requirements:
|
295
292
|
- - "~>"
|
296
293
|
- !ruby/object:Gem::Version
|
297
|
-
version: '3.
|
298
|
-
- - ">="
|
299
|
-
- !ruby/object:Gem::Version
|
300
|
-
version: 3.12.2
|
294
|
+
version: '3.13'
|
301
295
|
description: Configurable framework agnostic plain Ruby email validator. Verify email
|
302
|
-
via Regex, DNS and
|
296
|
+
via Regex, DNS, SMTP and even more.
|
303
297
|
email:
|
304
298
|
- admin@bestweb.com.ua
|
305
299
|
executables: []
|
306
300
|
extensions: []
|
307
301
|
extra_rdoc_files: []
|
308
302
|
files:
|
303
|
+
- ".circleci/config.yml"
|
309
304
|
- ".codeclimate.yml"
|
310
305
|
- ".github/BRANCH_NAMING_CONVENTION.md"
|
311
306
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
@@ -330,7 +325,6 @@ files:
|
|
330
325
|
- Rakefile
|
331
326
|
- bin/console
|
332
327
|
- bin/setup
|
333
|
-
- circle.yml
|
334
328
|
- lib/truemail.rb
|
335
329
|
- lib/truemail/audit/base.rb
|
336
330
|
- lib/truemail/audit/dns.rb
|
@@ -353,6 +347,7 @@ files:
|
|
353
347
|
- lib/truemail/validate/base.rb
|
354
348
|
- lib/truemail/validate/domain_list_match.rb
|
355
349
|
- lib/truemail/validate/mx.rb
|
350
|
+
- lib/truemail/validate/mx_blacklist.rb
|
356
351
|
- lib/truemail/validate/regex.rb
|
357
352
|
- lib/truemail/validate/smtp.rb
|
358
353
|
- lib/truemail/validate/smtp/request.rb
|
@@ -386,8 +381,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
386
381
|
- !ruby/object:Gem::Version
|
387
382
|
version: '0'
|
388
383
|
requirements: []
|
389
|
-
|
390
|
-
rubygems_version: 2.7.3
|
384
|
+
rubygems_version: 3.2.20
|
391
385
|
signing_key:
|
392
386
|
specification_version: 4
|
393
387
|
summary: truemail
|