def analyse(resultats_scan, tache): logginghashscan.info('Begin hash analysis for host %s' % tache.ip) smbreachable = True # Scan not completed if resultats_scan is None: tache.retries_left_hash -= 1 # Still got some retries left if tache.retries_left_hash > 0: tache.hashscanned = False tache.last_retry_hash = datetime.datetime.now() tache.priority_hash -= 1 else: tache.hashscanned = True smbreachable = False else: tache.hashscanned = True tache.reserved_hash = False session.commit() r = session.query(Result).filter_by(tache_id=tache.id).first() # No result for now if r is None: r = Result( smbreachable=smbreachable, tache_id=tache.id, ) else: r.smbreachable = smbreachable session.add(r) session.commit() # If scan has been completed, add the detections to the database if smbreachable: for ioc_id, dic in resultats_scan.items(): if dic['res'] != 'True': continue id = IOCDetection(result_id=r.id, indicator_id=ioc_id, indicator_data=json.dumps(dic['data']), xmlioc_id=dic['iocid']) session.add(id) session.commit() logginghashscan.info('End hash analysis for host %s' % tache.ip)
def analyse(resultats_scan, tache): logginghashscan.info('Begin hash analysis for host %s' % tache.ip) smbreachable = True # Scan not completed if resultats_scan is None : tache.retries_left_hash -= 1 # Still got some retries left if tache.retries_left_hash > 0: tache.hashscanned = False tache.last_retry_hash = datetime.datetime.now() tache.priority_hash -= 1 else: tache.hashscanned = True smbreachable = False else: tache.hashscanned = True tache.reserved_hash = False session.commit() r = session.query(Result).filter_by(tache_id = tache.id).first() # No result for now if r is None: r = Result( smbreachable = smbreachable, tache_id=tache.id, ) else: r.smbreachable = smbreachable session.add(r) session.commit() # If scan has been completed, add the detections to the database if smbreachable: for ioc_id, dic in resultats_scan.items(): if dic['res']!='True': continue id = IOCDetection(result_id = r.id, indicator_id = ioc_id, xmlioc_id = dic['iocid']) session.add(id) session.commit() logginghashscan.info('End hash analysis for host %s' % tache.ip)