def test_sort_mime(): args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg']) cfg = maltrieve.config(args, args.config) cfg.sort_mime = True r = requests.get('http://xwell.org/assets/docs/test.pdf') assert maltrieve.save_malware(r, cfg) assert os.access('archive-test/application_pdf/b9ff662486d448da7b60ba6234867c65', os.F_OK)
def test_config_args(): args = maltrieve.setup_args(['-l', 'testlog', '-p', '127.0.0.1:8080', '-d', '/tmp/mwtest']) cfg = maltrieve.config(args, 'maltrieve-test.cfg') assert cfg.logfile == 'testlog' test_proxy = {'http': '127.0.0.1:8080'} assert cmp(cfg.proxy, test_proxy) == 0 assert cfg.dumpdir == '/tmp/mwtest'
def test_config_args(): args = maltrieve.setup_args( ['-l', 'testlog', '-p', '127.0.0.1:8080', '-d', '/tmp/mwtest']) cfg = maltrieve.config(args, 'maltrieve-test.cfg') assert cfg.logfile == 'testlog' test_proxy = {'http': '127.0.0.1:8080'} assert cmp(cfg.proxy, test_proxy) == 0 assert cfg.dumpdir == '/tmp/mwtest'
def test_sort_mime(): args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg']) cfg = maltrieve.config(args, args.config) cfg.sort_mime = True r = requests.get('http://xwell.org/assets/docs/test.pdf') assert maltrieve.save_malware(r, cfg) assert os.access( 'archive-test/application_pdf/b9ff662486d448da7b60ba6234867c65', os.F_OK)
def test_alt_config(): args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg']) cfg = maltrieve.config(args, args.config) assert cfg.dumpdir == 'archive-test' assert cfg.logfile == 'maltrieve-test.log' test_ua = {'User-Agent': 'Test-Agent'} assert cmp(cfg.useragent, test_ua) == 0 test_proxy = {'http': '127.0.0.1:3128'} assert cmp(cfg.proxy, test_proxy) == 0 assert cfg.black_list == ['text/html', 'text/plain'] assert cfg.white_list == ['application/pdf', 'application/x-dosexec'] assert cfg.crits == 'http://127.0.0.1:8080' assert cfg.crits_user == 'maltrieve' assert cfg.crits_key == 'YOUR_API_KEY_HERE' assert cfg.crits_source == 'maltrieve' assert cfg.inputfile is None
def test_save_whitelist_pass(): args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg']) cfg = maltrieve.config(args, args.config) r = requests.get('http://xwell.org/assets/docs/test.pdf') assert maltrieve.save_malware(r, cfg) assert os.access('archive-test/b9ff662486d448da7b60ba6234867c65', os.F_OK)
def test_save_whitelist_fail(): args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg']) cfg = maltrieve.config(args, args.config) r = requests.get('http://xwell.org/assets/images/dodecahedron.png') assert maltrieve.save_malware(r, cfg) is False
def test_create_default_dumpdir_when_specified_doesnt_exist(): args = maltrieve.setup_args(['-d', '/_nope_']) cfg = maltrieve.config(args, 'maltrieve-test.cfg') assert cfg.dumpdir == '/tmp/malware'
def test_inputfile(): args = maltrieve.setup_args(['-i', 'test-input']) cfg = maltrieve.config(args, 'maltrieve-test.cfg') assert cfg.inputfile == 'test-input'
def test_read_alt_config(): args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg']) assert args.config == "maltrieve-test.cfg"
def test_saving_args(): args = maltrieve.setup_args(['-v', '-x', '-c', '-s']) assert args.viper assert args.vxcage assert args.cuckoo assert args.sort_mime
def test_create_default_dumpdir(): args = maltrieve.setup_args(['-d', '/']) cfg = maltrieve.config(args, 'maltrieve-test.cfg') assert cfg.dumpdir == '/tmp/malware'
def test_basic_args(): args = maltrieve.setup_args(['-l', 'testlog', '-p', '127.0.0.1:8080', '-d', '/opt/']) assert args.logfile == 'testlog' assert args.proxy == '127.0.0.1:8080' assert args.dumpdir == '/opt/'
def test_save_blacklist(): args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg']) cfg = maltrieve.config(args, args.config) r = requests.get('http://xwell.org') assert maltrieve.save_malware(r, cfg) is False
def test_basic_args(): args = maltrieve.setup_args( ['-l', 'testlog', '-p', '127.0.0.1:8080', '-d', '/opt/']) assert args.logfile == 'testlog' assert args.proxy == '127.0.0.1:8080' assert args.dumpdir == '/opt/'