Merge branch 'master' of https://codefirst.iut.uca.fr/git/louis.dufour/Detection_d_intrusion
commit
c7a8c0677a
@ -0,0 +1,85 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: python:3.9-slim-buster
|
||||
volumes:
|
||||
- name: docs
|
||||
path: /docs
|
||||
commands:
|
||||
- cd src/
|
||||
- python -m venv venv
|
||||
- source venv/bin/activate
|
||||
- pip install -r requirements.txt
|
||||
- python setup.py install
|
||||
- python -m pytest
|
||||
- python setup.py sdist bdist_wheel
|
||||
|
||||
|
||||
# docker image build
|
||||
- name: docker-build-and-push
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: ./Dockerfile
|
||||
context: src/
|
||||
registry: hub.codefirst.iut.uca.fr
|
||||
repo: hub.codefirst.iut.uca.fr/louis.dufour/detection_d_intrusion
|
||||
username:
|
||||
from_secret: SECRET_REGISTRY_USERNAME
|
||||
password:
|
||||
from_secret: SECRET_REGISTRY_PASSWORD
|
||||
|
||||
|
||||
- name: generate-and-deploy-docs
|
||||
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer
|
||||
failure: ignore
|
||||
volumes:
|
||||
- name: docs
|
||||
path: /docs
|
||||
commands:
|
||||
#- cd Documentation/doxygen
|
||||
#- doxygen Doxyfile
|
||||
- /entrypoint.sh
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
depends_on: [ build ]
|
||||
|
||||
# container deployment
|
||||
- name: deploy-container
|
||||
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||
environment:
|
||||
IMAGENAME: hub.codefirst.iut.uca.fr/louis.dufour/detection_d_intrusion:latest
|
||||
CONTAINERNAME: containersae
|
||||
COMMAND: create
|
||||
OVERWRITE: true
|
||||
depends_on: [ docker-build-and-push ]
|
||||
|
||||
- name: code-analysis
|
||||
image: sonarsource/sonar-scanner-cli:latest
|
||||
commands:
|
||||
- cd src/
|
||||
- sonar-scanner \
|
||||
-Dsonar.projectKey=detection_d_intrusion \
|
||||
-Dsonar.projectName=detection_d_intrusion \
|
||||
-Dsonar.sources=. \
|
||||
-Dsonar.host.url=https://codefirst.iut.uca.fr/sonar \
|
||||
-Dsonar.login=$${PLUGIN_SONAR_TOKEN}
|
||||
secrets: [ SONAR_TOKEN ]
|
||||
settings:
|
||||
# accessible en ligne de commande par $${PLUGIN_SONAR_HOST}
|
||||
sonar_host: https://codefirst.iut.uca.fr/sonar/
|
||||
# accessible en ligne de commande par $${PLUGIN_SONAR_TOKEN}
|
||||
sonar_token:
|
||||
from_secret: SONAR_TOKEN
|
||||
depends_on: [build]
|
||||
|
||||
volumes:
|
||||
- name: docs
|
||||
temp: {}
|
@ -0,0 +1,15 @@
|
||||
FROM python:3.9-slim-buster
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY src/ /app/src/
|
||||
COPY requirements.txt /app/
|
||||
COPY setup.py /app/
|
||||
|
||||
RUN python -m venv venv
|
||||
RUN . venv/bin/activate && pip install -r requirements.txt && python setup.py install
|
||||
|
||||
RUN python -m pytest
|
||||
RUN python setup.py sdist bdist_wheel
|
||||
|
||||
CMD ["python", "app.py"]
|
@ -0,0 +1,9 @@
|
||||
## Rendez-vous du 17 Mars
|
||||
|
||||
- Il nous reste 14h (sans compter la séance du 17/03)
|
||||
|
||||
- Une fois la BDD qui marche, comment à tester :
|
||||
- Utiliser des scripts de client pymodbus;
|
||||
- ou avec des envois de paquets en dur directement dans le decodeur.
|
||||
|
||||
#### Prochain rendez-vous le Mardi 21 Mars à 10h15 (Démo du code)
|
@ -0,0 +1,23 @@
|
||||
## Rendez-vous du 21 Mars
|
||||
|
||||
- Commenter la récursivité et justifier *(dans triPacket)*
|
||||
- En terme de qualité de code c'est Zéro si on rend le décoder brut
|
||||
- Doxygen
|
||||
- Docker wazuh
|
||||
|
||||
### Ce qu'il reste à faire:
|
||||
- filtrer les paquets (donc juste un dictionnaire "si j'ai coils 5 qui vaut true et le regsitre 45 j'empêche cette variable à tel valeurs" création de règle)
|
||||
- Si un scénario est repérer on bloque tout la request *(S'il y a valeur interdite je bloque tout ou non ? (utile soustenance))*
|
||||
- Prévoir démo soustenance
|
||||
- Idée indicateur (métrique) pilnt/sonnar *(un code comme ça c'est détruit et refais)*
|
||||
|
||||
### Un docker pour:
|
||||
- Code python
|
||||
- Docker compose entre tout les container *(postgree, client, serveur, python)*
|
||||
|
||||
|
||||
#### Prochain rendez-vous:
|
||||
- Mercredi 29 Mars à 8h30 : démo BDD et rapport *(envoie Lundi 27 Mars soir)*
|
||||
- Jeudi 30 Mars à 9h : oral blanc soutenance
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
psycopg2
|
||||
pandas
|
||||
getpass
|
||||
scapy.all
|
||||
scapy.contrib.modbus
|
@ -0,0 +1,24 @@
|
||||
import psycopg2 as psy
|
||||
import pandas as pd
|
||||
import getpass
|
||||
|
||||
def verifRegle(a):
|
||||
return True
|
||||
|
||||
def ecritureBDD(lStatus,connec):
|
||||
co = None
|
||||
try:
|
||||
co = psy.connect(host=connec[0],database=connec[1],user=connec[2],password=connec[3])
|
||||
cur = co.cursor()
|
||||
for i in lStatus:
|
||||
cur.execute("INSERT INTO Status VALUES (%s,%s,%s ) ON CONFLICT (addresse,type) DO UPDATE SET valeur=%s;",(i[1],i[0],i[2],i[2]))
|
||||
if verifRegle(co):
|
||||
co.commit()
|
||||
else:
|
||||
co.rollback()
|
||||
cur.close()
|
||||
except(Exception,psy.DatabaseError) as error:
|
||||
print(error)
|
||||
finally:
|
||||
if co is not None:
|
||||
co.close()
|
@ -0,0 +1,22 @@
|
||||
from ecritureBDD import ecritureBDD
|
||||
|
||||
def decoupePacket(lPkt):
|
||||
if type(lPkt)!=list:
|
||||
print('pas liste')
|
||||
return
|
||||
if len(lPkt)==0:
|
||||
print('liste vide')
|
||||
return
|
||||
if len(lPkt)==1:
|
||||
return decoupePacket(lPkt[0])
|
||||
if len(lPkt)==3 and type(lPkt[0])==str:
|
||||
return [[lPkt[0],int(lPkt[1]),int(lPkt[2])]]
|
||||
else:
|
||||
l=[]
|
||||
for i in lPkt:
|
||||
l+=decoupePacket(i)
|
||||
return l
|
||||
|
||||
def triPacket(lPkt,connec):
|
||||
lNettoyee=decoupePacket(lPkt)
|
||||
ecritureBDD(lNettoyee,connec)
|
Loading…
Reference in new issue