Skip to content

Commit

Permalink
fix: improved spoofing detection accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Feb 27, 2025
1 parent ce89be9 commit 5579386
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions helpers/get-bounce-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isRetryableError = require('#helpers/is-retryable-error');
const IP_ADDRESS = ip.address();

const REGEX_SPOOFING = new RE2(/spoof|impersonation|impersonate/im);
const REGEX_SPAM = new RE2(/spam/im);
const REGEX_SPAM = new RE2(/ spam /im);
const REGEX_VIRUS = new RE2(/virus|phishing|malware|trojan/im);
const REGEX_DENYLIST = new RE2(/denylist|deny\s+list/im);
const REGEX_BLACKLIST = new RE2(/blacklist|black\s+list/im);
Expand Down Expand Up @@ -57,13 +57,18 @@ function getBounceInfo(err) {
//
if (
bounceInfo.message === 'Unknown' ||
// bounceInfo.action === 'reject' && // <-- we should include defer so this is commented out
['blocklist', 'envelope', 'policy', 'message', 'block', 'other'].includes(
bounceInfo.category
)
(bounceInfo.action === 'reject' &&
['blocklist', 'envelope', 'policy', 'message', 'block', 'other'].includes(
bounceInfo.category
))
) {
if (REGEX_VIRUS.test(response)) bounceInfo.category = 'virus';
else if (REGEX_SPAM.test(response)) bounceInfo.category = 'spam';
else if (
REGEX_SPAM.test(response) ||
response.toLowerCase() === 'spam' ||
response.toLowerCase() === 'spam.'
)
bounceInfo.category = 'spam';
}

if (isRetryableError(err)) {
Expand Down

0 comments on commit 5579386

Please sign in to comment.