chore: initial project setup with backend, frontend, CI/CD, and documentation
Add complete NexaFabric project structure including: - FastAPI backend with SQLAlchemy models, JWT auth, RBAC, audit logging, and provider interfaces - React + TypeScript frontend with Vite, Tailwind CSS, TanStack Query, and Zustand - Docker Compose configuration for PostgreSQL, Redis, API, worker, frontend, and nginx - GitHub Actions and GitLab CI workflows for testing, linting, building, and security scanning - Environment
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from typing import Any
|
||||
|
||||
from app.models.domain import Policy
|
||||
|
||||
|
||||
class PolicyEngine:
|
||||
def compile(self, policy: Policy) -> dict[str, Any]:
|
||||
definition = policy.definition or {}
|
||||
source = definition.get("source", "any")
|
||||
destination = definition.get("destination", "any")
|
||||
service = definition.get("service", {"protocol": "any", "ports": "any"})
|
||||
action = definition.get("action", "allow")
|
||||
direction = definition.get("direction", "ingress")
|
||||
|
||||
generated_rule = {
|
||||
"policy_id": policy.id,
|
||||
"policy_version": policy.version,
|
||||
"source": source,
|
||||
"destination": destination,
|
||||
"protocol": service.get("protocol", "any"),
|
||||
"ports": service.get("ports", "any"),
|
||||
"direction": direction,
|
||||
"action": action,
|
||||
"logging": bool(definition.get("logging", False)),
|
||||
"description": definition.get("description", policy.name),
|
||||
}
|
||||
|
||||
warnings = []
|
||||
if source == "any" and destination == "any":
|
||||
warnings.append("Policy targets all sources and destinations.")
|
||||
if action == "allow" and service.get("ports") == "any":
|
||||
warnings.append("Broad allow policy uses all ports.")
|
||||
|
||||
return {"rules": [generated_rule], "warnings": warnings, "conflicts": []}
|
||||
|
||||
Reference in New Issue
Block a user