sentinelforge 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sentinelforge-0.4.0/.env.example +57 -0
- sentinelforge-0.4.0/.github/workflows/ci.yml +49 -0
- sentinelforge-0.4.0/.github/workflows/release.yml +64 -0
- sentinelforge-0.4.0/.gitignore +52 -0
- sentinelforge-0.4.0/CONTRIBUTING.md +91 -0
- sentinelforge-0.4.0/DEPLOYMENT.md +278 -0
- sentinelforge-0.4.0/DISCLAIMER.md +58 -0
- sentinelforge-0.4.0/LICENSE +21 -0
- sentinelforge-0.4.0/Makefile +60 -0
- sentinelforge-0.4.0/PKG-INFO +686 -0
- sentinelforge-0.4.0/README.md +617 -0
- sentinelforge-0.4.0/SECURITY.md +37 -0
- sentinelforge-0.4.0/SentinelForge_Project_Info.txt +396 -0
- sentinelforge-0.4.0/THREAT_MODEL.md +154 -0
- sentinelforge-0.4.0/configs/critical.yaml +91 -0
- sentinelforge-0.4.0/configs/default.yaml +126 -0
- sentinelforge-0.4.0/configs/homelab.yaml +76 -0
- sentinelforge-0.4.0/configs/production.yaml +53 -0
- sentinelforge-0.4.0/data/sample_logs.txt +10 -0
- sentinelforge-0.4.0/data/threat_db.json +36 -0
- sentinelforge-0.4.0/docker/Dockerfile +40 -0
- sentinelforge-0.4.0/docker-compose.yml +170 -0
- sentinelforge-0.4.0/download.htm +3403 -0
- sentinelforge-0.4.0/pyproject.toml +105 -0
- sentinelforge-0.4.0/scripts/setup_linux.sh +58 -0
- sentinelforge-0.4.0/scripts/setup_windows.ps1 +66 -0
- sentinelforge-0.4.0/src/sentinelforge/__init__.py +3 -0
- sentinelforge-0.4.0/src/sentinelforge/agents/__init__.py +17 -0
- sentinelforge-0.4.0/src/sentinelforge/agents/base.py +42 -0
- sentinelforge-0.4.0/src/sentinelforge/agents/containment.py +183 -0
- sentinelforge-0.4.0/src/sentinelforge/agents/explainer.py +199 -0
- sentinelforge-0.4.0/src/sentinelforge/agents/guardian.py +160 -0
- sentinelforge-0.4.0/src/sentinelforge/agents/investigator.py +306 -0
- sentinelforge-0.4.0/src/sentinelforge/agents/monitor.py +199 -0
- sentinelforge-0.4.0/src/sentinelforge/agents/responder.py +238 -0
- sentinelforge-0.4.0/src/sentinelforge/api/__init__.py +1 -0
- sentinelforge-0.4.0/src/sentinelforge/api/server.py +346 -0
- sentinelforge-0.4.0/src/sentinelforge/cli.py +269 -0
- sentinelforge-0.4.0/src/sentinelforge/connectors/__init__.py +1 -0
- sentinelforge-0.4.0/src/sentinelforge/connectors/siem.py +82 -0
- sentinelforge-0.4.0/src/sentinelforge/connectors/threat_intel.py +118 -0
- sentinelforge-0.4.0/src/sentinelforge/core/__init__.py +1 -0
- sentinelforge-0.4.0/src/sentinelforge/core/alerting.py +289 -0
- sentinelforge-0.4.0/src/sentinelforge/core/audit.py +139 -0
- sentinelforge-0.4.0/src/sentinelforge/core/auth.py +144 -0
- sentinelforge-0.4.0/src/sentinelforge/core/config.py +170 -0
- sentinelforge-0.4.0/src/sentinelforge/core/database.py +384 -0
- sentinelforge-0.4.0/src/sentinelforge/core/executors.py +364 -0
- sentinelforge-0.4.0/src/sentinelforge/core/guardrails.py +118 -0
- sentinelforge-0.4.0/src/sentinelforge/core/health.py +135 -0
- sentinelforge-0.4.0/src/sentinelforge/core/knowledge.py +134 -0
- sentinelforge-0.4.0/src/sentinelforge/core/llm.py +193 -0
- sentinelforge-0.4.0/src/sentinelforge/core/logging.py +71 -0
- sentinelforge-0.4.0/src/sentinelforge/core/models.py +162 -0
- sentinelforge-0.4.0/src/sentinelforge/core/orchestrator.py +139 -0
- sentinelforge-0.4.0/src/sentinelforge/core/safety.py +233 -0
- sentinelforge-0.4.0/src/sentinelforge/core/secrets.py +138 -0
- sentinelforge-0.4.0/src/sentinelforge/dashboard/__init__.py +1 -0
- sentinelforge-0.4.0/src/sentinelforge/dashboard/app.py +776 -0
- sentinelforge-0.4.0/src/sentinelforge/evaluation/__init__.py +1 -0
- sentinelforge-0.4.0/src/sentinelforge/evaluation/harness.py +170 -0
- sentinelforge-0.4.0/src/sentinelforge/knowledge/__init__.py +1 -0
- sentinelforge-0.4.0/src/sentinelforge/knowledge/vector_store.py +100 -0
- sentinelforge-0.4.0/src/sentinelforge/monitoring/__init__.py +0 -0
- sentinelforge-0.4.0/src/sentinelforge/monitoring/file_integrity.py +161 -0
- sentinelforge-0.4.0/src/sentinelforge/monitoring/network.py +200 -0
- sentinelforge-0.4.0/src/sentinelforge/monitoring/windows_events.py +183 -0
- sentinelforge-0.4.0/src/sentinelforge/simulation/__init__.py +1 -0
- sentinelforge-0.4.0/src/sentinelforge/simulation/scenarios.py +169 -0
- sentinelforge-0.4.0/tests/__init__.py +0 -0
- sentinelforge-0.4.0/tests/test_agents.py +151 -0
- sentinelforge-0.4.0/tests/test_alerting.py +118 -0
- sentinelforge-0.4.0/tests/test_api.py +163 -0
- sentinelforge-0.4.0/tests/test_audit.py +55 -0
- sentinelforge-0.4.0/tests/test_auth.py +97 -0
- sentinelforge-0.4.0/tests/test_executors.py +169 -0
- sentinelforge-0.4.0/tests/test_guardrails.py +192 -0
- sentinelforge-0.4.0/tests/test_health.py +36 -0
- sentinelforge-0.4.0/tests/test_integration.py +218 -0
- sentinelforge-0.4.0/tests/test_llm.py +175 -0
- sentinelforge-0.4.0/tests/test_monitoring.py +113 -0
- sentinelforge-0.4.0/tests/test_safety.py +151 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# SentinelForge Environment Configuration
|
|
2
|
+
# Copy this to .env and fill in your values.
|
|
3
|
+
# NEVER commit .env to version control.
|
|
4
|
+
|
|
5
|
+
# --- Core ---
|
|
6
|
+
SF_ENVIRONMENT=development
|
|
7
|
+
SF_SIMULATION_MODE=true
|
|
8
|
+
SF_DEBUG=false
|
|
9
|
+
|
|
10
|
+
# --- Authentication ---
|
|
11
|
+
# JWT secret for API authentication (minimum 32 characters)
|
|
12
|
+
# Generate with: python -c "import secrets; print(secrets.token_hex(32))"
|
|
13
|
+
SF_AUTH__ENABLED=false
|
|
14
|
+
SF_AUTH__JWT_SECRET=
|
|
15
|
+
SF_AUTH__DASHBOARD_PASSWORD=changeme
|
|
16
|
+
|
|
17
|
+
# --- LLM Provider ---
|
|
18
|
+
# Supported: ollama, anthropic, openai
|
|
19
|
+
SF_LLM__PROVIDER=ollama
|
|
20
|
+
SF_LLM__MODEL=llama3.1:8b
|
|
21
|
+
SF_LLM__BASE_URL=http://localhost:11434
|
|
22
|
+
SF_LLM__API_KEY=
|
|
23
|
+
|
|
24
|
+
# --- Database ---
|
|
25
|
+
SF_DATABASE_PATH=./data/sentinelforge.db
|
|
26
|
+
SF_AUDIT_LOG_PATH=./data/audit.log
|
|
27
|
+
SF_VECTOR_DB_PATH=./data/vector_db
|
|
28
|
+
|
|
29
|
+
# --- API ---
|
|
30
|
+
SF_API__HOST=0.0.0.0
|
|
31
|
+
SF_API__PORT=8000
|
|
32
|
+
SF_API__RATE_LIMIT_PER_MINUTE=60
|
|
33
|
+
SF_API__MAX_REQUEST_SIZE_KB=1024
|
|
34
|
+
|
|
35
|
+
# --- Alerting ---
|
|
36
|
+
SF_ALERTS__ENABLED=true
|
|
37
|
+
SF_ALERTS__CONSOLE_ALERTS=true
|
|
38
|
+
SF_ALERTS__WEBHOOK_ENABLED=false
|
|
39
|
+
SF_ALERTS__WEBHOOK_URL=
|
|
40
|
+
SF_ALERTS__MIN_SEVERITY=high
|
|
41
|
+
|
|
42
|
+
# --- Slack (optional) ---
|
|
43
|
+
SF_SLACK_WEBHOOK_URL=
|
|
44
|
+
SF_SLACK_CHANNEL=#security-alerts
|
|
45
|
+
|
|
46
|
+
# --- Email (optional) ---
|
|
47
|
+
SF_SMTP_HOST=
|
|
48
|
+
SF_SMTP_PORT=587
|
|
49
|
+
SF_SMTP_USER=
|
|
50
|
+
SF_SMTP_PASSWORD=
|
|
51
|
+
SF_SMTP_FROM=sentinelforge@example.com
|
|
52
|
+
SF_SMTP_TO=security-team@example.com
|
|
53
|
+
|
|
54
|
+
# --- External Integrations ---
|
|
55
|
+
SF_SIEM_API_KEY=
|
|
56
|
+
SF_OTX_API_KEY=
|
|
57
|
+
SF_MISP_API_KEY=
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, develop]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-python@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.11"
|
|
17
|
+
- name: Install ruff
|
|
18
|
+
run: pip install ruff
|
|
19
|
+
- name: Run linter
|
|
20
|
+
run: ruff check src/ tests/
|
|
21
|
+
|
|
22
|
+
test:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
needs: lint
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: actions/setup-python@v5
|
|
28
|
+
with:
|
|
29
|
+
python-version: "3.11"
|
|
30
|
+
cache: pip
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: pip install -e ".[all]"
|
|
33
|
+
- name: Run tests
|
|
34
|
+
run: python -m pytest tests/ -v --tb=short
|
|
35
|
+
- name: Run evaluation harness
|
|
36
|
+
run: python -m sentinelforge.cli evaluate
|
|
37
|
+
|
|
38
|
+
security:
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
needs: lint
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
- uses: actions/setup-python@v5
|
|
44
|
+
with:
|
|
45
|
+
python-version: "3.11"
|
|
46
|
+
- name: Install bandit
|
|
47
|
+
run: pip install bandit
|
|
48
|
+
- name: Run security scan
|
|
49
|
+
run: bandit -r src/sentinelforge/ -ll -ii --skip B101,B404,B603
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
packages: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.11"
|
|
20
|
+
cache: pip
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: pip install -e ".[all]"
|
|
23
|
+
- name: Run tests
|
|
24
|
+
run: python -m pytest tests/ -v --tb=short
|
|
25
|
+
- name: Run evaluation
|
|
26
|
+
run: python -m sentinelforge.cli evaluate
|
|
27
|
+
|
|
28
|
+
docker:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
needs: test
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- name: Set up Docker Buildx
|
|
34
|
+
uses: docker/setup-buildx-action@v3
|
|
35
|
+
- name: Log in to GHCR
|
|
36
|
+
uses: docker/login-action@v3
|
|
37
|
+
with:
|
|
38
|
+
registry: ghcr.io
|
|
39
|
+
username: ${{ github.actor }}
|
|
40
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
41
|
+
- name: Extract version from tag
|
|
42
|
+
id: version
|
|
43
|
+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
|
44
|
+
- name: Build and push Docker image
|
|
45
|
+
uses: docker/build-push-action@v5
|
|
46
|
+
with:
|
|
47
|
+
context: .
|
|
48
|
+
file: docker/Dockerfile
|
|
49
|
+
push: true
|
|
50
|
+
tags: |
|
|
51
|
+
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.VERSION }}
|
|
52
|
+
ghcr.io/${{ github.repository }}:latest
|
|
53
|
+
cache-from: type=gha
|
|
54
|
+
cache-to: type=gha,mode=max
|
|
55
|
+
|
|
56
|
+
github-release:
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
needs: [test, docker]
|
|
59
|
+
steps:
|
|
60
|
+
- uses: actions/checkout@v4
|
|
61
|
+
- name: Create GitHub Release
|
|
62
|
+
uses: softprops/action-gh-release@v2
|
|
63
|
+
with:
|
|
64
|
+
generate_release_notes: true
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.egg-info/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
.eggs/
|
|
8
|
+
*.egg
|
|
9
|
+
.venv/
|
|
10
|
+
venv/
|
|
11
|
+
env/
|
|
12
|
+
.env
|
|
13
|
+
*.env.local
|
|
14
|
+
*.env.production
|
|
15
|
+
|
|
16
|
+
# Logs
|
|
17
|
+
logs/
|
|
18
|
+
*.log
|
|
19
|
+
|
|
20
|
+
# Data (keep sample, ignore runtime)
|
|
21
|
+
data/vector_db/
|
|
22
|
+
data/audit.log
|
|
23
|
+
|
|
24
|
+
# IDE
|
|
25
|
+
.vscode/
|
|
26
|
+
.idea/
|
|
27
|
+
*.swp
|
|
28
|
+
*.swo
|
|
29
|
+
|
|
30
|
+
# OS
|
|
31
|
+
.DS_Store
|
|
32
|
+
Thumbs.db
|
|
33
|
+
|
|
34
|
+
# Docker
|
|
35
|
+
.docker/
|
|
36
|
+
|
|
37
|
+
# Test artifacts
|
|
38
|
+
.pytest_cache/
|
|
39
|
+
.coverage
|
|
40
|
+
htmlcov/
|
|
41
|
+
.mypy_cache/
|
|
42
|
+
.ruff_cache/
|
|
43
|
+
|
|
44
|
+
# Database runtime
|
|
45
|
+
data/*.db
|
|
46
|
+
data/*.db-wal
|
|
47
|
+
data/*.db-shm
|
|
48
|
+
|
|
49
|
+
# Secrets - never commit
|
|
50
|
+
*.pem
|
|
51
|
+
*.key
|
|
52
|
+
secrets/
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Contributing to SentinelForge
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing. SentinelForge is a security-critical project — contributions are welcome but must meet safety and quality standards.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/SageshAdhikari/SentinelForge.git
|
|
9
|
+
cd SentinelForge
|
|
10
|
+
make install # Linux/Mac
|
|
11
|
+
# .\scripts\setup_windows.ps1 # Windows
|
|
12
|
+
make test
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Development Workflow
|
|
16
|
+
|
|
17
|
+
1. Fork the repository
|
|
18
|
+
2. Create a feature branch (`git checkout -b feature/my-feature`)
|
|
19
|
+
3. Write tests for new functionality
|
|
20
|
+
4. Ensure all tests pass (`pytest tests/ -v`)
|
|
21
|
+
5. Run linting (`ruff check src/`)
|
|
22
|
+
6. Submit a pull request with a clear description
|
|
23
|
+
|
|
24
|
+
## Code Standards
|
|
25
|
+
|
|
26
|
+
- **Python 3.11+** required
|
|
27
|
+
- **Type hints** on all public functions
|
|
28
|
+
- **Pydantic models** for data validation
|
|
29
|
+
- **structlog** for logging (never `print()`)
|
|
30
|
+
- **ruff** for linting (config in `pyproject.toml`)
|
|
31
|
+
- Keep functions short and focused
|
|
32
|
+
|
|
33
|
+
## Security Requirements
|
|
34
|
+
|
|
35
|
+
Every contribution must follow these rules:
|
|
36
|
+
|
|
37
|
+
1. **Never introduce hardcoded secrets** — use environment variables or `.env`
|
|
38
|
+
2. **Never bypass the Guardian agent** — all actions must be validated
|
|
39
|
+
3. **Never add irreversible actions** without human approval gates
|
|
40
|
+
4. **Always sanitize user input** through the SafetyEngine
|
|
41
|
+
5. **Never log sensitive data** — use `redact()` from `core/secrets.py`
|
|
42
|
+
6. **Add tests** for any security-relevant code
|
|
43
|
+
7. **Keep the audit hash chain intact** — never modify the AuditLogger interface
|
|
44
|
+
|
|
45
|
+
## Adding a New Agent
|
|
46
|
+
|
|
47
|
+
1. Create `src/sentinelforge/agents/your_agent.py`
|
|
48
|
+
2. Extend `BaseAgent` and implement `async def run(self, state) -> OrchestratorState`
|
|
49
|
+
3. Register in `core/orchestrator.py`
|
|
50
|
+
4. Add tests in `tests/test_agents.py`
|
|
51
|
+
5. Update the README architecture diagram
|
|
52
|
+
|
|
53
|
+
## Adding a New Connector
|
|
54
|
+
|
|
55
|
+
1. Create a class extending the appropriate ABC in `connectors/`
|
|
56
|
+
2. Register it in the config system (`core/config.py`)
|
|
57
|
+
3. Add tests
|
|
58
|
+
4. Document in README
|
|
59
|
+
|
|
60
|
+
## Adding New Detection Signatures
|
|
61
|
+
|
|
62
|
+
1. Add to `ANOMALY_SIGNATURES` in `agents/monitor.py`
|
|
63
|
+
2. Include: regex pattern, severity, MITRE technique IDs, description
|
|
64
|
+
3. Add test cases
|
|
65
|
+
4. Add the MITRE technique to `MITRE_LABELS` in `dashboard/app.py`
|
|
66
|
+
|
|
67
|
+
## Testing
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Run all tests
|
|
71
|
+
pytest tests/ -v
|
|
72
|
+
|
|
73
|
+
# Run specific test file
|
|
74
|
+
pytest tests/test_safety.py -v
|
|
75
|
+
|
|
76
|
+
# Run evaluation harness
|
|
77
|
+
sentinelforge evaluate
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
All PRs must pass:
|
|
81
|
+
- All existing tests (currently 166+)
|
|
82
|
+
- All 3 evaluation scenarios (brute_force, ransomware, lateral_movement)
|
|
83
|
+
- Ruff linting with no errors
|
|
84
|
+
|
|
85
|
+
## Reporting Security Vulnerabilities
|
|
86
|
+
|
|
87
|
+
If you find a security vulnerability, **do not open a public issue**. Instead, email the maintainers directly. We will respond within 48 hours.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# SentinelForge Deployment Guide
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
- Python 3.11+
|
|
6
|
+
- Docker & Docker Compose (for containerized deployment)
|
|
7
|
+
- Ollama (optional, for local LLM inference)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Quick Start (Development)
|
|
12
|
+
|
|
13
|
+
### Windows
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
powershell -ExecutionPolicy Bypass -File scripts/setup_windows.ps1
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Linux / macOS
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
bash scripts/setup_linux.sh
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Manual Setup
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
python -m venv .venv
|
|
29
|
+
source .venv/bin/activate # Linux/macOS
|
|
30
|
+
# .venv\Scripts\activate # Windows
|
|
31
|
+
|
|
32
|
+
pip install -e ".[all]"
|
|
33
|
+
cp .env.example .env
|
|
34
|
+
# Edit .env with your configuration
|
|
35
|
+
|
|
36
|
+
mkdir -p data logs
|
|
37
|
+
|
|
38
|
+
# Run tests to verify
|
|
39
|
+
python -m pytest tests/ -q
|
|
40
|
+
|
|
41
|
+
# Run a simulation
|
|
42
|
+
sentinelforge run --scenario brute_force
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Docker Deployment
|
|
48
|
+
|
|
49
|
+
### Architecture
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
53
|
+
│ API Server │ │ Worker │ │ Dashboard │ │ Ollama │
|
|
54
|
+
│ :8000 │ │ (one-shot) │ │ :8501 │ │ :11434 │
|
|
55
|
+
│ FastAPI │ │ Defense │ │ Streamlit │ │ Local LLM │
|
|
56
|
+
│ │ │ Cycles │ │ │ │ │
|
|
57
|
+
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘
|
|
58
|
+
│ │ │ │
|
|
59
|
+
└─────────────────┴─────────────────┴─────────────────┘
|
|
60
|
+
sentinelforge-net (bridge)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Steps
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 1. Configure environment
|
|
67
|
+
cp .env.example .env
|
|
68
|
+
# Edit .env — set at minimum:
|
|
69
|
+
# SF_AUTH__JWT_SECRET (generate with: python -c "import secrets; print(secrets.token_hex(32))")
|
|
70
|
+
# SF_AUTH__DASHBOARD_PASSWORD
|
|
71
|
+
|
|
72
|
+
# 2. Build and start
|
|
73
|
+
docker compose build
|
|
74
|
+
docker compose up -d
|
|
75
|
+
|
|
76
|
+
# 3. (Optional) Pull Ollama model for LLM analysis
|
|
77
|
+
docker exec sentinelforge-ollama ollama pull llama3.1:8b
|
|
78
|
+
|
|
79
|
+
# 4. Verify
|
|
80
|
+
curl http://localhost:8000/health
|
|
81
|
+
# Open http://localhost:8501 for dashboard
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Services
|
|
85
|
+
|
|
86
|
+
| Service | Port | Purpose |
|
|
87
|
+
|---------|------|---------|
|
|
88
|
+
| sentinelforge-api | 8000 | REST API, event submission, defense cycles |
|
|
89
|
+
| sentinelforge-worker | - | Runs defense cycles (one-shot, restarts manually) |
|
|
90
|
+
| sentinelforge-dashboard | 8501 | Streamlit web UI |
|
|
91
|
+
| sentinelforge-ollama | 11434 (localhost only) | Local LLM inference |
|
|
92
|
+
|
|
93
|
+
### Volumes
|
|
94
|
+
|
|
95
|
+
| Volume | Purpose |
|
|
96
|
+
|--------|---------|
|
|
97
|
+
| sf-data | SQLite database, audit logs, vector DB |
|
|
98
|
+
| sf-logs | Application logs, alert logs |
|
|
99
|
+
| ollama-models | Downloaded LLM models |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Production Checklist
|
|
104
|
+
|
|
105
|
+
### Security
|
|
106
|
+
|
|
107
|
+
- [ ] Set a strong `SF_AUTH__JWT_SECRET` (64+ hex chars)
|
|
108
|
+
- [ ] Set `SF_AUTH__ENABLED=true`
|
|
109
|
+
- [ ] Change `SF_AUTH__DASHBOARD_PASSWORD` from default
|
|
110
|
+
- [ ] Set `SF_SIMULATION_MODE=true` initially, switch to `false` only after testing
|
|
111
|
+
- [ ] Review `configs/default.yaml` allowed/blocked action lists
|
|
112
|
+
- [ ] Restrict CORS origins to your dashboard domain
|
|
113
|
+
- [ ] Place the API behind a reverse proxy (nginx/Caddy) with TLS
|
|
114
|
+
|
|
115
|
+
### Monitoring
|
|
116
|
+
|
|
117
|
+
- [ ] Enable file alerts: `SF_ALERTS__FILE_ALERTS=true`
|
|
118
|
+
- [ ] Configure Slack webhooks: `SF_SLACK_WEBHOOK_URL=https://hooks.slack.com/...`
|
|
119
|
+
- [ ] Configure email alerts: set `SF_SMTP_*` variables
|
|
120
|
+
- [ ] Set up syslog forwarding: `SF_SYSLOG_HOST=your-siem.example.com`
|
|
121
|
+
- [ ] Verify audit chain periodically: `sentinelforge audit --verify`
|
|
122
|
+
|
|
123
|
+
### Infrastructure
|
|
124
|
+
|
|
125
|
+
- [ ] Back up `data/sentinelforge.db` and `data/audit.log` regularly
|
|
126
|
+
- [ ] Set up log rotation (Docker json-file driver handles this)
|
|
127
|
+
- [ ] Monitor container health: `docker compose ps`
|
|
128
|
+
- [ ] Set resource limits appropriate to your hardware
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## LLM Configuration
|
|
133
|
+
|
|
134
|
+
SentinelForge works in three modes:
|
|
135
|
+
|
|
136
|
+
### 1. Rule-Based (No LLM)
|
|
137
|
+
|
|
138
|
+
Default mode. No API keys needed. Uses pattern matching and heuristics.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
sentinelforge run --scenario brute_force
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 2. Local LLM (Ollama)
|
|
145
|
+
|
|
146
|
+
Private, no data leaves your network.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Install Ollama: https://ollama.com
|
|
150
|
+
ollama pull llama3.1:8b
|
|
151
|
+
|
|
152
|
+
# Set in .env:
|
|
153
|
+
SF_LLM__PROVIDER=ollama
|
|
154
|
+
SF_LLM__BASE_URL=http://localhost:11434
|
|
155
|
+
SF_LLM__MODEL=llama3.1:8b
|
|
156
|
+
|
|
157
|
+
sentinelforge run --scenario brute_force --llm
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### 3. Cloud LLM (Anthropic / OpenAI)
|
|
161
|
+
|
|
162
|
+
Higher quality analysis, requires API key.
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Anthropic
|
|
166
|
+
SF_LLM__PROVIDER=anthropic
|
|
167
|
+
SF_LLM__API_KEY=sk-ant-...
|
|
168
|
+
|
|
169
|
+
# OpenAI
|
|
170
|
+
SF_LLM__PROVIDER=openai
|
|
171
|
+
SF_LLM__API_KEY=sk-...
|
|
172
|
+
|
|
173
|
+
sentinelforge run --scenario brute_force --llm
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Auto-detection:** If `SF_LLM__PROVIDER` is not set, the system checks for `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and `OLLAMA_HOST` environment variables in order.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Alerting Configuration
|
|
181
|
+
|
|
182
|
+
### Slack
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
SF_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T00/B00/xxx
|
|
186
|
+
SF_SLACK_CHANNEL=#security-alerts
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Email (SMTP)
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
SF_SMTP_HOST=smtp.gmail.com
|
|
193
|
+
SF_SMTP_PORT=587
|
|
194
|
+
SF_SMTP_USER=alerts@example.com
|
|
195
|
+
SF_SMTP_PASSWORD=app-password
|
|
196
|
+
SF_SMTP_FROM=sentinelforge@example.com
|
|
197
|
+
SF_SMTP_TO=security-team@example.com
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Syslog (RFC 5424)
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
SF_SYSLOG_HOST=siem.example.com
|
|
204
|
+
SF_SYSLOG_PORT=514
|
|
205
|
+
SF_SYSLOG_PROTO=udp # or tcp
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## API Authentication
|
|
211
|
+
|
|
212
|
+
### Generate a JWT Secret
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
python -c "import secrets; print(secrets.token_hex(32))"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Login and Get Token
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
curl -X POST http://localhost:8000/api/v1/auth/login \
|
|
222
|
+
-H "Content-Type: application/json" \
|
|
223
|
+
-d '{"username": "admin", "password": "your-dashboard-password"}'
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Use the Token
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
curl -H "Authorization: Bearer <token>" \
|
|
230
|
+
http://localhost:8000/api/v1/audit
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Troubleshooting
|
|
236
|
+
|
|
237
|
+
### Tests Failing
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Reset singletons and run tests
|
|
241
|
+
python -m pytest tests/ -v --tb=short
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Database Issues
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# The database auto-creates on startup. To reset:
|
|
248
|
+
rm data/sentinelforge.db
|
|
249
|
+
sentinelforge run --scenario brute_force
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Audit Chain Broken
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
sentinelforge audit --verify
|
|
256
|
+
# If broken, the old log can be archived and a new chain starts
|
|
257
|
+
mv data/audit.log data/audit.log.bak
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Ollama Not Connecting
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Check Ollama is running
|
|
264
|
+
curl http://localhost:11434/api/tags
|
|
265
|
+
|
|
266
|
+
# In Docker, ensure the service name is used
|
|
267
|
+
SF_LLM__BASE_URL=http://ollama:11434
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Dashboard Not Loading
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# Check if Streamlit is installed
|
|
274
|
+
pip install streamlit plotly
|
|
275
|
+
|
|
276
|
+
# Run directly
|
|
277
|
+
python -m streamlit run src/sentinelforge/dashboard/app.py
|
|
278
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Disclaimer & Liability Notice
|
|
2
|
+
|
|
3
|
+
## Important Safety Warning
|
|
4
|
+
|
|
5
|
+
SentinelForge is an **AI-powered autonomous cyber defense framework** that can
|
|
6
|
+
execute real containment actions on live systems including:
|
|
7
|
+
|
|
8
|
+
- Blocking IP addresses via firewall rules
|
|
9
|
+
- Isolating hosts from the network
|
|
10
|
+
- Killing running processes
|
|
11
|
+
- Disabling user accounts
|
|
12
|
+
- Quarantining files
|
|
13
|
+
|
|
14
|
+
## Use at Your Own Risk
|
|
15
|
+
|
|
16
|
+
**BY USING THIS SOFTWARE, YOU ACKNOWLEDGE AND AGREE THAT:**
|
|
17
|
+
|
|
18
|
+
1. **No Warranty.** This software is provided "AS IS" without warranty of any
|
|
19
|
+
kind. The authors make no guarantees about the correctness, reliability, or
|
|
20
|
+
safety of any automated actions taken by this system.
|
|
21
|
+
|
|
22
|
+
2. **Potential for Damage.** Automated containment actions can disrupt
|
|
23
|
+
legitimate services, lock out authorized users, and cause data loss. Always
|
|
24
|
+
run in **simulation mode** first and thoroughly test in an isolated
|
|
25
|
+
environment before enabling real execution.
|
|
26
|
+
|
|
27
|
+
3. **Human Oversight Required.** This software is designed to assist human
|
|
28
|
+
security analysts, not replace them. Critical actions require human approval
|
|
29
|
+
by default. Disabling the approval workflow is done at your own risk.
|
|
30
|
+
|
|
31
|
+
4. **AI Limitations.** The LLM-powered analysis can produce incorrect
|
|
32
|
+
assessments, false positives, or miss real threats. Never rely solely on
|
|
33
|
+
automated analysis for critical security decisions.
|
|
34
|
+
|
|
35
|
+
5. **Compliance.** You are responsible for ensuring your use of this software
|
|
36
|
+
complies with all applicable laws, regulations, and organizational policies.
|
|
37
|
+
Automated IP blocking and account disabling may have legal implications in
|
|
38
|
+
your jurisdiction.
|
|
39
|
+
|
|
40
|
+
6. **No Liability.** The authors and contributors shall not be liable for any
|
|
41
|
+
direct, indirect, incidental, special, exemplary, or consequential damages
|
|
42
|
+
arising from the use of this software.
|
|
43
|
+
|
|
44
|
+
## Recommended Precautions
|
|
45
|
+
|
|
46
|
+
- Always start with `SIMULATION_MODE=true`
|
|
47
|
+
- Enable `CANARY_MODE=true` for dry-run previews before execution
|
|
48
|
+
- Set `REQUIRE_HUMAN_APPROVAL=true` for all critical actions
|
|
49
|
+
- Test in an isolated lab environment before any production deployment
|
|
50
|
+
- Maintain manual override access to all systems SentinelForge manages
|
|
51
|
+
- Keep audit logging enabled and review logs regularly
|
|
52
|
+
- Set up alerting (Slack/Email/Syslog) for immediate visibility
|
|
53
|
+
|
|
54
|
+
## Contact
|
|
55
|
+
|
|
56
|
+
For security vulnerabilities, please email: sageshadhikari@gmail.com
|
|
57
|
+
|
|
58
|
+
Do NOT open public issues for security vulnerabilities.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sagesh Adhikari
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|