Initial import from Proxmox host

This commit is contained in:
Hermes CT107
2026-06-12 17:59:34 +00:00
commit 74edd09eb8
20 changed files with 1595 additions and 0 deletions

23
src/opnsense_mcp/audit.py Normal file
View File

@@ -0,0 +1,23 @@
"""Append-only audit log for mutating operations."""
from __future__ import annotations
import json
from datetime import datetime, timezone
from pathlib import Path
from typing import Any
from opnsense_mcp.config import settings
def audit_log(action: str, details: dict[str, Any], *, dry_run: bool = False) -> None:
entry = {
"timestamp": datetime.now(timezone.utc).isoformat(),
"action": action,
"dry_run": dry_run,
**details,
}
path = Path(settings.audit_log_path)
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("a", encoding="utf-8") as fh:
fh.write(json.dumps(entry, default=str) + "\n")