인증 경로 보존과 의존성 보안 검증을 보강
This commit is contained in:
parent
d2ba836565
commit
d801a1619d
10 changed files with 222 additions and 77 deletions
|
|
@ -6,7 +6,9 @@ from pathlib import Path
|
|||
from pydantic import ValidationError
|
||||
|
||||
from .contracts.supervision_research import (
|
||||
AttentionQueueItem,
|
||||
EvaluationVersionBatch,
|
||||
LedgerEvidencePointer,
|
||||
LearnerAttentionSignal,
|
||||
Phase3OutcomeEvidenceManifest,
|
||||
TeacherAiDisagreement,
|
||||
|
|
@ -99,6 +101,61 @@ class AttentionQueueTests(unittest.TestCase):
|
|||
LearnerAttentionSignal.model_validate(payload)
|
||||
|
||||
|
||||
class SupervisionRouteContractTests(unittest.TestCase):
|
||||
VALID_ROUTES = (
|
||||
"/teach",
|
||||
"/teach/session/uuid/review",
|
||||
"/teacher/dashboard?cohort=abc",
|
||||
)
|
||||
INVALID_ROUTES = (
|
||||
"//evil.test/path",
|
||||
"https://evil.test/path",
|
||||
"/\\evil.test/path",
|
||||
"/teach\nnext",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.pack = load_supervision_research_benchmark(BENCHMARK_PATH)
|
||||
cls.queue_item_payload = build_attention_queue(cls.pack.attention_signals)[
|
||||
0
|
||||
].model_dump(mode="json")
|
||||
|
||||
def test_ledger_evidence_routes_allow_app_relative_paths(self) -> None:
|
||||
for route in self.VALID_ROUTES:
|
||||
with self.subTest(route=route):
|
||||
pointer = LedgerEvidencePointer(
|
||||
ledger="measurement_event",
|
||||
event_id="event-1",
|
||||
route_hint=route,
|
||||
)
|
||||
self.assertEqual(pointer.route_hint, route)
|
||||
|
||||
def test_ledger_evidence_routes_reject_external_and_unsupported_paths(self) -> None:
|
||||
for route in self.INVALID_ROUTES:
|
||||
with self.subTest(route=route):
|
||||
with self.assertRaises(ValidationError):
|
||||
LedgerEvidencePointer(
|
||||
ledger="measurement_event",
|
||||
event_id="event-1",
|
||||
route_hint=route,
|
||||
)
|
||||
|
||||
def test_attention_queue_routes_allow_app_relative_paths(self) -> None:
|
||||
payload = dict(self.queue_item_payload)
|
||||
payload["drilldown_routes"] = list(self.VALID_ROUTES)
|
||||
item = AttentionQueueItem.model_validate(payload)
|
||||
self.assertEqual(item.drilldown_routes, self.VALID_ROUTES)
|
||||
|
||||
def test_attention_queue_routes_reject_external_and_unsupported_paths(self) -> None:
|
||||
for route in self.INVALID_ROUTES:
|
||||
with self.subTest(route=route):
|
||||
payload = dict(self.queue_item_payload)
|
||||
payload["drilldown_routes"] = [route]
|
||||
with self.assertRaises(ValidationError):
|
||||
AttentionQueueItem.model_validate(payload)
|
||||
|
||||
|
||||
class CalibrationDatasetTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue