docs: verify full-range image validation and record bounded-memory receipts
This commit is contained in:
@@ -114,18 +114,27 @@ docker compose run --rm --no-deps research
|
||||
|
||||
### Результат десяти конкурентных upload
|
||||
|
||||
`upload-memory-final.json` — исходный снимок до поздних исправлений валидатора. Его данные и hashes не переписаны. Отдельная новая image-validation проверка ниже проверяет текущий short-lived child на больших файлах; это другой сценарий, не подмена старого эксперимента.
|
||||
|
||||
|
||||
После рестарта API с сохранением старого токена проверены PNG 788100 и 8683594 байт. На каждом размере десять клиентов начали одновременно; **2 получили 201, 8 — контролируемый 429**, затем readiness200. У API и LB `oom=0`, `oom_kill=0`, процессы остались живы. Cgroup lifetime peaks: API 122773504 и122679296 байт, LB19656704 байт. Лимиты соответственно512/512/128MiB.
|
||||
|
||||
Before/after peaks не выросли: начальная загрузка приложения/Argon2 уже создала больший high-water. Поэтому опыт доказывает ограниченное поведение выбранной нагрузки без OOM, но не выделяет точную память одной загрузки и не доказывает экономию RAM самим spool.
|
||||
|
||||
### Поздняя проверка полного диапазона изображений
|
||||
|
||||
Повторное изучение замечаний обнаружило допустимый36M progressiveRGBJPEG, который прежний nativebudget192MiB отклонял, и APNG с повреждённым вторым кадром. Регрессия на отдельном Docker project до правки:3 failed/1 passed. После правки проверены большие RGB/CMYK progressiveJPEG, маленькиеCMYK baseline/progressive, полный APNG decode, повреждённый later frame, rawacTL0/forgedcount, default image,40M cumulative boundary и50M rejection. Последовательность APNG40M→CMYK40M→RGB36M→обычныйPNG возвращает201 с неизменными original bytes при API512MiB и безOOM. Пик/счётчики и текущие source hashes сохранены в отдельном receipt.
|
||||
|
||||
Полный собственный набор после основной правки:155 passed; child timeout/crash boundary дополнительно проверена пятью unit-тестами. Финальные smoke/schema/lint и целевые image-регрессии находятся в новых evidence с суффиксом image-fix.
|
||||
|
||||
## Проверки и доказательства
|
||||
|
||||
| Критерий | Сценарий | Доказательство |
|
||||
|---|---|---|
|
||||
| Контракт и схема | make check validate | evidence/contract-checks.txt |
|
||||
| Обязательный API, PNG/ACL/checksum/idempotency | make test | evidence/smoke-final.txt |
|
||||
| Негативные/параллельные/Unicode/вложения/cursor | make student-test | evidence/tests-final.txt |
|
||||
| Повреждённый JPEG с поддельным EOI | regression до исправления и полный тест после djpeg | evidence/attachments-before-strict-jpeg.txt; evidence/tests-final.txt |
|
||||
| Обязательный API, PNG/ACL/checksum/idempotency | make test | evidence/smoke-image-fix-final.txt |
|
||||
| Негативные/параллельные/Unicode/вложения/cursor | make student-test | evidence/tests-image-fix-final.txt |
|
||||
| Повреждённый JPEG с поддельным EOI | regression до исправления и полный тест после djpeg | evidence/attachments-before-strict-jpeg.txt; evidence/tests-image-fix-final.txt |
|
||||
| Независимая проверка реального HTTP | root external regression | Отдельная итоговая проверка общего пакета |
|
||||
| Десять одновременных upload | research/upload_memory.py | evidence/upload-memory-final.json |
|
||||
| Reconciler/fault-injection/стоимость | tools profile research | evidence/reconcile-study.json |
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
.venv/bin/python scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
.venv/bin/python scripts/validate_openapi.py
|
||||
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
|
||||
@@ -0,0 +1,2 @@
|
||||
...................... [100%]
|
||||
22 passed in 13.29s
|
||||
@@ -0,0 +1,82 @@
|
||||
FF.F [100%]
|
||||
=================================== FAILURES ===================================
|
||||
_______________ test_36m_progressive_jpeg_is_valid_and_unchanged _______________
|
||||
|
||||
scenario = (<client.Client object at 0x102ae4290>, {'id': 'ef1e6ee9-739a-4dfe-8b05-78bef274c542', 'user': {'id': 'ef1e6ee9-739a-4...-06T15:51:51.913231Z', 'member_ids': ['ef1e6ee9-739a-4dfe-8b05-78bef274c542', '830c471d-1354-43d3-9241-ef98ffc87c7c']})
|
||||
|
||||
def test_36m_progressive_jpeg_is_valid_and_unchanged(scenario):
|
||||
data = progressive_jpeg()
|
||||
> attachment = upload(scenario, data, "image/jpeg", 201)["json"]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
student-tests/test_image_edges.py:73:
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
student-tests/test_image_edges.py:21: in upload
|
||||
return c.call(
|
||||
tests/client.py:132: in call
|
||||
check(status in allowed, method + ' ' + path.split('?')[0] + ': expected ' + str(allowed) + ', received ' + str(status))
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
|
||||
condition = False
|
||||
message = 'POST /api/v1/chats/e9b3f246-cba5-470b-b88f-35da5340b635/attachments: expected [201], received 415'
|
||||
|
||||
def check(condition, message):
|
||||
if not condition:
|
||||
> raise Failure(message)
|
||||
E client.Failure: POST /api/v1/chats/e9b3f246-cba5-470b-b88f-35da5340b635/attachments: expected [201], received 415
|
||||
|
||||
tests/client.py:24: Failure
|
||||
__________________ test_apng_corrupt_later_frame_is_rejected ___________________
|
||||
|
||||
scenario = (<client.Client object at 0x102ae4290>, {'id': 'ef1e6ee9-739a-4dfe-8b05-78bef274c542', 'user': {'id': 'ef1e6ee9-739a-4...-06T15:51:51.913231Z', 'member_ids': ['ef1e6ee9-739a-4dfe-8b05-78bef274c542', '830c471d-1354-43d3-9241-ef98ffc87c7c']})
|
||||
|
||||
def test_apng_corrupt_later_frame_is_rejected(scenario):
|
||||
> upload(scenario, broken_later_frame(apng()), "image/png", 415)
|
||||
|
||||
student-tests/test_image_edges.py:81:
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
student-tests/test_image_edges.py:21: in upload
|
||||
return c.call(
|
||||
tests/client.py:132: in call
|
||||
check(status in allowed, method + ' ' + path.split('?')[0] + ': expected ' + str(allowed) + ', received ' + str(status))
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
|
||||
condition = False
|
||||
message = 'POST /api/v1/chats/e9b3f246-cba5-470b-b88f-35da5340b635/attachments: expected [415], received 201'
|
||||
|
||||
def check(condition, message):
|
||||
if not condition:
|
||||
> raise Failure(message)
|
||||
E client.Failure: POST /api/v1/chats/e9b3f246-cba5-470b-b88f-35da5340b635/attachments: expected [415], received 201
|
||||
|
||||
tests/client.py:24: Failure
|
||||
______________________ test_apng_cumulative_canvas_limit _______________________
|
||||
|
||||
scenario = (<client.Client object at 0x102ae4290>, {'id': 'ef1e6ee9-739a-4dfe-8b05-78bef274c542', 'user': {'id': 'ef1e6ee9-739a-4...-06T15:51:51.913231Z', 'member_ids': ['ef1e6ee9-739a-4dfe-8b05-78bef274c542', '830c471d-1354-43d3-9241-ef98ffc87c7c']})
|
||||
|
||||
def test_apng_cumulative_canvas_limit(scenario):
|
||||
# Two 25M-pixel canvases exceed the total 40M decode budget.
|
||||
> upload(scenario, apng((5000, 5000)), "image/png", 413)
|
||||
|
||||
student-tests/test_image_edges.py:95:
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
student-tests/test_image_edges.py:21: in upload
|
||||
return c.call(
|
||||
tests/client.py:132: in call
|
||||
check(status in allowed, method + ' ' + path.split('?')[0] + ': expected ' + str(allowed) + ', received ' + str(status))
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
|
||||
condition = False
|
||||
message = 'POST /api/v1/chats/e9b3f246-cba5-470b-b88f-35da5340b635/attachments: expected [413], received 201'
|
||||
|
||||
def check(condition, message):
|
||||
if not condition:
|
||||
> raise Failure(message)
|
||||
E client.Failure: POST /api/v1/chats/e9b3f246-cba5-470b-b88f-35da5340b635/attachments: expected [413], received 201
|
||||
|
||||
tests/client.py:24: Failure
|
||||
=========================== short test summary info ============================
|
||||
FAILED student-tests/test_image_edges.py::test_36m_progressive_jpeg_is_valid_and_unchanged
|
||||
FAILED student-tests/test_image_edges.py::test_apng_corrupt_later_frame_is_rejected
|
||||
FAILED student-tests/test_image_edges.py::test_apng_cumulative_canvas_limit
|
||||
3 failed, 1 passed in 2.41s
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"scenario": "APNG40M\u2192CMYK40M\u2192RGB36M\u2192ordinaryPNG, plus malformed frames/JPEG and repeated cases",
|
||||
"api_limit_bytes": 536870912,
|
||||
"containers": [
|
||||
{
|
||||
"id": "7b1331ef2f48894e180f55aa43a7fc926ebdb8119b70c6b12e6154ddd7718c41",
|
||||
"image": "sha256:0f1975a55bf57b7a413815f678e29d500924f18a1485e2e3000aa9b09c2e23ae",
|
||||
"current_bytes": 88059904,
|
||||
"peak_bytes": 426946560,
|
||||
"events": {
|
||||
"low": 0,
|
||||
"high": 0,
|
||||
"max": 0,
|
||||
"oom": 0,
|
||||
"oom_kill": 0,
|
||||
"oom_group_kill": 0
|
||||
},
|
||||
"running": true,
|
||||
"oom_killed": false,
|
||||
"limit_bytes": 536870912
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"api_limit_bytes": 536870912,
|
||||
"native_budget_mib": 384,
|
||||
"child_linux_as_mib": 512,
|
||||
"child_cpu_seconds": 4,
|
||||
"parent_wall_seconds": 5,
|
||||
"scenario": "APNG40M\u2192CMYK40M\u2192RGB36M\u2192ordinaryPNG plus malformed/full-range cases",
|
||||
"targeted_result": "22 passed in 13.29s",
|
||||
"full_suite_result": "155 passed in 50.44s",
|
||||
"final_source_hashes": {
|
||||
"src/messenger/__init__.py": "9a72a49106367ca514cc6147d0e727e62c4d33fefd61572d209a5c9494551a2c",
|
||||
"src/messenger/__main__.py": "ba9a59ad44ee8884cd65cf88d5ea15cbd7051b10f7c729043ddd44ca2f34defe",
|
||||
"src/messenger/app.py": "bea8bc70db73e99cb26a794db9549ff6d5ffc51951e587c44c36ea2656410e54",
|
||||
"src/messenger/attachments.py": "fb8735c19140c96b16ecdc7b643c175c8e418bfa9683a986d5c9c92617dc8082",
|
||||
"src/messenger/config.py": "e4d4aaf674ede8b5abdc361f77c7793ee94d8d7856030c28834eb7c95291b193",
|
||||
"src/messenger/domain.py": "7bf6f177ab5bdeea09b303dc886160335d348f64f47912b9bba45355db378bef",
|
||||
"src/messenger/image_validation.py": "d9aa8db65edaab88c9a76cf2e5459ad3028ba808579311aeb0d8c4f01f875720",
|
||||
"src/messenger/migrate.py": "eb5cad7ac6abe38dd40b2db307d298b297abe9543b3928c36bab8ef06283664e",
|
||||
"src/messenger/models.py": "c43769d2d4ba0369129a86bf80364a626ab91442f9b9020e6bc904e363a39665",
|
||||
"src/messenger/postgres.py": "8a9c0cd275bbb04604d94c1a0155176e9f0348d1e05abe2120c74b0b83f36f6c",
|
||||
"src/messenger/reconcile.py": "792e21f50e777458df367069694e5ff751817fff4dbec4276e4d73e9c64a2fd7",
|
||||
"src/messenger/storage.py": "70b0fb157b285b674a7388a2bfe5c5a7feb8149a9266ac7ad035961d769008a5",
|
||||
"src/messenger/storage_bootstrap.py": "b29a2a1f8864ec3425a7499b1752688f69d8f402f3881957e790ed4522d35589"
|
||||
},
|
||||
"containers": [
|
||||
{
|
||||
"id": "beb1633f31867054f0f1d251df15769de8c8a7a8ee955fb1c5a4df75b0a7fb88",
|
||||
"image": "sha256:362e7406d132beae97a8824381832939f98de42b02ac914367b0a6edf8549ce6",
|
||||
"current_bytes": 83705856,
|
||||
"peak_bytes": 422154240,
|
||||
"events": {
|
||||
"low": 0,
|
||||
"high": 0,
|
||||
"max": 0,
|
||||
"oom": 0,
|
||||
"oom_kill": 0,
|
||||
"oom_group_kill": 0
|
||||
},
|
||||
"running": true,
|
||||
"oom_killed": false,
|
||||
"limit_bytes": 536870912,
|
||||
"runtime_source_matches": true
|
||||
},
|
||||
{
|
||||
"id": "8368fe5482e93bba9a337f21aca3e7e72c6a3844bb2ecd451878c66bbb07aa33",
|
||||
"image": "sha256:362e7406d132beae97a8824381832939f98de42b02ac914367b0a6edf8549ce6",
|
||||
"current_bytes": 83824640,
|
||||
"peak_bytes": 422637568,
|
||||
"events": {
|
||||
"low": 0,
|
||||
"high": 0,
|
||||
"max": 0,
|
||||
"oom": 0,
|
||||
"oom_kill": 0,
|
||||
"oom_group_kill": 0
|
||||
},
|
||||
"running": true,
|
||||
"oom_killed": false,
|
||||
"limit_bytes": 536870912,
|
||||
"runtime_source_matches": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
All checks passed!
|
||||
@@ -0,0 +1 @@
|
||||
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,4 @@
|
||||
........................................................................ [ 46%]
|
||||
........................................................................ [ 92%]
|
||||
........... [100%]
|
||||
155 passed in 50.44s
|
||||
@@ -0,0 +1,2 @@
|
||||
..... [100%]
|
||||
5 passed in 0.14s
|
||||
@@ -70,6 +70,10 @@ def validate_image(fileobj, declared_type):
|
||||
process.communicate()
|
||||
raise Failure(415, "Изображение не прошло ограниченную проверку") from None
|
||||
if process.returncode:
|
||||
try:
|
||||
os.killpg(process.pid, signal.SIGKILL)
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
raise Failure(415, "Изображение не прошло ограниченную проверку")
|
||||
except OSError:
|
||||
raise Failure(503, "Проверка изображения временно недоступна") from None
|
||||
|
||||
Reference in New Issue
Block a user