Skip to content

๐Ÿ—ก๏ธ ShadowOps - Security Operations Discord Bot fรผr Server-Monitoring (Fail2ban, CrowdSec, Docker, AIDE)

Notifications You must be signed in to change notification settings

Commandershadow9/shadowops-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—ก๏ธ ShadowOps - Active Security Guardian v3.5 ๐Ÿš€

Status: โœ… LIVE & PRODUKTIV | Version: 3.5.0 | Letzte Aktualisierung: 02.12.2025

ShadowOps ist ein vollstรคndig autonomer Security Guardian mit KI-gesteuerter Auto-Remediation, intelligenter Request-Queue, persistentem Lernsystem und Multi-Projekt-Management, der Sicherheitsbedrohungen nicht nur erkennt und analysiert, sondern eigenstรคndig behebt und aus Erfahrungen lernt.

๐Ÿ“– Vollstรคndige v3.1 Dokumentation: ACTIVE_SECURITY_GUARDIAN.md ๐Ÿ“š Dokumentations-รœbersicht: DOCS_OVERVIEW.md ๐Ÿง  KI-Lernsystem Dokumentation: AI_LEARNING_MULTI_PROJECT.md ๐Ÿ”ง API Dokumentation: docs/API.md ๐Ÿš€ Setup Guide: docs/SETUP_GUIDE.md

โšก Highlights v3.5

๐Ÿ”„ Ollama Queue Management & Auto-Resolve (v3.5 - NEW)

  • โœ… Intelligentes Request-Queuing
    • Priority-basierte AsyncIO Queue (verhindert Ollama รœberlastung)
    • 4 Prioritรคtsstufen: CRITICAL > HIGH > NORMAL > LOW
    • Security-First: Security-Events erhalten IMMER Vorrang
    • Single Worker Pattern (max 1 Ollama Request gleichzeitig)
    • State Persistence & Performance-Statistiken
  • โœ… Live Dashboard in Discord
    • Channel: ๐Ÿ”„-ollama-queue
    • Updates alle 30 Sekunden
    • Zeigt: Aktueller Request, Queue Size, Statistiken, Priority-Verteilung
    • Worker-Status (Running/Stopped)
  • โœ… Admin Commands
    • /queue-status - Detaillierter Status
    • /queue-stats - Performance-Statistiken
    • /queue-clear - Queue leeren (ADMIN)
    • /queue-pause / /queue-resume - Worker steuern (ADMIN)
  • โœ… Auto-Resolve fรผr Service-Recovery
    • Incidents werden automatisch geschlossen wenn Service wieder online
    • Berechnet Ausfallzeit (Xh Ym)
    • Thread-Update: "โœ… GELร–ST von Auto-Resolve: Dienst wieder erreichbar..."
    • Komplette Timeline in Incident-Thread
  • โœ… Deutsche Incident-Meldungen
    • Alle Embeds und Threads auf Deutsch
    • "Vorfall", "Schweregrad", "Betroffene Projekte", etc.
    • Konsistente รœbersetzung im gesamten System

Vorteile:

  • ๐Ÿšซ Keine Ollama-รœberlastung mehr (450% CPU, 5.6GB RAM โ†’ gelรถst)
  • ๐Ÿ”’ Security-First Prinzip garantiert
  • ๐Ÿ“Š Volle Transparenz durch Dashboard
  • ๐Ÿ‡ฉ๐Ÿ‡ช Deutschsprachige Benutzeroberflรคche

โšก Highlights v3.4

