feat: confine a compromised worker and drill its compromise end to end
- narrow the worker S3 user to staging reads and attachments writes - add database rules the worker role cannot bypass: no return to pending, variant keys of its own attachment, known error codes only - let the cleaner remove a ready source only after its own SHA-256 check - add make jobs_audit [REPAIR=1] to name and requeue damaged jobs - add make worker_compromise: isolated before/after stands, one operation table, response windows, job safety, controls and committed hypotheses Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -557,6 +557,11 @@ async def check_lock_staging_candidate(new_uow: NewUow) -> None:
|
||||
)
|
||||
assert found is not None
|
||||
assert found.staging_key == row.staging_key
|
||||
# по ним уборщик сверяет результат до удаления исходника
|
||||
assert (found.size_bytes, found.sha256) == (
|
||||
row.size_bytes,
|
||||
row.sha256,
|
||||
)
|
||||
assert (
|
||||
await uow.attachments.lock_staging_candidate(
|
||||
attachment_id=row.id,
|
||||
@@ -1458,7 +1463,12 @@ async def check_variants(new_uow: NewUow) -> None:
|
||||
)
|
||||
assert not await repo.insert_variant(
|
||||
attachment_id=row.id,
|
||||
variant=replace(thumbnail, object_key="other"),
|
||||
# ключ другой, но своего вложения: чужой отвергает БД (спек
|
||||
# storage-access, «Значения, которых роль не может записать»)
|
||||
variant=replace(
|
||||
thumbnail,
|
||||
object_key=f"{thumbnail.object_key}other",
|
||||
),
|
||||
)
|
||||
assert await repo.insert_variant(attachment_id=row.id, variant=crop)
|
||||
await uow.commit()
|
||||
|
||||
Reference in New Issue
Block a user