Update DMARC Status check

Handle edge case for domains where DMARC `p` policy is set to  reject or quarantine but `sp` (subdomain policy) is set to none

The previous implementation will return dmarcStatus === none when
sp is none but will not check for p policy as well.

If the `sp` is reject or quarantine, it would supersede the `p` status

MAILPOET-4302
This commit is contained in:
Oluwaseun Olorunsola
2022-07-24 12:43:43 +01:00
committed by Veljko V
parent 449fde75a7
commit fcd12b41b5
2 changed files with 8 additions and 2 deletions

View File

@@ -133,7 +133,7 @@ class AuthorizedSenderDomainController {
* otherwise returns `false` * otherwise returns `false`
*/ */
public function isDomainDmarcRetricted(string $domain): bool { public function isDomainDmarcRetricted(string $domain): bool {
$result = $this->dmarcPolicyChecker->getDomainDmarcPolicy($domain); $result = $this->getDmarcPolicyForDomain($domain);
return $result !== DmarcPolicyChecker::POLICY_NONE; return $result !== DmarcPolicyChecker::POLICY_NONE;
} }

View File

@@ -51,7 +51,13 @@ class DmarcPolicyChecker {
} }
// policy can either be reject or quarantine or none // policy can either be reject or quarantine or none
$dmarcStatus = $dmarcInfo['sp'] ?? $dmarcInfo['p'] ?? self::POLICY_NONE; $dmarcStatus = $dmarcInfo['p'] ?? self::POLICY_NONE;
// check for subdomain policy
$dmarcStatus = (
isset($dmarcInfo['sp']) &&
($dmarcInfo['sp'] === self::POLICY_QUARANTINE ||
$dmarcInfo['sp'] === self::POLICY_REJECT)
) ? $dmarcInfo['sp'] : $dmarcStatus;
return $dmarcStatus; return $dmarcStatus;
} }