mirror of
https://github.com/mblanke/ThreatHunt.git
synced 2026-03-01 05:50:21 -05:00
6.3 KiB
6.3 KiB
ThreatHunt Update Log
2026-02-20: Host-Centric Network Map & Analysis Platform
Network Map Overhaul
- Problem: Network Map showed 409 misclassified "domain" nodes (mostly process names like svchost.exe) and 0 hosts. No deduplication same host counted once per dataset.
- Root Cause: IOC column detection misclassified
Fqdnas "domain" instead of "hostname";Namecolumn (process names) wrongly tagged as "domain" IOC;ClientIdwas innormalized_columnsas "hostname" but not inioc_columns. - Solution: Created a new host-centric inventory system that scans all datasets, groups by
Fqdn/ClientId, and extracts IPs, users, OS, and network connections.
New Backend Files
backend/app/services/host_inventory.pyDeduplicated host inventory builder. Scans all datasets in a hunt, identifies unique hosts via regex-based column detection (ClientId,Fqdn,User/Username,Laddr.IP/Raddr.IP), groups rows, extracts metadata. Filters system accounts (DWM-, UMFD-, LOCAL SERVICE, NETWORK SERVICE). Infers OS from hostname patterns (W10-* Windows 10). Builds network connection graph from netstat remote IPs.backend/app/api/routes/network.pyGET /api/network/host-inventory?hunt_id=Xendpoint returning{hosts, connections, stats}.backend/app/services/ioc_extractor.pyIOC extraction service (IP, domain, hash, email, URL patterns).backend/app/services/anomaly_detector.pyStatistical anomaly detection across datasets.backend/app/services/data_query.pyNatural language to structured query translation.backend/app/services/load_balancer.pyRound-robin load balancer for Ollama LLM nodes.backend/app/services/job_queue.pyAsync job queue for long-running analysis tasks.backend/app/api/routes/analysis.py16 analysis endpoints (IOC extraction, anomaly detection, host profiling, triage, reports, job management).
Modified Backend Files
backend/app/main.pyAddednetwork_routerandanalysis_routerincludes.backend/app/db/models.pyAdded 4 AI/analysis ORM models (ProcessingJob,AnalysisResult,HostProfile,IOCEntry).backend/app/db/engine.pyConnection pool tuning for SQLite async.
Frontend Changes
frontend/src/components/NetworkMap.tsxComplete rewrite: host-centric force-directed graph using Canvas 2D. Two node types (Host / External IP). Shows hostname, IP, OS in labels. Click popover shows FQDN, IPs, OS, logged-in users, datasets, connections. Search across hostname/IP/user/OS. Stats cards showing host counts.frontend/src/components/AnalysisDashboard.tsxNew 6-tab analysis dashboard (IOC Extraction, Anomaly Detection, Host Profiling, Query, Triage, Reports).frontend/src/api/client.tsAddednetwork.hostInventory()method +InventoryHost,InventoryConnection,InventoryStatstypes. Added analysis API namespace with 16 endpoint methods.frontend/src/App.tsxAdded Analysis Dashboard route and navigation.
Results (Radio Hunt 20 Velociraptor datasets, 394K rows)
| Metric | Before | After |
|---|---|---|
| Nodes shown | 409 misclassified "domains" | 163 unique hosts |
| Hosts identified | 0 | 163 |
| With IP addresses | N/A | 48 (172.17.x.x LAN) |
| With logged-in users | N/A | 43 (real names only) |
| OS detected | None | Windows 10 (inferred from hostnames) |
| Deduplication | None (same host 20 datasets) | Full (by FQDN/ClientId) |
| System account filtering | None | DWM-, UMFD-, LOCAL/NETWORK SERVICE removed |
2026-02-23: Agent Execution Controls, Learning Mode, and Dev Startup Hardening
Agent Assist: Explicit Execution + Learning Controls
- Problem: Agent behavior was partly implicit (intent-triggered execution only), with no analyst override to force/disable execution and no explicit "learning mode" explainability toggle.
- Solution:
- Added
execution_preferenceto assist requests (auto | force | off). - Added
learning_modeflag for analyst-friendly explanations and rationale. - Preserved deterministic execution path for policy-domain scans while allowing explicit override.
- Added
Backend Updates
backend/app/api/routes/agent_v2.py- Extended
AssistRequestwithexecution_preferenceandlearning_mode. - Added
_should_execute_policy_scan(request)helper:off: advisory-only (never execute scan)force: execute scan regardless of query phrasingauto: existing intent-based policy execution behavior
- Wired
learning_modeinto agent context calls.
- Extended
backend/app/agents/core_v2.py- Extended
AgentContextwithlearning_mode: bool. - Prompt construction now adds analyst-teaching/explainability guidance when enabled.
- Extended
Frontend Updates
frontend/src/api/client.ts- Extended
AssistRequestwithexecution_preferenceandlearning_mode. - Extended
AssistResponsewith optionalexecutionpayload.
- Extended
frontend/src/components/AgentPanel.tsx- Added Execution selector (
Auto,Force execute,Advisory only). - Added
Learning modeswitch. - Added execution results accordion (scope, datasets, top domains, hit count, elapsed).
- Cleaned stream update logic to avoid loop-closure lint warnings.
- Added Execution selector (
Tests and Validation
backend/tests/test_agent_policy_execution.py- Added regression tests for:
execution_preference=off(stays advisory)execution_preference=force(executes scanner)
- Added regression tests for:
- Validation:
- Backend tests:
test_agent_policy_execution.pypassed. - Frontend build: clean compile after warning cleanup.
- Backend tests:
Frontend Warning Cleanup
frontend/src/components/AnalysisDashboard.tsx- Removed unused
DeleteIconimport.
- Removed unused
frontend/src/components/MitreMatrix.tsx- Fixed
useCallbackdependency warning by includinghuntList.
- Fixed
Dev Reliability: Docker Compose Startup on PowerShell
- Problem: Intermittent
docker compose up -d 2>&1exit code1despite healthy/running containers. - Root Cause: PowerShell
2>&1handling can surfaceNativeCommandErrorfor compose stderr/progress output (false failure signal). - Solution:
- Added
scripts/dev-up.ps1startup helper to:- run compose with stable output handling,
- show container status,
- verify backend/frontend readiness,
- return actionable exit codes.
- Updated backend liveness probe to
http://localhost:8000/openapi.json(current app does not expose/health).
- Added