App-DubiousHTTP
view release on metacpan or search on metacpan
lib/App/DubiousHTTP/Tests/Common.pm view on Meta::CPAN
use strict;
use warnings;
package App::DubiousHTTP::Tests::Common;
use Compress::Raw::Zlib;
use MIME::Base64 'decode_base64';
use Exporter 'import';
our @EXPORT = qw(
MUSTBE_VALID SHOULDBE_VALID VALID INVALID UNCOMMON_VALID UNCOMMON_INVALID COMMON_INVALID
SETUP content html_escape url_encode garble_url ungarble_url bro_compress zlib_compress
$NOGARBLE $CLIENTIP $TRACKHDR $FAST_FEEDBACK
);
use Scalar::Util 'blessed';
our $CLIENTIP = undef;
our $NOGARBLE = 0;
our $FAST_FEEDBACK = 0;
use constant {
SHOULDBE_VALID => 3, # simple chunked, gzip.. - note if blocked
MUSTBE_VALID => 2, # no browser should fail on this
VALID => 1,
INVALID => 0,
UNCOMMON_VALID => -1,
UNCOMMON_INVALID => -2,
COMMON_INVALID => -3,
};
my $basedir = 'static/';
sub basedir { $basedir = pop }
# some AV will find the EICAR test virus just by checking for the string
# anywhere and not matter which postfix/prefix. That's not how this was supposed
# to work but anyway - make sure that they don't find it here.
my $eicar = 'X5O!P'.'%@AP[4'.'\PZX54'.'(P^)7CC)'.'7}$EICA'.'R-STAND'.'ARD-ANT'
.'IVIRU'.'S-TEST-FILE!$H+H*';
{
my %bro = (
"Don't be afraid to look at this message. It is completely harmless. Really!"
=> decode_base64('G0oAAIyUq+1oRZSkJ0v1kiZ2hk1hs4NDDti/XVogkErgISv5M41kDrdKRMH7fRK8YAmyXwFNYppR3EBMbVhyBA=='),
$eicar
=> decode_base64('G0MAABQhyezgvJQnNVXciUrtsAEHrvlk0bTzGSRPqOdwPRhITMNtn+G6LB8+EYrC/LjqijSZFRhTlo5XllmqeTHxsABuVSsB'),
);
sub bro_compress {
my $plain = shift;
$bro{$plain} = shift if @_;
return $bro{$plain};
}
}
my %builtin = (
'novirus.txt' => [
"Content-type: application/octet-stream\r\n".
"Content-disposition: attachment; filename=\"download.txt\"\r\n",
"Don't be afraid to look at this message. It is completely harmless. Really!",
],
'eicar.txt' => [
"Content-type: application/octet-stream\r\n".
"Content-disposition: attachment; filename=\"download.txt\"\r\n",
$eicar,
'EICAR test virus',
],
# EICAR test virus with junk behind (proper antivirus should not match
'eicar-junk.txt' => [
"Content-type: application/octet-stream\r\n".
"Content-disposition: attachment; filename=\"download.txt\"\r\n",
$eicar.'WHATEVER',
],
# EICAR test virus prefixed with junk (proper antivirus should not match)
'junk-eicar.txt' => [
"Content-type: application/octet-stream\r\n".
"Content-disposition: attachment; filename=\"download.txt\"\r\n",
'WHATEVER'.$eicar,
],
# zipped novirus
'novirus.zip' => [
"Content-type: application/octet-stream\r\n".
"Content-disposition: attachment; filename=\"download.zip\"\r\n",
decode_base64('UEsDBBQAAAAIAE1900g2ai/1SAAAAEwAAAAJABwAZWljYXIuY29tVVQJAANCoWZXQqFmV3V4CwABBOkDAAAE6QMAAA3JsRGAMAgF0N4pvpVdprCxzQaoaHKCeIEm25vy3VvtXQI7g65G9UQYxOwBBaJUh7I73ZywBQYP0084WDoKNZWxCZlJpM/TD1BLAQIeAxQAAAAIAE1900g2ai/1SAAAAEwAAAAJABgAAAAAAA...
( run in 0.756 second using v1.01-cache-2.11-cpan-39bf76dae61 )