Skip to content

Commit

Permalink
fix bug in notification
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarzin committed Nov 22, 2024
1 parent 06ad437 commit 2a565cd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
32 changes: 27 additions & 5 deletions app/Console/Commands/CVESearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ public function handle()
if (strtotime($cve->cveMetadata->datePublished)>= $min_timestamp) {
// put summary in lowercase
$text= strtolower($cve->containers->cna->title);
// Log::debug('CVESearch - CVE summary ' . $cve->summary);
Log::debug('CVESearch - CVE text ' . $text);
foreach ($names as $name) {
// Log::debug('CVESearch - check ' . $name);
if (str_contains($text, $name)) {
Log::debug('CVESearch - found ' . $name);
$message .= '<b>' . $name . ' </b> : <b>' . $cve->cveMetadata->cveId . ' </b> - ' . $cve->details . '<br>';
$found=true;
}
Expand All @@ -177,25 +178,46 @@ public function handle()
if (strtotime($cve->published)>= $min_timestamp) {
// put summary in lowercase
$text= strtolower($cve->details);
// Log::debug('CVESearch - CVE summary ' . $cve->summary);
Log::debug('CVESearch - CVE text ' . $text);
foreach ($names as $name) {
// Log::debug('CVESearch - check ' . $name);
if (str_contains($text, $name)) {
Log::debug('CVESearch - found ' . $name);
$message .= '<b>' . $name . ' </b> : <b>' . $cve->aliases[0] . ' </b> - ' . $cve->details . '<br>';
$found=true;
}
}
}
}
elseif (property_exists($cve,"document") &&
property_exists($cve->document,"category") &&
($cve->document->category == "csaf_security_advisory")) {
if (strtotime($cve->document->tracking->current_release_date)>= $min_timestamp) {
// put summary in lowercase
$text= strtolower($cve->document->title);
Log::debug('CVESearch - CVE text ' . $text);
foreach ($names as $name) {
if (str_contains($text, $name)) {
Log::debug('CVESearch - found ' . $name);
$message .= '<b>' . $name . ' </b> : <b>' . $cve->document->title . ' </b> - ' . $cve->document->notes[0]->text . '<br>';
$found=true;
}
}
}


}
else {
Log::error("Unknown CVE format !");
Log::error(json_encode($cve));
print_r("Unknwon CVE format:\n");
print_r($cve);
}
}
$message .= '</body></html>';

if ($found) {

Log::debug("CVESearch - Message {$message}");

// Send mail
$mail = new PHPMailer(true);

Expand All @@ -214,7 +236,7 @@ public function handle()

// Recipients
$mail->setFrom(config('mercator-config.cve.mail-from'));
foreach(explode(",",$mail_to) as $email)
foreach(explode(",",config('mercator-config.cve.mail-to')) as $email)
$mail->addAddress($email);

// Content
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/CertificateExpiracy.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function handle()
$mail->Port = env('MAIL_PORT'); // TCP port to connect to

// Recipients
$mail->setFrom(config('mercator-config.cert.mail-from'));
foreach(explode(",",config('mercator-config.cert.mail-to')) as $email)
$mail->setFrom($mail_from);
foreach(explode(",",$to_email) as $email)
$mail->addAddress($email);

// Content
Expand Down

0 comments on commit 2a565cd

Please sign in to comment.