Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7e6b new error reason authfailure #238

Merged
merged 5 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/sisimai/lhost/office365.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class << self
%r/\A4[.]4[.]7\z/ => 'expired',
%r/\A4[.]4[.]312\z/ => 'networkerror',
%r/\A4[.]4[.]316\z/ => 'expired',
%r/\A4[.]7[.]26\z/ => 'securityerror',
%r/\A4[.]7[.]26\z/ => 'authfailure',
%r/\A4[.]7[.][56]\d\d\z/ => 'blocked',
%r/\A4[.]7[.]8[5-9]\d\z/ => 'blocked',
%r/\A5[.]0[.]350\z/ => 'contenterror',
Expand All @@ -76,10 +76,10 @@ class << self
%r/\A5[.]7[.]50[4-5]\z/ => 'filtered',
%r/\A5[.]7[.]50[6-7]\z/ => 'blocked',
%r/\A5[.]7[.]508\z/ => 'toomanyconn',
%r/\A5[.]7[.]509\z/ => 'securityerror',
%r/\A5[.]7[.]509\z/ => 'authfailure',
%r/\A5[.]7[.]510\z/ => 'notaccept',
%r/\A5[.]7[.]511\z/ => 'rejected',
%r/\A5[.]7[.]512\z/ => 'securityerror',
%r/\A5[.]7[.]512\z/ => 'authfailure',
%r/\A5[.]7[.]57\z/ => 'securityerror',
%r/\A5[.]7[.]60[6-9]\z/ => 'blocked',
%r/\A5[.]7[.]6[1-4]\d\z/ => 'blocked',
Expand Down
23 changes: 12 additions & 11 deletions lib/sisimai/reason.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class << self
# @return [Array] Reason list
def index
return %w[
Blocked ContentError ExceedLimit Expired Filtered HasMoved HostUnknown MailboxFull
MailerError MesgTooBig NetworkError NotAccept OnHold Rejected NoRelaying SpamDetected
VirusDetected PolicyViolation SecurityError Suspend SystemError SystemFull TooManyConn
UserUnknown SyntaxError
AuthFailure Blocked ContentError ExceedLimit Expired Filtered HasMoved HostUnknown
MailboxFull MailerError MesgTooBig NetworkError NotAccept OnHold Rejected NoRelaying
SpamDetected VirusDetected PolicyViolation SecurityError Suspend SystemError SystemFull
TooManyConn UserUnknown SyntaxError
]
end

Expand All @@ -36,18 +36,19 @@ def retry
GetRetried = Sisimai::Reason.retry
ClassOrder = [
%w[
MailboxFull MesgTooBig ExceedLimit Suspend HasMoved NoRelaying UserUnknown Filtered
Rejected HostUnknown SpamDetected TooManyConn Blocked
MailboxFull MesgTooBig ExceedLimit Suspend HasMoved NoRelaying AuthFailure UserUnknown
Filtered Rejected HostUnknown SpamDetected TooManyConn Blocked
],
%w[
MailboxFull SpamDetected PolicyViolation VirusDetected NoRelaying SecurityError
SystemError NetworkError Suspend Expired ContentError SystemFull NotAccept MailerError
MailboxFull SpamDetected PolicyViolation VirusDetected NoRelaying AuthFailure
SecurityError SystemError NetworkError Suspend Expired ContentError SystemFull NotAccept
MailerError
],
%w[
MailboxFull MesgTooBig ExceedLimit Suspend UserUnknown Filtered Rejected HostUnknown
SpamDetected TooManyConn Blocked SpamDetected SecurityError SystemError NetworkError
Suspend Expired ContentError HasMoved SystemFull NotAccept MailerError NoRelaying
SyntaxError OnHold
SpamDetected TooManyConn Blocked SpamDetected AuthFailure SecurityError SystemError
NetworkError Suspend Expired ContentError HasMoved SystemFull NotAccept MailerError
NoRelaying SyntaxError OnHold
]
]

