Automated network incident response system for Cisco IOS-XE routers and switches.
Takes Wazuh SIEM alerts, classifies them with a fine-tuned LLM, queries live device
state via RESTCONF, generates CLI fix commands using domain-specific LoRA adapters,
and applies the fixes automatically via RESTCONF PATCH.
Two backends are provided: a manual 3-script pipeline for operator-controlled
workflows, and a fully autonomous daemon that watches Wazuh logs and resolves
incidents end-to-end without human intervention.
Architecture
Backend 1 — Manual Pipeline (3 scripts)
Wazuh alerts file
|
v
[runners/prefilter.py] filter level-12, drop auth noise
|
v
[runners/pipeline.py]
Stage 1 Wazuh LLM (Ollama) incident_type, severity, IOCs
Stage 2 Show command lookup deterministic table (incident -> show cmds)
Stage 3 RESTCONF mapping deterministic table (show cmd -> YANG path)
Stage 4 Domain routing selects correct LoRA adapter
|
v creates show_outputs/alert_NNN_DEVICE_INCIDENT/
restconf_commands.json <- execute these GETs against routers
alert_info.json
(operator executes RESTCONF GETs and drops response JSONs into the folder)
|
v
[runners/run_fix.py] polls folders, runs domain LoRA
|
|-- fix_commands.txt CLI fix commands (human readable)
+-- restconf_fix_commands.json RESTCONF PATCH ops to apply the fix
+-- pipeline_fix_output.jsonl full record of all alerts processed
Backend 2 — Autonomous Daemon (always-on)
/var/ossec/logs/alerts/alerts.json (Wazuh live output, tailed continuously)
|
v
[backend/daemon.py]
Watch tail alerts file, detect new entries (level 7-12)
Detect SSH brute-force: 5+ failures from same IP within 5-minute window
|
v per alert, fully automatic:
[1] Extract device IP -> device map
[2] Classify Ollama wazuh-llama -> incident_type, IOCs, severity
[3] Show commands deterministic table lookup
[4] RESTCONF GETs execute live against device, collect YANG state
[5] Domain LoRA generate CLI fix commands
[6] RESTCONF PATCHes apply fixes directly to device
[7] Log result managed_incidents.jsonl + managed_incidents.log
|
v per-alert folder:
restconf_get_results.json what the device reported
fix_commands.txt CLI commands the LLM generated
restconf_fix_commands.json PATCH ops with YANG bodies
patch_results.json HTTP status of each PATCH
LoRA Adapters
18 domain-specific adapters fine-tuned on Hermes-3-Llama-3.1-8B (r=8, alpha=32):
Domain
Adapter
Incidents covered
OSPF
incidents/ospf/ospf1
Neighbor down, full-to-down, adjacency loss
OSPF
incidents/ospf/ospf2
ExStart/Exchange stuck, Init stuck, 2-Way
OSPF
incidents/ospf/ospf3
Auth, hello/dead mismatch, area, network-type, MTU
The daemon tracks failed SSH login alerts independently of the level filter.
When 5 or more failures from the same source IP occur within 5 minutes,
a synthetic ssh_brute_force incident is triggered and the full pipeline runs —
even if each individual alert is below the level threshold.
Tune with --ssh-threshold N --ssh-window SECONDS.
Device Configuration
Edit the maps at the top of runners/pipeline.py and backend/daemon.py to match your network:
python
1SOURCE_IP_DEVICE_MAP ={2"10.10.10.10":"R1",3"2.2.2.2":"R2",4# ...5}6DEVICE_MGMT_IP ={7"R1":"10.10.10.10",# management IP used for RESTCONF8"R2":"2.2.2.2",9# ...10}
All communication uses RESTCONF over HTTPS (port 443) with Cisco IOS-XE YANG models.
Read (GET) — _RESTCONF_RULES table maps each show command to its YANG path:
show ip ospf neighbor -> /restconf/data/Cisco-IOS-XE-ospf-oper:ospf-oper-data/ospf-state
show ip bgp summary -> /restconf/data/Cisco-IOS-XE-bgp-oper:bgp-state-data/bgp-route-vrfs
show interfaces -> /restconf/data/Cisco-IOS-XE-interfaces-oper:interfaces
...
Write (PATCH) — CLI fix commands are parsed into context blocks and converted
to RESTCONF PATCH operations with YANG-native JSON bodies:
Training scripts and datasets are in training/ and datasets/.
Each adapter was trained on 900–1500 examples with LoRA (r=8, alpha=32, dropout=0.1)
targeting q_proj and v_proj on Hermes-3-Llama-3.1-8B.
bash
1python training/train_ospf1.py
2python training/train_bgp1.py
3# etc.