Repository navigation
Notices: add Discord webhook channel (#1204) - #1247
embrace897 wants to merge 3 commits into
Conversation
Signed-off-by: embrace897 <208367873+embrace897@users.noreply.github.com>
|
Thanks @embrace897. We are reviewing it now and will reply here. Since #1211 (email) changes the same two files, we will look at how the two fit together too. |
|
@embrace897 Thanks. We ran it end to end in a container: a real signer, a local HTTPS server standing in for Discord, and all six kinds of notice. A lot holds:
Before merge, one thing makes notices wrong:
Also needed:
#1211 (email) changes the same code in notice.py and webhook.py. Whichever is ready first lands first, and the other rebases. If yours is first, item 3's guard is yours, and #1211 builds on it. Once these are in, please show the 100-notice run again with each sentence arriving once, as in your PR body's example. |
…ion) Signed-off-by: embrace897 <208367873+embrace897@users.noreply.github.com>
|
Thanks for the thorough E2E test and detailed feedback, @LoopGlitch26! Addressed all seven items in
Verification
|
|
Thanks @embrace897. We are reviewing |
|
@embrace897 Thanks. Before merge:
Once these are in, please paste the 100-notice run's result into the PR body. |
…vents Signed-off-by: embrace897 <208367873+embrace897@users.noreply.github.com>
Closes the Discord channel item in #1204 (leaving the other channels and earlier email work in #1211 untouched).
Summary
tracekit/signer/notice.py:discord: {secret_file: ...}support inload(),dev(), andtargets()via a shared_load_webhook_url()helper.https://+remote_url_error()validation, strict{secret_file}shape checking, andst_mode & 0o077refusal (chmod 600guidance) on POSIX hosts.tracekit/signer/webhook.py:_discord()Markdown/mention escaping (\,`,*,_,~,|,<,>,[,],@) and_discord_chunks()(DISCORD_MAX = 2000batch packing/truncation).Sender._send()forfmt="discord"to omit the viewer token from[see it: ...]links, send{"content": ..., "allowed_mentions": {"parse": []}}, and return the first failing status across chunks.User-Agent: Tracekit/<version>inpost()so Discord's edge proxy acceptsurllibPOST requests.docs/notices.md: Documented the Discord channel in the channel table,signer.yamlexample, secret-file permissions, retry/drop behavior, and token-free links.tests/test_notice.py: Added unit tests covering all 6 notice kinds, mention/link escaping, local HTTP204end-to-end delivery overThreadingHTTPServer, 2,000-character batch splitting and single-line truncation,503retries /400refusal /queue_fullnon-blocking behavior,OneLinecross-channel formatting, and config / permission validation.Verification
pytest tests/test_notice.py tests/test_webhook.py -von Windows (rebased oncdb8807): 62 passed, 45 subtests passed in 7.43s (everyChannels,OneLine,Config,ViewerStart, andtest_webhook.pytest passed; 1 unrelated upstream#1219testSentences.test_an_outage_the_hook_kept_is_told_once_its_lines_have_comefails on Windows becausetime.tzsetis POSIX-only).python -m pyflakes tracekit tracekit_sdk.py tests eval examples contrib integrations-> exit code 0.webhook.Sender(..., fmt="discord")end-to-end against a localThreadingHTTPServerreturning204 No Content(POST /api/webhooks/1/tok), confirming headers (User-Agent: Tracekit/1.8.1,Content-Type: application/json) and JSON body:{"content": "Your agent tried this and Tracekit stopped it: reading or touching a credentials file (\\@everyone \\[x\\](https://bad)). Rules: TK-S004. [see it: run `tracekit view --dev`]", "allowed_mentions": {"parse": []}}204HTTP server rather than a live public Discord webhook URL.