This project is a Security Operations Center as a Service (SOCaaS) dashboard and backend.
The frontend is a single-page application built with HTML, CSS, and vanilla JavaScript. It uses Chart.js for charts and Lucide for icons.
To run the frontend, simply open index.html
in your web browser.
The backend is built with Python and FastAPI.
-
Navigate to the backend directory:
cd backend
-
Create and activate a virtual environment (if you haven't already):
python3 -m venv venv source venv/bin/activate # On Windows, use: venv\\Scripts\\activate
-
Install dependencies (if you haven't already):
pip install -r requirements.txt # Note: requirements.txt will be created in a future step. # For now, if it's the first time, you installed them manually in a previous step: # pip install fastapi uvicorn[standard] # With database dependencies: # pip install fastapi uvicorn[standard] psycopg2-binary sqlalchemy "databases[postgresql]" python-dotenv
-
Set up PostgreSQL: The application requires a PostgreSQL database. You can install it directly or run it using Docker.
-
Using Docker (Recommended for ease of setup):
docker run --name socaas-postgres -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -e POSTGRES_DB=socaas_db -p 5432:5432 -d postgres:15
This will start a PostgreSQL 15 container.
POSTGRES_USER
:user
POSTGRES_PASSWORD
:password
POSTGRES_DB
:socaas_db
These match the defaultDATABASE_URL
inbackend/config.py
.
-
Manual Installation: Follow the official PostgreSQL installation guide for your operating system. You will need to create a database (e.g.,
socaas_db
), a user (e.g.,user
), and grant privileges.
-
-
Configure Database Connection (Optional - if not using defaults): The database connection URL is configured in
backend/config.py
and defaults topostgresql://user:password@localhost:5432/socaas_db
. You can override this by creating a.env
file in thebackend/
directory with your custom URL:# backend/.env DATABASE_URL=postgresql://youruser:yourpassword@yourhost:yourport/yourdb
-
Run the FastAPI server: Ensure your PostgreSQL server is running and accessible.
uvicorn main:app --reload
The server will typically be available at
http://127.0.0.1:8000
. Upon startup, it will attempt to connect to the database and create the necessary tables if they don't exist. -
Health Check: You can check if the server is running and connected to the database by navigating to
http://127.0.0.1:8000/health
in your browser or usingcurl
:curl http://127.0.0.1:8000/health
You should see
{"status":"ok", "database": "connected"}
(if the database is reachable).
All API endpoints are prefixed with /api/v1
.
-
POST /incidents/
: Create a new incident.- Request Body: JSON object matching the
IncidentCreate
schema (seebackend/schemas.py
).(Note:{ "title": "Suspicious Login Attempt", "criticite": "Élevé", "statut": "Ouvert", "type": "Auth", "source": "VPN Gateway" }
CriticiteLevel
andStatutIncident
are enums:Critique
,Élevé
,Moyen
,Bas
for criticite;Ouvert
,En cours
,Résolu
,Fermé
for statut) - Response Body: JSON object of the created incident, matching
IncidentRead
schema. Status code 201.
- Request Body: JSON object matching the
-
GET /incidents/
: List all incidents.- Query Parameters:
skip
(int, optional, default 0): Number of records to skip.limit
(int, optional, default 100): Maximum number of records to return (max 200).
- Response Body: JSON object containing
items
(list of incidents matchingIncidentRead
schema) andtotal
(total number of incidents).{ "items": [ { "title": "Suspicious Login Attempt", "criticite": "Élevé", "statut": "Ouvert", "type": "Auth", "source": "VPN Gateway", "id": 1, "timestamp": "2023-10-27T10:30:00Z" } ], "total": 1 }
- Query Parameters:
-
GET /incidents/{incident_id}
: Get a specific incident by its ID.- Path Parameter:
incident_id
(int). - Response Body: JSON object of the incident, matching
IncidentRead
schema. Status 404 if not found.
- Path Parameter:
-
PUT /incidents/{incident_id}
: Update an existing incident.- Path Parameter:
incident_id
(int). - Request Body: JSON object with fields to update (see
IncidentUpdate
schema inbackend/schemas.py
). All fields are optional.{ "statut": "En cours", "title": "Investigation of Suspicious Login" }
- Response Body: JSON object of the updated incident, matching
IncidentRead
schema. Status 404 if not found.
- Path Parameter:
-
DELETE /incidents/{incident_id}
: Delete an incident.- Path Parameter:
incident_id
(int). - Response: Status code 204 (No Content) on successful deletion. Status 404 if not found.
- Path Parameter:
(Further backend setup and details will be added as development progresses)