def ipvalue(): for i in ResIp.objects.raw_query({"riskvalue":-1}): try: blackip = BlackIp.objects.get(blackip =i.suspiciousip) i.riskvalue = blackip.riskvalue i.save() if i.riskvalue>=i.user.ipalarmvalue: alarmdata = AlarmList(user=i.user,riskvalue=i.riskvalue,blackdata=i.suspiciousip,datatype="0",datapk_id=i.pk) alarmdata.save() except: i.riskvalue = 0 i.save()
def urlvalue(): for i in ResUrl.objects.raw_query({"riskvalue":-1}): host = urlparse(i.url).netloc blackurl = BlackUrl.objects.raw_query({"blackurl":{'$regex':host}}) if len(blackurl): blackurl = blackurl[0] i.riskvalue = blackurl.riskvalue i.save() if i.riskvalue>=i.user.urlalarmvalue: alarmdata = AlarmList(user=i.user,riskvalue=i.riskvalue,blackdata=i.url,datatype="1",datapk_id=i.pk) alarmdata.save() else: i.riskvalue = 0 i.save()
def emailvalue(): for i in ResEmail.objects.raw_query({"riskvalue":-1}): emailtolist = list() emailtolist+=[email for email in i.sendto.split(";") if email.find("@")!=-1] emailtolist+=[email for email in i.sendcc.split(";") if email.find("@")!=-1] emailtolist+=[email for email in i.sendbcc.split(";") if email.find("@")!=-1] for email in emailtolist: try: blackemail = BlackEmail.objects.get(blackemail=email) i.riskvalue = blackemail.riskvalue if i.riskvalue>=i.user.emailalarmvalue: alarmdata = AlarmList(user=i.user,riskvalue=i.riskvalue,blackdata=email,datatype="2",datapk_id=i.pk) alarmdata.save() break except: i.riskvalue = 0 i.save()