๐Ÿง  Advanced AI Learning System (v3.4 - NEW)

  • โœ… Vollstรคndige KI-Trainings-Pipeline: Kontinuierliches Lernen fรผr bessere Patch Notes
    • CHANGELOG.md-Parsing fรผr vollstรคndigen Kontext
    • Automatische Qualitรคtsbewertung (0-100 Skala)
    • Few-Shot-Learning mit Top-10 Beispielen
    • Trainingsdaten-Sammlung (โ‰ฅ80 Score)
  • โœ… Discord Feedback-Sammlung
    • Automatische Reaktions-Buttons (๐Ÿ‘ โค๏ธ ๐Ÿ”ฅ ๐Ÿ‘Ž ๐Ÿ˜ โŒ)
    • Benutzer-Feedback trainiert die KI
    • Funktioniert fรผr ALLE Projekte automatisch
  • โœ… A/B Testing System
    • 3 Prompt-Varianten mit Performance-Tracking
    • Gewichtete Auswahl basierend auf Erfolg
    • Kombinierte Bewertung (70% Qualitรคt + 30% Feedback)
  • โœ… Auto-Tuning Engine
    • Automatische Performance-Analyse
    • Verbesserungsvorschlรคge
    • Automatische Varianten-Erstellung
  • โœ… Fine-Tuning Export
    • Ollama-Format (JSONL) fรผr llama3.1
    • LoRA-Format (Alpaca-Style)
    • Auto-generiertes Fine-Tuning-Script
  • โœ… Admin-Befehle
    • /ai-stats - Trainings-Statistiken
    • /ai-variants - Varianten-รœbersicht
    • /ai-tune - Tuning-Vorschlรคge
    • /ai-export-finetune - Export fรผr Training
  • โœ… Multi-Projekt-Unterstรผtzung
    • Gemeinsamer Lern-Pool (alle profitieren voneinander)
    • Zero-Config (automatisch fรผr use_ai: true)
    • Projekt-รผbergreifendes Lernen
  • โœ… Intelligentes RAM-Management (3-Stufen)
    • Automatische Prozess-Bereinigung (unnรถtige Prozesse beenden)
    • Ollama-Neustart zur RAM-Freigabe
    • System-Cache-Flush als Fallback
    • Bis zu 3 Retry-Versuche mit gleichem Modell
    • Schรผtzt kritische Services (PostgreSQL, Redis, Nginx, etc.)

โšก Highlights v3.3

๐Ÿ” Webhook Security (v3.3 - NEW)

  • โœ… HMAC-SHA256 Signature Verification: Sichere GuildScout โ†” ShadowOps Kommunikation
    • Schรผtzt vor gefรคlschten/gespooften Alerts
    • Validiert Webhook-Authentizitรคt mit Shared Secret
    • Constant-time Signatur-Vergleich verhindert Timing-Attacks
    • Konfigurierbar per Projekt: webhook_secret in Config
  • โœ… Automatische Request-Validierung
    • Validiert X-Webhook-Signature Header Format
    • Lehnt ungรผltige Signaturen mit HTTP 403 ab
    • Abwรคrtskompatibel (Legacy-Modus ohne Secret)
    • Detailliertes Security-Logging fรผr Audits
  • โœ… Erweiterte GuildScout Integration
    • Unterstรผtzt alle neuen GuildScout v2.3.0 Alerts:
      • Health Monitoring Alerts
      • Performance Profiling Events
      • Weekly Report Summaries
      • Database Monitoring Warnings

Konfiguration:

projects:
  guildscout:
    webhook_secret: guildscout_shadowops_secure_key_2024
    # Muss identisch mit GuildScout Config sein!

Security Best Practices:

  • Verwende starke, zufรคllige Secrets (min. 32 Zeichen)
  • Rotiere Secrets regelmรครŸig (alle 90 Tage)
  • Verwende HTTPS fรผr Produktions-Webhooks
  • รœberwache abgelehnte Requests (403 Errors)

โšก Highlights v3.2

๐ŸŒ Multi-Guild Customer Notifications (v3.2 - NEW)

  • โœ… Automatic Channel Setup: Bot auto-creates monitoring channels on customer servers
  • โœ… External Notifications: Send Git updates and status alerts to customer Discord servers
  • โœ… AI-Generated Patch Notes: Professional, user-friendly updates with Ollama llama3.1
  • โœ… Dual-Channel System: Technical logs (internal) + friendly updates (customers)
  • โœ… Per-Project Configuration: Configurable language (DE/EN) and notification types
  • โœ… Message Splitting: Automatic handling of Discord's 4096 character limit
  • โœ… Centralized Monitoring: ShadowOps handles all notifications (Option B)
  • โœ… Manual Setup Command: /setup-customer-server for existing guilds

๐Ÿ”ง Security Integration Fixes (v3.2 - NEW)

  • โœ… CrowdSec Integration Fixed: Corrected JSON parsing, now shows "๐ŸŸข Aktiv"
  • โœ… Fail2ban Integration Fixed: Resolved systemd restrictions, now shows "๐ŸŸข Aktiv"
  • โœ… GitHub Webhook Logging: Fixed logger connection for full webhook visibility
  • โœ… Firewall Configuration: Port 9090 opened with HMAC security

