mirror of
https://github.com/Rarebuffalo/securelens-backend.git
synced 2026-06-19 07:00:30 +00:00
updated the architecture
This commit is contained in:
0
app/schemas/__init__.py
Normal file
0
app/schemas/__init__.py
Normal file
17
app/schemas/apikey.py
Normal file
17
app/schemas/apikey.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class ApiKeyCreate(BaseModel):
|
||||
name: str
|
||||
|
||||
|
||||
class ApiKeyResponse(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
key_prefix: str
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class ApiKeyCreateResponse(ApiKeyResponse):
|
||||
key: str # The raw API key returned only once upon creation
|
||||
28
app/schemas/auth.py
Normal file
28
app/schemas/auth.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
|
||||
|
||||
class RegisterRequest(BaseModel):
|
||||
email: EmailStr
|
||||
username: str = Field(..., min_length=3, max_length=100)
|
||||
password: str = Field(..., min_length=8, max_length=128)
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
email: EmailStr
|
||||
password: str
|
||||
|
||||
|
||||
class TokenResponse(BaseModel):
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
id: str
|
||||
email: str
|
||||
username: str
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
72
app/schemas/scan.py
Normal file
72
app/schemas/scan.py
Normal file
@@ -0,0 +1,72 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ScanRequest(BaseModel):
|
||||
url: str = Field(..., description="The URL of the website to scan")
|
||||
|
||||
|
||||
class Issue(BaseModel):
|
||||
issue: str
|
||||
severity: str
|
||||
layer: str
|
||||
fix: str
|
||||
contextual_severity: str | None = None
|
||||
explanation: str | None = None
|
||||
remediation_snippet: str | None = None
|
||||
|
||||
|
||||
class LayerStatus(BaseModel):
|
||||
issues: int = 0
|
||||
status: str = "green"
|
||||
|
||||
|
||||
class ScanResponse(BaseModel):
|
||||
id: str | None = None
|
||||
url: str
|
||||
security_score: int
|
||||
layers: dict[str, LayerStatus]
|
||||
issues: list[Issue]
|
||||
created_at: datetime | None = None
|
||||
|
||||
|
||||
class ScanHistoryItem(BaseModel):
|
||||
id: str
|
||||
url: str
|
||||
security_score: int
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class ScanHistoryResponse(BaseModel):
|
||||
scans: list[ScanHistoryItem]
|
||||
total: int
|
||||
page: int
|
||||
per_page: int
|
||||
|
||||
|
||||
class DashboardTrendsResponse(BaseModel):
|
||||
total_scans: int
|
||||
average_score: float
|
||||
recent_scans: list[ScanHistoryItem]
|
||||
|
||||
|
||||
class ChatRequest(BaseModel):
|
||||
message: str
|
||||
|
||||
|
||||
class ChatResponse(BaseModel):
|
||||
reply: str
|
||||
|
||||
|
||||
class ThreatNarrativeResponse(BaseModel):
|
||||
narrative: str
|
||||
|
||||
|
||||
class ScanDiffResponse(BaseModel):
|
||||
resolved_issues: list[Issue]
|
||||
new_issues: list[Issue]
|
||||
persisting_issues: list[Issue]
|
||||
score_change: int
|
||||
17
app/schemas/webhook.py
Normal file
17
app/schemas/webhook.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, HttpUrl
|
||||
|
||||
|
||||
class WebhookCreate(BaseModel):
|
||||
target_url: HttpUrl
|
||||
secret_key: str | None = None
|
||||
|
||||
|
||||
class WebhookResponse(BaseModel):
|
||||
id: str
|
||||
target_url: str
|
||||
is_active: bool
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in New Issue
Block a user