truemail 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -0
- data/Gemfile.lock +1 -1
- data/README.md +24 -4
- data/lib/truemail.rb +1 -1
- data/lib/truemail/audit/base.rb +8 -0
- data/lib/truemail/audit/dns.rb +26 -0
- data/lib/truemail/audit/ip.rb +28 -0
- data/lib/truemail/audit/ptr.rb +7 -36
- data/lib/truemail/auditor.rb +2 -2
- data/lib/truemail/core.rb +22 -20
- data/lib/truemail/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce37fd460cb5da28f5880be61ac6abb5ca5e8d0fe1010738e45a02a70417fa31
|
4
|
+
data.tar.gz: 3f66bb5169a012e7bd77af80c40c51c021332cb86be4f2ef6f1450611001cebf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4902f4e7d2c68cc8714c536ae1844904b99c7609a2b36d057902e6a838d2e2e33bb301f99b7cb067e108bb4bae845ec2e9dfbb9be529db8d53c9bf50a31dfdf9
|
7
|
+
data.tar.gz: f049315d919448d56d8082da28df31d1bc7ad6e191fc5b30629b38011ff4450f870fb7597a6bc4645007fe7bcbc4a7fa3b0855ee408f4115466e9a3496c926c8
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/Gemfile.lock
CHANGED
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.
|
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
|
1001
|
+
# Has audit warnings
|
985
1002
|
=> #<Truemail::Auditor:0x00005580df358828
|
986
1003
|
@result=
|
987
1004
|
#<struct Truemail::Auditor::Result
|
988
|
-
|
989
|
-
|
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=[],
|
data/lib/truemail.rb
CHANGED
data/lib/truemail/audit/base.rb
CHANGED
@@ -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
|
data/lib/truemail/audit/ptr.rb
CHANGED
@@ -3,38 +3,19 @@
|
|
3
3
|
module Truemail
|
4
4
|
module Audit
|
5
5
|
class Ptr < Truemail::Audit::Base
|
6
|
-
|
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
|
18
|
-
return if
|
19
|
-
|
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
|
-
|
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
|
49
|
-
|
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
|
data/lib/truemail/auditor.rb
CHANGED
@@ -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::
|
18
|
+
Truemail::Audit::Ip.check(result)
|
19
19
|
self
|
20
20
|
end
|
21
21
|
end
|
data/lib/truemail/core.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Truemail
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
41
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
data/lib/truemail/version.rb
CHANGED
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.
|
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-
|
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.
|
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: []
|