a2a-source-edit: write agent.py
This commit is contained in:
62
agent.py
62
agent.py
@@ -263,6 +263,68 @@ class AgentComplianceAuditorConfig(StrictModel):
|
||||
default_allowed_namespaces: list[str] = Field(default_factory=list, max_length=50)
|
||||
|
||||
|
||||
def _tool_schema(kind: str) -> dict[str, Any]:
|
||||
request_schema: dict[str, Any] = {
|
||||
"type": "object",
|
||||
"additionalProperties": False,
|
||||
"properties": {
|
||||
"target": {
|
||||
"type": "object",
|
||||
"additionalProperties": False,
|
||||
"properties": {
|
||||
"agent_name": {"type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[a-z0-9][a-z0-9-]{0,127}$"},
|
||||
"agent_url": {"type": ["string", "null"], "format": "uri"},
|
||||
"repository": {"type": ["string", "null"], "maxLength": 256},
|
||||
"namespace": {"type": ["string", "null"], "maxLength": 128},
|
||||
"deployment": {"type": ["string", "null"], "maxLength": 128},
|
||||
},
|
||||
"required": ["agent_name"],
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"additionalProperties": False,
|
||||
"properties": {
|
||||
"audit_id": {"type": ["string", "null"], "maxLength": 80, "pattern": "^[A-Za-z0-9_.-]+$"},
|
||||
"max_files": {"type": "integer", "minimum": 0, "maximum": MAX_FILES_PER_AUDIT, "default": 40},
|
||||
"probe_mode": {"type": "string", "enum": ["none", "health_only", "synthetic"], "default": "health_only"},
|
||||
"include_repository": {"type": "boolean", "default": True},
|
||||
"include_runtime": {"type": "boolean", "default": True},
|
||||
"include_remediation": {"type": "boolean", "default": True},
|
||||
"allowed_hosts": {"type": "array", "items": {"type": "string"}, "maxItems": 20, "default": []},
|
||||
"allowed_namespaces": {"type": "array", "items": {"type": "string"}, "maxItems": 20, "default": []},
|
||||
},
|
||||
},
|
||||
},
|
||||
"required": ["target"],
|
||||
}
|
||||
if kind in {"configuration", "runtime", "risk"}:
|
||||
request_schema["properties"]["inventory"] = {"type": ["object", "null"], "additionalProperties": True}
|
||||
finding_schema = {
|
||||
"type": "object",
|
||||
"additionalProperties": False,
|
||||
"properties": {
|
||||
"id": {"type": "string"},
|
||||
"control_id": {"type": "string"},
|
||||
"title": {"type": "string"},
|
||||
"severity": {"type": "string", "enum": ["critical", "high", "medium", "low", "info"]},
|
||||
"confidence": {"type": "string", "enum": ["high", "medium", "low"]},
|
||||
"status": {"type": "string", "enum": ["open", "passed", "unknown", "not_tested"], "default": "open"},
|
||||
"evidence_refs": {"type": "array", "items": {"type": "string"}, "maxItems": 20, "default": []},
|
||||
"impact": {"type": "string"},
|
||||
"remediation": {"type": "string"},
|
||||
"verification_procedure": {"type": "string"},
|
||||
},
|
||||
"required": ["id", "control_id", "title", "severity", "confidence", "impact", "remediation", "verification_procedure"],
|
||||
}
|
||||
if kind == "risk":
|
||||
request_schema["properties"]["configuration_findings"] = {"type": "array", "items": finding_schema, "maxItems": MAX_FINDINGS, "default": []}
|
||||
request_schema["properties"]["runtime_findings"] = {"type": "array", "items": finding_schema, "maxItems": MAX_FINDINGS, "default": []}
|
||||
if kind == "remediation":
|
||||
request_schema["properties"]["findings"] = {"type": "array", "items": finding_schema, "maxItems": MAX_FINDINGS, "default": []}
|
||||
request_schema["properties"]["risk_summary"] = {"type": ["object", "null"], "additionalProperties": True}
|
||||
return {"type": "object", "additionalProperties": False, "properties": {"request": request_schema}, "required": ["request"]}
|
||||
|
||||
|
||||
class AgentComplianceAuditor(A2AAgent[AgentComplianceAuditorConfig, NoAuth]):
|
||||
name = "agent-compliance-auditor"
|
||||
description = (
|
||||
|
||||
Reference in New Issue
Block a user