def db_inconsistency(file_hash): if (not valid_hash(file_hash)): raise ValueError("db_inconsistency invalid hash") pc = PackageController() v = VersionController() file_id = get_file_id(file_hash) if file_id is not None: #meta exists file_bin = pc.getFile(file_id) if file_bin is not None: #sample exists version = v.searchVersion(file_id) if version is not None: return 0 # ok else: #version does not exist logging.info( "inconsistency: meta and sample exists. Version does not") return 3 else: # has meta but not sample logging.info("inconsistency: meta exists, sample does not") return 2 else: # does not have meta if len(file_hash) == 64: return 0 # cant search in grid by sha256 if len(file_hash) == 40: file_bin = pc.getFile(file_hash) else: # md5 sha1 = pc.md5_to_sha1(file_hash) if sha1 is None: return 0 # does not have meta or sample file_bin = pc.getFile(file_hash) if file_bin is None: return 0 else: logging.info("inconsistency: does not have meta. has sample") return 1
def db_inconsistency(file_hash): if(not valid_hash(file_hash)): raise ValueError("db_inconsistency invalid hash") pc = PackageController() v = VersionController() file_id = get_file_id(file_hash) if file_id is not None: # meta exists file_bin = pc.getFile(file_id) if file_bin is not None: # sample exists version = v.searchVersion(file_id) if version is not None: return 0 # ok else: # version does not exist logging.info( "inconsistency: meta and sample exists. Version does not") return 3 else: # has meta but not sample logging.info("inconsistency: meta exists, sample does not") return 2 else: # does not have meta if len(file_hash) == 64: return 0 # cant search in grid by sha256 if len(file_hash) == 40: file_bin = pc.getFile(file_hash) else: # md5 sha1 = pc.md5_to_sha1(file_hash) if sha1 is None: return 0 # does not have meta or sample file_bin = pc.getFile(file_hash) if file_bin is None: return 0 else: logging.info("inconsistency: does not have meta. has sample") return 1
def generic_process_hash(hash_str): if hash_str is None: return None hash_str = clean_hash(hash_str) if(not valid_hash(hash_str)): return None if(len(hash_str) == 64): hash_str = get_file_id(hash_str) elif(len(hash_str) == 32): pc = PackageController() hash_str = pc.md5_to_sha1(hash_str) logging.debug("generic_process_hash-->sha1: " + str(hash_str)) if(hash_str is not None): return process_file(hash_str) else: return None
def generic_process_hash(hash_str): if hash_str is None: return None hash_str = clean_hash(hash_str) if (not valid_hash(hash_str)): return None if (len(hash_str) == 64): hash_str = get_file_id(hash_str) elif (len(hash_str) == 32): pc = PackageController() hash_str = pc.md5_to_sha1(hash_str) logging.debug("generic_process_hash-->sha1: " + str(hash_str)) if (hash_str is not None): return process_file(hash_str) else: return None