Expand Down
62 changes: 62 additions & 0 deletions lib/sisimai/reason/authfailure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module Sisimai
module Reason
# Sisimai::Reason::AuthFailure checks the bounce reason is "authfailure" or not. This class is
# called only Sisimai::Reason class.
#
# This is the error that an authenticaion failure related to SPF, DKIM, or DMARC was detected
# on a destination mail host.
#
# Action: failed
# Status: 5.7.1
# Remote-MTA: dns; smtp.example.com
# Diagnostic-Code: smtp; 550 5.7.1 Email rejected per DMARC policy for example.org
module AuthFailure
class << self
Index = [
'//spf.pobox.com',
'bad spf records for',
'dmarc policy',
'please inspect your spf settings',
'spf (sender policy framework) domain authentication fail',
'spf check: fail',
]
Regex = %r{(?>
is[ ]not[ ]allowed[ ]to[ ]send[ ]from[ ][<][^ ]+[>][ ]per[ ]it's[ ]spf[ ]record
|spf:[ ][^ ]+[ ]is[ ]not[ ]allowed[ ]to[ ]send[ ]mail[.][ ][a-z0-9]_401
)
}x

def text; return 'authfailure'; end
def description; return 'Email rejected due to SPF, DKIM, DMARC failure'; end

# Try to match that the given text and regular expressions
# @param [String] argv1 String to be matched with regular expressions
# @return [True,False] false: Did not match
# true: Matched
def match(argv1)
return nil unless argv1
return true if Index.any? { |a| argv1.include?(a) }
return true if argv1 =~ Regex
return false
end

# The bounce reason is "authfailure" or not
# @param [Sisimai::Fact] argvs Object to be detected the reason
# @return [True,False] true: is AuthFailure
# false: is not AuthFailure
# @see http://www.ietf.org/rfc/rfc2822.txt
def true(argvs)
return nil if argvs['deliverystatus'].empty?
return true if argvs['reason'] == 'authfailure'
return true if Sisimai::SMTP::Status.name(argvs['deliverystatus']).to_s == 'authfailure'

# Check the value of Diagnosic-Code: header with patterns
return true if match(argvs['diagnosticcode'].downcase)
return false
end

end
end
end
end

