MailScanner - Empty regular expression (Solved)

Report bugs and workarounds
Post Reply
henk
Posts: 517
Joined: 14 Dec 2015 22:16
Location: Netherlands
Contact:

MailScanner - Empty regular expression (Solved)

Post by henk »

When you login on the malscanner GUI, and toggle between the 'recent messages' and any other tab, you get the following PHP warnings ( read a lot) in the ssl error log. No clou why

To reproduce, set tail on ssl error log and login to the GUI.

Code: Select all

tail -F /var/log/httpd/ssl_error_log
[[Wed Jan 16 17:26:54 2019] [warn] [client your.client.ip.address] PHP Warning: preg_match(): Empty regular expression in /var/www/html/mailscanner/functions.php on line 4780, referer: https://<<EFA FQDN>>mailscanner/sf_version.php
[Wed Jan 16 17:27:24 2019] [warn] [client your.client.ip.address] PHP Warning: preg_match(): Empty regular expression in /var/www/html/mailscanner/functions.php on line 4780
[Wed Jan 16 17:27:24 2019] [warn] [client your.client.ip.address] PHP Warning: preg_match(): Empty regular expression in /var/www/html/mailscanner/functions.php on line 4780
[Wed Jan 16 17:27:24 2019] [warn] [client your.client.ip.address] PHP Warning: preg_match(): Empty regular expression in /var/www/html/mailscanner/functions.php on line 4780
[Wed Jan 16 17:27:24 2019] [warn] [client your.client.ip.address] PHP Warning: preg_match(): Empty regular expression in /var/www/html/mailscanner/functions.php on line 4780
...
...
Cause: The getVirus function loops thru the defined virusscanners, in my case clamd and sophos.

By default the VIRUS_REGEX is empty, aka not defined, since i don't use SophosSAVI, only clamd and Sophos.
line 4779 was inserted by me

4767 /**
4768 * @param string $report virus report message
4769 * @return string|null
4770 */
4771 function getVirus($report)
4772 {
4773 $match = null;
4774 if (defined('VIRUS_REGEX')) {
4775 preg_match(VIRUS_REGEX, $report, $match);
4776 } else {
4777 $scanners = explode(' ', get_conf_var('VirusScanners'));
4778 foreach ($scanners as $scanner) {
4779 #echo "$scanner)";
4780 if (preg_match(getVirusRegex($scanner), $report, $match) === 1) {
4781 break;
4782 }
4783 }
4784 }
4785 if (count($match) > 2) {
4786 return $match[2];
4787 }
4788 return $report;
4789 }
4790 /**

As I don't understand why function getVirusRegex($scanner = null) ( on line 149) didn't return the correct, scanner dependant, regex.
Can someone can explain this? With my solution there is only 1 regex for all scanners used .....

Temp solution: uncomment the Override VIRUS_REGEX

Code: Select all

vi /var/www/html/mailscanner/conf.php
// Override VIRUS_REGEX??
// define('VIRUS_REGEX', '/(\S+) was infected by (\S+)/'); // SophosSAVI

Change to

Code: Select all

// Display Virus on message listing
define('DISPLAY_VIRUS_REPORT', true);

// Override VIRUS_REGEX??
define('VIRUS_REGEX', '/(\S+) was infected by (\S+)/'); // SophosSAVI
//define('VIRUS_REGEX', '/(.+) was infected: (\S+)/'; // Clamd
“We are stuck with technology when what we really want is just stuff that works.” -Douglas Adams
User avatar
shawniverson
Posts: 3644
Joined: 13 Jan 2014 23:30
Location: Indianapolis, Indiana USA
Contact:

Re: MailScanner - Empty regular expression (Solved)

Post by shawniverson »

This is probably fixed in eFa4
Post Reply