From 4140960d6c5fb658125f7c57142207afcae01558 Mon Sep 17 00:00:00 2001 From: Paul Squizzato Date: Fri, 24 Mar 2023 14:58:34 +0000 Subject: [PATCH] regles :thumbs_up: --- src/decoderBrut.py | 1 - src/ecritureBDD.py | 15 ++++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/decoderBrut.py b/src/decoderBrut.py index 9eb65f2..d0797cf 100644 --- a/src/decoderBrut.py +++ b/src/decoderBrut.py @@ -94,7 +94,6 @@ def decode(pkt): bigL.append(miniL) if bigL!=[]: - print("attention") triPacket(bigL,connec) diff --git a/src/ecritureBDD.py b/src/ecritureBDD.py index 01232d3..41a58bb 100644 --- a/src/ecritureBDD.py +++ b/src/ecritureBDD.py @@ -1,6 +1,4 @@ import psycopg2 as psy -import pandas as pd -import getpass import regles def verifRegle(co): @@ -15,11 +13,13 @@ def verifRegle(co): ruleWarning=0 condition=len(rule[0]) for i in rule[0]: - if dataState[(i[0],i[1])]==i[2]: - ruleAccepted+=1 + if (i[0],i[1]) in dataState: + if dataState[(i[0],i[1])]==i[2]: + ruleWarning+=1 if ruleWarning>=condition: - if dataState(rule[1][0],rule[1][1])==rule[1][2]: - return False + if (rule[1][0],rule[1][1]) in dataState: + if dataState[(rule[1][0],rule[1][1])]==rule[1][2]: + return False return True @@ -35,10 +35,11 @@ def ecritureBDD(lStatus,connec): if verifRegle(co): co.commit() else: + print("A rule has been violated. The system is endangered. The database") co.rollback() cur.close() except(Exception,psy.DatabaseError) as error: print(error) finally: if co is not None: - co.close() \ No newline at end of file + co.close()