@echo off setlocal EnableDelayedExpansion cd /d "%~dp0.." set TMP=%TEMP%\lab5-private if not exist "%TMP%" mkdir "%TMP%" echo === Private bucket check (original + thumbnail) === for /f "usebackq delims=" %%a in (`docker compose exec -T postgres psql -U messenger -d messenger -tAc "SELECT s3_key FROM attachments WHERE status='ready' ORDER BY created_at DESC LIMIT 1"`) do set KEY=%%a if "%KEY%"=="" ( echo FAIL: no ready attachments found. Run scripts\manual-attachments.bat first. exit /b 1 ) echo Latest original key: %KEY% docker compose exec -T api sh -lc "wget -S -O /dev/null http://rustfs:9000/messenger/%KEY% 2>&1" > "%TMP%\out1.txt" 2>&1 findstr /c:"HTTP/1.1 200" "%TMP%\out1.txt" >nul if not errorlevel 1 ( echo FAIL: original is publicly readable & type "%TMP%\out1.txt" & exit /b 1 ) echo PASS: original not publicly readable for /f "usebackq delims=" %%a in (`docker compose exec -T postgres psql -U messenger -d messenger -tAc "SELECT chat_id || '/' || id || '/thumbnail' FROM attachments WHERE status='ready' ORDER BY created_at DESC LIMIT 1"`) do set TKEY=%%a if "%TKEY%"=="" ( echo FAIL: no ready attachment for thumbnail check exit /b 1 ) echo Latest thumbnail key: %TKEY% docker compose exec -T api sh -lc "wget -S -O /dev/null http://rustfs:9000/messenger/%TKEY% 2>&1" > "%TMP%\out2.txt" 2>&1 findstr /c:"HTTP/1.1 200" "%TMP%\out2.txt" >nul if not errorlevel 1 ( echo FAIL: thumbnail is publicly readable & type "%TMP%\out2.txt" & exit /b 1 ) echo PASS: thumbnail not publicly readable echo. echo PRIVATE BUCKET CHECKS PASSED exit /b 0