โšก Highlights v3.1

๐Ÿง  Persistent AI Learning System (v3.1 - NEW)

  • โœ… SQL Knowledge Base: Persistent storage for fixes, strategies, and success rates
  • โœ… Git History Analysis: Learns from past commits to understand codebase evolution
  • โœ… Code Structure Analyzer: Deep understanding of project architecture
  • โœ… Log-Based Learning: Analyzes security logs to improve threat detection
  • โœ… Success Rate Tracking: Historical performance metrics guide strategy selection
  • โœ… Best Strategy Recommendations: AI suggests fixes based on proven success
  • โœ… Adaptive Retry Logic: Failed fixes inform better subsequent attempts

๐ŸŒ Multi-Project Management (v3.1 - NEW)

  • โœ… GitHub Webhook Integration: Auto-deploy on push/PR merge events
  • โœ… Automated Patch-Notes: Detaillierte Change-Notifications bei Git-Push fรผr interne und Kunden-Channels.
  • โœ… Real-Time Health Monitoring: Continuous uptime tracking for all projects
  • โœ… Automated Deployment: Complete CI/CD pipeline with safety checks
  • โœ… Incident Management: Auto-detection, tracking, and Discord threads
  • โœ… Customer Notifications: Professional, user-friendly status updates
  • โœ… Project Dashboard: /projekt-status and /alle-projekte commands
  • โœ… Automatic Rollback: Failed deployments trigger instant restoration

๐Ÿงช Enterprise Test Suite (v3.1 - NEW)

  • โœ… 150+ Comprehensive Tests: Full coverage for all critical systems
  • โœ… Unit Tests: Config, AI Service, Orchestrator, Knowledge Base, Event Watcher
  • โœ… Integration Tests: End-to-end learning workflows
  • โœ… AI Learning Documentation: Tests demonstrate how AI learns patterns
  • โœ… pytest Configuration: Professional test infrastructure
  • โœ… Test Fixtures: 20+ reusable fixtures for consistent testing

๐Ÿ›ก๏ธ Active Security Guardian (v3.0)

  • โœ… Echte Fix-Execution: NPM audit fix, Docker rebuilds, Firewall-Updates, File Restoration
  • โœ… Automatische Backups: Vor JEDER ร„nderung mit 7-Tage Retention & Rollback
  • โœ… Impact-Analyse: Projekt-bewusste Entscheidungen (ShadowOps, GuildScout, Nexus, Sicherheitstool)
  • โœ… Service Management: Graceful Start/Stop mit Health Checks & Dependency-Ordering
  • โœ… Koordinierte Remediation: Multi-Event Batching mit single approval flow
  • โœ… Safety First: Dry-Run Mode, DO-NOT-TOUCH Validation, Circuit Breaker, Command Validation
  • โœ… Live Discord Updates: Echtzeit-Feedback wรคhrend kompletter Execution (Backup โ†’ Fix โ†’ Verify โ†’ Restart)

๐Ÿค– Advanced AI System

  • Hybrid AI System: Ollama (local llama3.1) โ†’ Claude โ†’ OpenAI (fallback chain)
  • RAG Context: Projekt-Wissen + DO-NOT-TOUCH Regeln + Infrastructure Knowledge + Code Structure
  • SQL Knowledge Base: Persistent learning across sessions
  • Event History: Remembers ALL previous fix attempts with outcomes
  • Confidence-Based: <85% confidence โ†’ automatisch blockiert
  • Batch-Processing: Mehrere Events โ†’ 1 koordinierter Plan
  • Adaptive Strategies: AI learns from failures and improves over time
  • Git History Integration: Analyzes commit patterns for better context

๐ŸŽฏ Enhanced Workflow (v3.1)

1. ๐Ÿšจ Security Event erkannt
   โ””โ”€> Event Watcher โ†’ Orchestrator (10s Batch-Fenster)

2. ๐Ÿง  AI Query Knowledge Base
   โ”œโ”€ Check previous fixes for similar events
   โ”œโ”€ Load best strategies based on success rate
   โ””โ”€ Analyze code structure and git history

3. ๐Ÿค– KI-Analyse (ALLE Events zusammen)
   โ”œโ”€ Hybrid AI mit RAG Context + KB + Code Analysis
   โ”œโ”€ Koordinierter Multi-Phasen Plan
   โ””โ”€ Impact-Analyse (Projekte, Downtime, Risks)