17 changes: 2 additions & 15 deletions lib/sisimai/reason/blocked.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,14 @@ class << self
|host[ ]+[^ ]refused[ ]to[ ]talk[ ]to[ ]me:[ ]\d+[ ]blocked
|host[ ]network[ ]not[ ]allowed
|hosts[ ]with[ ]dynamic[ ]ip
|http://(?:
spf[.]pobox[.]com/why[.]html
|www[.]spamcop[.]net/bl[.]
)
|http://www[.]spamcop[.]net/bl[.]
|invalid[ ]ip[ ]for[ ]sending[ ]mail[ ]of[ ]domain
|ip[ ]\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}[ ]is[ ]blocked[ ]by[ ]EarthLink # Earthlink
|ip[/]domain[ ]reputation[ ]problems
|is[ ](?:
in[ ]a[ ]black[ ]list(?:[ ]at[ ][^ ]+[.])?
|in[ ]an[ ][^ ]+rbl[ ]on[ ][^ ]+
|not[ ]allowed[ ]to[ ]send[ ](?:
mail[ ]from
|from[ ][<][^ ]+[>][ ]per[ ]it's[ ]spf[ ]record
)
|not[ ]allowed[ ]to[ ]send[ ]mail[ ]from
)
|mail[ ]server[ ]at[ ][^ ]+[ ]is[ ]blocked
|mail[ ]from[ ]\d+[.]\d+[.]\d+[.]\d[ ]refused:
Expand All @@ -89,7 +83,6 @@ class << self
|part[ ]of[ ]their[ ]network[ ]is[ ]on[ ]our[ ]block[ ]list
|please[ ](?:
get[ ]a[ ]custom[ ]reverse[ ]dns[ ]name[ ]from[ ]your[ ]isp[ ]for[ ]your[ ]host
|inspect[ ]your[ ]spf[ ]settings
|use[ ]the[ ]smtp[ ]server[ ]of[ ]your[ ]isp
)
|ptr[ ]record[ ]setup
Expand Down Expand Up @@ -120,12 +113,6 @@ class << self
that[ ]domain[ ]isn'?t[ ]in[ ]my[ ]list[ ]of[ ]allowed[ ]rcpthosts
|your[ ]remotehost[ ]looks[ ]suspiciously[ ]like[ ]spammer
)
|spf[ ](?:
[(]sender[ ]policy[ ]framework[)][ ]domain[ ]authentication[ ]fail
|record
|check:[ ]fail
)
|spf:[ ][^ ]+[ ]is[ ]not[ ]allowed[ ]to[ ]send[ ]mail[.][ ][a-z0-9]_401
|temporarily[ ]deferred[ ]due[ ]to[ ]unexpected[ ]volume[ ]or[ ]user[ ]complaints
|the[ ](?:email|domain|ip)[ ][^ ]+[ ]is[ ]blacklisted
|this[ ]system[ ]will[ ]not[ ]accept[ ]messages[ ]from[ ]servers[/]devices[ ]with[ ]no[ ]reverse[ ]dns
Expand Down
1 change: 0 additions & 1 deletion lib/sisimai/reason/policyviolation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class << self
'by non-member to a members-only list',
'closed mailing list',
'denied by policy',
'dmarc policy',
'email not accepted for policy reasons',
# http://kb.mimecast.com/Mimecast_Knowledge_Base/Administration_Console/Monitoring/Mimecast_SMTP_Error_Codes#554
'email rejected due to security policies',
Expand Down
11 changes: 4 additions & 7 deletions lib/sisimai/rhost/exchangeonline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ module ExchangeOnline
class << self
# https://technet.microsoft.com/en-us/library/bb232118
StatusList = {
'4.3.1' => [{ reason: 'systemfull', string: 'Insufficient system resources' }],
'4.3.2' => [{ reason: 'notaccept', string: 'System not accepting network messages' }],
'4.4.2' => [{ reason: 'blocked', string: 'Connection dropped' }],
'4.7.26' => [{
reason: 'securityerror',
string: 'must pass either SPF or DKIM validation, this message is not signed'
}],
'4.3.1' => [{ reason: 'systemfull', string: 'Insufficient system resources' }],
'4.3.2' => [{ reason: 'notaccept', string: 'System not accepting network messages' }],
'4.4.2' => [{ reason: 'blocked', string: 'Connection dropped' }],
'4.7.26' => [{ reason: 'authfailure', string: 'must pass either SPF or DKIM validation, this message is not signed' }],
'4.7.650' => [{ reason: 'blocked', string: 'has been temporarily rate limited due to IP reputation' }],
'5.0.0' => [{ reason: 'blocked', string: 'HELO / EHLO requires domain address' }],
'5.1.4' => [{ reason: 'systemerror', string: 'Destination mailbox address ambiguous' }],
Expand Down
16 changes: 9 additions & 7 deletions lib/sisimai/smtp/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ class << self
'4.7.12' => 'securityerror', # A password transition is needed
'4.7.15' => 'securityerror', # Priority Level is too low
'4.7.16' => 'mesgtoobig', # Message is too big for the specified priority
'4.7.24' => 'securityerror', # SPF validation error
'4.7.24' => 'authfailure ', # SPF validation error
'4.7.25' => 'blocked', # Reverse DNS validation failed
# ---------------------------------------------------------------------------------------
'5.1.0' => 'userunknown', # Other address status
Expand Down Expand Up @@ -581,18 +581,19 @@ class << self
'5.7.17' => 'hasmoved', # Mailbox owner has changed
'5.7.18' => 'hasmoved', # Domain owner has changed
'5.7.19' => 'securityerror', # RRVS test cannot be completed
'5.7.20' => 'securityerror', # No passing DKIM signature found
'5.7.21' => 'securityerror', # No acceptable DKIM signature found
'5.7.22' => 'securityerror', # No valid author-matched DKIM signature found
'5.7.23' => 'securityerror', # SPF validation failed
'5.7.24' => 'securityerror', # SPF validation error
'5.7.20' => 'authfailure', # No passing DKIM signature found
'5.7.21' => 'authfailure', # No acceptable DKIM signature found
'5.7.22' => 'authfailure', # No valid author-matched DKIM signature found
'5.7.23' => 'authfailure', # SPF validation failed
'5.7.24' => 'authfailure', # SPF validation error
'5.7.25' => 'blocked', # Reverse DNS validation failed
'5.7.26' => 'securityerror', # Multiple authentication checks failed
'5.7.26' => 'authfailure', # Multiple authentication checks failed
'5.7.27' => 'notaccept', # MX resource record of a destination host is Null MX: RFC7505
}.freeze

