Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Orchestration System TFM

This repository contains the implementation developed for the Master's Thesis on the design and development of a cybersecurity model orchestration system.

The project is framed within the ECYSAP-EYE context and provides a software architecture to define, execute and monitor analytical pipelines composed of heterogeneous cybersecurity models.

System overview

The system is divided into four main components:

  • Frontend: a web interface developed with Vue 3 and Vite that allows users to design pipelines, launch executions, monitor their status and visualise results.
  • Backend: a service developed in Python with FastAPI that manages pipeline definitions, execution control, communication with Airflow and retrieval of execution data.
  • Apache Airflow: the orchestration engine responsible for dynamically generating and executing DAGs from the pipeline definitions.
  • Apache Kafka: the communication layer used to exchange execution requests, intermediate information and model results.

The general execution flow is:

Frontend
   |
   v
FastAPI Backend
   |
   v
Apache Airflow
   |
   v
Apache Kafka
   |
   v
Analytical Models

Repository structure

.
├── airflow-kafka/
│   ├── airflow/
│   │   └── dags/
│   │       ├── dag_factory.py
│   │       └── model_lib/
│   │           ├── MITRE/
│   │           │   ├── activity_details.json
│   │           │   ├── activity_exposure_scores.json
│   │           │   ├── approach_activity_mappings.json
│   │           │   ├── approach_details.json
│   │           │   ├── attack_mapping.json
│   │           │   ├── engage_mapper.py
│   │           │   ├── goal_approach_mappings.json
│   │           │   └── goal_details.json
│   │           ├── models/
│   │           │   ├── m23.py
│   │           │   └── m24.py
│   │           └── Translator/
│   │               ├── alert_processed.json
│   │               └── translator.py
│   ├── kafka/
│   └── Vagrantfile
├── backend/
├── public/
├── src/
├── .gitignore
├── docker-compose.yml
├── Dockerfile
├── index.html
├── jsconfig.json
├── package-lock.json
├── package.json
├── README.md
└── vite.config.js

The .vagrant/ directory is generated locally by Vagrant and should not be committed to the repository.

Main features

  • Visual design of analytical pipelines.
  • Validation of nodes and model connections.
  • Execution control through a REST API.
  • Monitoring of execution states, tasks and logs.
  • Results visualisation through a dedicated view.
  • Dynamic DAG generation with Apache Airflow.
  • Communication with analytical models through Apache Kafka.
  • Integration with the simulation microservice.
  • Internal UUID management and user-friendly pipeline aliases.

Frontend

The frontend is implemented with Vue 3 and built with Vite.

Install dependencies

From the repository root:

npm install

Run in development mode

npm run dev

Build for production

npm run build

Run with Docker

If Docker Compose is available, the frontend can also be launched as a container:

docker compose up -d

By default, the interface is exposed on port 10081.

Frontend configuration

The frontend communicates with the backend through the BACKEND_URL configured in the main views.

In the current development setup, the backend URL is:

http://localhost:5667

The frontend also uses the model and pipeline catalogues exposed by the backend.

Backend

The backend is implemented with FastAPI and is exposed on port 5667.

Create and activate the virtual environment

From the backend/ directory:

python3 -m venv venv
source venv/bin/activate

On Windows PowerShell:

python -m venv venv
.\venv\Scripts\Activate.ps1

Install dependencies

pip install -r requirements.txt

Run the backend

uvicorn main:app --host 0.0.0.0 --port 5667

Backend responsibilities

The backend is responsible for:

  • Loading available models and pipelines.
  • Validating pipeline definitions.
  • Registering and controlling executions.
  • Managing pipeline UUIDs and visible aliases.
  • Communicating with Apache Airflow.
  • Synchronising execution states with the simulation microservice.
  • Exposing execution status, tasks and logs.
  • Storing execution data in memory during the current development stage.

Backend configuration

The backend uses the model and pipeline catalogues stored in the backend/assets/ directory.

It also communicates with the Airflow environment through its REST API.

In the current setup, the Airflow base URL is:

http://138.4.21.13:19080

The default simulation service URL is:

http://simulation-core-service:8080/api/simulation-core-service

Apache Airflow

Apache Airflow is used as the orchestration engine.

The Airflow source files included in the repository are stored under:

airflow-kafka/airflow/dags/

DAG factory

The dag_factory.py file reads the pipeline definitions exposed by the backend and dynamically generates an Airflow DAG for each pipeline.

Each pipeline is represented as a directed acyclic graph in which:

  • Each node represents an analytical model.
  • Each edge represents a dependency between models.
  • Independent branches can be executed in parallel.
  • The state of every task can be monitored through Airflow.

Analytical model library

The models used by the DAG factory are grouped under:

airflow-kafka/airflow/dags/model_lib/

MITRE

The MITRE/ directory contains the engage_mapper.py model and the JSON datasets required for the MITRE Engage mapping process.

Translator

The Translator/ directory contains the alert translation model implemented in translator.py and its associated JSON data.

Models

The models/ directory contains the scripts corresponding to the analytical models currently identified as m23 and m24.

Apache Kafka

Apache Kafka is used as the communication layer between Airflow and the analytical models.

Its responsibilities include:

  • Publishing model execution requests.
  • Transporting model input parameters.
  • Receiving intermediate and final model results.
  • Decoupling the orchestration engine from the analytical model implementations.

The Kafka configuration files are stored under:

airflow-kafka/kafka/

Kafka topics

The current orchestration environment uses the following application topics:

Topic Purpose
control_m23 Receives execution requests and input parameters for model M23.
control_m24 Receives execution requests and input parameters for model M24.
respuestas Collects the responses and execution results produced by the analytical models.

Each topic has one partition and a replication factor of one, which is suitable for the single-broker development environment used in this project.

Kafka also creates internal system topics, such as __consumer_offsets, which are managed automatically and are not part of the application-level communication flow.

Start Kafka

From inside the Kafka virtual machine, enter the Kafka directory:

cd ~/kafka

Start the containers:

docker compose up -d

Check that Kafka, ZooKeeper and Kafka UI are running:

docker ps

Create the Kafka topics

Create the topic used by model M23:

docker exec kafka kafka-topics \
  --bootstrap-server kafka:29092 \
  --create \
  --if-not-exists \
  --topic control_m23 \
  --partitions 1 \
  --replication-factor 1

Create the topic used by model M24:

docker exec kafka kafka-topics \
  --bootstrap-server kafka:29092 \
  --create \
  --if-not-exists \
  --topic control_m24 \
  --partitions 1 \
  --replication-factor 1

Create the shared responses topic:

docker exec kafka kafka-topics \
  --bootstrap-server kafka:29092 \
  --create \
  --if-not-exists \
  --topic respuestas \
  --partitions 1 \
  --replication-factor 1

The three topics can also be created using a single loop:

for topic in control_m23 control_m24 respuestas; do
  docker exec kafka kafka-topics \
    --bootstrap-server kafka:29092 \
    --create \
    --if-not-exists \
    --topic "$topic" \
    --partitions 1 \
    --replication-factor 1
done

The --if-not-exists option allows these commands to be executed multiple times without failing when a topic already exists.

List the available topics

docker exec kafka kafka-topics \
  --bootstrap-server kafka:29092 \
  --list

The expected application topics are:

control_m23
control_m24
respuestas

Kafka may also display internal or legacy topics that are not part of the current application flow.

Inspect the application topics

for topic in control_m23 control_m24 respuestas; do
  echo "===== $topic ====="
  docker exec kafka kafka-topics \
    --bootstrap-server kafka:29092 \
    --describe \
    --topic "$topic"
done

Consume messages from a topic

Read messages published in the M23 control topic:

docker exec -it kafka kafka-console-consumer \
  --bootstrap-server kafka:29092 \
  --topic control_m23 \
  --from-beginning

Read messages published in the M24 control topic:

docker exec -it kafka kafka-console-consumer \
  --bootstrap-server kafka:29092 \
  --topic control_m24 \
  --from-beginning

Read the model responses:

docker exec -it kafka kafka-console-consumer \
  --bootstrap-server kafka:29092 \
  --topic respuestas \
  --from-beginning

Press Ctrl+C to stop the consumer.

Publish a test message

Publish a message in the M23 control topic:

docker exec -it kafka kafka-console-producer \
  --bootstrap-server kafka:29092 \
  --topic control_m23

Publish a message in the M24 control topic:

docker exec -it kafka kafka-console-producer \
  --bootstrap-server kafka:29092 \
  --topic control_m24

Write the message and press Enter. Press Ctrl+C to close the producer.

Airflow and Kafka environment

The development environment uses Vagrant and VirtualBox to deploy two separate virtual machines.

Virtual machine Private IP Forwarded host port
airflow-mario 192.168.60.30 19080
kafka-mario 192.168.60.40 19081

From the airflow-kafka/ directory, start both machines:

vagrant up airflow-mario
vagrant up kafka-mario

Check their status:

vagrant status

Access the Airflow virtual machine:

vagrant ssh airflow-mario

Access the Kafka virtual machine:

vagrant ssh kafka-mario

Stop the environment:

vagrant halt

The detailed Docker Compose configuration for Airflow and Kafka will be added to their corresponding directories.

Simulation integration

The backend integrates the pipeline execution flow with simulation-core-service.

The integration supports:

  • Assigning a pipeline UUID and alias to a simulation.
  • Updating the visible pipeline alias.
  • Starting a simulation.
  • Pausing an execution.
  • Resuming a paused execution.
  • Stopping an execution.
  • Resetting an execution to Ready.
  • Archiving a simulation.

The UUID is used internally between services, while the alias is the identifier displayed to the user.

The execution states used by the system are:

Ready
Running
Paused
Aborted
Finished
Error
Archived

Development context

This project was developed as part of a Master's Thesis in Cybersecurity at ETSIT-UPM.

Its purpose is to provide a functional basis for orchestrating cybersecurity models in structured analytical pipelines, enabling reproducible execution, monitoring and decision support in mission-oriented cybersecurity scenarios.

License

This repository is intended for academic and research purposes.

A specific licence file should be added if the project is to be redistributed or reused outside this context.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages