Skip to content

Commit a12f8b1

Browse files
authored
Feature/Ability to specify whitelisted/blacklisted emails (#82)
* Added ability to specify whitelisted/blacklisted emails * Updated runtime/development dependencies * Updated rubocop/codeclimate configs * Updated version, docs, changelog
1 parent 8e06ce2 commit a12f8b1

File tree

12 files changed

+408
-272
lines changed

12 files changed

+408
-272
lines changed

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ checks:
77
plugins:
88
rubocop:
99
enabled: true
10-
channel: rubocop-1-36
10+
channel: rubocop-1-38
1111

1212
reek:
1313
enabled: true

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,6 @@ RSpec/StubbedMock:
104104

105105
RSpec/VerifiedDoubleReference:
106106
Enabled: false
107+
108+
RSpec/Rails/InferredSpecType:
109+
Enabled: false

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
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).
44

5+
## [0.5.0] - 2022-11-03
6+
7+
### Added
8+
9+
- Ability to specify [whitelisted/blacklisted emails](https://github.com/truemail-rb/truemail/releases/tag/v3.0.0)
10+
11+
### Changed
12+
13+
- Updated application dependencies (truemail 3.0.1)
14+
- Updated development dependencies
15+
- Updated application codebase, tests
16+
- Updated application docs, version
17+
518
## [0.4.2] - 2022-10-11
619

720
### Changed

Gemfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ source 'https://rubygems.org'
44

55
ruby(::File.read(::File.join(::File.dirname(__FILE__), '.ruby-version')).strip[/-(.+)/, 1])
66

7-
gem 'dry-struct', '~> 1.4'
8-
gem 'net-smtp', '~> 0.3.2'
7+
gem 'dry-struct', '~> 1.5', '>= 1.5.2'
8+
gem 'net-smtp', '~> 0.3.3'
99
gem 'rack', '~> 2.2', '>= 2.2.4'
1010
gem 'thin', '~> 1.8', '>= 1.8.1'
11-
gem 'truemail', '~> 2.7', '>= 2.7.5'
11+
gem 'truemail', '~> 3.0', '>= 3.0.1'
1212

1313
group :development, :test do
1414
gem 'pry-byebug', '~> 3.10', '>= 3.10.1'
1515
gem 'rack-test', '~> 2.0', '>= 2.0.2'
16-
gem 'rspec', '~> 3.11'
16+
gem 'rspec', '~> 3.12'
1717

1818
# Code quality
1919
gem 'bundler-audit', '~> 0.9.1', require: false
2020
gem 'fasterer', '~> 0.10.0', require: false
2121
gem 'overcommit', '~> 0.59.1', require: false
2222
gem 'reek', '~> 6.1', '>= 6.1.1', require: false
23-
gem 'rubocop', '~> 1.36', require: false
23+
gem 'rubocop', '~> 1.38', require: false
2424
gem 'rubocop-performance', '~> 1.15', require: false
25-
gem 'rubocop-rspec', '~> 2.13', '>= 2.13.2', require: false
25+
gem 'rubocop-rspec', '~> 2.14', '>= 2.14.2', require: false
2626
end
2727

2828
group :test do

Gemfile.lock

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,26 @@ GEM
1515
docile (1.4.0)
1616
dry-container (0.11.0)
1717
concurrent-ruby (~> 1.0)
18-
dry-core (0.8.1)
18+
dry-core (0.9.1)
1919
concurrent-ruby (~> 1.0)
20+
zeitwerk (~> 2.6)
2021
dry-inflector (0.3.0)
21-
dry-logic (1.2.0)
22+
dry-logic (1.3.0)
2223
concurrent-ruby (~> 1.0)
23-
dry-core (~> 0.5, >= 0.5)
24-
dry-struct (1.4.0)
25-
dry-core (~> 0.5, >= 0.5)
26-
dry-types (~> 1.5)
24+
dry-core (~> 0.9, >= 0.9)
25+
zeitwerk (~> 2.6)
26+
dry-struct (1.5.2)
27+
dry-core (~> 0.9, >= 0.9)
28+
dry-types (~> 1.6)
2729
ice_nine (~> 0.11)
28-
dry-types (1.5.1)
30+
zeitwerk (~> 2.6)
31+
dry-types (1.6.1)
2932
concurrent-ruby (~> 1.0)
3033
dry-container (~> 0.3)
31-
dry-core (~> 0.5, >= 0.5)
34+
dry-core (~> 0.9, >= 0.9)
3235
dry-inflector (~> 0.1, >= 0.1.2)
33-
dry-logic (~> 1.0, >= 1.0.2)
36+
dry-logic (~> 1.3, >= 1.3)
37+
zeitwerk (~> 2.6)
3438
eventmachine (1.2.7)
3539
fasterer (0.10.0)
3640
colorize (~> 0.7)
@@ -45,7 +49,7 @@ GEM
4549
method_source (1.0.0)
4650
net-protocol (0.1.3)
4751
timeout
48-
net-smtp (0.3.2)
52+
net-smtp (0.3.3)
4953
net-protocol
5054
overcommit (0.59.1)
5155
childprocess (>= 0.6.3, < 5)
@@ -70,35 +74,35 @@ GEM
7074
rainbow (>= 2.0, < 4.0)
7175
regexp_parser (2.6.0)
7276
rexml (3.2.5)
73-
rspec (3.11.0)
74-
rspec-core (~> 3.11.0)
75-
rspec-expectations (~> 3.11.0)
76-
rspec-mocks (~> 3.11.0)
77-
rspec-core (3.11.0)
78-
rspec-support (~> 3.11.0)
79-
rspec-expectations (3.11.1)
77+
rspec (3.12.0)
78+
rspec-core (~> 3.12.0)
79+
rspec-expectations (~> 3.12.0)
80+
rspec-mocks (~> 3.12.0)
81+
rspec-core (3.12.0)
82+
rspec-support (~> 3.12.0)
83+
rspec-expectations (3.12.0)
8084
diff-lcs (>= 1.2.0, < 2.0)
81-
rspec-support (~> 3.11.0)
82-
rspec-mocks (3.11.1)
85+
rspec-support (~> 3.12.0)
86+
rspec-mocks (3.12.0)
8387
diff-lcs (>= 1.2.0, < 2.0)
84-
rspec-support (~> 3.11.0)
85-
rspec-support (3.11.1)
86-
rubocop (1.36.0)
88+
rspec-support (~> 3.12.0)
89+
rspec-support (3.12.0)
90+
rubocop (1.38.0)
8791
json (~> 2.3)
8892
parallel (~> 1.10)
8993
parser (>= 3.1.2.1)
9094
rainbow (>= 2.2.2, < 4.0)
9195
regexp_parser (>= 1.8, < 3.0)
9296
rexml (>= 3.2.5, < 4.0)
93-
rubocop-ast (>= 1.20.1, < 2.0)
97+
rubocop-ast (>= 1.23.0, < 2.0)
9498
ruby-progressbar (~> 1.7)
9599
unicode-display_width (>= 1.4.0, < 3.0)
96-
rubocop-ast (1.21.0)
100+
rubocop-ast (1.23.0)
97101
parser (>= 3.1.1.0)
98102
rubocop-performance (1.15.0)
99103
rubocop (>= 1.7.0, < 2.0)
100104
rubocop-ast (>= 0.4.0)
101-
rubocop-rspec (2.13.2)
105+
rubocop-rspec (2.14.2)
102106
rubocop (~> 1.33)
103107
ruby-progressbar (1.11.0)
104108
ruby_parser (3.19.1)
@@ -118,34 +122,35 @@ GEM
118122
rack (>= 1, < 3)
119123
thor (1.2.1)
120124
timeout (0.3.0)
121-
truemail (2.7.5)
125+
truemail (3.0.1)
122126
simpleidn (~> 0.2.1)
123127
unf (0.1.4)
124128
unf_ext
125129
unf_ext (0.0.8.2)
126130
unicode-display_width (2.3.0)
131+
zeitwerk (2.6.4)
127132

128133
PLATFORMS
129134
x86_64-darwin-20
130135

131136
DEPENDENCIES
132137
bundler-audit (~> 0.9.1)
133-
dry-struct (~> 1.4)
138+
dry-struct (~> 1.5, >= 1.5.2)
134139
fasterer (~> 0.10.0)
135140
json_matchers (~> 0.11.1)
136-
net-smtp (~> 0.3.2)
141+
net-smtp (~> 0.3.3)
137142
overcommit (~> 0.59.1)
138143
pry-byebug (~> 3.10, >= 3.10.1)
139144
rack (~> 2.2, >= 2.2.4)
140145
rack-test (~> 2.0, >= 2.0.2)
141146
reek (~> 6.1, >= 6.1.1)
142-
rspec (~> 3.11)
143-
rubocop (~> 1.36)
147+
rspec (~> 3.12)
148+
rubocop (~> 1.38)
144149
rubocop-performance (~> 1.15)
145-
rubocop-rspec (~> 2.13, >= 2.13.2)
150+
rubocop-rspec (~> 2.14, >= 2.14.2)
146151
simplecov (~> 0.21.2)
147152
thin (~> 1.8, >= 1.8.1)
148-
truemail (~> 2.7, >= 2.7.5)
153+
truemail (~> 3.0, >= 3.0.1)
149154

150155
RUBY VERSION
151156
ruby 3.1.2p20

README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ Before run application you must configure it first. List of available env vars n
5858
| `CONNECTION_ATTEMPTS` | `3` | - | Total of connection attempts. It is equal to `2` by default. This parameter uses in mx lookup timeout error and smtp request (for cases when there is one mx server). |
5959
| `DEFAULT_VALIDATION_TYPE` | `mx` | - | You can predefine Truemail default validation type (`smtp`). Available validation types: [`regex`](https://truemail-rb.org/truemail-gem/#/validations-layers?id=regex-validation), [`mx`](https://truemail-rb.org/truemail-gem/#/validations-layers?id=mx-validation), [`mx_blacklist`](https://truemail-rb.org/truemail-gem/#/validations-layers?id=mx-blacklist-validation), [`smtp`](https://truemail-rb.org/truemail-gem/#/validations-layers?id=smtp-validation). |
6060
| `VALIDATION_TYPE_FOR` | `somedomain.com:regex` | - | You can predefine which type of validation will be used for domains. Available validation types: `regex`, `mx`, `mx_blacklist`, `smtp`. This configuration will be used over `DEFAULT_VALIDATION_TYPE`. All of validations for `somedomain.com` will be processed with `regex` validation only. Accepts one or more key:value separated by commas. |
61+
| `WHITELISTED_EMAILS` | `user@somedomain1.com` | - | Validation of email which [contains whitelisted email](https://truemail-rb.org/truemail-gem/#/validations-layers?id=whitelist-case) always will return `true`. Other validations will not processed even if it was defined in `VALIDATION_TYPE_FOR`. Accepts one ore more values separated by commas. |
62+
| `BLACKLISTED_EMAILS` | `user@somedomain2.com` | - | Validation of email which [contains blacklisted email](https://truemail-rb.org/truemail-gem/#/validations-layers?id=blacklist-case) always will return `false`. Other validations will not processed even if it was defined in `VALIDATION_TYPE_FOR`. Accepts one ore more values separated by commas. |
6163
| `WHITELISTED_DOMAINS` | `somedomain1.com` | - | Validation of email which [contains whitelisted domain](https://truemail-rb.org/truemail-gem/#/validations-layers?id=whitelist-case) always will return `true`. Other validations will not processed even if it was defined in `VALIDATION_TYPE_FOR`. Accepts one ore more values separated by commas. |
62-
| `WHITELIST_VALIDATION` | `true` | - | With this option Truemail will validate email which [contains whitelisted domain only](https://truemail-rb.org/truemail-gem/#/validations-layers?id=whitelist-validation-case), i.e. if domain whitelisted, validation will passed to Regex, MX or SMTP validators. Validation of email which not contains whitelisted domain always will return `false`. It is equal `false` by default. |
6364
| `BLACKLISTED_DOMAINS` | `somedomain2.com` | - | Validation of email which [contains blacklisted domain](https://truemail-rb.org/truemail-gem/#/validations-layers?id=blacklist-case) always will return `false`. Other validations will not processed even if it was defined in `VALIDATION_TYPE_FOR`. Accepts one ore more values separated by commas. |
65+
| `WHITELIST_VALIDATION` | `true` | - | With this option Truemail will validate email which [contains whitelisted domain only](https://truemail-rb.org/truemail-gem/#/validations-layers?id=whitelist-validation-case), i.e. if domain whitelisted, validation will passed to Regex, MX or SMTP validators. Validation of email which not contains whitelisted domain always will return `false`. It is equal `false` by default. |
6466
| `BLACKLISTED_MX_IP_ADDRESSES` | `127.0.1.1,127.0.1.2` | - | With this option Truemail will filter out unwanted mx servers via predefined list of ip addresses. It can be used as a part of DEA (disposable email address) validations. Accepts one ore more values separated by commas.
6567
| `DNS` | `8.8.8.8,8.8.4.4:53` | - | This option will provide to use custom DNS gateway when Truemail interacts with DNS. If you won't specify nameserver's ports Truemail will use default DNS TCP/UDP port 53. Accepts one ore more values separated by commas. By default Truemail uses DNS gateway from system settings.
6668
| `NOT_RFC_MX_LOOKUP_FLOW` | `true` | - | This option will provide to use not RFC MX lookup flow. It means that MX and Null MX records will be cheked on the DNS validation layer only. By default [this option is disabled](https://truemail-rb.org/truemail-gem/#/validations-layers?id=not-rfc-mx-lookup-flow). |
@@ -90,9 +92,11 @@ ACCESS_TOKENS=a262d915-15bc-417c-afeb-842c63b54154,f44cd67e-aaa0-4e6c-aa6c-d52cf
9092
EMAIL_PATTERN="/\A.+@.+\z/" \
9193
SMTP_ERROR_BODY_PATTERN="/(?=.*550)(?=.*(user|account|customer|mailbox|something_else)).*/" \
9294
VALIDATION_TYPE_FOR=somedomain1.com:regex,somedomain2.com:mx \
95+
WHITELISTED_EMAILS=whitelisted@example.com \
96+
BLACKLISTED_EMAILS=blacklisted1@example.com,blacklisted2@example.com \
9397
WHITELISTED_DOMAINS=somedomain3.com \
94-
WHITELIST_VALIDATION=true \
9598
BLACKLISTED_DOMAINS=somedomain4.com,somedomain5.com \
99+
WHITELIST_VALIDATION=true \
96100
BLACKLISTED_MX_IP_ADDRESSES=127.0.1.1,127.0.1.2 \
97101
DNS=8.8.8.8,8.8.4.4:53 \
98102
NOT_RFC_MX_LOOKUP_FLOW=true \
@@ -132,17 +136,19 @@ Server: thin
132136
"errors": null,
133137
"smtp_debug": null,
134138
"configuration": {
139+
"validation_type_by_domain": null,
140+
"whitelisted_emails": null,
141+
"blacklisted_emails": null,
142+
"whitelisted_domains": null,
135143
"blacklisted_domains": null,
144+
"whitelist_validation": false,
136145
"blacklisted_mx_ip_addresses": null,
137146
"dns": null,
138147
"email_pattern": "default gem value",
139148
"not_rfc_mx_lookup_flow": false,
140149
"smtp_error_body_pattern": "default gem value",
141150
"smtp_fail_fast": false,
142-
"smtp_safe_check": false,
143-
"validation_type_by_domain": null,
144-
"whitelist_validation": false,
145-
"whitelisted_domains": null
151+
"smtp_safe_check": false
146152
}
147153
}
148154
```
@@ -179,17 +185,19 @@ Server: thin
179185
}
180186
],
181187
"configuration": {
188+
"validation_type_by_domain": null,
189+
"whitelisted_emails": null,
190+
"blacklisted_emails": null,
191+
"whitelisted_domains": null,
182192
"blacklisted_domains": null,
193+
"whitelist_validation": false,
183194
"blacklisted_mx_ip_addresses": null,
184195
"dns": null,
185196
"email_pattern": "default gem value",
186197
"not_rfc_mx_lookup_flow": false,
187198
"smtp_error_body_pattern": "default gem value",
188199
"smtp_fail_fast": false,
189-
"smtp_safe_check": false,
190-
"validation_type_by_domain": null,
191-
"whitelist_validation": false,
192-
"whitelisted_domains": null
200+
"smtp_safe_check": false
193201
}
194202
}
195203
```
@@ -208,9 +216,9 @@ Content-Type: application/json
208216
Server: thin
209217

210218
{
211-
"core": "2.7.1",
212-
"platform": "ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-darwin20]",
213-
"version": "0.4.0"
219+
"core": "3.0.1",
220+
"platform": "ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]",
221+
"version": "0.5.0"
214222
}
215223
```
216224

app/truemail_server/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module TruemailServer
4-
VERSION = '0.4.2'
4+
VERSION = '0.5.0'
55
end

config/system/command_line_params.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ class CommandLineParams < Dry::Struct
1313
attribute :connection_attempts, System::Types::Coercible::Integer.optional
1414
attribute :default_validation_type, System::Types::Coercible::Symbol.optional
1515
attribute :validation_type_for, System::Types::StringToHash.optional
16+
attribute :whitelisted_emails, System::Types::StringToArray.optional
17+
attribute :blacklisted_emails, System::Types::StringToArray.optional
1618
attribute :whitelisted_domains, System::Types::StringToArray.optional
17-
attribute :whitelist_validation, System::Types::Params::Bool.optional
1819
attribute :blacklisted_domains, System::Types::StringToArray.optional
20+
attribute :whitelist_validation, System::Types::Params::Bool.optional
1921
attribute :blacklisted_mx_ip_addresses, System::Types::StringToArray.optional
2022
attribute :dns, System::Types::StringToArray.optional
2123
attribute :not_rfc_mx_lookup_flow, System::Types::Params::Bool.optional

config/system/configuration.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class Error < StandardError; end
1515
connection_attempts
1616
default_validation_type
1717
validation_type_for
18+
whitelisted_emails
19+
blacklisted_emails
1820
whitelisted_domains
19-
whitelist_validation
2021
blacklisted_domains
22+
whitelist_validation
2123
blacklisted_mx_ip_addresses
2224
dns
2325
not_rfc_mx_lookup_flow

spec/support/config/environment.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
ENV_VARS = {
44
verifier_email: 'admin@bestweb.com.ua',
55
access_tokens: 'token',
6+
whitelisted_emails: 'whitelisted@example.com',
7+
blacklisted_emails: 'blacklisted@example.com',
68
whitelisted_domains: 'true.com',
79
blacklisted_domains: 'false.com',
810
log_stdout: 'false'

0 commit comments

Comments
 (0)