codeframe-ai 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.
- codeframe/__init__.py +11 -0
- codeframe/__main__.py +20 -0
- codeframe/adapters/__init__.py +5 -0
- codeframe/adapters/e2b/__init__.py +13 -0
- codeframe/adapters/e2b/adapter.py +342 -0
- codeframe/adapters/e2b/budget.py +71 -0
- codeframe/adapters/e2b/credential_scanner.py +134 -0
- codeframe/adapters/llm/__init__.py +92 -0
- codeframe/adapters/llm/anthropic.py +414 -0
- codeframe/adapters/llm/base.py +444 -0
- codeframe/adapters/llm/mock.py +281 -0
- codeframe/adapters/llm/openai.py +483 -0
- codeframe/agents/__init__.py +8 -0
- codeframe/agents/dependency_resolver.py +714 -0
- codeframe/auth/__init__.py +16 -0
- codeframe/auth/api_key_router.py +238 -0
- codeframe/auth/api_keys.py +156 -0
- codeframe/auth/dependencies.py +358 -0
- codeframe/auth/manager.py +178 -0
- codeframe/auth/models.py +30 -0
- codeframe/auth/router.py +93 -0
- codeframe/auth/schemas.py +15 -0
- codeframe/auth/scopes.py +53 -0
- codeframe/cli/__init__.py +12 -0
- codeframe/cli/__main__.py +20 -0
- codeframe/cli/api_client.py +275 -0
- codeframe/cli/app.py +5688 -0
- codeframe/cli/auth.py +122 -0
- codeframe/cli/auth_commands.py +958 -0
- codeframe/cli/commands/__init__.py +5 -0
- codeframe/cli/config_commands.py +79 -0
- codeframe/cli/dashboard_commands.py +67 -0
- codeframe/cli/engines_commands.py +205 -0
- codeframe/cli/env_commands.py +409 -0
- codeframe/cli/helpers.py +56 -0
- codeframe/cli/hooks_commands.py +208 -0
- codeframe/cli/import_commands.py +129 -0
- codeframe/cli/pr_commands.py +549 -0
- codeframe/cli/proof_commands.py +415 -0
- codeframe/cli/stats_commands.py +311 -0
- codeframe/cli/telemetry_runtime.py +153 -0
- codeframe/cli/validators.py +123 -0
- codeframe/config/rate_limits.py +165 -0
- codeframe/core/__init__.py +15 -0
- codeframe/core/adapters/__init__.py +43 -0
- codeframe/core/adapters/agent_adapter.py +114 -0
- codeframe/core/adapters/builtin.py +326 -0
- codeframe/core/adapters/claude_code.py +62 -0
- codeframe/core/adapters/codex.py +393 -0
- codeframe/core/adapters/git_utils.py +40 -0
- codeframe/core/adapters/kilocode.py +126 -0
- codeframe/core/adapters/opencode.py +48 -0
- codeframe/core/adapters/streaming_chat.py +483 -0
- codeframe/core/adapters/subprocess_adapter.py +213 -0
- codeframe/core/adapters/verification_wrapper.py +269 -0
- codeframe/core/agent.py +2183 -0
- codeframe/core/agents_config.py +569 -0
- codeframe/core/api_key_service.py +211 -0
- codeframe/core/artifacts.py +428 -0
- codeframe/core/blocker_detection.py +218 -0
- codeframe/core/blockers.py +433 -0
- codeframe/core/checkpoints.py +481 -0
- codeframe/core/conductor.py +2255 -0
- codeframe/core/config.py +827 -0
- codeframe/core/config_watcher.py +268 -0
- codeframe/core/context.py +542 -0
- codeframe/core/context_packager.py +234 -0
- codeframe/core/credentials.py +735 -0
- codeframe/core/dependency_analyzer.py +229 -0
- codeframe/core/dependency_graph.py +290 -0
- codeframe/core/diagnostic_agent.py +712 -0
- codeframe/core/diagnostics.py +616 -0
- codeframe/core/editor.py +556 -0
- codeframe/core/engine_registry.py +256 -0
- codeframe/core/engine_stats.py +231 -0
- codeframe/core/environment.py +697 -0
- codeframe/core/events.py +375 -0
- codeframe/core/executor.py +1005 -0
- codeframe/core/fix_tracker.py +480 -0
- codeframe/core/gates.py +1322 -0
- codeframe/core/git.py +477 -0
- codeframe/core/github_connect_service.py +178 -0
- codeframe/core/github_integration_config.py +118 -0
- codeframe/core/github_issues_service.py +449 -0
- codeframe/core/hooks.py +184 -0
- codeframe/core/importers/__init__.py +1 -0
- codeframe/core/importers/ralph.py +540 -0
- codeframe/core/installer.py +650 -0
- codeframe/core/models.py +1026 -0
- codeframe/core/notifications_config.py +183 -0
- codeframe/core/planner.py +437 -0
- codeframe/core/prd.py +670 -0
- codeframe/core/prd_discovery.py +1118 -0
- codeframe/core/prd_stress_test.py +499 -0
- codeframe/core/progress.py +126 -0
- codeframe/core/proof/__init__.py +34 -0
- codeframe/core/proof/capture.py +79 -0
- codeframe/core/proof/evidence.py +56 -0
- codeframe/core/proof/ledger.py +574 -0
- codeframe/core/proof/models.py +162 -0
- codeframe/core/proof/obligations.py +103 -0
- codeframe/core/proof/runner.py +233 -0
- codeframe/core/proof/scope.py +81 -0
- codeframe/core/proof/stubs.py +156 -0
- codeframe/core/quick_fixes.py +558 -0
- codeframe/core/react_agent.py +1650 -0
- codeframe/core/reconciliation.py +183 -0
- codeframe/core/replay.py +788 -0
- codeframe/core/review.py +285 -0
- codeframe/core/runtime.py +1134 -0
- codeframe/core/sandbox/__init__.py +27 -0
- codeframe/core/sandbox/context.py +98 -0
- codeframe/core/sandbox/worktree.py +20 -0
- codeframe/core/schedule.py +396 -0
- codeframe/core/stall_detector.py +71 -0
- codeframe/core/stall_monitor.py +134 -0
- codeframe/core/state_machine.py +121 -0
- codeframe/core/streaming.py +502 -0
- codeframe/core/task_tree.py +400 -0
- codeframe/core/tasks.py +1022 -0
- codeframe/core/telemetry.py +232 -0
- codeframe/core/templates.py +221 -0
- codeframe/core/tools.py +942 -0
- codeframe/core/workspace.py +887 -0
- codeframe/core/worktrees.py +276 -0
- codeframe/git/__init__.py +5 -0
- codeframe/git/github_integration.py +505 -0
- codeframe/lib/__init__.py +0 -0
- codeframe/lib/audit_logger.py +248 -0
- codeframe/lib/metrics_tracker.py +800 -0
- codeframe/lib/quality/__init__.py +7 -0
- codeframe/lib/quality/complexity_analyzer.py +316 -0
- codeframe/lib/quality/owasp_patterns.py +284 -0
- codeframe/lib/quality/security_scanner.py +250 -0
- codeframe/lib/rate_limiter.py +312 -0
- codeframe/notifications/__init__.py +0 -0
- codeframe/notifications/webhook.py +380 -0
- codeframe/planning/__init__.py +30 -0
- codeframe/planning/issue_generator.py +219 -0
- codeframe/planning/prd_template_functions.py +137 -0
- codeframe/planning/prd_templates.py +975 -0
- codeframe/planning/task_scheduler.py +511 -0
- codeframe/planning/task_templates.py +533 -0
- codeframe/platform_store/__init__.py +5 -0
- codeframe/platform_store/database.py +277 -0
- codeframe/platform_store/repositories/__init__.py +24 -0
- codeframe/platform_store/repositories/api_key_repository.py +245 -0
- codeframe/platform_store/repositories/audit_repository.py +67 -0
- codeframe/platform_store/repositories/base.py +295 -0
- codeframe/platform_store/repositories/interactive_sessions.py +165 -0
- codeframe/platform_store/repositories/token_repository.py +598 -0
- codeframe/platform_store/repositories/workspace_registry_repository.py +175 -0
- codeframe/platform_store/schema_manager.py +321 -0
- codeframe/templates/AGENTS.md.default +94 -0
- codeframe/tui/__init__.py +5 -0
- codeframe/tui/app.py +256 -0
- codeframe/tui/data_service.py +103 -0
- codeframe/ui/__init__.py +0 -0
- codeframe/ui/dependencies.py +103 -0
- codeframe/ui/models.py +999 -0
- codeframe/ui/response_models.py +201 -0
- codeframe/ui/routers/__init__.py +5 -0
- codeframe/ui/routers/_helpers.py +29 -0
- codeframe/ui/routers/batches_v2.py +315 -0
- codeframe/ui/routers/blockers_v2.py +320 -0
- codeframe/ui/routers/checkpoints_v2.py +310 -0
- codeframe/ui/routers/costs_v2.py +322 -0
- codeframe/ui/routers/diagnose_v2.py +225 -0
- codeframe/ui/routers/discovery_v2.py +417 -0
- codeframe/ui/routers/environment_v2.py +284 -0
- codeframe/ui/routers/events_v2.py +75 -0
- codeframe/ui/routers/gates_v2.py +166 -0
- codeframe/ui/routers/git_v2.py +284 -0
- codeframe/ui/routers/github_integrations_v2.py +532 -0
- codeframe/ui/routers/interactive_sessions_v2.py +238 -0
- codeframe/ui/routers/pr_v2.py +709 -0
- codeframe/ui/routers/prd_v2.py +695 -0
- codeframe/ui/routers/proof_v2.py +755 -0
- codeframe/ui/routers/review_v2.py +360 -0
- codeframe/ui/routers/schedule_v2.py +214 -0
- codeframe/ui/routers/session_chat_ws.py +354 -0
- codeframe/ui/routers/settings_v2.py +562 -0
- codeframe/ui/routers/streaming_v2.py +155 -0
- codeframe/ui/routers/tasks_v2.py +1098 -0
- codeframe/ui/routers/templates_v2.py +232 -0
- codeframe/ui/routers/terminal_ws.py +267 -0
- codeframe/ui/routers/workspace_v2.py +527 -0
- codeframe/ui/server.py +568 -0
- codeframe/ui/shared.py +241 -0
- codeframe/workspace/__init__.py +5 -0
- codeframe/workspace/manager.py +249 -0
- codeframe_ai-0.9.0.dist-info/METADATA +517 -0
- codeframe_ai-0.9.0.dist-info/RECORD +197 -0
- codeframe_ai-0.9.0.dist-info/WHEEL +5 -0
- codeframe_ai-0.9.0.dist-info/entry_points.txt +3 -0
- codeframe_ai-0.9.0.dist-info/licenses/LICENSE +661 -0
- codeframe_ai-0.9.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"""Audit logging infrastructure for CodeFRAME.
|
|
2
|
+
|
|
3
|
+
This module provides centralized audit logging for security-relevant events including:
|
|
4
|
+
- Authentication events (login, logout, failed attempts)
|
|
5
|
+
- Authorization checks (access granted/denied)
|
|
6
|
+
- Project lifecycle events (create, update, delete)
|
|
7
|
+
- User management events (user creation, role changes)
|
|
8
|
+
|
|
9
|
+
All audit logs are stored in the database with timestamps, user context, and event metadata.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from datetime import datetime, UTC
|
|
13
|
+
from typing import Optional, Dict, Any
|
|
14
|
+
from enum import Enum
|
|
15
|
+
|
|
16
|
+
from codeframe.platform_store.database import Database
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class AuditEventType(Enum):
|
|
20
|
+
"""Types of audit events to log."""
|
|
21
|
+
|
|
22
|
+
# Authentication events
|
|
23
|
+
AUTH_LOGIN_SUCCESS = "auth.login.success"
|
|
24
|
+
AUTH_LOGIN_FAILED = "auth.login.failed"
|
|
25
|
+
AUTH_LOGOUT = "auth.logout"
|
|
26
|
+
AUTH_SESSION_CREATED = "auth.session.created"
|
|
27
|
+
AUTH_SESSION_EXPIRED = "auth.session.expired"
|
|
28
|
+
|
|
29
|
+
# Authorization events
|
|
30
|
+
AUTHZ_ACCESS_GRANTED = "authz.access.granted"
|
|
31
|
+
AUTHZ_ACCESS_DENIED = "authz.access.denied"
|
|
32
|
+
AUTHZ_PERMISSION_CHECK = "authz.permission.check"
|
|
33
|
+
|
|
34
|
+
# Project lifecycle events
|
|
35
|
+
PROJECT_CREATED = "project.created"
|
|
36
|
+
PROJECT_UPDATED = "project.updated"
|
|
37
|
+
PROJECT_DELETED = "project.deleted"
|
|
38
|
+
PROJECT_ACCESS_GRANTED = "project.access.granted"
|
|
39
|
+
PROJECT_ACCESS_REVOKED = "project.access.revoked"
|
|
40
|
+
|
|
41
|
+
# User management events
|
|
42
|
+
USER_CREATED = "user.created"
|
|
43
|
+
USER_UPDATED = "user.updated"
|
|
44
|
+
USER_DELETED = "user.deleted"
|
|
45
|
+
USER_ROLE_CHANGED = "user.role.changed"
|
|
46
|
+
|
|
47
|
+
# Rate limiting events
|
|
48
|
+
RATE_LIMIT_EXCEEDED = "rate_limit.exceeded"
|
|
49
|
+
RATE_LIMIT_WARNING = "rate_limit.warning"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class AuditLogger:
|
|
53
|
+
"""Centralized audit logger for security events.
|
|
54
|
+
|
|
55
|
+
Logs all security-relevant events to the database for compliance,
|
|
56
|
+
security monitoring, and incident investigation.
|
|
57
|
+
|
|
58
|
+
Example:
|
|
59
|
+
audit = AuditLogger(db)
|
|
60
|
+
audit.log_auth_event(
|
|
61
|
+
user_id=123,
|
|
62
|
+
event_type=AuditEventType.AUTH_LOGIN_SUCCESS,
|
|
63
|
+
metadata={"ip_address": "192.168.1.1"}
|
|
64
|
+
)
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def __init__(self, db: Database):
|
|
68
|
+
"""Initialize audit logger.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
db: Database instance for persisting audit logs
|
|
72
|
+
"""
|
|
73
|
+
self.db = db
|
|
74
|
+
|
|
75
|
+
def log_auth_event(
|
|
76
|
+
self,
|
|
77
|
+
event_type: AuditEventType,
|
|
78
|
+
user_id: Optional[int] = None,
|
|
79
|
+
email: Optional[str] = None,
|
|
80
|
+
ip_address: Optional[str] = None,
|
|
81
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
82
|
+
) -> None:
|
|
83
|
+
"""Log authentication-related event.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
event_type: Type of authentication event
|
|
87
|
+
user_id: User ID (if authenticated)
|
|
88
|
+
email: User email (for login attempts)
|
|
89
|
+
ip_address: Client IP address
|
|
90
|
+
metadata: Additional event metadata
|
|
91
|
+
"""
|
|
92
|
+
self._log_event(
|
|
93
|
+
event_type=event_type,
|
|
94
|
+
user_id=user_id,
|
|
95
|
+
resource_type="auth",
|
|
96
|
+
resource_id=None,
|
|
97
|
+
ip_address=ip_address,
|
|
98
|
+
metadata={
|
|
99
|
+
**(metadata or {}),
|
|
100
|
+
"email": email,
|
|
101
|
+
},
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
def log_authz_event(
|
|
105
|
+
self,
|
|
106
|
+
event_type: AuditEventType,
|
|
107
|
+
user_id: int,
|
|
108
|
+
resource_type: str,
|
|
109
|
+
resource_id: int,
|
|
110
|
+
granted: bool,
|
|
111
|
+
ip_address: Optional[str] = None,
|
|
112
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
113
|
+
) -> None:
|
|
114
|
+
"""Log authorization-related event.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
event_type: Type of authorization event
|
|
118
|
+
user_id: User ID performing the action
|
|
119
|
+
resource_type: Type of resource (e.g., "project", "task")
|
|
120
|
+
resource_id: ID of the resource
|
|
121
|
+
granted: Whether access was granted or denied
|
|
122
|
+
ip_address: Client IP address
|
|
123
|
+
metadata: Additional event metadata
|
|
124
|
+
"""
|
|
125
|
+
self._log_event(
|
|
126
|
+
event_type=event_type,
|
|
127
|
+
user_id=user_id,
|
|
128
|
+
resource_type=resource_type,
|
|
129
|
+
resource_id=resource_id,
|
|
130
|
+
ip_address=ip_address,
|
|
131
|
+
metadata={
|
|
132
|
+
**(metadata or {}),
|
|
133
|
+
"granted": granted,
|
|
134
|
+
},
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
def log_project_event(
|
|
138
|
+
self,
|
|
139
|
+
event_type: AuditEventType,
|
|
140
|
+
user_id: int,
|
|
141
|
+
project_id: int,
|
|
142
|
+
ip_address: Optional[str] = None,
|
|
143
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
144
|
+
) -> None:
|
|
145
|
+
"""Log project lifecycle event.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
event_type: Type of project event
|
|
149
|
+
user_id: User ID performing the action
|
|
150
|
+
project_id: Project ID
|
|
151
|
+
ip_address: Client IP address
|
|
152
|
+
metadata: Additional event metadata
|
|
153
|
+
"""
|
|
154
|
+
self._log_event(
|
|
155
|
+
event_type=event_type,
|
|
156
|
+
user_id=user_id,
|
|
157
|
+
resource_type="project",
|
|
158
|
+
resource_id=project_id,
|
|
159
|
+
ip_address=ip_address,
|
|
160
|
+
metadata=metadata,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
def log_user_event(
|
|
164
|
+
self,
|
|
165
|
+
event_type: AuditEventType,
|
|
166
|
+
user_id: int,
|
|
167
|
+
target_user_id: Optional[int] = None,
|
|
168
|
+
ip_address: Optional[str] = None,
|
|
169
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
170
|
+
) -> None:
|
|
171
|
+
"""Log user management event.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
event_type: Type of user event
|
|
175
|
+
user_id: User ID performing the action
|
|
176
|
+
target_user_id: User ID being affected (if different from user_id)
|
|
177
|
+
ip_address: Client IP address
|
|
178
|
+
metadata: Additional event metadata
|
|
179
|
+
"""
|
|
180
|
+
self._log_event(
|
|
181
|
+
event_type=event_type,
|
|
182
|
+
user_id=user_id,
|
|
183
|
+
resource_type="user",
|
|
184
|
+
resource_id=target_user_id,
|
|
185
|
+
ip_address=ip_address,
|
|
186
|
+
metadata=metadata,
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
def log_rate_limit_event(
|
|
190
|
+
self,
|
|
191
|
+
event_type: AuditEventType,
|
|
192
|
+
user_id: Optional[int] = None,
|
|
193
|
+
ip_address: Optional[str] = None,
|
|
194
|
+
endpoint: Optional[str] = None,
|
|
195
|
+
limit_category: Optional[str] = None,
|
|
196
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
197
|
+
) -> None:
|
|
198
|
+
"""Log rate limiting event.
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
event_type: Type of rate limit event (exceeded or warning)
|
|
202
|
+
user_id: User ID (if authenticated)
|
|
203
|
+
ip_address: Client IP address
|
|
204
|
+
endpoint: API endpoint path
|
|
205
|
+
limit_category: Rate limit category (auth, standard, ai, websocket)
|
|
206
|
+
metadata: Additional event metadata
|
|
207
|
+
"""
|
|
208
|
+
self._log_event(
|
|
209
|
+
event_type=event_type,
|
|
210
|
+
user_id=user_id,
|
|
211
|
+
resource_type="rate_limit",
|
|
212
|
+
resource_id=None,
|
|
213
|
+
ip_address=ip_address,
|
|
214
|
+
metadata={
|
|
215
|
+
**(metadata or {}),
|
|
216
|
+
"endpoint": endpoint,
|
|
217
|
+
"limit_category": limit_category,
|
|
218
|
+
},
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
def _log_event(
|
|
222
|
+
self,
|
|
223
|
+
event_type: AuditEventType,
|
|
224
|
+
user_id: Optional[int],
|
|
225
|
+
resource_type: str,
|
|
226
|
+
resource_id: Optional[int],
|
|
227
|
+
ip_address: Optional[str],
|
|
228
|
+
metadata: Optional[Dict[str, Any]],
|
|
229
|
+
) -> None:
|
|
230
|
+
"""Internal method to log audit event to database.
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
event_type: Type of audit event
|
|
234
|
+
user_id: User ID (if authenticated)
|
|
235
|
+
resource_type: Type of resource being accessed
|
|
236
|
+
resource_id: ID of the resource
|
|
237
|
+
ip_address: Client IP address
|
|
238
|
+
metadata: Additional event metadata
|
|
239
|
+
"""
|
|
240
|
+
self.db.create_audit_log(
|
|
241
|
+
event_type=event_type.value,
|
|
242
|
+
user_id=user_id,
|
|
243
|
+
resource_type=resource_type,
|
|
244
|
+
resource_id=resource_id,
|
|
245
|
+
ip_address=ip_address,
|
|
246
|
+
metadata=metadata,
|
|
247
|
+
timestamp=datetime.now(UTC),
|
|
248
|
+
)
|