Пример #1
0
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'
Пример #2
0
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)
Пример #3
0
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'
Пример #4
0
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)
Пример #5
0
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
Пример #6
0
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
Пример #7
0
def test_inputfile():
    args = maltrieve.setup_args(['-i', 'test-input'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.inputfile == 'test-input'
Пример #8
0
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)
Пример #9
0
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
Пример #10
0
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
Пример #11
0
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'
Пример #12
0
def test_create_default_dumpdir():
    args = maltrieve.setup_args(['-d', '/'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.dumpdir == '/tmp/malware'
Пример #13
0
def test_inputfile():
    args = maltrieve.setup_args(['-i', 'test-input'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.inputfile == 'test-input'
Пример #14
0
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)
Пример #15
0
def test_create_default_dumpdir():
    args = maltrieve.setup_args(['-d', '/'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.dumpdir == '/tmp/malware'
Пример #16
0
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
Пример #17
0
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'
Пример #18
0
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