How albinjacob/cybersec-agent works
Purpose and Entry Points
This repository is a multi-agent cybersecurity analysis pipeline. It ingests authentication logs, container/dependency artifacts, and policy data; detects threats and vulnerabilities; correlates intelligence and controls; produces remediation guidance; optionally dispatches alerts; and generates a traceable Markdown report.
Primary entry points:
• Gradio demo/UI: app.py
• CLI execution and report/state persistence: main.py
• Pipeline assembly: orchestrator.py
Orchestration and Shared State
orchestrator.py builds the LangGraph StateGraph that carries one shared investigation state through agent stages. The graph is the central control boundary: agents contribute structured findings rather than directly invoking one another.
Independent initial branches analyze logs and build artifacts, then converge for correlation. Subsequent response and policy stages consume combined findings; notification is terminal. Shared model access and offline reasoning behavior are centralized in agents/llm.py.
Paths: orchestrator.py, agents/llm.py, main.py
Detection Inputs and Parallel Analysis
The log-monitor branch parses authentication/security events to identify brute-force, reconnaissance, and port-scan signals. The vulnerability branch evaluates Docker and dependency posture, preferring Trivy when installed and otherwise applying static checks against bundled CVE data.
These branches operate on distinct evidence sources before their results join downstream.
Paths: agents/log_monitor.py, agents/vuln_scanner.py, data/sample_auth.log, data/Dockerfile, data/requirements.txt
Threat Correlation and Intelligence Boundary
Threat intelligence consumes findings from both initial branches and enriches surfaced CVEs or attack patterns. It calls the public NVD REST API when reachable, with data/cve_dataset.json as an offline fallback. This keeps external threat-feed availability from blocking an investigation.
Paths: agents/threat_intel.py, data/cve_dataset.json, agents/embeddings.py
Response and Policy Analysis
Incident response converts correlated findings into a prioritized remediation/action plan. Policy checking maps gaps to security controls using semantic retrieval over the full cached NIST 800-53 catalog, with a TF-IDF-style fallback over a smaller policy excerpt when semantic resources are unavailable.
This separates operational remediation from compliance/control evidence while allowing both to use the same combined findings.
Paths: agents/incident_response.py, agents/policy_checker.py, data/nist_800_53_catalog.json, data/policy_index_vectors.npy, data/policy_excerpt.md
Notification Action Stage
Notification is a terminal side-effect stage rather than a reasoning agent. It evaluates configured severity thresholds and dispatches qualifying findings to Slack webhooks and/or Gmail SMTP. Missing credentials or channels produce a labeled skipped result, preserving pipeline completion.
Configuration can arrive from the UI session or environment variables; secrets are not repository-owned.
Paths: agents/notify.py, app.py, .env.example
Presentation, Reporting, and Deployment
app.py is a thin Gradio layer over pipeline execution, while ui_render.py holds UI presentation formatting without Gradio coupling. CLI runs write the aggregate report and state under output/; report_builder.py assembles stage outputs into Markdown.
Runtime dependencies include Python, LangGraph, optional Trivy, optional LLM providers (Anthropic/OpenAI/OpenRouter), NVD, Slack, and Gmail SMTP. Render deployment support installs Trivy during builds.
Paths: report_builder.py, ui_render.py, output/report.md, render.yaml, scripts/render_build.sh
Main entry points: threat_intel.py Threat intelligence · orchestrator.py LangGraph pipeline · log_monitor.py Log monitor · policy_checker.py Policy checker
Components 20
Entry & Presentation
- Gradio UI · Starts investigations from an interactive session.
app.py - CLI runner · Executes runs and persists report and state.
main.py - UI formatter
ui_render.py
Analysis Pipeline
- LangGraph pipeline · Shared investigation state joins parallel findings before downstream stages.
orchestrator.py - Model access · Centralizes provider access and offline reasoning behavior.
agents/llm.py - Log monitor · Detects authentication attacks and reconnaissance signals.
agents/log_monitor.py - Vulnerability scanner · Uses Trivy when available, otherwise static CVE checks.
agents/vuln_scanner.py - Threat intelligence · Enriches CVEs and attack patterns from joined findings.
agents/threat_intel.py - Incident response · Produces prioritized remediation actions.
agents/incident_response.py - Policy checker · Maps findings to security controls through retrieval.
agents/policy_checker.py
Knowledge & External Services
- Authentication log
data/sample_auth.log - Container dependencies · Dockerfile and Python dependency posture.
data/Dockerfile - NVD API · Public CVE enrichment service.
- Bundled CVE dataset
data/cve_dataset.json - NIST control catalog · Cached NIST 800-53 catalog and vector index.
data/nist_800_53_catalog.json - Policy excerpt
data/policy_excerpt.md
Output & Actions
- Notification dispatcher · Sends qualifying alerts or records a skipped result.
agents/notify.py - Markdown report builder · Assembles aggregate stage outputs into a report.
report_builder.py - Investigation report
output/report.md - Slack / Gmail · Webhook and SMTP alert channels.
Connections 23
- Gradio UI → LangGraph pipeline: starts run
- CLI runner → LangGraph pipeline: starts run
- Gradio UI → UI formatter: renders results
- LangGraph pipeline → Log monitor: parallel branch
- LangGraph pipeline → Vulnerability scanner: parallel branch
- Authentication log → Log monitor: events
- Container dependencies → Vulnerability scanner: artifacts
- Log monitor → Threat intelligence: attack findings
- Vulnerability scanner → Threat intelligence: vulnerability findings
- NVD API → Threat intelligence: online enrichment
- Bundled CVE dataset → Threat intelligence: offline fallback
- Threat intelligence → Incident response: correlated findings
- Threat intelligence → Policy checker: combined findings
- NIST control catalog → Policy checker: semantic retrieval
- Policy excerpt → Policy checker: TF-IDF fallback
- Model access → Log monitor: shared reasoning
- Model access → Threat intelligence: shared reasoning
- Model access → Incident response: shared reasoning
- Incident response → Notification dispatcher: action plan
- Policy checker → Notification dispatcher: control gaps
- Notification dispatcher → Slack / Gmail: qualifying alerts
- LangGraph pipeline → Markdown report builder: aggregate state
- Markdown report builder → Investigation report: writes Markdown