4. โœ‹ Single Approval Request
   โ”œโ”€ Kompletter Plan mit allen Phasen
   โ”œโ”€ Betroffene Projekte + Downtime-Schรคtzung
   โ”œโ”€ Historical success rate (if applicable)
   โ””โ”€ Rollback-Strategie

5. ๐Ÿ”ง Autonome Execution
   โ”œโ”€ Phase 0: Backups erstellen
   โ”œโ”€ Phase 1-N: Fixes ausfรผhren (npm audit, Docker rebuild, etc.)
   โ”œโ”€ Verification: Re-Scans prรผfen Erfolg
   โ”œโ”€ Bei Fehler: Automatischer Rollback!
   โ””โ”€ Record result to Knowledge Base

6. โœ… Completion & Learning
   โ”œโ”€ Discord: Status + Results + Stats
   โ”œโ”€ Save fix outcome to SQL KB
   โ”œโ”€ Update success rates
   โ””โ”€ Improve future strategies

๐ŸŽฏ Features

๐Ÿ”” Auto-Alerts

  • Fail2ban - IP-Bans bei Brute-Force-Angriffen
  • CrowdSec - KI-basierte Bedrohungserkennung
  • AIDE - File Integrity Monitoring
  • Docker Security Scans - Container-Schwachstellen (Trivy)
  • Project Health Checks - Real-time monitoring for all services
  • Incident Detection - Automatic incident creation and tracking
  • GitHub Events - Detaillierte Patch-Notes fรผr Push, PR und Release Events
  • Deployment Status - Real-time deployment progress

๐Ÿค– Slash Commands

Security & Monitoring

  • /status - Gesamt-Sicherheitsstatus
  • /scan - Manuellen Docker-Scan triggern
  • /threats - Letzte erkannte Bedrohungen
  • /bans - Aktuell gebannte IPs (Fail2ban + CrowdSec)
  • /aide - AIDE Integrity Check Status

Auto-Remediation

  • /remediation-stats - Auto-Remediation Statistiken
  • /stop-all-fixes - ๐Ÿ›‘ EMERGENCY: Stoppt alle laufenden Fixes
  • /set-approval-mode [mode] - ร„ndere Approval Mode (paranoid/auto/dry-run)

AI & Learning System

  • /get-ai-stats - AI-Provider Status und Fallback-Chain
  • /reload-context - Lade Project-Context neu

Multi-Project Management

  • /projekt-status [name] - Status fรผr spezifisches Projekt (Uptime, Response Time, Health)
  • /alle-projekte - รœbersicht aller รผberwachten Projekte

๐ŸŽจ Features

  • Rich Embeds - Farbcodierte Alerts (๐Ÿ”ด CRITICAL, ๐ŸŸ  HIGH, ๐ŸŸข OK)
  • Multi-Channel Support - Kategorisierte Channels (Security, AI Learning, Deployments, etc.)
  • Project Tagging - Filtere Alerts nach Projekt
  • Role Permissions - Admin-only Commands
  • Auto-Reconnect - Robust gegen Netzwerk-Probleme
  • Incident Threads - Automatische Discord-Threads pro Incident
  • Real-Time Dashboards - Live project status updates

๐Ÿ“‹ Voraussetzungen

  • Python 3.9+
  • Discord Bot Token (siehe Setup)
  • Systemd (fรผr Service)
  • Root/Sudo-Zugriff (fรผr Log-Zugriff und Deployments)
  • Optional: GitHub Webhook fรผr Auto-Deploy
  • Optional: Ollama fรผr lokale AI (llama3.1)

๐Ÿš€ Quick Start

1. Discord Bot erstellen

  1. Gehe zu Discord Developer Portal
  2. "New Application" โ†’ Name: ShadowOps
  3. Bot-Tab โ†’ "Add Bot"
  4. "Reset Token" โ†’ Token kopieren (โš ๏ธ nur einmal sichtbar!)
  5. Unter "Privileged Gateway Intents":
    • โœ… Message Content Intent (optional)
    • โœ… Server Members Intent (optional)
  6. OAuth2 โ†’ URL Generator:
    • Scopes: bot, applications.commands
    • Permissions: Send Messages, Embed Links, Use Slash Commands, Create Public Threads, Send Messages in Threads
  7. Generierte URL รถffnen โ†’ Bot zu Server einladen

