Spaces:
Sleeping
Sleeping
File size: 2,958 Bytes
80a4a65 f7a0350 80a4a65 04fc815 80a4a65 04fc815 80a4a65 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | """Pydantic request models, one block per concern.
Kept in a single file because they're all small BaseModel definitions
and importing them from one place makes the routers easy to scan.
"""
from typing import Optional
from pydantic import BaseModel
# ---------- Auth ---------- #
class AuthRequest(BaseModel):
action: str
email: str
password: str
name: Optional[str] = None
user_id: Optional[str] = None
# ---------- XP ---------- #
class XpRequest(BaseModel):
action: str
user_id: Optional[str] = None
xp_amount: Optional[int] = None
# ---------- Training (generic / red-team web) ---------- #
class TrainingRequest(BaseModel):
module: str
path: str
category: str
moduleId: Optional[str] = None
teamRole: Optional[str] = "red"
challengeId: Optional[str] = None
class EvaluateRequest(BaseModel):
action: str = "evaluate"
originalChallenge: dict
userCode: str
teamRole: Optional[str] = "red"
# Web exploitation challenges have been removed from the platform.
# The WebEvaluateRequest model that used to back /api/training/evaluate-web
# is gone; the /api/training/evaluate endpoint + the per-type blue
# evaluators now cover all remaining challenge types.
# ---------- Terminal ---------- #
class TerminalRequest(BaseModel):
teamRole: Optional[str] = "red"
challengeId: str
command: str
class TerminalWriteRequest(BaseModel):
teamRole: Optional[str] = "red"
challengeId: str
filename: str
content: str
class TerminalListRequest(BaseModel):
teamRole: Optional[str] = "red"
challengeId: str
# ---------- Certificates ---------- #
class CertificateRequest(BaseModel):
action: str = "list"
user_id: str
category: Optional[str] = None
verify_code: Optional[str] = None
details: Optional[dict] = None
# ---------- Solved (consume one from the pool) ---------- #
class SolvedRequest(BaseModel):
scenarioId: str
module: Optional[str] = None
teamRole: Optional[str] = "red"
difficulty: Optional[str] = "متوسط"
path: Optional[str] = "cryptography"
category: Optional[str] = "encryption"
# ---------- Blue-team evaluators ---------- #
class CodeFixEvaluateRequest(BaseModel):
"""Request model for code-fixing challenge evaluation."""
challengeId: str
fixedCode: str
teamRole: Optional[str] = "blue"
userId: Optional[str] = None
class LogAnalysisEvaluateRequest(BaseModel):
"""Request model for log-analysis challenge evaluation."""
challengeId: str
attackType: str
attackerIp: str
timestamp: str
ioc: str
explanation: str = ""
teamRole: Optional[str] = "blue"
userId: Optional[str] = None
class VulnHunterEvaluateRequest(BaseModel):
"""Request model for vulnerability-hunter challenge evaluation."""
challengeId: str
vulnerabilityType: str
teamRole: Optional[str] = "blue"
userId: Optional[str] = None
|