# if (lc($ext) =~ /\.zip$/) { # use Archive::Zip qw(:ERROR_CODES); # my $path = $entity->bodyhandle->path; # my $zip = Archive::Zip->new(); # Archive::Zip::setErrorHandler(sub {}); # if ($zip->read($path) == AZ_OK) { # md_syslog('debug', "Scanning zip file, Path=$path"); # my $tfname = Archive::Zip::tempFileName('.'); # my @members = $zip->members(); # foreach my $member (@members) { # my $file = $member->fileName(); # $size = $member->uncompressedSize(); # md_syslog('debug', "Scanning zip entry $file, size=$size"); # # Approx. 50MB size limit # if ($size > 50 * 1024 * 1024) { # md_graphdefang_log('zip_bomb ', $file, $RelayAddr); # action_bounce("Archive member $file too big"); # return; # } # # if ($member->isEncrypted()) { # md_syslog('debug', "scanning Encrypted ZIP member $file"); # my ($re); # #$re = '\.' . $bad_exts . '\.*([^-A-Za-z0-9_.,]|$)'; # $re = '\.' . $bad_exts . '\.*$'; # if (lc($file) =~ $re) { # md_graphdefang_log('Encrypted_badfile', $file,$RelayAddr); # action_notify_administrator("A file called $file was detected in an encrypted ZIP file attached to an incoming e-mail - quarantined."); # action_quarantine_entire_message("An encrypted ZIP attachment containing $file was removed from this document as it\nconstituted a security hazard. If you require this document, please contact\nRoadway Information Security to arrange for it to be released.\n"); # action_discard(); # return; # } # md_syslog('warning', "Encrypted file $file"); # } else { # $zip->extractMember($member, $tfname); # md_syslog('debug', "Scanning ZIP entry $file"); # use File::Scan; # my $scanner = File::Scan->new; # my $virus = $scanner->scan($tfname); # unlink($tfname); # if ($virus) { # md_graphdefang_log('virus-zip', $virus, $RelayAddr); # action_discard(); # return; # } # } # } # } # } #############################