2. Bot installieren

cd /home/user/shadowops-bot

# Dependencies installieren
pip3 install -r requirements.txt

# Config erstellen
cp config/config.example.yaml config/config.yaml
nano config/config.yaml  # guild_id und andere statische IDs eintragen

# Secrets als Umgebungsvariablen setzen
# (z.B. in ~/.bashrc, ~/.zshrc oder einer .env Datei, die vom Service geladen wird)
export DISCORD_BOT_TOKEN="DEIN_BOT_TOKEN_HIER"
# Optional:
# export ANTHROPIC_API_KEY="DEIN_ANTHROPIC_KEY"
# export OPENAI_API_KEY="DEIN_OPENAI_KEY"

3. Systemd Service aktivieren

sudo cp shadowops-bot.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable shadowops-bot
sudo systemctl start shadowops-bot

# Status prรผfen
sudo systemctl status shadowops-bot

# Logs live verfolgen
sudo journalctl -u shadowops-bot -f

4. Discord Channels Setup (Automatisch)

Der Bot erstellt automatisch alle benรถtigten Channels beim ersten Start:

๐Ÿค– Auto-Remediation Kategorie:

  • ๐Ÿšจ-security-alerts - Sicherheits-Alarme
  • โœ…-approval-requests - Fix-Genehmigungen
  • โš™๏ธ-execution-logs - Execution-Logs
  • ๐Ÿ“Š-stats - Tรคgliche Statistiken
  • ๐Ÿง -ai-learning - AI Learning Logs
  • ๐Ÿ”ง-code-fixes - Code Fixer Logs
  • โšก-orchestrator - Orchestrator Logs

โ„น๏ธ Channel-Fallbacks: Falls die Auto-Remediation-Notification-IDs nicht gesetzt sind, nutzt der Bot automatisch die IDs aus channels.* (z.B. channels.ai_learning, channels.code_fixes, channels.orchestrator). So bleiben AI-Learning und Discord-Logs aktiv, selbst wenn die Notifications-Section fehlt.

๐ŸŒ Multi-Project Kategorie (v3.1):

  • ๐Ÿ‘ฅ-customer-alerts - Kunden-sichtbare Alerts
  • ๐Ÿ“Š-customer-status - Projekt-Status Updates
  • ๐Ÿš€-deployment-log - Deployment-Benachrichtigungen

๐Ÿ’ก Tipp: Der Bot updated die Config automatisch mit allen Channel-IDs!

โš™๏ธ Konfiguration

Vollstรคndige Konfigurationsdokumentation: docs/API.md

Basis-Config in config/config.yaml:

discord:
  # token: "" # WIRD JETZT รœBER ENV VAR: DISCORD_BOT_TOKEN GESETZT
  guild_id: 123456789

ai:
  ollama:
    enabled: true
    url: http://localhost:11434
    model: phi3:mini
    model_critical: llama3.1
    hybrid_models: true

  anthropic:
    enabled: false
    # api_key: "" # WIRD JETZT รœBER ENV VAR: ANTHROPIC_API_KEY GESETZT

  openai:
    enabled: false
    # api_key: "" # WIRD JETZT รœBER ENV VAR: OPENAI_API_KEY GESETZT

auto_remediation:
  enabled: true
  dry_run: false
  approval_mode: paranoid  # paranoid | auto | dry-run
  max_batch_size: 10

projects:
  shadowops-bot:
    enabled: true
    path: /home/user/shadowops-bot
    branch: main
    monitor:
      enabled: true
      url: http://localhost:5000/health
      check_interval: 60
    deploy:
      run_tests: true
      test_command: pytest tests/

github:
  enabled: false
  webhook_secret: "your_webhook_secret"
  webhook_port: 8080
  auto_deploy: true
  deploy_branches: [main, master]

deployment:
  backup_dir: backups
  max_backups: 5
  health_check_timeout: 30

โ„น๏ธ Config Loader: Die Einstellungen kรถnnen per Attribute und Dictionary-Access gelesen werden (z.B. config.discord['token'] oder config['discord']). Fehlende Pflichtfelder (discord.token, discord.guild_id) lรถsen einen klaren KeyError aus, damit Fehlkonfigurationen sofort auffallen.

