🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
149 lines
4.5 KiB
Python
149 lines
4.5 KiB
Python
"""
|
|
Pydantic models for SHHH API endpoints.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from typing import List, Dict, Any, Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class QuarantineEntryResponse(BaseModel):
|
|
"""Response model for quarantine entries"""
|
|
id: int
|
|
timestamp: datetime
|
|
hypercore_position: int
|
|
bzzz_message_id: Optional[str] = None
|
|
secret_type: str
|
|
severity: str
|
|
confidence: float
|
|
redacted_content: str
|
|
content_hash: str
|
|
source_agent: str
|
|
match_count: int
|
|
reviewed: bool
|
|
review_action: Optional[str] = None
|
|
reviewer: Optional[str] = None
|
|
review_timestamp: Optional[datetime] = None
|
|
metadata: Dict[str, Any] = {}
|
|
|
|
|
|
class QuarantineReviewRequest(BaseModel):
|
|
"""Request model for reviewing quarantine entries"""
|
|
action: str = Field(..., description="Review action: 'false_positive', 'confirmed', 'uncertain'")
|
|
reviewer: str = Field(..., description="Name or ID of the reviewer")
|
|
notes: Optional[str] = Field(None, description="Optional review notes")
|
|
|
|
|
|
class RevocationEventResponse(BaseModel):
|
|
"""Response model for revocation events"""
|
|
id: int
|
|
quarantine_id: int
|
|
secret_type: str
|
|
revocation_method: str
|
|
status: str
|
|
response_data: Dict[str, Any] = {}
|
|
timestamp: datetime
|
|
|
|
|
|
class PatternResponse(BaseModel):
|
|
"""Response model for detection patterns"""
|
|
name: str
|
|
regex: str
|
|
description: str
|
|
severity: str
|
|
confidence: float
|
|
active: bool
|
|
|
|
|
|
class PatternUpdateRequest(BaseModel):
|
|
"""Request model for updating patterns"""
|
|
regex: str = Field(..., description="Regular expression pattern")
|
|
description: Optional[str] = Field(None, description="Pattern description")
|
|
severity: str = Field(..., description="Severity level: LOW, MEDIUM, HIGH, CRITICAL")
|
|
confidence: float = Field(..., ge=0.0, le=1.0, description="Confidence score")
|
|
active: bool = Field(True, description="Whether pattern is active")
|
|
|
|
|
|
class StatsResponse(BaseModel):
|
|
"""Response model for system statistics"""
|
|
total_entries: int
|
|
pending_review: int
|
|
critical_count: int
|
|
high_count: int
|
|
medium_count: int
|
|
low_count: int
|
|
last_24h: int
|
|
last_7d: int
|
|
|
|
|
|
class SystemHealthResponse(BaseModel):
|
|
"""Response model for system health"""
|
|
status: str
|
|
timestamp: datetime
|
|
components: Dict[str, Dict[str, Any]]
|
|
|
|
|
|
class ProcessingStatsResponse(BaseModel):
|
|
"""Response model for processing statistics"""
|
|
entries_processed: int
|
|
secrets_detected: int
|
|
messages_quarantined: int
|
|
revocations_triggered: int
|
|
processing_errors: int
|
|
uptime_hours: Optional[float] = None
|
|
entries_per_second: Optional[float] = None
|
|
secrets_per_hour: Optional[float] = None
|
|
is_running: bool
|
|
|
|
|
|
class AlertRequest(BaseModel):
|
|
"""Request model for manual alerts"""
|
|
message: str = Field(..., description="Alert message")
|
|
severity: str = Field(..., description="Alert severity")
|
|
source: str = Field(..., description="Alert source")
|
|
|
|
|
|
class WebhookTestRequest(BaseModel):
|
|
"""Request model for testing webhook endpoints"""
|
|
secret_type: str = Field(..., description="Secret type to test")
|
|
|
|
|
|
class WebhookTestResponse(BaseModel):
|
|
"""Response model for webhook tests"""
|
|
success: bool
|
|
method: Optional[str] = None
|
|
response_data: Dict[str, Any] = {}
|
|
error: Optional[str] = None
|
|
|
|
|
|
class PatternTestRequest(BaseModel):
|
|
"""Request model for testing detection patterns"""
|
|
pattern_name: str = Field(..., description="Name of pattern to test")
|
|
test_text: str = Field(..., description="Text to test against pattern")
|
|
|
|
|
|
class PatternTestResponse(BaseModel):
|
|
"""Response model for pattern testing"""
|
|
matches: List[Dict[str, Any]]
|
|
match_count: int
|
|
|
|
|
|
class SearchRequest(BaseModel):
|
|
"""Request model for searching quarantine entries"""
|
|
query: Optional[str] = Field(None, description="Search query")
|
|
secret_type: Optional[str] = Field(None, description="Filter by secret type")
|
|
severity: Optional[str] = Field(None, description="Filter by severity")
|
|
reviewed: Optional[bool] = Field(None, description="Filter by review status")
|
|
start_date: Optional[datetime] = Field(None, description="Start date filter")
|
|
end_date: Optional[datetime] = Field(None, description="End date filter")
|
|
limit: int = Field(100, ge=1, le=1000, description="Result limit")
|
|
offset: int = Field(0, ge=0, description="Result offset")
|
|
|
|
|
|
class PaginatedResponse(BaseModel):
|
|
"""Generic paginated response model"""
|
|
items: List[Any]
|
|
total: int
|
|
limit: int
|
|
offset: int
|
|
has_more: bool |