Exemplo n.º 1
0
 def test_scan(self):
     malware = 'eicar.com.txt'
     # malware = 'blat.ex_'
     my_clamav_engine = clamav_engine()
     TEST_FILE_DIR_PATH = os.path.join(os.path.dirname(__file__), '..', 'file')
     path = PickleableFileSample.path_factory(os.path.join(TEST_FILE_DIR_PATH, malware))
     # path = os.path.join(TEST_FILE_DIR_PATH, 'eicar.com.txt')
     my_scan = my_clamav_engine.scan(path)
     if my_scan.infected:
         print
         print "Infected:"
         print my_scan.infected_string
         print
     ok_(my_scan, msg="Test A/V def update - version")
Exemplo n.º 2
0
def clamav_scan(this_file):
    my_clamav_engine = clamav_engine()
    results = my_clamav_engine.scan(PickleableFileSample.string_factory(this_file))
    file_md5_hash = hashlib.md5(this_file).hexdigest().upper()
    found = is_hash_in_db(file_md5_hash)
    if found:
        found['user_uploads'][-1].setdefault('av_results', []).append(scan_to_dict(results, 'ClamAV'))
        if results.infected:
            found['user_uploads'][-1]['detection_ratio']['infected'] += 1
        found['user_uploads'][-1]['detection_ratio']['count'] += 1
        data = found
    else:
        data = dict(md5=file_md5_hash)
        data['user_uploads'][-1].setdefault('av_results', []).append(scan_to_dict(results, 'ClamAV'))
    db_insert(data)
    return data
Exemplo n.º 3
0
 def test_scan(self):
     malware = 'eicar.com.txt'
     # malware = 'blat.ex_'
     my_clamav_engine = clamav_engine()
     TEST_FILE_DIR_PATH = os.path.join(os.path.dirname(__file__), '..',
                                       'file')
     path = PickleableFileSample.path_factory(
         os.path.join(TEST_FILE_DIR_PATH, malware))
     # path = os.path.join(TEST_FILE_DIR_PATH, 'eicar.com.txt')
     my_scan = my_clamav_engine.scan(path)
     if my_scan.infected:
         print
         print "Infected:"
         print my_scan.infected_string
         print
     ok_(my_scan, msg="Test A/V def update - version")