๐Ÿ“Š Verwendung

Commands in Discord

Security Commands:
  /status              - Gesamt-Sicherheitsstatus
  /scan                - Docker Security Scan
  /threats [hours]     - Bedrohungen der letzten X Stunden
  /bans [limit]        - Gebannte IPs
  /aide                - AIDE Check-Status

Auto-Remediation:
  /remediation-stats             - Statistiken
  /stop-all-fixes                - Emergency Stop
  /set-approval-mode [mode]      - Approval Mode รคndern

AI System:
  /get-ai-stats                  - AI Provider Status
  /reload-context                - Context neu laden

Multi-Project:
  /projekt-status [name]         - Detaillierter Projekt-Status
  /alle-projekte                 - รœbersicht aller Projekte

GitHub Webhook Setup

  1. Repository Settings โ†’ Webhooks โ†’ Add webhook
  2. Payload URL: http://your-server:8080/webhook
  3. Content type: application/json
  4. Secret: (from config.yaml)
  5. Events: Push, Pull request, Release

๐Ÿ”ง Entwicklung & Testing

# Dependencies installieren
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt

# Tests ausfรผhren
pytest tests/ -v

# Mit Coverage
pytest tests/ --cov=src --cov-report=html

# Einzelne Test-Kategorie
pytest tests/unit/ -v
pytest tests/integration/ -v

# Bot lokal testen
python3 src/bot.py

# Logs anschauen
tail -f logs/shadowops.log

# Service neu starten
sudo systemctl restart shadowops-bot

๐Ÿ“ Projekt-Struktur

shadowops-bot/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ bot.py                          # Haupt-Bot-Logik
โ”‚   โ”œโ”€โ”€ cogs/                           # NEU: Modulare Slash Commands
โ”‚   โ”‚   โ”œโ”€โ”€ admin.py
โ”‚   โ”‚   โ”œโ”€โ”€ inspector.py
โ”‚   โ”‚   โ””โ”€โ”€ monitoring.py
โ”‚   โ”œโ”€โ”€ integrations/
โ”‚   โ”‚   โ”œโ”€โ”€ ai_service.py               # AI Service (Ollama/Claude/OpenAI)
โ”‚   โ”‚   โ”œโ”€โ”€ orchestrator.py             # Remediation Orchestrator
โ”‚   โ”‚   โ”œโ”€โ”€ event_watcher.py            # Security Event Watcher
โ”‚   โ”‚   โ”œโ”€โ”€ knowledge_base.py           # SQL Learning System
โ”‚   โ”‚   โ”œโ”€โ”€ code_analyzer.py            # Code Structure Analyzer
โ”‚   โ”‚   โ”œโ”€โ”€ context_manager.py          # RAG Context Manager
โ”‚   โ”‚   โ”œโ”€โ”€ github_integration.py       # GitHub Webhooks
โ”‚   โ”‚   โ”œโ”€โ”€ project_monitor.py          # Multi-Project Monitoring
โ”‚   โ”‚   โ”œโ”€โ”€ deployment_manager.py       # Auto-Deployment
โ”‚   โ”‚   โ”œโ”€โ”€ incident_manager.py         # Incident Tracking
โ”‚   โ”‚   โ”œโ”€โ”€ customer_notifications.py   # Customer-Facing Alerts
โ”‚   โ”‚   โ”œโ”€โ”€ fail2ban.py                 # Fail2ban Integration
โ”‚   โ”‚   โ”œโ”€โ”€ crowdsec.py                 # CrowdSec Integration
โ”‚   โ”‚   โ”œโ”€โ”€ aide.py                     # AIDE Integration
โ”‚   โ”‚   โ””โ”€โ”€ docker.py                   # Docker Scan Integration
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ config.py                   # Config-Loader
โ”‚       โ”œโ”€โ”€ state_manager.py            # NEU: State-Management
โ”‚       โ”œโ”€โ”€ logger.py                   # Logging
โ”‚       โ”œโ”€โ”€ embeds.py                   # Discord Embed-Builder
โ”‚       โ””โ”€โ”€ discord_logger.py           # Discord Channel Logger
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ conftest.py                     # Test Fixtures
โ”‚   โ”œโ”€โ”€ unit/                           # Unit Tests (150+)
โ”‚   โ”‚   โ”œโ”€โ”€ test_config.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_ai_service.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_orchestrator.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_knowledge_base.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_event_watcher.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_github_integration.py
โ”‚   โ”‚   โ”œโ”€โ”€ test_project_monitor.py
โ”‚   โ”‚   โ””โ”€โ”€ test_incident_manager.py
โ”‚   โ””โ”€โ”€ integration/
โ”‚       โ””โ”€โ”€ test_learning_workflow.py   # End-to-End Tests
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ config.example.yaml             # Example Config
โ”‚   โ”œโ”€โ”€ config.yaml                     # Your Config (gitignored)
โ”‚   โ”œโ”€โ”€ DO-NOT-TOUCH.md                 # Safety Rules
โ”‚   โ”œโ”€โ”€ INFRASTRUCTURE.md               # Infrastructure Knowledge
โ”‚   โ””โ”€โ”€ PROJECT_*.md                    # Project Documentation
โ”œโ”€โ”€ context/                            # AI Context Files
โ”‚   โ”œโ”€โ”€ git_history/                    # Git History Analysis
โ”‚   โ””โ”€โ”€ logs/                           # Log Learning Files
โ”œโ”€โ”€ data/                               # Persistent Data
โ”‚   โ”œโ”€โ”€ state.json                      # NEU: Dynamic State File
โ”‚   โ”œโ”€โ”€ knowledge_base.db               # SQL Learning Database
โ”‚   โ”œโ”€โ”€ project_monitor_state.json      # Project Monitor State
โ”‚   โ””โ”€โ”€ incidents.json                  # Incident Tracking
โ”œโ”€โ”€ backups/                            # Auto-Backups (gitignored)
โ”œโ”€โ”€ logs/                               # Log-Dateien (gitignored)
โ”œโ”€โ”€ docs/                               # Documentation
โ”‚   โ”œโ”€โ”€ API.md                          # API Documentation
โ”‚   โ”œโ”€โ”€ SETUP_GUIDE.md                  # Setup Guide
โ”‚   โ”œโ”€โ”€ ACTIVE_SECURITY_GUARDIAN.md     # Feature Documentation
โ”‚   โ””โ”€โ”€ DOCS_OVERVIEW.md                # Documentation Overview
โ”œโ”€โ”€ requirements.txt                    # Python Dependencies
โ”œโ”€โ”€ requirements-dev.txt                # Dev Dependencies
โ”œโ”€โ”€ pytest.ini                          # pytest Configuration
โ”œโ”€โ”€ safe_upgrades.yaml                  # Upgrade Recommendations
โ”œโ”€โ”€ shadowops-bot.service               # Systemd Service
โ”œโ”€โ”€ CHANGELOG.md                        # Version History
โ””โ”€โ”€ README.md                           # This file

