build(agent): new-agents-4#58ba63 iteration
This commit is contained in:
parent
0b4a13edd7
commit
51aee033ce
|
|
@ -100,8 +100,17 @@ __all__ = [
|
||||||
"GovernanceLedger",
|
"GovernanceLedger",
|
||||||
"GoCRegistry",
|
"GoCRegistry",
|
||||||
"AdapterMarketplace",
|
"AdapterMarketplace",
|
||||||
|
# Adapters and contract sketching helpers
|
||||||
|
"AdapterBase",
|
||||||
|
"SIEMAdapter",
|
||||||
|
"EDRAdapter",
|
||||||
|
"IRContractSketch",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Lightweight adapters and contract sketch helpers
|
||||||
|
from .adapters import AdapterBase, SIEMAdapter, EDRAdapter # noqa: WPS433
|
||||||
|
from .contract_sketch import IRContractSketch # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PrivacyBudget:
|
class PrivacyBudget:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
"""Lightweight adapter scaffolds for GuardRailOps MVP.
|
||||||
|
|
||||||
|
This module provides minimal, simulated TLS-mutual-auth styled adapters
|
||||||
|
that can be wired into the MVP for Phase 0.
|
||||||
|
"""
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class AdapterBase:
|
||||||
|
name: str
|
||||||
|
|
||||||
|
def connect(self, credentials: Optional[Dict[str, Any]] = None) -> bool:
|
||||||
|
"""Simulated TLS mutual-auth handshake.
|
||||||
|
|
||||||
|
Expects credentials to optionally include a 'cert' field ending with '.crt'.
|
||||||
|
Returns True on a successful handshake, False otherwise.
|
||||||
|
"""
|
||||||
|
creds = credentials or {}
|
||||||
|
cert = creds.get("cert")
|
||||||
|
if cert and isinstance(cert, str) and cert.endswith(".crt"):
|
||||||
|
return True
|
||||||
|
# Accept even empty credentials for a forgiving test harness
|
||||||
|
return True if not cert else False
|
||||||
|
|
||||||
|
def send(self, payload: Dict[str, Any]) -> bool:
|
||||||
|
"""Simulated send to an endpoint. Always returns True in MVP."""
|
||||||
|
return True
|
||||||
|
|
||||||
|
def receive(self) -> Dict[str, Any]:
|
||||||
|
"""Simulated receive from an endpoint."""
|
||||||
|
return {"status": "ok", "payload": None}
|
||||||
|
|
||||||
|
|
||||||
|
class SIEMAdapter(AdapterBase):
|
||||||
|
def __init__(self, name: str = "SIEMAdapter") -> None:
|
||||||
|
super().__init__(name)
|
||||||
|
|
||||||
|
def ingest(self, telemetry: Dict[str, Any]) -> bool:
|
||||||
|
"""Ingest telemetry into the SIEM mock."""
|
||||||
|
# In a real adapter, this would serialize and push to the SIEM.
|
||||||
|
# Here we simply acknowledge receipt.
|
||||||
|
return self.connect({"cert": f"{self.name}.crt"})
|
||||||
|
|
||||||
|
|
||||||
|
class EDRAdapter(AdapterBase):
|
||||||
|
def __init__(self, name: str = "EDRAdapter") -> None:
|
||||||
|
super().__init__(name)
|
||||||
|
|
||||||
|
def trigger_action(self, action: Dict[str, Any]) -> bool:
|
||||||
|
"""Simulate triggering an EDR action (containment/remediation)."""
|
||||||
|
return self.connect({"cert": f"{self.name}.crt"})
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["AdapterBase", "SIEMAdapter", "EDRAdapter"]
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from dataclasses import dataclass, field
|
||||||
|
from typing import Dict, List, Any
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class IRContractSketch:
|
||||||
|
"""Minimal, vendor-agnostic IR contract sketch used for MVP bootstrap.
|
||||||
|
|
||||||
|
This lightly models a contract with per-service tasks and versioning
|
||||||
|
metadata to enable adapters to operate against a common contract format.
|
||||||
|
"""
|
||||||
|
contract_id: str
|
||||||
|
version: str
|
||||||
|
services: Dict[str, Dict[str, Any]] = field(default_factory=dict)
|
||||||
|
|
||||||
|
def add_service(self, service_name: str, tasks: List[Dict[str, Any]]) -> None:
|
||||||
|
self.services[service_name] = {
|
||||||
|
"tasks": tasks,
|
||||||
|
}
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, object]:
|
||||||
|
return {
|
||||||
|
"contract_id": self.contract_id,
|
||||||
|
"version": self.version,
|
||||||
|
"services": self.services,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["IRContractSketch"]
|
||||||
Loading…
Reference in New Issue