Skip to content

Commit

Permalink
fixup! fix(phishing): NPEs
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Nov 19, 2024
1 parent 4c6200f commit 0639a9e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/Service/PhishingDetection/PhishingDetectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@ public function __construct(
public function checkHeadersForPhishing(Horde_Mime_Headers $headers, bool $hasHtmlMessage, string $htmlMessage = ''): array {
$list = new PhishingDetectionList();
$fromHeader = $headers->getHeader('From');
if (!($fromHeader instanceof Horde_Mime_Headers_Element_Address)) {
return $list->jsonSerialize();
}
$sender = AddressList::fromHorde($fromHeader->getAddressList(true))->first();

Check failure on line 36 in lib/Service/PhishingDetection/PhishingDetectionService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

UndefinedMethod

lib/Service/PhishingDetection/PhishingDetectionService.php:36:49: UndefinedMethod: Method Horde_Mime_Headers_Element::getAddressList does not exist (see https://psalm.dev/022)
if ($sender === null) {
return $list->jsonSerialize();
}
$fromFN = $sender->getLabel();
$fromEmail = $sender->getEmail();
$fromFN = $sender?->getLabel();
$fromEmail = $sender?->getEmail();
$replyToHeader = $headers->getHeader('Reply-To');
if ($replyToHeader instanceof Horde_Mime_Headers_Element_Address) {
$replyToEmailHeader = $replyToHeader->getAddressList(true);
Expand All @@ -50,7 +44,7 @@ public function checkHeadersForPhishing(Horde_Mime_Headers $headers, bool $hasHt
$replyToEmail = null;

Check warning on line 44 in lib/Service/PhishingDetection/PhishingDetectionService.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/PhishingDetection/PhishingDetectionService.php#L44

Added line #L44 was not covered by tests
}
$date = $headers->getHeader('Date')->__get('value');
$customEmail = $sender->getCustomEmail();
$customEmail = $sender?->getCustomEmail();
if ($fromEmail !== null) {
$list->addCheck($this->replyToCheck->run($fromEmail, $replyToEmail));
}
Expand Down

0 comments on commit 0639a9e

Please sign in to comment.