mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-09-17 10:20:22 +00:00
Phase 1+2 of the 2026-05-09 review remediation plan:
- Go-version alignment (Dockerfile/go.mod) + 4 nil-deref guards + CI
docker-build step (Phase 1, c89aa1c carried over).
- Env allowlist: secretEnvKeys denylist replaced; modules opt-in via
RequiredEnv. Future API keys do not auto-leak.
- Visibility enforcement: dispatcher gates Private/Protected commands
via BOT_OWNER_ID / ADMIN_USER_IDS; non-permitted callers are silently
denied.
- Panic recovery in webhook handler; logs runtime/debug.Stack and
returns 200 to prevent Telegram retry storm.
- Cron timeout reduced 5m -> 60s.
- MaxBytesError handled separately from generic decode errors so 413
from MaxBytesReader is not shadowed by a 400.
- Emoji clue HTML-escaped defensively in loldle-emoji renderer.
- Tests added for dispatcher Auth.Permits + webhook panic recovery.
10 lines
352 B
Go
10 lines
352 B
Go
package server
|
|
|
|
import "time"
|
|
|
|
// defaultCronTimeout caps a single /cron/{name} invocation. Cloud Run free
|
|
// tier runs at most 1 instance, so a long cron serializes all other crons
|
|
// behind it and amplifies any DoS via the cron route. 60s is the budget; long
|
|
// crons must publish to PubSub and exit fast.
|
|
const defaultCronTimeout = 60 * time.Second
|