๐Ÿ›ก๏ธ Security

  • Secrets Management: Secrets (Token, API Keys) mรผssen als Umgebungsvariablen gesetzt werden.
  • Config-Schutz: Niemals die config.yaml oder .env-Dateien committen!
  • File Permissions: chmod 600 config/config.yaml
  • Service-User: Bot lรคuft als nicht-root user
  • Rate Limiting: Eingebaut gegen Spam
  • Webhook Verification: HMAC signatures for GitHub webhooks
  • DO-NOT-TOUCH Validation: Critical files protected
  • Dry-Run Mode: Test fixes without execution
  • Automatic Backups: Before every change
  • Rollback Capability: Instant restoration on failure

๐Ÿ“ˆ Performance & Reliability

  • Persistent Learning: SQL database survives restarts
  • Exponential Backoff: Smart retry logic for API calls
  • Circuit Breaker: Prevents cascade failures
  • Race Condition Protection: Async locks for shared state
  • Memory Management: Automatic cleanup of old data
  • Health Monitoring: Continuous project uptime tracking
  • Auto-Recovery: Projects automatically resume after downtime

๐Ÿ“ Changelog

See CHANGELOG.md for detailed version history.

Version 3.2.0 (2025-11-25) - Current

๐ŸŒ Multi-Guild Customer Notifications:

  • Automatic channel setup on customer servers
  • AI-generated patch notes (Ollama llama3.1)
  • Dual-channel system (internal technical + customer friendly)
  • Per-project language configuration (DE/EN)
  • Message splitting for long patch notes
  • Manual setup command /setup-customer-server

