actshield 0.9.0__py3-none-any.whl
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.
- actshield/__init__.py +439 -0
- actshield/__main__.py +46 -0
- actshield/agents/__init__.py +12 -0
- actshield/agents/agent.py +200 -0
- actshield/agents/identity.py +114 -0
- actshield/api/__init__.py +34 -0
- actshield/api/models.py +198 -0
- actshield/api/server.py +669 -0
- actshield/api/service.py +599 -0
- actshield/approval/__init__.py +15 -0
- actshield/approval/approval.py +164 -0
- actshield/cli/__init__.py +8 -0
- actshield/cli/graph.py +49 -0
- actshield/cli/main.py +802 -0
- actshield/cli/shell.py +406 -0
- actshield/cli/theme.py +110 -0
- actshield/client.py +757 -0
- actshield/config.py +88 -0
- actshield/context/__init__.py +14 -0
- actshield/context/context.py +161 -0
- actshield/context/provenance.py +108 -0
- actshield/context/taint.py +48 -0
- actshield/decisions/decision.py +74 -0
- actshield/delegation/__init__.py +11 -0
- actshield/delegation/authority.py +63 -0
- actshield/delegation/delegation.py +180 -0
- actshield/demo.py +139 -0
- actshield/doctor.py +94 -0
- actshield/drift/__init__.py +27 -0
- actshield/drift/drift_engine.py +149 -0
- actshield/drift/drift_models.py +63 -0
- actshield/evaluation/__init__.py +1 -0
- actshield/evaluation/cases/__init__.py +1 -0
- actshield/evaluation/eval_suite.py +254 -0
- actshield/forensics/__init__.py +53 -0
- actshield/forensics/access_graph.py +216 -0
- actshield/forensics/authority_graph.py +186 -0
- actshield/forensics/delegation_graph.py +119 -0
- actshield/forensics/explanation.py +254 -0
- actshield/forensics/models.py +488 -0
- actshield/forensics/queries.py +367 -0
- actshield/forensics/serializers.py +68 -0
- actshield/forensics/service.py +310 -0
- actshield/forensics/snapshots.py +174 -0
- actshield/gates/__init__.py +13 -0
- actshield/gates/gate_models.py +46 -0
- actshield/gates/security_gate.py +191 -0
- actshield/gateway/__init__.py +13 -0
- actshield/gateway/http.py +191 -0
- actshield/gateway/mcp.py +292 -0
- actshield/incidents/__init__.py +25 -0
- actshield/incidents/incident.py +94 -0
- actshield/incidents/incident_engine.py +163 -0
- actshield/incidents/incident_rules.py +116 -0
- actshield/incidents/incident_state.py +58 -0
- actshield/integrations/__init__.py +24 -0
- actshield/integrations/ai_secura.py +169 -0
- actshield/integrations/ai_secura_analysis.py +236 -0
- actshield/integrations/apiris.py +122 -0
- actshield/integrations/few_shot.py +104 -0
- actshield/integrations/ollama_adapter.py +538 -0
- actshield/integrations/prompts/__init__.py +1 -0
- actshield/integrations/prompts/examples/__init__.py +1 -0
- actshield/integrations/security_packet.py +82 -0
- actshield/llm_config.py +89 -0
- actshield/offensive/__init__.py +95 -0
- actshield/offensive/adaptive/__init__.py +22 -0
- actshield/offensive/adaptive/adaptive_engine.py +165 -0
- actshield/offensive/adaptive/attack_selector.py +51 -0
- actshield/offensive/adaptive/boundary_search.py +99 -0
- actshield/offensive/adaptive/campaign_memory.py +123 -0
- actshield/offensive/adaptive/feedback.py +84 -0
- actshield/offensive/adaptive/mutation_planner.py +57 -0
- actshield/offensive/attack.py +78 -0
- actshield/offensive/campaign.py +219 -0
- actshield/offensive/corpus.py +155 -0
- actshield/offensive/engine.py +466 -0
- actshield/offensive/evaluator.py +116 -0
- actshield/offensive/evidence.py +63 -0
- actshield/offensive/generator.py +128 -0
- actshield/offensive/mutation.py +101 -0
- actshield/offensive/results.py +77 -0
- actshield/offensive/safety.py +80 -0
- actshield/offensive/strategies/__init__.py +22 -0
- actshield/offensive/strategies/authority_escalation.py +100 -0
- actshield/offensive/strategies/base.py +34 -0
- actshield/offensive/strategies/context_manipulation.py +100 -0
- actshield/offensive/strategies/data_exfiltration.py +100 -0
- actshield/offensive/strategies/delegation_attacks.py +100 -0
- actshield/offensive/strategies/mcp_attacks.py +100 -0
- actshield/offensive/strategies/prompt_injection.py +100 -0
- actshield/offensive/strategies/tool_poisoning.py +100 -0
- actshield/offensive/target.py +113 -0
- actshield/offensive/vulnerable_target.py +121 -0
- actshield/persistence/__init__.py +18 -0
- actshield/persistence/siem.py +102 -0
- actshield/persistence/storage.py +240 -0
- actshield/policy/__init__.py +12 -0
- actshield/policy/evaluator.py +294 -0
- actshield/policy/intent.py +113 -0
- actshield/policy/policy.py +48 -0
- actshield/posture/__init__.py +26 -0
- actshield/posture/posture_engine.py +186 -0
- actshield/posture/posture_models.py +152 -0
- actshield/posture/posture_rules.py +137 -0
- actshield/providers/__init__.py +32 -0
- actshield/providers/anthropic_provider.py +146 -0
- actshield/providers/base.py +160 -0
- actshield/providers/gemini_provider.py +133 -0
- actshield/providers/null_provider.py +40 -0
- actshield/providers/ollama_provider.py +135 -0
- actshield/providers/openai_provider.py +142 -0
- actshield/providers/registry.py +244 -0
- actshield/py.typed +0 -0
- actshield/response/__init__.py +14 -0
- actshield/response/response_actions.py +39 -0
- actshield/response/response_audit.py +32 -0
- actshield/response/response_engine.py +139 -0
- actshield/risk/models.py +104 -0
- actshield/serve.py +117 -0
- actshield/static/404.html +1 -0
- actshield/static/__next.__PAGE__.txt +24 -0
- actshield/static/__next._full.txt +20 -0
- actshield/static/__next._tree.txt +4 -0
- actshield/static/_next/static/Yp_swxN-C9UoCRNOwkYnY/_buildManifest.js +11 -0
- actshield/static/_next/static/Yp_swxN-C9UoCRNOwkYnY/_clientMiddlewareManifest.js +1 -0
- actshield/static/_next/static/Yp_swxN-C9UoCRNOwkYnY/_ssgManifest.js +1 -0
- actshield/static/_next/static/chunks/09kny2eqjc2or.js +1 -0
- actshield/static/_next/static/chunks/0c1zba1u9whdp.js +1 -0
- actshield/static/_next/static/chunks/0cz1d0mv5g_q7.js +1 -0
- actshield/static/_next/static/chunks/0dbjjeg01x25o.js +1 -0
- actshield/static/_next/static/chunks/0duobs55ne238.js +1 -0
- actshield/static/_next/static/chunks/0iaz41l6068e4.js +1 -0
- actshield/static/_next/static/chunks/0mjhyv72x2idp.js +1 -0
- actshield/static/_next/static/chunks/0nelpqfu_ciq6.js +1 -0
- actshield/static/_next/static/chunks/0p1bci9ch797v.js +1 -0
- actshield/static/_next/static/chunks/0tld_ygho5tgm.js +1 -0
- actshield/static/_next/static/chunks/0w1-y7oni66j9.js +1 -0
- actshield/static/_next/static/chunks/10537zyl427zj.js +1 -0
- actshield/static/_next/static/chunks/11pc_jkl3aggn.js +1 -0
- actshield/static/_next/static/chunks/16k7nw0b3t8ys.js +1 -0
- actshield/static/_next/static/chunks/19mx3mg6lkumu.js +1 -0
- actshield/static/_next/static/chunks/1_8p47b-kxg2a.js +1 -0
- actshield/static/_next/static/chunks/1dszjozwfqegx.js +1 -0
- actshield/static/_next/static/chunks/1h43jcb90-m2r.js +22 -0
- actshield/static/_next/static/chunks/1ly04cvt_wh_j.js +1 -0
- actshield/static/_next/static/chunks/1odxrypuwuwp_.js +1 -0
- actshield/static/_next/static/chunks/1oes4c35qz5ku.js +1 -0
- actshield/static/_next/static/chunks/1ow883jl4ln-r.js +16 -0
- actshield/static/_next/static/chunks/1po7bna1as8tc.js +1 -0
- actshield/static/_next/static/chunks/1rsh0og8ifkzx.js +1 -0
- actshield/static/_next/static/chunks/1v0lwzv-859z_.js +1 -0
- actshield/static/_next/static/chunks/25iat2epwx25a.js +1 -0
- actshield/static/_next/static/chunks/25uvt4s2f39a4.js +1 -0
- actshield/static/_next/static/chunks/27t_qfc-3_lzs.js +1 -0
- actshield/static/_next/static/chunks/28bkmy8mez7gm.js +1 -0
- actshield/static/_next/static/chunks/2b6brmw_drw1p.js +1 -0
- actshield/static/_next/static/chunks/2fnhtxi4j6vge.js +1 -0
- actshield/static/_next/static/chunks/2p087eftxemg4.js +6 -0
- actshield/static/_next/static/chunks/2s8pao_z8pgtq.js +1 -0
- actshield/static/_next/static/chunks/2yj7ooc2c-zpg.js +1 -0
- actshield/static/_next/static/chunks/3-mrrr8udt5tk.js +1 -0
- actshield/static/_next/static/chunks/310vm2bl3xxpt.js +31 -0
- actshield/static/_next/static/chunks/35mvsv251jx1r.css +3 -0
- actshield/static/_next/static/chunks/370vf0oetlsx9.js +1 -0
- actshield/static/_next/static/chunks/3e-2m72tyo556.js +1 -0
- actshield/static/_next/static/chunks/3fntmmi971322.js +1 -0
- actshield/static/_next/static/chunks/3fzw-g0hycl2c.js +1 -0
- actshield/static/_next/static/chunks/3lopq3lhmcjxg.js +129 -0
- actshield/static/_next/static/chunks/3mpe2jejel0v2.css +1 -0
- actshield/static/_next/static/chunks/3t8o4f2lzr2sf.js +1 -0
- actshield/static/_next/static/chunks/3y-v1neyllne5.js +1 -0
- actshield/static/_next/static/chunks/43oiwy8mx6cs1.js +1 -0
- actshield/static/_next/static/chunks/turbopack-23wzuebcy_lxm.js +1 -0
- actshield/static/_next/static/media/1bffadaabf893a1e-s.3-6t-g6q0vh0a.woff2 +0 -0
- actshield/static/_next/static/media/2bbe8d2671613f1f-s.0k62hbripvv8p.woff2 +0 -0
- actshield/static/_next/static/media/2c55a0e60120577a-s.0-dom-5bn10r2.woff2 +0 -0
- actshield/static/_next/static/media/5476f68d60460930-s.2uwcyprjm3xu3.woff2 +0 -0
- actshield/static/_next/static/media/83afe278b6a6bb3c-s.p.2bn3s6zvc0dyp.woff2 +0 -0
- actshield/static/_next/static/media/9c72aa0f40e4eef8-s.1y4-pdgsjb-pw.woff2 +0 -0
- actshield/static/_next/static/media/ad66f9afd8947f86-s.3lvt2whj97whp.woff2 +0 -0
- actshield/static/_next/static/media/favicon.2vob68tjqpejf.ico +0 -0
- actshield/static/_not-found/__next._full.txt +17 -0
- actshield/static/_not-found/__next._not-found/__PAGE__.txt +23 -0
- actshield/static/_not-found/__next._tree.txt +3 -0
- actshield/static/_not-found.html +1 -0
- actshield/static/_not-found.txt +17 -0
- actshield/static/access/matrix/__next._full.txt +24 -0
- actshield/static/access/matrix/__next._tree.txt +4 -0
- actshield/static/access/matrix/__next.access/matrix/__PAGE__.txt +30 -0
- actshield/static/access/matrix.html +1 -0
- actshield/static/access/matrix.txt +24 -0
- actshield/static/activity/__next._full.txt +22 -0
- actshield/static/activity/__next._tree.txt +4 -0
- actshield/static/activity/__next.activity/__PAGE__.txt +27 -0
- actshield/static/activity.html +1 -0
- actshield/static/activity.txt +22 -0
- actshield/static/agents/__next._full.txt +22 -0
- actshield/static/agents/__next._tree.txt +4 -0
- actshield/static/agents/__next.agents/__PAGE__.txt +27 -0
- actshield/static/agents.html +1 -0
- actshield/static/agents.txt +22 -0
- actshield/static/ai-secura/__next._full.txt +22 -0
- actshield/static/ai-secura/__next._tree.txt +4 -0
- actshield/static/ai-secura/__next.ai-secura/__PAGE__.txt +27 -0
- actshield/static/ai-secura.html +1 -0
- actshield/static/ai-secura.txt +22 -0
- actshield/static/api/__next._full.txt +22 -0
- actshield/static/api/__next._tree.txt +4 -0
- actshield/static/api/__next.api/__PAGE__.txt +27 -0
- actshield/static/api.html +15 -0
- actshield/static/api.txt +22 -0
- actshield/static/apiris/__next._full.txt +22 -0
- actshield/static/apiris/__next._tree.txt +4 -0
- actshield/static/apiris/__next.apiris/__PAGE__.txt +27 -0
- actshield/static/apiris.html +1 -0
- actshield/static/apiris.txt +22 -0
- actshield/static/attack-graph/__next._full.txt +23 -0
- actshield/static/attack-graph/__next._tree.txt +5 -0
- actshield/static/attack-graph/__next.attack-graph/__PAGE__.txt +28 -0
- actshield/static/attack-graph.html +2 -0
- actshield/static/attack-graph.txt +23 -0
- actshield/static/campaigns/__next._full.txt +22 -0
- actshield/static/campaigns/__next._tree.txt +4 -0
- actshield/static/campaigns/__next.campaigns/__PAGE__.txt +27 -0
- actshield/static/campaigns.html +1 -0
- actshield/static/campaigns.txt +22 -0
- actshield/static/context/__next._full.txt +22 -0
- actshield/static/context/__next._tree.txt +4 -0
- actshield/static/context/__next.context/__PAGE__.txt +27 -0
- actshield/static/context.html +1 -0
- actshield/static/context.txt +22 -0
- actshield/static/dashboard/__next._full.txt +22 -0
- actshield/static/dashboard/__next._tree.txt +4 -0
- actshield/static/dashboard/__next.dashboard/__PAGE__.txt +27 -0
- actshield/static/dashboard.html +1 -0
- actshield/static/dashboard.txt +22 -0
- actshield/static/delegations/__next._full.txt +22 -0
- actshield/static/delegations/__next._tree.txt +4 -0
- actshield/static/delegations/__next.delegations/__PAGE__.txt +27 -0
- actshield/static/delegations.html +1 -0
- actshield/static/delegations.txt +22 -0
- actshield/static/demo/__next._full.txt +22 -0
- actshield/static/demo/__next._tree.txt +4 -0
- actshield/static/demo/__next.demo/__PAGE__.txt +27 -0
- actshield/static/demo.html +1 -0
- actshield/static/demo.txt +22 -0
- actshield/static/drift/__next._full.txt +22 -0
- actshield/static/drift/__next._tree.txt +4 -0
- actshield/static/drift/__next.drift/__PAGE__.txt +27 -0
- actshield/static/drift.html +1 -0
- actshield/static/drift.txt +22 -0
- actshield/static/favicon.ico +0 -0
- actshield/static/file.svg +1 -0
- actshield/static/forensics/__next._full.txt +22 -0
- actshield/static/forensics/__next._tree.txt +4 -0
- actshield/static/forensics/__next.forensics/__PAGE__.txt +27 -0
- actshield/static/forensics.html +1 -0
- actshield/static/forensics.txt +22 -0
- actshield/static/globe.svg +1 -0
- actshield/static/incidents/__next._full.txt +22 -0
- actshield/static/incidents/__next._tree.txt +4 -0
- actshield/static/incidents/__next.incidents/__PAGE__.txt +27 -0
- actshield/static/incidents.html +1 -0
- actshield/static/incidents.txt +22 -0
- actshield/static/index.html +3 -0
- actshield/static/index.txt +20 -0
- actshield/static/logo.png +0 -0
- actshield/static/metrics/__next._full.txt +22 -0
- actshield/static/metrics/__next._tree.txt +4 -0
- actshield/static/metrics/__next.metrics/__PAGE__.txt +27 -0
- actshield/static/metrics.html +1 -0
- actshield/static/metrics.txt +22 -0
- actshield/static/next.svg +1 -0
- actshield/static/offensive/__next._full.txt +22 -0
- actshield/static/offensive/__next._tree.txt +4 -0
- actshield/static/offensive/__next.offensive/__PAGE__.txt +27 -0
- actshield/static/offensive.html +1 -0
- actshield/static/offensive.txt +22 -0
- actshield/static/policies/__next._full.txt +22 -0
- actshield/static/policies/__next._tree.txt +4 -0
- actshield/static/policies/__next.policies/__PAGE__.txt +27 -0
- actshield/static/policies.html +1 -0
- actshield/static/policies.txt +22 -0
- actshield/static/posture/__next._full.txt +22 -0
- actshield/static/posture/__next._tree.txt +4 -0
- actshield/static/posture/__next.posture/__PAGE__.txt +27 -0
- actshield/static/posture.html +1 -0
- actshield/static/posture.txt +22 -0
- actshield/static/regressions/__next._full.txt +22 -0
- actshield/static/regressions/__next._tree.txt +4 -0
- actshield/static/regressions/__next.regressions/__PAGE__.txt +27 -0
- actshield/static/regressions.html +1 -0
- actshield/static/regressions.txt +22 -0
- actshield/static/reports/__next._full.txt +22 -0
- actshield/static/reports/__next._tree.txt +4 -0
- actshield/static/reports/__next.reports/__PAGE__.txt +27 -0
- actshield/static/reports.html +1 -0
- actshield/static/reports.txt +22 -0
- actshield/static/resources/__next._full.txt +22 -0
- actshield/static/resources/__next._tree.txt +4 -0
- actshield/static/resources/__next.resources/__PAGE__.txt +27 -0
- actshield/static/resources.html +1 -0
- actshield/static/resources.txt +22 -0
- actshield/static/security-gates/__next._full.txt +22 -0
- actshield/static/security-gates/__next._tree.txt +4 -0
- actshield/static/security-gates/__next.security-gates/__PAGE__.txt +27 -0
- actshield/static/security-gates.html +1 -0
- actshield/static/security-gates.txt +22 -0
- actshield/static/settings/__next._full.txt +22 -0
- actshield/static/settings/__next._tree.txt +4 -0
- actshield/static/settings/__next.settings/__PAGE__.txt +27 -0
- actshield/static/settings.html +1 -0
- actshield/static/settings.txt +22 -0
- actshield/static/tasks/__next._full.txt +22 -0
- actshield/static/tasks/__next._tree.txt +4 -0
- actshield/static/tasks/__next.tasks/__PAGE__.txt +27 -0
- actshield/static/tasks.html +1 -0
- actshield/static/tasks.txt +22 -0
- actshield/static/threats/__next._full.txt +22 -0
- actshield/static/threats/__next._tree.txt +4 -0
- actshield/static/threats/__next.threats/__PAGE__.txt +27 -0
- actshield/static/threats.html +1 -0
- actshield/static/threats.txt +22 -0
- actshield/static/tools/__next._full.txt +22 -0
- actshield/static/tools/__next._tree.txt +4 -0
- actshield/static/tools/__next.tools/__PAGE__.txt +27 -0
- actshield/static/tools.html +1 -0
- actshield/static/tools.txt +22 -0
- actshield/static/traces/__next._full.txt +22 -0
- actshield/static/traces/__next._tree.txt +4 -0
- actshield/static/traces/__next.traces/__PAGE__.txt +27 -0
- actshield/static/traces.html +1 -0
- actshield/static/traces.txt +22 -0
- actshield/static/vercel.svg +1 -0
- actshield/static/window.svg +1 -0
- actshield/tasks/__init__.py +6 -0
- actshield/tasks/task.py +143 -0
- actshield/threatmodel/__init__.py +70 -0
- actshield/threatmodel/actors.py +210 -0
- actshield/threatmodel/analyzer.py +131 -0
- actshield/threatmodel/assets.py +167 -0
- actshield/threatmodel/boundaries.py +165 -0
- actshield/threatmodel/exporters.py +49 -0
- actshield/threatmodel/mitigations.py +209 -0
- actshield/threatmodel/models.py +80 -0
- actshield/threatmodel/report.py +341 -0
- actshield/threatmodel/scenarios.py +212 -0
- actshield/threatmodel/scoring.py +66 -0
- actshield/threatmodel/threats.py +387 -0
- actshield/tools/__init__.py +20 -0
- actshield/tools/interceptor.py +256 -0
- actshield/tools/tool.py +71 -0
- actshield/tracing/__init__.py +38 -0
- actshield/tracing/correlation.py +173 -0
- actshield/tracing/events.py +75 -0
- actshield/tracing/tracer.py +305 -0
- actshield/watch.py +129 -0
- actshield-0.9.0.dist-info/METADATA +57 -0
- actshield-0.9.0.dist-info/RECORD +366 -0
- actshield-0.9.0.dist-info/WHEEL +5 -0
- actshield-0.9.0.dist-info/entry_points.txt +4 -0
- actshield-0.9.0.dist-info/top_level.txt +2 -0
- agentguard/__init__.py +39 -0
- agentguard/__main__.py +8 -0
- agentguard/py.typed +1 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""Agent identity and capability definitions."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any, Dict, List, Optional, Union
|
|
5
|
+
from pydantic import BaseModel, Field, field_validator
|
|
6
|
+
|
|
7
|
+
from actshield.tracing.correlation import generate_id
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AgentTrustLevel(str, Enum):
|
|
11
|
+
"""Standardized agent trust levels."""
|
|
12
|
+
HIGH = "high"
|
|
13
|
+
MEDIUM = "medium"
|
|
14
|
+
LOW = "low"
|
|
15
|
+
UNTRUSTED = "untrusted"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AgentStatus(str, Enum):
|
|
19
|
+
"""Standardized agent operational and security lifecycle statuses."""
|
|
20
|
+
STARTING = "starting"
|
|
21
|
+
ACTIVE = "active"
|
|
22
|
+
IDLE = "idle"
|
|
23
|
+
BLOCKED = "blocked"
|
|
24
|
+
QUARANTINED = "quarantined"
|
|
25
|
+
REVOKED = "revoked"
|
|
26
|
+
OFFLINE = "offline"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class AgentCapability(BaseModel):
|
|
30
|
+
"""Specific permission or functional capability possessed or granted to an agent."""
|
|
31
|
+
name: str = Field(..., description="Canonical capability name (e.g., 'public_search', 'database_read')")
|
|
32
|
+
description: Optional[str] = Field(default=None, description="Description of the capability")
|
|
33
|
+
scope: Optional[str] = Field(default=None, description="Resource scope limitation (e.g. 'domain:finance')")
|
|
34
|
+
sensitivity: Optional[str] = Field(default=None, description="Sensitivity classification")
|
|
35
|
+
|
|
36
|
+
def matches(self, required_capability: str) -> bool:
|
|
37
|
+
"""Check if this capability satisfies a required capability name or pattern."""
|
|
38
|
+
if self.name == required_capability or self.name == "*":
|
|
39
|
+
return True
|
|
40
|
+
if self.name.endswith(".*") and required_capability.startswith(self.name[:-2]):
|
|
41
|
+
return True
|
|
42
|
+
return False
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class AgentIdentity(BaseModel):
|
|
46
|
+
"""Identity record for an AI agent registered in actshield."""
|
|
47
|
+
|
|
48
|
+
agent_id: str = Field(default_factory=lambda: generate_id("agt"), description="Unique agent identifier")
|
|
49
|
+
name: str = Field(..., description="Human-readable agent name")
|
|
50
|
+
framework: str = Field(default="custom", description="Framework name (e.g., 'langchain', 'autogen', 'crewai', 'custom')")
|
|
51
|
+
version: str = Field(default="1.0.0", description="Agent implementation version")
|
|
52
|
+
status: AgentStatus = Field(
|
|
53
|
+
default=AgentStatus.ACTIVE,
|
|
54
|
+
description="Current lifecycle and security status of the agent"
|
|
55
|
+
)
|
|
56
|
+
trust_level: AgentTrustLevel = Field(
|
|
57
|
+
default=AgentTrustLevel.MEDIUM,
|
|
58
|
+
description="Assigned baseline trust level"
|
|
59
|
+
)
|
|
60
|
+
capabilities: List[AgentCapability] = Field(
|
|
61
|
+
default_factory=list,
|
|
62
|
+
description="Declared capabilities of this agent"
|
|
63
|
+
)
|
|
64
|
+
parent_agent_id: Optional[str] = Field(
|
|
65
|
+
default=None,
|
|
66
|
+
description="Parent orchestrator or delegating agent ID if hierarchical"
|
|
67
|
+
)
|
|
68
|
+
owner_context: Optional[str] = Field(
|
|
69
|
+
default=None,
|
|
70
|
+
description="Owning execution context or session identifier"
|
|
71
|
+
)
|
|
72
|
+
current_task: Optional[str] = Field(
|
|
73
|
+
default=None,
|
|
74
|
+
description="Active task description or task ID being executed"
|
|
75
|
+
)
|
|
76
|
+
created_at: Optional[str] = Field(
|
|
77
|
+
default=None,
|
|
78
|
+
description="Agent registration timestamp (ISO-8601 string)"
|
|
79
|
+
)
|
|
80
|
+
last_seen: Optional[str] = Field(
|
|
81
|
+
default=None,
|
|
82
|
+
description="Most recent activity timestamp (ISO-8601 string)"
|
|
83
|
+
)
|
|
84
|
+
metadata: Dict[str, Any] = Field(
|
|
85
|
+
default_factory=dict,
|
|
86
|
+
description="Additional identity metadata, tags, or deployment labels"
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
@field_validator("capabilities", mode="before")
|
|
90
|
+
@classmethod
|
|
91
|
+
def parse_capabilities(cls, v: Any) -> List[AgentCapability]:
|
|
92
|
+
"""Allow passing strings or dicts as capabilities."""
|
|
93
|
+
if not v:
|
|
94
|
+
return []
|
|
95
|
+
parsed = []
|
|
96
|
+
for item in v:
|
|
97
|
+
if isinstance(item, str):
|
|
98
|
+
parsed.append(AgentCapability(name=item))
|
|
99
|
+
elif isinstance(item, dict):
|
|
100
|
+
parsed.append(AgentCapability(**item))
|
|
101
|
+
elif isinstance(item, AgentCapability):
|
|
102
|
+
parsed.append(item)
|
|
103
|
+
else:
|
|
104
|
+
raise ValueError(f"Invalid capability format: {item}")
|
|
105
|
+
return parsed
|
|
106
|
+
|
|
107
|
+
def has_capability(self, capability_name: str) -> bool:
|
|
108
|
+
"""Verify whether this identity possesses a specified capability."""
|
|
109
|
+
return any(cap.matches(capability_name) for cap in self.capabilities)
|
|
110
|
+
|
|
111
|
+
def capability_names(self) -> List[str]:
|
|
112
|
+
"""Return list of string capability names."""
|
|
113
|
+
return [c.name for c in self.capabilities]
|
|
114
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""ActShield Unified Product API — FastAPI routes for dashboard consumption.
|
|
2
|
+
|
|
3
|
+
Provides clean JSON endpoints that the future React dashboard can consume
|
|
4
|
+
without importing any ActShield Python internals.
|
|
5
|
+
|
|
6
|
+
Architecture:
|
|
7
|
+
ForensicService → ForensicQueryEngine → API routes → JSON responses
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from actshield.api.service import ApiService
|
|
11
|
+
from actshield.api.models import (
|
|
12
|
+
AgentAccessResponse,
|
|
13
|
+
ResourceAccessResponse,
|
|
14
|
+
AccessMatrixResponse,
|
|
15
|
+
OverviewResponse,
|
|
16
|
+
AttackForensicsResponse,
|
|
17
|
+
IncidentResponse,
|
|
18
|
+
ErrorResponse,
|
|
19
|
+
HealthResponse,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"ApiService",
|
|
24
|
+
"AgentAccessResponse",
|
|
25
|
+
"ResourceAccessResponse",
|
|
26
|
+
"AccessMatrixResponse",
|
|
27
|
+
"OverviewResponse",
|
|
28
|
+
"AttackForensicsResponse",
|
|
29
|
+
"IncidentResponse",
|
|
30
|
+
"ErrorResponse",
|
|
31
|
+
"HealthResponse",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
|
actshield/api/models.py
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"""Clean API response models — dashboard-ready JSON shapes.
|
|
2
|
+
|
|
3
|
+
The dashboard NEVER needs to understand internal Python classes.
|
|
4
|
+
These models define the stable JSON contract consumed by the React dashboard.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from datetime import datetime, timezone
|
|
10
|
+
from typing import Any, Dict, List, Optional
|
|
11
|
+
from pydantic import BaseModel, Field
|
|
12
|
+
|
|
13
|
+
from actshield.tracing.correlation import generate_id
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class HealthResponse(BaseModel):
|
|
17
|
+
status: str = "ok"
|
|
18
|
+
version: str = "1.0.0"
|
|
19
|
+
timestamp: str = Field(
|
|
20
|
+
default_factory=lambda: datetime.now(timezone.utc).isoformat()
|
|
21
|
+
)
|
|
22
|
+
components: Dict[str, str] = Field(default_factory=dict)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ErrorResponse(BaseModel):
|
|
26
|
+
error: Dict[str, str]
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def make(
|
|
30
|
+
cls, code: str, message: str, request_id: Optional[str] = None
|
|
31
|
+
) -> "ErrorResponse":
|
|
32
|
+
return cls(
|
|
33
|
+
error={
|
|
34
|
+
"code": code,
|
|
35
|
+
"message": message,
|
|
36
|
+
"request_id": request_id or generate_id("req"),
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class OverviewResponse(BaseModel):
|
|
42
|
+
agents: Optional[int] = None
|
|
43
|
+
active_tasks: Optional[int] = None
|
|
44
|
+
protected_tools: Optional[int] = None
|
|
45
|
+
mcp_servers: Optional[int] = None
|
|
46
|
+
attacks_today: Optional[int] = None
|
|
47
|
+
blocked: Optional[int] = None
|
|
48
|
+
hitl: Optional[int] = None
|
|
49
|
+
bypasses: Optional[int] = None
|
|
50
|
+
sensitive_attempts: Optional[int] = None
|
|
51
|
+
sensitive_prevented: Optional[int] = None
|
|
52
|
+
sensitive_executed: Optional[int] = None
|
|
53
|
+
campaigns: Optional[int] = None
|
|
54
|
+
regressions: Optional[int] = None
|
|
55
|
+
incidents: Optional[int] = None
|
|
56
|
+
availability: Optional[Dict[str, bool]] = None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class AgentSummary(BaseModel):
|
|
60
|
+
agent_id: str
|
|
61
|
+
agent_name: str
|
|
62
|
+
trust_level: str
|
|
63
|
+
effective_capabilities: List[str]
|
|
64
|
+
total_attempts: int
|
|
65
|
+
total_blocked: int
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class AgentAccessResponse(BaseModel):
|
|
69
|
+
agent_id: str
|
|
70
|
+
agent_name: str
|
|
71
|
+
trust_level: str
|
|
72
|
+
declared: List[str] = Field(default_factory=list)
|
|
73
|
+
delegated: List[str] = Field(default_factory=list)
|
|
74
|
+
effective: List[str] = Field(default_factory=list)
|
|
75
|
+
restricted: List[str] = Field(default_factory=list)
|
|
76
|
+
reachable_tools: List[str] = Field(default_factory=list)
|
|
77
|
+
reachable_resources: List[str] = Field(default_factory=list)
|
|
78
|
+
total_attempts: int = 0
|
|
79
|
+
total_blocked: int = 0
|
|
80
|
+
total_allowed: int = 0
|
|
81
|
+
total_executions: int = 0
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class ResourceAccessResponse(BaseModel):
|
|
85
|
+
resource_id: str
|
|
86
|
+
resource_name: str
|
|
87
|
+
resource_type: str
|
|
88
|
+
sensitivity: str
|
|
89
|
+
exposing_tools: List[str] = Field(default_factory=list)
|
|
90
|
+
authorized_agents: List[str] = Field(default_factory=list)
|
|
91
|
+
attempted_agents: List[str] = Field(default_factory=list)
|
|
92
|
+
actual_access_agents: List[str] = Field(default_factory=list)
|
|
93
|
+
blocked_agents: List[str] = Field(default_factory=list)
|
|
94
|
+
total_attempts: int = 0
|
|
95
|
+
total_blocked: int = 0
|
|
96
|
+
total_executions: int = 0
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class AccessMatrixResponse(BaseModel):
|
|
100
|
+
matrix_id: str
|
|
101
|
+
agents: List[str]
|
|
102
|
+
resources: List[str]
|
|
103
|
+
table: Dict[str, Dict[str, str]] = Field(default_factory=dict)
|
|
104
|
+
effective_permissions: Dict[str, Dict[str, bool]] = Field(default_factory=dict)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class SnapshotSummary(BaseModel):
|
|
108
|
+
snapshot_id: str
|
|
109
|
+
label: str
|
|
110
|
+
timestamp: str
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class DiffResponse(BaseModel):
|
|
114
|
+
diff_id: str
|
|
115
|
+
before_snapshot_id: str
|
|
116
|
+
after_snapshot_id: str
|
|
117
|
+
authority_changed: bool
|
|
118
|
+
new_capabilities: List[str]
|
|
119
|
+
lost_capabilities: List[str]
|
|
120
|
+
attack_detected: bool
|
|
121
|
+
taint_changed: bool
|
|
122
|
+
context_changed: bool
|
|
123
|
+
summary: str
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class AttackSummary(BaseModel):
|
|
127
|
+
attack_id: str
|
|
128
|
+
campaign_id: Optional[str]
|
|
129
|
+
attack_type: str
|
|
130
|
+
target: str
|
|
131
|
+
entry_point: str
|
|
132
|
+
expected_decision: str
|
|
133
|
+
actual_decision: str
|
|
134
|
+
bypassed: bool
|
|
135
|
+
tool_executed: bool
|
|
136
|
+
execution_count: int
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class AttackForensicsResponse(BaseModel):
|
|
140
|
+
report_id: str
|
|
141
|
+
attack_id: str
|
|
142
|
+
campaign_id: Optional[str]
|
|
143
|
+
attack_type: str
|
|
144
|
+
target: str
|
|
145
|
+
agent_id: str
|
|
146
|
+
original_intent: str
|
|
147
|
+
mutation_lineage: List[str]
|
|
148
|
+
taint_state: str
|
|
149
|
+
policy_decision: str
|
|
150
|
+
policy_reason_code: str
|
|
151
|
+
tool_executed: bool
|
|
152
|
+
execution_count: int
|
|
153
|
+
sensitive_db_calls: int
|
|
154
|
+
bypassed: bool
|
|
155
|
+
reachable_resources: List[str]
|
|
156
|
+
regression_status: str
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class CampaignSummary(BaseModel):
|
|
160
|
+
campaign_id: str
|
|
161
|
+
total_attacks: int
|
|
162
|
+
bypasses: int
|
|
163
|
+
blocks: int
|
|
164
|
+
bypass_rate: float
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class IncidentResponse(BaseModel):
|
|
168
|
+
incident_id: str
|
|
169
|
+
incident_type: str
|
|
170
|
+
severity: str
|
|
171
|
+
agent_id: Optional[str]
|
|
172
|
+
resource_name: Optional[str]
|
|
173
|
+
tool_name: Optional[str]
|
|
174
|
+
decision: str
|
|
175
|
+
executed: bool
|
|
176
|
+
trace_id: Optional[str]
|
|
177
|
+
attack_id: Optional[str]
|
|
178
|
+
status: str
|
|
179
|
+
description: str
|
|
180
|
+
timestamp: str
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class PolicyEvaluateRequest(BaseModel):
|
|
184
|
+
tool_name: str
|
|
185
|
+
agent_id: str
|
|
186
|
+
capabilities: List[str] = Field(default_factory=list)
|
|
187
|
+
tainted_context: bool = False
|
|
188
|
+
intent: str = ""
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
class PolicyEvaluateResponse(BaseModel):
|
|
192
|
+
tool_name: str
|
|
193
|
+
agent_id: str
|
|
194
|
+
decision: str
|
|
195
|
+
reason_code: str
|
|
196
|
+
explanation: str
|
|
197
|
+
risk_score: float
|
|
198
|
+
|