truemail 1.7.1 → 1.8.0

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: '08c2fc87715dca966f6671f6b1d58d58e9d411bb01ae460ff31a34125d8f4a14'
4
- data.tar.gz: 30ef54377bce7d03294e73dafbbb9d637ed8d6e55dfbf0931768a1246837b45d
3
+ metadata.gz: ce37fd460cb5da28f5880be61ac6abb5ca5e8d0fe1010738e45a02a70417fa31
4
+ data.tar.gz: 3f66bb5169a012e7bd77af80c40c51c021332cb86be4f2ef6f1450611001cebf
5
5
  SHA512:
6
- metadata.gz: 9ef76732a55fb837e0f0eeb77da337a34b5b019e9f774debc777f5a4155c4a7ba6640ca245e106c90dd560814f87870513664a601986518e4f23399b1351ce56
7
- data.tar.gz: 203da733353f7377bda0527d6f330281c1d8357b6e65ba384c3f80decfcc8cdbf2cec8b6f80a31aa967e22bfa9e4afa16c77d576412848f397ba91cfb2035e8e
6
+ metadata.gz: 4902f4e7d2c68cc8714c536ae1844904b99c7609a2b36d057902e6a838d2e2e33bb301f99b7cb067e108bb4bae845ec2e9dfbb9be529db8d53c9bf50a31dfdf9
7
+ data.tar.gz: f049315d919448d56d8082da28df31d1bc7ad6e191fc5b30629b38011ff4450f870fb7597a6bc4645007fe7bcbc4a7fa3b0855ee408f4115466e9a3496c926c8
@@ -1,6 +1,54 @@
1
1
  # Changelog
2
+
2
3
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
3
4
 
5
+ ## [1.8.0] - 2020.06.21
6
+
7
+ ## Added
8
+
9
+ Separated audit features for verifier host.
10
+
11
+ - `Truemail::Audit::Ip`
12
+ - `Truemail::Audit::Dns`
13
+
14
+ ```ruby
15
+ Truemail.host_audit
16
+
17
+ => #<Truemail::Auditor:0x00005580df358828
18
+ @result=
19
+ #<struct Truemail::Auditor::Result
20
+ current_host_ip="127.0.0.1",
21
+ warnings={
22
+ :dns=>"a record of verifier domain not refers to current host ip address",
23
+ :ptr=>"ptr record does not reference to current verifier domain"
24
+ },
25
+ configuration=
26
+ #<Truemail::Configuration:0x00005615e86327a8
27
+ @blacklisted_domains=[],
28
+ @connection_attempts=2,
29
+ @connection_timeout=2,
30
+ @default_validation_type=:smtp,
31
+ @email_pattern=/(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w|\-|\.|\+]*)@((?i-mx:[\p{L}0-9]+([\-\.]{1}[\p{L}0-9]+)*\.[\p{L}]{2,63}))\z)/,
32
+ @response_timeout=2,
33
+ @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
34
+ @not_rfc_mx_lookup_flow=false,
35
+ @smtp_safe_check=false,
36
+ @validation_type_by_domain={},
37
+ @verifier_domain="example.com",
38
+ @verifier_email="verifier@example.com",
39
+ @whitelist_validation=false,
40
+ @whitelisted_domains=[]>
41
+ ```
42
+
43
+ ### Changed
44
+
45
+ - `Truemail::Auditor`
46
+ - `Truemail::Auditor::Result`
47
+ - `Truemail::Audit::Base`
48
+ - `Truemail::Audit::Ptr`
49
+ - `Truemail::VERSION`
50
+ - gem documentation
51
+
4
52
  ## [1.7.1] - 2020.05.10
5
53
 
6
54
  ## Added
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- truemail (1.7.1)
4
+ truemail (1.8.0)
5
5
  simpleidn (~> 0.1.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -36,7 +36,10 @@ Configurable framework agnostic plain Ruby email validator. Verify email via Reg
36
36
  - [Available tracking events](#available-tracking-events)
37
37
  - [JSON serializer](#json-serializer)
38
38
  - [Host audit features](#host-audit-features)
39
+ - [IP audit](#ip-audit)
40
+ - [DNS audit](#dns-audit)
39
41
  - [PTR audit](#ptr-audit)
42
+ - [Example of using](#example-of-using)
40
43
  - [Truemail helpers](#truemail-helpers)
41
44
  - [.valid?](#valid)
42
45
  - [#as_json](#as_json)
@@ -70,6 +73,7 @@ Also Truemail gem allows performing an audit of the host in which runs.
70
73
  - Whitelist/blacklist validation layers
71
74
  - Simple SMTP debugger
72
75
  - Event logger
76
+ - Host auditor tools (helps to detect common host problems interfering to proper email verification)
73
77
  - JSON serializer
74
78
 
75
79
  ## Requirements
@@ -951,18 +955,31 @@ Truemail::Log::Serializer::Json.call(Truemail.validate('nonexistent_email@bestwe
951
955
 
952
956
  ### Host audit features
953
957
 
954
- Truemail gem allows performing an audit of the host in which runs. Only PTR record audit performs for today.
958
+ Truemail gem allows performing an audit of the host in which runs. It will help to detect common host problems interfering to proper email verification.
959
+
960
+ #### IP audit
961
+
962
+ Checks is current Truemail host has proper internet connection and detects current host ip address.
963
+
964
+ #### DNS audit
965
+
966
+ Checks is verifier domain refer to current Truemail host IP address.
955
967
 
956
968
  #### PTR audit
957
969
 
958
970
  So what is a PTR record? A PTR record, or pointer record, enables someone to perform a reverse DNS lookup. This allows them to determine your domain name based on your IP address. Because generic domain names without a PTR are often associated with spammers, incoming mail servers identify email from hosts without PTR records as spam and you can't verify yours emails qualitatively.
959
971
 
972
+ Checks is PTR record exists for your Truemail host ip address exists and refers to current verifier domain.
973
+
974
+ #### Example of using
975
+
960
976
  ```ruby
961
977
  Truemail.host_audit
962
978
  # Everything is good
963
979
  => #<Truemail::Auditor:0x00005580df358828
964
980
  @result=
965
981
  #<struct Truemail::Auditor::Result
982
+ current_host_ip="127.0.0.1",
966
983
  warnings={}>,
967
984
  configuration=
968
985
  #<Truemail::Configuration:0x00005615e86327a8
@@ -981,12 +998,15 @@ Truemail.host_audit
981
998
  @whitelist_validation=false,
982
999
  @whitelisted_domains=[]>
983
1000
 
984
- # Has PTR warning
1001
+ # Has audit warnings
985
1002
  => #<Truemail::Auditor:0x00005580df358828
986
1003
  @result=
987
1004
  #<struct Truemail::Auditor::Result
988
- warnings=
989
- {:ptr=>"ptr record does not reference to current verifier domain"}>,
1005
+ current_host_ip="127.0.0.1",
1006
+ warnings={
1007
+ :dns=>"a record of verifier domain not refers to current host ip address",
1008
+ :ptr=>"ptr record does not reference to current verifier domain"
1009
+ },
990
1010
  configuration=
991
1011
  #<Truemail::Configuration:0x00005615e86327a8
992
1012
  @blacklisted_domains=[],
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'truemail/core'
3
+ require_relative 'truemail/core'
4
4
 
5
5
  module Truemail
6
6
  INCOMPLETE_CONFIG = 'verifier_email is required parameter'
@@ -3,12 +3,20 @@
3
3
  module Truemail
4
4
  module Audit
5
5
  class Base < Truemail::Worker
6
+ require 'net/http'
7
+ require 'ipaddr'
8
+ require 'resolv'
9
+
6
10
  private
7
11
 
8
12
  def add_warning(message)
9
13
  result.warnings[self.class.name.split('::').last.downcase.to_sym] = message
10
14
  end
11
15
 
16
+ def current_host_ip
17
+ result.current_host_ip
18
+ end
19
+
12
20
  def configuration
13
21
  result.configuration
14
22
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Truemail
4
+ module Audit
5
+ class Dns < Truemail::Audit::Base
6
+ VERIFIER_DOMAIN_NOT_REFER = 'a record of verifier domain not refers to current host ip address'
7
+
8
+ def run
9
+ return if verifier_domain_refer_to_current_host_ip?
10
+ add_warning(Truemail::Audit::Dns::VERIFIER_DOMAIN_NOT_REFER)
11
+ end
12
+
13
+ private
14
+
15
+ def a_record
16
+ Truemail::Wrapper.call(configuration: configuration) do
17
+ Resolv::DNS.new.getaddress(verifier_domain).to_s
18
+ end
19
+ end
20
+
21
+ def verifier_domain_refer_to_current_host_ip?
22
+ a_record.eql?(current_host_ip)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Truemail
4
+ module Audit
5
+ class Ip < Truemail::Audit::Base
6
+ GET_MY_IP_URL = 'https://api.ipify.org'
7
+ IPIFY_ERROR = 'impossible to detect current host address via third party service'
8
+
9
+ def run
10
+ return add_warning(Truemail::Audit::Ip::IPIFY_ERROR) unless detect_current_host_ip
11
+ Truemail::Audit::Dns.check(result)
12
+ Truemail::Audit::Ptr.check(result)
13
+ end
14
+
15
+ private
16
+
17
+ def detect_ip_via_ipify
18
+ Net::HTTP.get(URI(Truemail::Audit::Ip::GET_MY_IP_URL))
19
+ end
20
+
21
+ def detect_current_host_ip
22
+ result.current_host_ip = Truemail::Wrapper.call(configuration: configuration) do
23
+ detect_ip_via_ipify
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -3,38 +3,19 @@
3
3
  module Truemail
4
4
  module Audit
5
5
  class Ptr < Truemail::Audit::Base
6
- require 'net/http'
7
- require 'ipaddr'
8
- require 'resolv'
9
-
10
- GET_MY_IP_URL = 'https://api.ipify.org'
11
- IPIFY_ERROR = 'impossible to detect current host address via third party service'
12
- PTR_NOT_FOUND = 'ptr record for current host address was not found'
6
+ PTR_NOT_FOUND = 'ptr record for current host ip address was not found'
13
7
  PTR_NOT_REFER = 'ptr record does not reference to current verifier domain'
14
- VERIFIER_DOMAIN_NOT_REFER = 'a record of verifier domain not refers to current host address'
15
8
 
16
9
  def run
17
- return if !current_host_address && add_warning(Truemail::Audit::Ptr::IPIFY_ERROR)
18
- return if ptr_records.empty? && add_warning(Truemail::Audit::Ptr::PTR_NOT_FOUND)
19
- return if ptr_not_refer_to_verifier_domain? && add_warning(Truemail::Audit::Ptr::PTR_NOT_REFER)
20
- return if verifier_domain_refer_to_current_host_address?
21
- add_warning(Truemail::Audit::Ptr::VERIFIER_DOMAIN_NOT_REFER)
10
+ return add_warning(Truemail::Audit::Ptr::PTR_NOT_FOUND) if ptr_records.empty?
11
+ return if ptr_refer_to_verifier_domain?
12
+ add_warning(Truemail::Audit::Ptr::PTR_NOT_REFER)
22
13
  end
23
14
 
24
15
  private
25
16
 
26
- def detect_ip_via_ipify
27
- Net::HTTP.get(URI(Truemail::Audit::Ptr::GET_MY_IP_URL))
28
- end
29
-
30
- def current_host_address
31
- @current_host_address ||= Truemail::Wrapper.call(configuration: configuration) do
32
- IPAddr.new(detect_ip_via_ipify)
33
- end
34
- end
35
-
36
17
  def current_host_reverse_lookup
37
- current_host_address.reverse
18
+ IPAddr.new(current_host_ip).reverse
38
19
  end
39
20
 
40
21
  def ptr_records
@@ -45,18 +26,8 @@ module Truemail
45
26
  end || []
46
27
  end
47
28
 
48
- def ptr_not_refer_to_verifier_domain?
49
- !ptr_records.include?(verifier_domain)
50
- end
51
-
52
- def a_record
53
- Truemail::Wrapper.call(configuration: configuration) do
54
- Resolv::DNS.new.getaddress(verifier_domain).to_s
55
- end
56
- end
57
-
58
- def verifier_domain_refer_to_current_host_address?
59
- a_record.eql?(current_host_address.to_s)
29
+ def ptr_refer_to_verifier_domain?
30
+ ptr_records.include?(verifier_domain)
60
31
  end
61
32
  end
62
33
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Truemail
4
4
  class Auditor
5
- Result = Struct.new(:warnings, :configuration, keyword_init: true) do
5
+ Result = Struct.new(:current_host_ip, :warnings, :configuration, keyword_init: true) do
6
6
  def initialize(warnings: {}, **args)
7
7
  super
8
8
  end
@@ -15,7 +15,7 @@ module Truemail
15
15
  end
16
16
 
17
17
  def run
18
- Truemail::Audit::Ptr.check(result)
18
+ Truemail::Audit::Ip.check(result)
19
19
  self
20
20
  end
21
21
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Truemail
4
- require 'truemail/version'
5
- require 'truemail/configuration'
6
- require 'truemail/worker'
7
- require 'truemail/wrapper'
8
- require 'truemail/auditor'
9
- require 'truemail/validator'
10
- require 'truemail/logger'
4
+ require_relative '../truemail/version'
5
+ require_relative '../truemail/configuration'
6
+ require_relative '../truemail/worker'
7
+ require_relative '../truemail/wrapper'
8
+ require_relative '../truemail/auditor'
9
+ require_relative '../truemail/validator'
10
+ require_relative '../truemail/logger'
11
11
 
12
12
  ConfigurationError = Class.new(StandardError)
13
13
 
@@ -37,24 +37,26 @@ module Truemail
37
37
  end
38
38
 
39
39
  module Audit
40
- require 'truemail/audit/base'
41
- require 'truemail/audit/ptr'
40
+ require_relative '../truemail/audit/base'
41
+ require_relative '../truemail/audit/ip'
42
+ require_relative '../truemail/audit/dns'
43
+ require_relative '../truemail/audit/ptr'
42
44
  end
43
45
 
44
46
  module Validate
45
- require 'truemail/validate/base'
46
- require 'truemail/validate/domain_list_match'
47
- require 'truemail/validate/regex'
48
- require 'truemail/validate/mx'
49
- require 'truemail/validate/smtp'
50
- require 'truemail/validate/smtp/response'
51
- require 'truemail/validate/smtp/request'
47
+ require_relative '../truemail/validate/base'
48
+ require_relative '../truemail/validate/domain_list_match'
49
+ require_relative '../truemail/validate/regex'
50
+ require_relative '../truemail/validate/mx'
51
+ require_relative '../truemail/validate/smtp'
52
+ require_relative '../truemail/validate/smtp/response'
53
+ require_relative '../truemail/validate/smtp/request'
52
54
  end
53
55
 
54
56
  module Log
55
- require 'truemail/log/event'
56
- require 'truemail/log/serializer/base'
57
- require 'truemail/log/serializer/text'
58
- require 'truemail/log/serializer/json'
57
+ require_relative '../truemail/log/event'
58
+ require_relative '../truemail/log/serializer/base'
59
+ require_relative '../truemail/log/serializer/text'
60
+ require_relative '../truemail/log/serializer/json'
59
61
  end
60
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Truemail
4
- VERSION = '1.7.1'
4
+ VERSION = '1.8.0'
5
5
  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: 1.7.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Trotsenko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-10 00:00:00.000000000 Z
11
+ date: 2020-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simpleidn
@@ -277,6 +277,8 @@ files:
277
277
  - bin/setup
278
278
  - lib/truemail.rb
279
279
  - lib/truemail/audit/base.rb
280
+ - lib/truemail/audit/dns.rb
281
+ - lib/truemail/audit/ip.rb
280
282
  - lib/truemail/audit/ptr.rb
281
283
  - lib/truemail/auditor.rb
282
284
  - lib/truemail/configuration.rb
@@ -302,7 +304,7 @@ homepage: https://github.com/rubygarage/truemail
302
304
  licenses:
303
305
  - MIT
304
306
  metadata: {}
305
- post_install_message:
307
+ post_install_message:
306
308
  rdoc_options: []
307
309
  require_paths:
308
310
  - lib
@@ -317,9 +319,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
317
319
  - !ruby/object:Gem::Version
318
320
  version: '0'
319
321
  requirements: []
320
- rubyforge_project:
321
- rubygems_version: 2.7.9
322
- signing_key:
322
+ rubyforge_project:
323
+ rubygems_version: 2.7.3
324
+ signing_key:
323
325
  specification_version: 4
324
326
  summary: truemail
325
327
  test_files: []