@jaguilar87/gaia 5.0.2 → 5.0.4
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/ARCHITECTURE.md +0 -1
- package/CHANGELOG.md +54 -0
- package/bin/cli/approvals.py +23 -21
- package/config/surface-routing.json +0 -1
- package/dist/gaia-ops/.claude-plugin/plugin.json +1 -1
- package/dist/gaia-ops/config/surface-routing.json +0 -1
- package/dist/gaia-ops/hooks/modules/agents/contract_validator.py +18 -0
- package/dist/gaia-ops/hooks/modules/agents/handoff_persister.py +212 -2
- package/dist/gaia-ops/hooks/modules/agents/response_contract.py +26 -0
- package/dist/gaia-ops/hooks/modules/agents/transcript_reader.py +15 -0
- package/dist/gaia-ops/hooks/modules/security/__init__.py +0 -5
- package/dist/gaia-ops/hooks/modules/security/approval_grants.py +122 -19
- package/dist/gaia-ops/hooks/modules/security/mutative_verbs.py +99 -7
- package/dist/gaia-ops/hooks/modules/tools/bash_validator.py +125 -24
- package/dist/gaia-ops/skills/agent-contract-handoff/SKILL.md +3 -0
- package/dist/gaia-ops/skills/agent-response/SKILL.md +4 -2
- package/dist/gaia-ops/skills/gaia-patterns/reference.md +2 -2
- package/dist/gaia-ops/skills/orchestrator-present-approval/SKILL.md +20 -5
- package/dist/gaia-ops/skills/orchestrator-present-approval/reference.md +32 -15
- package/dist/gaia-ops/skills/security-tiers/SKILL.md +5 -1
- package/dist/gaia-ops/skills/security-tiers/reference.md +3 -1
- package/dist/gaia-ops/skills/subagent-request-approval/SKILL.md +43 -6
- package/dist/gaia-ops/skills/subagent-request-approval/reference.md +66 -16
- package/dist/gaia-ops/tools/context/README.md +1 -1
- package/dist/gaia-ops/tools/gaia_simulator/extractor.py +0 -1
- package/dist/gaia-security/.claude-plugin/plugin.json +1 -1
- package/dist/gaia-security/hooks/modules/agents/contract_validator.py +18 -0
- package/dist/gaia-security/hooks/modules/agents/handoff_persister.py +212 -2
- package/dist/gaia-security/hooks/modules/agents/response_contract.py +26 -0
- package/dist/gaia-security/hooks/modules/agents/transcript_reader.py +15 -0
- package/dist/gaia-security/hooks/modules/security/__init__.py +0 -5
- package/dist/gaia-security/hooks/modules/security/approval_grants.py +122 -19
- package/dist/gaia-security/hooks/modules/security/mutative_verbs.py +99 -7
- package/dist/gaia-security/hooks/modules/tools/bash_validator.py +125 -24
- package/gaia/state/transitions.py +4 -4
- package/gaia/store/writer.py +56 -0
- package/hooks/modules/README.md +2 -4
- package/hooks/modules/agents/contract_validator.py +18 -0
- package/hooks/modules/agents/handoff_persister.py +212 -2
- package/hooks/modules/agents/response_contract.py +26 -0
- package/hooks/modules/agents/transcript_reader.py +15 -0
- package/hooks/modules/security/__init__.py +0 -5
- package/hooks/modules/security/approval_grants.py +122 -19
- package/hooks/modules/security/mutative_verbs.py +99 -7
- package/hooks/modules/tools/bash_validator.py +125 -24
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/skills/agent-contract-handoff/SKILL.md +3 -0
- package/skills/agent-response/SKILL.md +4 -2
- package/skills/gaia-patterns/reference.md +2 -2
- package/skills/orchestrator-present-approval/SKILL.md +20 -5
- package/skills/orchestrator-present-approval/reference.md +32 -15
- package/skills/security-tiers/SKILL.md +5 -1
- package/skills/security-tiers/reference.md +3 -1
- package/skills/subagent-request-approval/SKILL.md +43 -6
- package/skills/subagent-request-approval/reference.md +66 -16
- package/tools/context/README.md +1 -1
- package/tools/gaia_simulator/extractor.py +0 -1
- package/dist/gaia-ops/hooks/modules/security/gitops_validator.py +0 -179
- package/dist/gaia-security/hooks/modules/security/gitops_validator.py +0 -179
- package/hooks/modules/security/gitops_validator.py +0 -179
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
GitOps workflow validation for kubectl, helm, and flux commands.
|
|
3
|
-
|
|
4
|
-
Ensures commands follow GitOps principles:
|
|
5
|
-
- No direct cluster modifications
|
|
6
|
-
- Use --dry-run for apply operations
|
|
7
|
-
- Prefer read-only commands
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
import re
|
|
11
|
-
import logging
|
|
12
|
-
from typing import List, Optional
|
|
13
|
-
from dataclasses import dataclass, field
|
|
14
|
-
|
|
15
|
-
logger = logging.getLogger(__name__)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@dataclass
|
|
19
|
-
class GitOpsValidationResult:
|
|
20
|
-
"""Result of GitOps validation."""
|
|
21
|
-
allowed: bool
|
|
22
|
-
reason: str
|
|
23
|
-
severity: str = "info" # info, warning, high, critical
|
|
24
|
-
suggestions: List[str] = field(default_factory=list)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# Safe read-only commands (always allowed)
|
|
28
|
-
SAFE_KUBECTL_COMMANDS = [
|
|
29
|
-
r'kubectl\s+get',
|
|
30
|
-
r'kubectl\s+describe',
|
|
31
|
-
r'kubectl\s+logs',
|
|
32
|
-
r'kubectl\s+top',
|
|
33
|
-
r'kubectl\s+explain',
|
|
34
|
-
r'kubectl\s+version',
|
|
35
|
-
r'kubectl\s+cluster-info',
|
|
36
|
-
r'kubectl\s+config\s+view',
|
|
37
|
-
r'kubectl\s+api-resources',
|
|
38
|
-
r'kubectl\s+api-versions',
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
SAFE_FLUX_COMMANDS = [
|
|
42
|
-
r'flux\s+get',
|
|
43
|
-
r'flux\s+check',
|
|
44
|
-
r'flux\s+version',
|
|
45
|
-
r'flux\s+logs',
|
|
46
|
-
r'flux\s+stats',
|
|
47
|
-
r'flux\s+tree',
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
SAFE_HELM_COMMANDS = [
|
|
51
|
-
r'helm\s+list',
|
|
52
|
-
r'helm\s+status',
|
|
53
|
-
r'helm\s+history',
|
|
54
|
-
r'helm\s+template',
|
|
55
|
-
r'helm\s+lint',
|
|
56
|
-
r'helm\s+version',
|
|
57
|
-
r'helm\s+show',
|
|
58
|
-
r'helm\s+search',
|
|
59
|
-
]
|
|
60
|
-
|
|
61
|
-
# Forbidden commands (modify cluster state)
|
|
62
|
-
FORBIDDEN_KUBECTL_COMMANDS = [
|
|
63
|
-
r'kubectl\s+apply(?!\s+.*--dry-run)',
|
|
64
|
-
r'kubectl\s+create(?!\s+.*--dry-run)',
|
|
65
|
-
r'kubectl\s+patch',
|
|
66
|
-
r'kubectl\s+replace',
|
|
67
|
-
r'kubectl\s+delete',
|
|
68
|
-
r'kubectl\s+scale',
|
|
69
|
-
r'kubectl\s+rollout\s+restart',
|
|
70
|
-
r'kubectl\s+annotate(?!\s+.*--dry-run)',
|
|
71
|
-
r'kubectl\s+label(?!\s+.*--dry-run)',
|
|
72
|
-
]
|
|
73
|
-
|
|
74
|
-
FORBIDDEN_FLUX_COMMANDS = [
|
|
75
|
-
r'flux\s+create',
|
|
76
|
-
r'flux\s+delete',
|
|
77
|
-
r'flux\s+suspend',
|
|
78
|
-
r'flux\s+resume',
|
|
79
|
-
]
|
|
80
|
-
|
|
81
|
-
FORBIDDEN_HELM_COMMANDS = [
|
|
82
|
-
r'helm\s+install(?!\s+.*--dry-run)',
|
|
83
|
-
r'helm\s+upgrade(?!\s+.*--dry-run)',
|
|
84
|
-
r'helm\s+uninstall',
|
|
85
|
-
r'helm\s+rollback',
|
|
86
|
-
]
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def is_safe_gitops_command(command: str) -> bool:
|
|
90
|
-
"""Check if command is explicitly safe (read-only)."""
|
|
91
|
-
safe_patterns = SAFE_KUBECTL_COMMANDS + SAFE_FLUX_COMMANDS + SAFE_HELM_COMMANDS
|
|
92
|
-
for pattern in safe_patterns:
|
|
93
|
-
if re.search(pattern, command, re.IGNORECASE):
|
|
94
|
-
return True
|
|
95
|
-
return False
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def is_forbidden_gitops_command(command: str) -> bool:
|
|
99
|
-
"""Check if command is forbidden (modifies cluster state)."""
|
|
100
|
-
forbidden_patterns = (
|
|
101
|
-
FORBIDDEN_KUBECTL_COMMANDS +
|
|
102
|
-
FORBIDDEN_FLUX_COMMANDS +
|
|
103
|
-
FORBIDDEN_HELM_COMMANDS
|
|
104
|
-
)
|
|
105
|
-
for pattern in forbidden_patterns:
|
|
106
|
-
if re.search(pattern, command, re.IGNORECASE):
|
|
107
|
-
return True
|
|
108
|
-
return False
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def validate_gitops_workflow(
|
|
112
|
-
command: str,
|
|
113
|
-
agent_type: Optional[str] = None
|
|
114
|
-
) -> GitOpsValidationResult:
|
|
115
|
-
"""
|
|
116
|
-
Validate command against GitOps security principles.
|
|
117
|
-
|
|
118
|
-
Args:
|
|
119
|
-
command: Shell command to validate
|
|
120
|
-
agent_type: Optional agent type for stricter validation
|
|
121
|
-
|
|
122
|
-
Returns:
|
|
123
|
-
GitOpsValidationResult with status and suggestions
|
|
124
|
-
"""
|
|
125
|
-
# Check if command is explicitly safe
|
|
126
|
-
if is_safe_gitops_command(command):
|
|
127
|
-
return GitOpsValidationResult(
|
|
128
|
-
allowed=True,
|
|
129
|
-
reason="Read-only operation - safe to execute",
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
# Check if command is forbidden
|
|
133
|
-
if is_forbidden_gitops_command(command):
|
|
134
|
-
suggestions = []
|
|
135
|
-
|
|
136
|
-
# Provide specific suggestions based on command type
|
|
137
|
-
if "kubectl apply" in command and "--dry-run" not in command:
|
|
138
|
-
suggestions.extend([
|
|
139
|
-
"Use: kubectl apply --dry-run=client -f <file>",
|
|
140
|
-
"Create manifests in gitops repository first",
|
|
141
|
-
"Commit changes and let Flux CD reconcile"
|
|
142
|
-
])
|
|
143
|
-
elif "flux reconcile" in command and "--dry-run" not in command:
|
|
144
|
-
suggestions.extend([
|
|
145
|
-
"Use: flux reconcile <resource> --dry-run",
|
|
146
|
-
"Follow GitOps workflow: commit -> push -> automatic reconciliation"
|
|
147
|
-
])
|
|
148
|
-
elif "helm install" in command or "helm upgrade" in command:
|
|
149
|
-
suggestions.extend([
|
|
150
|
-
"Use: helm template or helm upgrade --dry-run",
|
|
151
|
-
"Deploy via HelmRelease manifests in gitops repository"
|
|
152
|
-
])
|
|
153
|
-
else:
|
|
154
|
-
suggestions.append("Use read-only commands or --dry-run alternatives")
|
|
155
|
-
|
|
156
|
-
return GitOpsValidationResult(
|
|
157
|
-
allowed=False,
|
|
158
|
-
reason="Command violates GitOps principles - modifies cluster state directly",
|
|
159
|
-
severity="critical",
|
|
160
|
-
suggestions=suggestions,
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
# For gitops-operator agent, be extra strict
|
|
164
|
-
if agent_type == "gitops-operator":
|
|
165
|
-
if ("apply" in command or "create" in command) and "--dry-run" not in command:
|
|
166
|
-
return GitOpsValidationResult(
|
|
167
|
-
allowed=False,
|
|
168
|
-
reason="GitOps operator must use --dry-run for all apply operations",
|
|
169
|
-
severity="high",
|
|
170
|
-
suggestions=["Add --dry-run=client flag to command"],
|
|
171
|
-
)
|
|
172
|
-
|
|
173
|
-
# Default: allow but warn about unclear intent
|
|
174
|
-
return GitOpsValidationResult(
|
|
175
|
-
allowed=True,
|
|
176
|
-
reason="Command not explicitly validated - proceed with caution",
|
|
177
|
-
severity="warning",
|
|
178
|
-
suggestions=["Verify command follows GitOps principles"],
|
|
179
|
-
)
|