Documentation

NAME

Mail::MIMEDefang::Antivirus - Antivirus interface methods for email filters

DESCRIPTION

Mail::MIMEDefang::Antivirus are a set of methods that can be called from mimedefang-filter to scan with installed antivirus software the email message.

The message_contains_virus* methods scan the Work directory, which normally contains only the unpacked, decoded parts of the message. To have the original, undecoded message scanned as well, call md_copy_orig_msg_to_work_dir_as_mbox_file (see Mail::MIMEDefang::Utils) before calling message_contains_virus or any message_contains_virus_* method. It copies the message into the Work directory as a UNIX-style mbox file, which some scanners (such as ClamAV) need in order to recognise it as an e-mail message.

sub filter_end {
  my ($entity) = @_;
  md_copy_orig_msg_to_work_dir_as_mbox_file();
  my ($code, $category, $action) = message_contains_virus();
  ...
}

Scanner support is loaded on demand. This module only holds the dispatch logic and the list of known scanners; the code that talks to each scanner lives in the submodules listed below, and is compiled the first time that scanner is initialized or used. The original function names (message_contains_virus_clamd, interpret_nai_code, ...) are still provided by this module, so filters do not need to change.

Scanner modules

Legacy scanners:

METHODS

  • message_contains_virus

    Method that scans a message using every installed virus scanner. md_copy_orig_msg_to_work_dir_as_mbox_file should be called before this method so that the original message is scanned too (see "DESCRIPTION").

  • entity_contains_virus

    Method that scans a MIME::Entity part using every installed virus scanner.

  • initialize_virus_scanner_routines

    Method that sets @VirusScannerMessageRoutines and @VirusScannerEntityRoutines to arrays of virus-scanner routines to call, based on installed scanners.

  • run_virus_scanner

    Method that runs a virus scanner, collecting output in $VirusScannerMessages.