def _find_similar_file_for(self, file, parent_id, potential_matches): hash_one = self.database.get_ssdeep_hash(file) if hash_one: id1 = '{}:{}'.format(parent_id, file) for potential_match in potential_matches.files_included: id2 = '{}:{}'.format(potential_matches.uid, potential_match) hash_two = self.database.get_ssdeep_hash(potential_match) if hash_two and get_ssdeep_comparison(hash_one, hash_two) > self.ssdeep_ignore_threshold: yield [id1, id2], get_ssdeep_comparison(hash_one, hash_two)
def _find_similar_file_for(self, file, parent_id, potential_matches): fo_one = self.database.get_object(uid=file) id1 = '{}:{}'.format(parent_id, fo_one.get_uid()) hash_one = fo_one.processed_analysis['file_hashes']['ssdeep'] for potential_match in potential_matches.files_included: fo_two = self.database.get_object(uid=potential_match) id2 = '{}:{}'.format(potential_matches.get_uid(), fo_two.get_uid()) hash_two = fo_two.processed_analysis['file_hashes']['ssdeep'] if get_ssdeep_comparison(hash_one, hash_two) > self.SSDEEP_IGNORE: yield [id1, id2], get_ssdeep_comparison(hash_one, hash_two)
def test_get_ssdeep_comparison(): factor = get_ssdeep_comparison( '192:3xaGk2v7RNOrG4D9tVwTiGTUwMyKP3JDddt2vT3GiH3gnK:BHTWy66gnK', '192:3xaGk2v7RNOrG4D9tVwTiGTUwMyKP3JDddt2vT3GK:B') assert factor == 96, 'ssdeep similarity seems to be out of shape'