feat: enrichir la colonne Cloudflare pour tous les sous-domaines DNS

src/Command/CheckDnsCommand.php:
- Nouvelle methode enrichLastCheck() qui cherche un record dans les
  records Cloudflare par nom+type et remplit cloudflare/cf_status
  sur le dernier check ajoute au tableau
- Bounce: enrichissement CF sur bounce.{domain} type MX
- AWS SES DKIM CNAME: enrichissement CF sur {token}._domainkey.{domain}
  type CNAME pour chacun des 3 tokens DKIM
- AWS SES MAIL FROM MX: enrichissement CF sur bounce.{domain} type MX
- AWS SES MAIL FROM TXT: enrichissement CF sur bounce.{domain} type TXT
- Mailcow DNS: enrichissement CF pour chaque record attendu
  (autodiscover CNAME, autoconfig CNAME, _autodiscover._tcp SRV,
  _mta-sts TXT, mta-sts CNAME) avec le nom et type exacts
- checkAwsSes() et checkMailcow() recoivent maintenant $cfRecords
  en parametre pour effectuer les enrichissements

La colonne Cloudflare du rapport web et email affiche maintenant
la valeur presente dans la zone CF pour bounce, DKIM CNAME,
MAIL FROM, autodiscover, autoconfig, mta-sts au lieu de "Non trouve"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-04-02 22:04:43 +02:00
parent 74a7220fcd
commit cf85c6b25a

View File

@@ -78,12 +78,13 @@ class CheckDnsCommand extends Command
$this->enrichWithCloudflare($checks, $domain, 'MX', 'MX', $cfRecords);
$this->dnsCheck->checkBounce($domain, $checks, $errors, $warnings, $successes);
$this->enrichWithCloudflare($checks, 'bounce.'.$domain, 'Bounce', 'MX', $cfRecords);
// AWS SES
$this->checkAwsSes($domain, $checks, $errors, $successes);
$this->checkAwsSes($domain, $checks, $errors, $successes, $cfRecords);
// Mailcow
$this->checkMailcow($domain, $checks, $errors, $warnings, $successes);
$this->checkMailcow($domain, $checks, $errors, $warnings, $successes, $cfRecords);
// Affichage console
foreach ($checks as $check) {
@@ -175,12 +176,37 @@ class CheckDnsCommand extends Command
}
}
/**
* @param list<array> $checks
* @param list<array<string, mixed>> $cfRecords
*/
private function enrichLastCheck(array &$checks, string $recordName, string $dnsType, array $cfRecords): void
{
$cfValue = 'Non trouve';
$cfStatus = '';
foreach ($cfRecords as $r) {
if (($r['name'] ?? '') === $recordName && ($r['type'] ?? '') === $dnsType) {
$cfValue = $r['content'] ?? '';
$cfStatus = 'ok';
break;
}
}
$last = \count($checks) - 1;
if ($last >= 0) {
$checks[$last]['cloudflare'] = $cfValue;
$checks[$last]['cf_status'] = $cfStatus;
}
}
/**
* @param list<array> $checks
* @param list<string> $errors
* @param list<string> $successes
* @param list<array<string, mixed>> $cfRecords
*/
private function checkAwsSes(string $domain, array &$checks, array &$errors, array &$successes): void
private function checkAwsSes(string $domain, array &$checks, array &$errors, array &$successes, array $cfRecords = []): void
{
if (!$this->awsSes->isAvailable()) {
$checks[] = DnsCheckService::check('AWS SES', 'API', 'warning', 'Cles non configurees', 'Acces API SES', 'N/A');
@@ -232,6 +258,8 @@ class CheckDnsCommand extends Command
$actualCname ?? 'Non trouve'
);
$this->enrichLastCheck($checks, $dkimFqdn, 'CNAME', $cfRecords);
if ($found) {
$successes[] = "[$domain] AWS SES DKIM CNAME $token : OK";
} else {
@@ -270,6 +298,8 @@ class CheckDnsCommand extends Command
$actualMx ?: 'Non trouve'
);
$this->enrichLastCheck($checks, $mailFromDomain, 'MX', $cfRecords);
if ($mxFound) {
$successes[] = "[$domain] AWS SES MAIL FROM MX : OK";
} else {
@@ -288,6 +318,7 @@ class CheckDnsCommand extends Command
"$mailFromDomain TXT $txtExpected",
$actualTxt ?: 'Non trouve'
);
$this->enrichLastCheck($checks, $mailFromDomain, 'TXT', $cfRecords);
if ($txtFound) {
$successes[] = "[$domain] AWS SES MAIL FROM SPF : OK";
@@ -342,7 +373,7 @@ class CheckDnsCommand extends Command
* @param list<string> $warnings
* @param list<string> $successes
*/
private function checkMailcow(string $domain, array &$checks, array &$errors, array &$warnings, array &$successes): void
private function checkMailcow(string $domain, array &$checks, array &$errors, array &$warnings, array &$successes, array $cfRecords = []): void
{
if (!$this->mailcow->isAvailable()) {
$checks[] = DnsCheckService::check('Mailcow', 'API', 'warning', 'Non disponible', 'Acces API Mailcow', 'N/A');
@@ -388,6 +419,8 @@ class CheckDnsCommand extends Command
$expected['content'], $found ? 'Trouve' : 'Non trouve'
);
$this->enrichLastCheck($checks, $expected['name'], $expected['type'], $cfRecords);
if ($found) {
$successes[] = "[$domain] Mailcow DNS : $label OK";
} elseif ($isOptional) {