diff --git a/CHANGELOG.md b/CHANGELOG.md index 345e865..40f491e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ 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). +## [2.4.5] - 2021.07.09 + +### Removed + +- `Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL` + +### Updated + +- `Truemail::Validate::Mx` +- Updated gem development dependencies +- Updated gem version + ## [2.4.4] - 2021.06.29 ### Updated diff --git a/Gemfile.lock b/Gemfile.lock index 3815a69..fe689a5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,13 @@ PATH remote: . specs: - truemail (2.4.4) + truemail (2.4.5) simpleidn (~> 0.2.1) GEM remote: https://rubygems.org/ specs: - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) ast (2.4.2) bundler-audit (0.8.0) @@ -21,7 +21,7 @@ GEM crack (0.4.5) rexml diff-lcs (1.4.4) - dns_mock (1.3.0) + dns_mock (1.3.1) docile (1.4.0) faker (2.18.0) i18n (>= 1.6, < 2) @@ -43,7 +43,7 @@ GEM iniparse (~> 1.4) rexml (~> 3.2) parallel (1.20.1) - parser (3.0.1.1) + parser (3.0.2.0) ast (~> 2.4.1) pry (0.13.1) coderay (~> 1.1) @@ -54,7 +54,7 @@ GEM psych (3.3.2) public_suffix (4.0.6) rainbow (3.0.0) - rake (13.0.3) + rake (13.0.6) reek (6.0.4) kwalify (~> 0.7.0) parser (~> 3.0.0) @@ -75,7 +75,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - rubocop (1.18.0) + rubocop (1.18.3) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) @@ -86,7 +86,7 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.7.0) parser (>= 3.0.1.1) - rubocop-performance (1.11.3) + rubocop-performance (1.11.4) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rspec (2.4.0) @@ -121,19 +121,19 @@ PLATFORMS x86_64-darwin-20 DEPENDENCIES - bundler (~> 2.2, >= 2.2.21) + bundler (~> 2.2, >= 2.2.23) bundler-audit (~> 0.8.0) - dns_mock (~> 1.3) + dns_mock (~> 1.3, >= 1.3.1) faker (~> 2.18) fasterer (~> 0.9.0) json_matchers (~> 0.11.1) overcommit (~> 0.58.0) pry-byebug (~> 3.9) - rake (~> 13.0, >= 13.0.3) + rake (~> 13.0, >= 13.0.6) reek (~> 6.0, >= 6.0.4) rspec (~> 3.10) - rubocop (~> 1.18) - rubocop-performance (~> 1.11, >= 1.11.3) + rubocop (~> 1.18, >= 1.18.3) + rubocop-performance (~> 1.11, >= 1.11.4) rubocop-rspec (~> 2.4) simplecov (~> 0.17.1) truemail! @@ -141,4 +141,4 @@ DEPENDENCIES webmock (~> 3.13) BUNDLED WITH - 2.2.21 + 2.2.23 diff --git a/lib/truemail/core.rb b/lib/truemail/core.rb index 004ea13..206d0b1 100644 --- a/lib/truemail/core.rb +++ b/lib/truemail/core.rb @@ -22,7 +22,6 @@ module RegexConstant REGEX_DOMAIN = /[\p{L}0-9]+([\-.]{1}[\p{L}0-9]+)*\.\p{L}{2,63}/i.freeze REGEX_EMAIL_PATTERN = /(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\W\w]*)@(#{REGEX_DOMAIN})\z)/.freeze REGEX_DOMAIN_PATTERN = /(?=\A.{4,255}\z)(\A#{REGEX_DOMAIN}\z)/.freeze - REGEX_DOMAIN_FROM_EMAIL = /\A.+@(.+)\z/.freeze REGEX_SMTP_ERROR_BODY_PATTERN = /(?=.*550)(?=.*(user|account|customer|mailbox)).*/i.freeze REGEX_IP_ADDRESS = /((1\d|[1-9]|2[0-4])?\d|25[0-5])(\.\g<1>){3}/.freeze REGEX_IP_ADDRESS_PATTERN = /\A#{REGEX_IP_ADDRESS}\z/.freeze diff --git a/lib/truemail/validate/domain_list_match.rb b/lib/truemail/validate/domain_list_match.rb index 72c4cc6..e285973 100644 --- a/lib/truemail/validate/domain_list_match.rb +++ b/lib/truemail/validate/domain_list_match.rb @@ -15,7 +15,7 @@ def run private def email_domain - @email_domain ||= result.email[Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL, 1] + @email_domain ||= result.email[Truemail::RegexConstant::REGEX_EMAIL_PATTERN, 3] end def whitelisted_domain? diff --git a/lib/truemail/validate/mx.rb b/lib/truemail/validate/mx.rb index cebaa6e..5bddd84 100644 --- a/lib/truemail/validate/mx.rb +++ b/lib/truemail/validate/mx.rb @@ -8,7 +8,6 @@ class Mx < Truemail::Validate::Base def run return false unless Truemail::Validate::Regex.check(result) - result.domain = result.punycode_email[Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL, 1] return true if success(mx_lookup && domain_not_include_null_mx) mail_servers.clear && add_error(Truemail::Validate::Mx::ERROR) false @@ -53,7 +52,10 @@ def mail_servers_found? end def domain - result.domain + @domain ||= begin + result.domain = result.email[Truemail::RegexConstant::REGEX_EMAIL_PATTERN, 3] + result.punycode_email[Truemail::RegexConstant::REGEX_EMAIL_PATTERN, 3] + end end def hosts_from_mx_records? diff --git a/lib/truemail/version.rb b/lib/truemail/version.rb index b479e2d..4e8cb4f 100644 --- a/lib/truemail/version.rb +++ b/lib/truemail/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Truemail - VERSION = '2.4.4' + VERSION = '2.4.5' end diff --git a/spec/support/helpers/context_helper.rb b/spec/support/helpers/context_helper.rb index c3835ce..a52717a 100644 --- a/spec/support/helpers/context_helper.rb +++ b/spec/support/helpers/context_helper.rb @@ -18,6 +18,10 @@ def random_uniq_domain_name faker.unique.domain_name end + def rdns_lookup_host_address(host_address) + host_address.gsub(/(\d+).(\d+).(\d+).(\d+)/, '\4.\3.\2.\1.in-addr.arpa') + end + private def faker diff --git a/spec/support/helpers/context_helper_spec.rb b/spec/support/helpers/context_helper_spec.rb index d00c60e..7c0d969 100644 --- a/spec/support/helpers/context_helper_spec.rb +++ b/spec/support/helpers/context_helper_spec.rb @@ -30,4 +30,10 @@ expect(random_ip_address).to match(Truemail::RegexConstant::REGEX_DNS_SERVER_ADDRESS_PATTERN) end end + + describe '#rdns_lookup_host_address' do + specify do + expect(rdns_lookup_host_address('10.20.30.40')).to eq('40.30.20.10.in-addr.arpa') + end + end end diff --git a/spec/truemail/core_spec.rb b/spec/truemail/core_spec.rb index 5ccbb16..d986ed8 100644 --- a/spec/truemail/core_spec.rb +++ b/spec/truemail/core_spec.rb @@ -17,7 +17,6 @@ specify { expect(described_class).to be_const_defined(:REGEX_DOMAIN) } specify { expect(described_class).to be_const_defined(:REGEX_EMAIL_PATTERN) } specify { expect(described_class).to be_const_defined(:REGEX_DOMAIN_PATTERN) } - specify { expect(described_class).to be_const_defined(:REGEX_DOMAIN_FROM_EMAIL) } specify { expect(described_class).to be_const_defined(:REGEX_SMTP_ERROR_BODY_PATTERN) } specify { expect(described_class).to be_const_defined(:REGEX_IP_ADDRESS) } specify { expect(described_class).to be_const_defined(:REGEX_IP_ADDRESS_PATTERN) } @@ -140,15 +139,6 @@ end end - describe 'Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL' do - subject(:regex_pattern) { described_class::REGEX_DOMAIN_FROM_EMAIL } - - let(:email) { 'i@domain' } - - specify { expect(regex_pattern.match?(email)).to be(true) } - specify { expect(email[regex_pattern, 1]).to eq('domain') } - end - describe 'Truemail::RegexConstant::REGEX_SMTP_ERROR_BODY_PATTERN' do subject(:regex_pattern) { described_class::REGEX_SMTP_ERROR_BODY_PATTERN } diff --git a/spec/truemail/dns/worker_spec.rb b/spec/truemail/dns/worker_spec.rb index 1d6221f..11b76fd 100644 --- a/spec/truemail/dns/worker_spec.rb +++ b/spec/truemail/dns/worker_spec.rb @@ -89,12 +89,9 @@ def dns_resolver_worker_instance end describe '#ptr_records' do - subject(:resolve_ptr_records) { dns_resolver_worker_instance.ptr_records(host_address) } + subject(:resolve_ptr_records) { dns_resolver_worker_instance.ptr_records(rdns_lookup_host_address(host_address)) } - # TODO: change it after update dns_mock - # let(:host_address) { random_ip_address } - # should works with 42.42.42.42 or 42.42.42.42.in-addr.arpa; request for 42.42.42.42 - let(:host_address) { '42.42.42.42.in-addr.arpa' } + let(:host_address) { random_ip_address } let(:ptr_records) { ::Array.new(2) { random_domain_name } } before { dns_mock_server.assign_mocks(host_address => { ptr: ptr_records }) } diff --git a/spec/truemail/validate/domain_list_match_spec.rb b/spec/truemail/validate/domain_list_match_spec.rb index f9fa613..85747a3 100644 --- a/spec/truemail/validate/domain_list_match_spec.rb +++ b/spec/truemail/validate/domain_list_match_spec.rb @@ -13,7 +13,7 @@ subject(:domain_list_match_validator) { described_class.check(result_instance) } let(:email) { random_email } - let(:domain) { email[Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL, 1] } + let(:domain) { email[Truemail::RegexConstant::REGEX_EMAIL_PATTERN, 3] } let(:configuration_instance) { create_configuration } let(:result_instance) { Truemail::Validator::Result.new(email: email, configuration: configuration_instance) } diff --git a/truemail.gemspec b/truemail.gemspec index 894712f..c6ba7a7 100644 --- a/truemail.gemspec +++ b/truemail.gemspec @@ -33,19 +33,19 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'simpleidn', '~> 0.2.1' - spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.21' + spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.23' spec.add_development_dependency 'bundler-audit', '~> 0.8.0' - spec.add_development_dependency 'dns_mock', '~> 1.3' + spec.add_development_dependency 'dns_mock', '~> 1.3', '>= 1.3.1' spec.add_development_dependency 'faker', '~> 2.18' spec.add_development_dependency 'fasterer', '~> 0.9.0' spec.add_development_dependency 'json_matchers', '~> 0.11.1' spec.add_development_dependency 'overcommit', '~> 0.58.0' spec.add_development_dependency 'pry-byebug', '~> 3.9' - spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.3' + spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.4' spec.add_development_dependency 'rspec', '~> 3.10' - spec.add_development_dependency 'rubocop', '~> 1.18' - spec.add_development_dependency 'rubocop-performance', '~> 1.11', '>= 1.11.3' + spec.add_development_dependency 'rubocop', '~> 1.18', '>= 1.18.3' + spec.add_development_dependency 'rubocop-performance', '~> 1.11', '>= 1.11.4' spec.add_development_dependency 'rubocop-rspec', '~> 2.4' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'truemail-rspec', '~> 0.6'