WeKnora/internal/im/wecom
ordinary being 03059997fe
fix(im): cap IM callback bodies before any adapter reads them (#4369)
Every IM platform calls a public, unauthenticated endpoint - the callback URL
cannot carry a bearer token - and each platform's signature is computed over the
request body, so the bytes have to be read before the request can be
authenticated at all. Each adapter read c.Request.Body with an unbounded
io.ReadAll, so a single unauthenticated POST decided how much memory the
process would allocate.

Add LimitWebhookBody to the shared internal/im package, mirroring how
internal/handler caps uploads and JSON bodies on the authenticated routes, and
call it ahead of all fifteen reads across the eight adapters. Nine of those
reads sit in VerifyCallback or HandleURLVerification, ahead of the credential
check; the rest parse the payload afterwards.

The cap is 4 MiB, far above any real callback: chat messages, interactive cards
and block payloads are kilobytes, and attachments travel as URLs the server
fetches separately under maxIMAttachmentBytes.
2026-10-16 17:16:15 +08:00
..
endpoint_test.go test(im/wecom): satisfy errcheck and lll in endpoint tests 2026-10-10 20:29:15 +08:00
factory.go fix(im): harden connection lifecycle across replicas 2026-07-27 20:39:12 +08:00
longconn.go fix(im/wecom): preserve image in mixed messages with text captions (#3901) 2026-10-08 01:25:25 +08:00
longconn_close_test.go fix(im/wecom): scope connection close to its own generation 2026-08-06 12:26:00 +08:00
mention_test.go feat(im): support custom endpoints for private WeCom deployments 2026-04-13 22:54:42 +08:00
mixed_test.go fix(im/wecom): preserve image in mixed messages with text captions (#3901) 2026-10-08 01:25:25 +08:00
quote.go fix(im): anti-hallucination for non-text quotes and unprocessable media messages 2026-04-03 11:34:22 +08:00
quote_test.go feat(memory): add cross-session long-term memory 2026-08-13 18:00:02 +08:00
reconnect_test.go fix(im): clamp reconnect backoff to avoid int64 overflow → busy loop 2026-05-05 00:36:18 +08:00
webhook_adapter.go fix(im): cap IM callback bodies before any adapter reads them (#4369) 2026-10-16 17:16:15 +08:00
webhook_adapter_test.go fix(im): handle WeCom 32-byte PKCS7 padding (#2848) 2026-08-28 15:40:42 +08:00
ws_adapter.go feat(im): align agent stream display with web thinking and tool progress 2026-06-24 10:33:55 +08:00