๐Ÿ”ง Security Integration Fixes:

  • Fixed CrowdSec integration (JSON parsing)
  • Fixed Fail2ban integration (systemd restrictions)
  • Fixed GitHub webhook logging
  • Opened port 9090 with HMAC security

๐Ÿ“š Documentation:

  • Complete multi-guild setup guide
  • Customer onboarding instructions
  • GitHub webhook configuration guide
  • Security integration fixes documentation

Version 3.1.0 (2025-11-21)

๐Ÿง  Persistent Learning System:

  • SQL Knowledge Base for permanent learning
  • Git history analysis for codebase understanding
  • Code structure analyzer for architecture insights
  • Enhanced AI prompts with log-based learning
  • Success rate tracking and best strategy recommendations

๐ŸŒ Multi-Project Infrastructure:

  • GitHub webhook integration with auto-deploy
  • Real-time project health monitoring
  • Automated deployment system with rollback
  • Incident management with Discord threads
  • Customer-facing notification system
  • Project status commands (/projekt-status, /alle-projekte)

๐Ÿงช Enterprise Test Suite:

  • 150+ comprehensive tests (unit + integration)
  • AI learning workflow demonstrations
  • pytest configuration with fixtures
  • Full coverage for critical systems

๐Ÿ”ง Code Improvements:

  • Before/after verification for fixes
  • Race condition protection
  • Retry logic with exponential backoff
  • Service validation
  • Memory leak prevention

๐ŸŽฎ New Commands:

  • /set-approval-mode - Change remediation mode
  • /get-ai-stats - AI provider status
  • /reload-context - Reload project context
  • /projekt-status - Detailed project status
  • /alle-projekte - All projects overview

Version 3.0.0 (2025-11-20)

  • AI Learning System with event history tracking
  • Smart Docker image analysis
  • CVE-aware upgrade recommendations
  • Multi-project execution
  • Git history learning

Version 2.0.1 (2025-11-15)

  • AI Service fixes
  • HTTP client conflict resolution

Version 2.0.0 (2025-11-14)

  • Event-driven auto-remediation
  • AI-powered analysis
  • Live status updates

Version 1.0.0 (2025-11-12)

  • Initial Release
  • Basic security monitoring
  • Discord integration

๐Ÿ“Š Statistics (v3.1.0)

  • Total Lines of Code: 15,000+
  • Test Coverage: 150+ tests
  • AI Integrations: 3 (Ollama, Claude, OpenAI)
  • Security Integrations: 4 (Fail2ban, CrowdSec, AIDE, Trivy)
  • Discord Commands: 14
  • Supported Projects: Unlimited
  • Deployment Automation: Full CI/CD
  • Incident Tracking: Automatic with threads

๐Ÿ“„ Lizenz

MIT License - Erstellt von CommanderShadow

๐Ÿค Support & Troubleshooting

Hรคufige Probleme

Bot startet nicht:

# Logs prรผfen
sudo journalctl -u shadowops-bot -f

# Service-Status
sudo systemctl status shadowops-bot

# Config validieren
python3 -c "from src.utils.config import get_config; get_config()"

Slash Commands werden nicht angezeigt:

# Commands neu synchronisieren (automatisch beim Bot-Start)
# Kann bis zu 1 Stunde dauern (Discord Cache)

AI Service funktioniert nicht:

# Ollama Status prรผfen
curl http://localhost:11434/api/tags

# AI Stats in Discord
/get-ai-stats

Deployments schlagen fehl:

# Permissions prรผfen
sudo -l

# Backup-Verzeichnis prรผfen
ls -la backups/

# Deployment-Logs
tail -f logs/shadowops.log | grep deployment

Vollstรคndige Dokumentation

Bei Problemen

  1. Logs prรผfen: sudo journalctl -u shadowops-bot -f
  2. Service-Status: sudo systemctl status shadowops-bot
  3. Permissions prรผfen: Bot braucht Zugriff auf Logs und Deployment-Pfade
  4. Test-Suite ausfรผhren: pytest tests/ -v
  5. GitHub Issues: Report a Bug

Made with ๐Ÿ—ก๏ธ by CommanderShadow

ShadowOps v3.1 - The Ultimate AI-Powered Security Guardian

About

๐Ÿ—ก๏ธ ShadowOps - Security Operations Discord Bot fรผr Server-Monitoring (Fail2ban, CrowdSec, Docker, AIDE)

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •