regles :thumbs_up:

master
Paul SQUIZZATO 2 years ago
parent 53bdd62652
commit 4140960d6c

@ -94,7 +94,6 @@ def decode(pkt):
bigL.append(miniL) bigL.append(miniL)
if bigL!=[]: if bigL!=[]:
print("attention")
triPacket(bigL,connec) triPacket(bigL,connec)

@ -1,6 +1,4 @@
import psycopg2 as psy import psycopg2 as psy
import pandas as pd
import getpass
import regles import regles
def verifRegle(co): def verifRegle(co):
@ -15,11 +13,13 @@ def verifRegle(co):
ruleWarning=0 ruleWarning=0
condition=len(rule[0]) condition=len(rule[0])
for i in rule[0]: for i in rule[0]:
if dataState[(i[0],i[1])]==i[2]: if (i[0],i[1]) in dataState:
ruleAccepted+=1 if dataState[(i[0],i[1])]==i[2]:
ruleWarning+=1
if ruleWarning>=condition: if ruleWarning>=condition:
if dataState(rule[1][0],rule[1][1])==rule[1][2]: if (rule[1][0],rule[1][1]) in dataState:
return False if dataState[(rule[1][0],rule[1][1])]==rule[1][2]:
return False
return True return True
@ -35,6 +35,7 @@ def ecritureBDD(lStatus,connec):
if verifRegle(co): if verifRegle(co):
co.commit() co.commit()
else: else:
print("A rule has been violated. The system is endangered. The database")
co.rollback() co.rollback()
cur.close() cur.close()
except(Exception,psy.DatabaseError) as error: except(Exception,psy.DatabaseError) as error:

Loading…
Cancel
Save