def check_exists(self): result = es.search({"hashes.sha256": self.hashes['sha256']}) exists = ('hits' in result and result['hits']['total'] != 0) if exists: data = result['hits']['hits'][0]['_source'] self.uuid = data['uuid'] self.sources = data['sources'] self.dispose() return exists
def check_exists(self): result = es.search({"hashes.sha256": self.hashes["sha256"]}) exists = "hits" in result and result["hits"]["total"] != 0 if exists: data = result["hits"]["hits"][0]["_source"] self.uuid = data["uuid"] self.sources = data["sources"] self.dispose() return exists
def update_submissions(user_id): try: user = User.query.get(user_id) pending = user.submissions.filter(Submission.sample_uuid == None).all() for row in pending: result = es.search({"hashes.sha256": row.file_hash}) exists = ('hits' in result and result['hits']['total'] != 0) if exists: data = result['hits']['hits'][0]['_source'] row.sample_uuid = data['uuid'] db.session.add(row) db.session.commit() except TransportError: flash(gettext('Error querying ElasticSearch database. Please check configuration.'))
def update_submissions(user_id): try: user = User.query.get(user_id) pending = user.submissions.filter(Submission.sample_uuid == None).all() for row in pending: result = es.search({"hashes.sha256": row.file_hash}) exists = ('hits' in result and result['hits']['total'] != 0) if exists: data = result['hits']['hits'][0]['_source'] row.sample_uuid = data['uuid'] db.session.add(row) db.session.commit() except TransportError: flash( gettext( 'Error querying ElasticSearch database. Please check configuration.' ))