InternalCode = {
:temporary => {
'authfailure' => '4.0.972',
'blocked' => '4.0.971',
'contenterror' => '4.0.960',
# 'exceedlimit' => '4.0.923',
Expand All @@ -618,6 +619,7 @@ class << self
'undefined' => '4.0.900',
},
:permanent => {
'authfailure' => '5.0.972',
'blocked' => '5.0.971',
'contenterror' => '5.0.960',
'exceedlimit' => '5.0.923',
Expand Down
2 changes: 1 addition & 1 deletion test/private/lhost-exim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ module Exim
['5.3.4', '552', 'mesgtoobig', false]],
'01162' => [['5.7.1', '550', 'blocked', false]],
'01163' => [['5.1.1', '550', 'mailboxfull', false]],
'01164' => [['5.7.1', '553', 'blocked', false]],
'01164' => [['5.7.1', '553', 'authfailure', false]],
'01165' => [['5.7.1', '550', 'spamdetected', false]],
'01168' => [['4.0.947', '', 'expired', false]],
'01169' => [['5.4.3', '', 'systemerror', false]],
Expand Down
2 changes: 1 addition & 1 deletion test/private/lhost-office365.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Office365
'01007' => [['5.1.1', '550', 'userunknown', true]],
'01008' => [['5.1.1', '550', 'userunknown', true]],
'01009' => [['5.0.0', '553', 'securityerror', false]],
'01010' => [['5.1.0', '550', 'blocked', false]],
'01010' => [['5.1.0', '550', 'authfailure', false]],
'01011' => [['5.1.351', '550', 'filtered', false]],
'01012' => [['5.1.8', '501', 'rejected', false]],
'01013' => [['5.4.312', '550', 'networkerror', false]],
Expand Down
14 changes: 7 additions & 7 deletions test/private/lhost-postfix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ module Postfix
'01224' => [['5.7.9', '554', 'policyviolation', false]],
'01225' => [['5.0.0', '554', 'policyviolation', false]],
'01226' => [['5.7.9', '554', 'policyviolation', false]],
'01227' => [['5.7.26', '550', 'policyviolation', false]],
'01228' => [['5.7.1', '554', 'policyviolation', false]],
'01229' => [['5.7.1', '550', 'policyviolation', false]],
'01230' => [['5.7.1', '550', 'policyviolation', false]],
'01231' => [['5.7.1', '550', 'policyviolation', false],
['5.7.1', '550', 'policyviolation', false],
['5.7.1', '550', 'policyviolation', false]],
'01227' => [['5.7.26', '550', 'authfailure', false]],
'01228' => [['5.7.1', '554', 'authfailure', false]],
'01229' => [['5.7.1', '550', 'authfailure', false]],
'01230' => [['5.7.1', '550', 'authfailure', false]],
'01231' => [['5.7.1', '550', 'authfailure', false],
['5.7.1', '550', 'authfailure', false],
['5.7.1', '550', 'authfailure', false]],
'01232' => [['4.7.0', '421', 'blocked', false]],
'01233' => [['5.0.0', '550', 'blocked', false]],
'01234' => [['5.0.0', '553', 'blocked', false]],
Expand Down
8 changes: 4 additions & 4 deletions test/private/lhost-sendmail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ module Sendmail
'01219' => [['5.7.27', '550', 'notaccept', true]],
'01220' => [['5.7.1', '550', 'policyviolation', false]],
'01221' => [['5.6.0', '552', 'contenterror', false]],
'01222' => [['5.7.1', '550', 'policyviolation', false]],
'01223' => [['5.7.1', '550', 'policyviolation', false]],
'01224' => [['5.7.1', '550', 'policyviolation', false]],
'01225' => [['5.7.1', '550', 'policyviolation', false]],
'01222' => [['5.7.1', '550', 'authfailure', false]],
'01223' => [['5.7.1', '550', 'authfailure', false]],
'01224' => [['5.7.1', '550', 'authfailure', false]],
'01225' => [['5.7.1', '550', 'authfailure', false]],
'01226' => [['5.7.1', '550', 'rejected', false]],
'01227' => [['5.7.1', '550', 'rejected', false]],
'01228' => [['5.1.1', '550', 'userunknown', true]],
Expand Down
2 changes: 1 addition & 1 deletion test/public/lhost-exim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Exim
'06' => [['4.0.947', '', 'expired', false]],
'07' => [['4.0.922', '', 'mailboxfull', false]],
'08' => [['4.0.947', '', 'expired', false]],
'29' => [['5.0.0', '550', 'blocked', false]],
'29' => [['5.0.0', '550', 'authfailure', false]],
'30' => [['5.7.1', '554', 'userunknown', true]],
'31' => [['5.0.912', '', 'hostunknown', true]],
'32' => [['5.0.971', '571', 'blocked', false]],
Expand Down
2 changes: 1 addition & 1 deletion test/public/lhost-office365.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Office365
# INDEX => [['D.S.N.', 'replycode', 'REASON', 'hardbounce'], [...]]
'01' => [['5.1.10', '550', 'userunknown', true]],
'02' => [['5.1.1', '550', 'userunknown', true]],
'03' => [['5.1.0', '550', 'blocked', false]],
'03' => [['5.1.0', '550', 'authfailure', false]],
'04' => [['5.1.351', '550', 'filtered', false]],
'05' => [['5.1.8', '501', 'rejected', false]],
'06' => [['5.4.312', '550', 'networkerror', false]],
Expand Down
8 changes: 4 additions & 4 deletions test/public/lhost-postfix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ module Postfix
'67' => [['5.7.9', '554', 'policyviolation', false]],
'68' => [['5.0.0', '554', 'policyviolation', false]],
'69' => [['5.7.9', '554', 'policyviolation', false]],
'70' => [['5.7.26', '550', 'policyviolation', false]],
'71' => [['5.7.1', '554', 'policyviolation', false]],
'72' => [['5.7.1', '550', 'policyviolation', false]],
'73' => [['5.7.1', '550', 'policyviolation', false]],
'70' => [['5.7.26', '550', 'authfailure', false]],
'71' => [['5.7.1', '554', 'authfailure', false]],
'72' => [['5.7.1', '550', 'authfailure', false]],
'73' => [['5.7.1', '550', 'authfailure', false]],
'74' => [['4.7.0', '421', 'blocked', false]],
'75' => [['4.3.0', '451', 'systemerror', false]],
'76' => [['5.0.0', '550', 'userunknown', true]],
Expand Down
2 changes: 1 addition & 1 deletion test/public/lhost-sendmail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Sendmail
'55' => [['4.5.0', '451', 'mailererror', false]],
'56' => [['5.5.0', '554', 'blocked', false]],
'57' => [['5.7.27', '550', 'notaccept', true]],
'58' => [['5.7.1', '550', 'policyviolation', false]],
'58' => [['5.7.1', '550', 'authfailure', false]],
'59' => [['5.7.1', '550', 'rejected', false]],
}
end
Expand Down
1 change: 1 addition & 0 deletions test/public/reason-children-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class ReasonChildrenTest < Minitest::Test
Reasons = {
'AuthFailure' => ["550 5.1.0 192.0.2.222 is not allowed to send from <example.net> per it's SPF Record"],
'Blocked' => ['550 Access from ip address 192.0.2.1 blocked.'],
'ContentError' => ['550 5.6.0 the headers in this message contain improperly-formatted binary content'],
'ExceedLimit' => ['5.2.3 Message too large'],
Expand Down
1 change: 1 addition & 0 deletions test/public/reason-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class ReasonTest < Minitest::Test
'smtp;550 5.1.1 <[email protected]>... User unknown',
'550 5.1.1 <[email protected]>... User Unknown ',
'550 5.1.1 <[email protected]>... ',
'550 Bad SPF records for [example.org:192.0.2.2], see http://spf.pobox.com/',
'Connection timed out',
]

Expand Down