Skip to content

Harden API: SSRF guard, bearer auth, bounded caches, stateless scalin… - #4

Merged
nub-coders merged 1 commit into
mainfrom
harden/phases-0-5
Jul 28, 2026
Merged

Harden API: SSRF guard, bearer auth, bounded caches, stateless scalin…#4
nub-coders merged 1 commit into
mainfrom
harden/phases-0-5

Conversation

@nub-coders

Copy link
Copy Markdown
Owner

…g, tests+CI

Phase 0 — correctness: single DAILY/ADMIN_LIMIT source, secrets-based tokens, awaited get_user_by_token, shared setup_bot_commands, README fixes.

Phase 1 — security: SSRF allow-list on /stream /video-stream /info /playlist; Authorization: Bearer header (deprecated ?token= kept as fallback); pinned deps; Redis SCAN instead of KEYS.

Phase 2 — stability: stdlib OrderedDict LRU+TTL BoundedCache for MEMORY_CACHE, LOCKS, stream job state; asyncio.Semaphore caps yt-dlp/ffmpeg spawns (YTDLP_MAX_PROCS).

Phase 3 — tests+CI: pytest + fakeredis route-contract suite (TESTING=1 guards bot/cookie startup); GitHub Actions runs ruff + pytest.

Phase 4 — scaling: stream job state in Redis (stateless API, scalable via WEB_CONCURRENCY / --scale); zero-dep /metrics + JSON logging; compose split into scalable api + single bot.

Also: default BASE_URL to https; ignore runtime cache + pytest cache.

…g, tests+CI

Phase 0 — correctness: single DAILY/ADMIN_LIMIT source, secrets-based
tokens, awaited get_user_by_token, shared setup_bot_commands, README fixes.

Phase 1 — security: SSRF allow-list on /stream /video-stream /info /playlist;
Authorization: Bearer header (deprecated ?token= kept as fallback); pinned
deps; Redis SCAN instead of KEYS.

Phase 2 — stability: stdlib OrderedDict LRU+TTL BoundedCache for MEMORY_CACHE,
LOCKS, stream job state; asyncio.Semaphore caps yt-dlp/ffmpeg spawns
(YTDLP_MAX_PROCS).

Phase 3 — tests+CI: pytest + fakeredis route-contract suite (TESTING=1 guards
bot/cookie startup); GitHub Actions runs ruff + pytest.

Phase 4 — scaling: stream job state in Redis (stateless API, scalable via
WEB_CONCURRENCY / --scale); zero-dep /metrics + JSON logging; compose split
into scalable api + single bot.

Also: default BASE_URL to https; ignore runtime cache + pytest cache.
@nub-coders
nub-coders merged commit 4e7d2c5 into main Jul 28, 2026
2 checks passed
@nub-coders
nub-coders deleted the harden/phases-0-5 branch July 28, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant