[PR #2375] [MERGED] Suppress mentions in Discord webhook mirror payloads #5563

Closed
opened 2026-10-22 04:17:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2375
Author: @Romuromylus
Created: 6/5/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Romuromylus

Base: refactor ← Head: fix/discord-allowed-mentions


📝 Commits (1)

  • a7f6f02 Suppress mentions in Discord webhook mirror payloads

📊 Changes

1 file changed (+59 additions, -19 deletions)

View changed files

📝 src-tauri/src/commands/storage/integrations/discord.rs (+59 -19)

📄 Description

Linked issue

Closes #2369

Why this change

The Discord mirror built its webhook payload with no allowed_mentions field. Discord parses mentions in content by default when the field is absent, so any @everyone / @here / role / user mention in the mirrored model or card output fired real notifications on the target server.

What changed

  • Factor payload construction into build_discord_payload and always set allowed_mentions to { "parse": [] }, disabling all mention resolution while leaving the visible text intact (suppression at the API level, not by mangling content).

Refactor impact

Primary owner: Rust integrations (src-tauri/src/commands/storage/integrations/discord.rs)

Impact areas reviewed:

  • Only the webhook send path; the existing webhook-URL and outbound-URL (SSRF) guards are unchanged.

Boundary notes:

  • none

Pressure points touched:

  • none

Validation

  • Matching validation command passes locally
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo test --workspace — green, including new payload_always_suppresses_mentions and payload_rejects_reserved_avatar_url.

Feature Discoverability

  • N/A because this PR is a security bugfix and does not add a new thing users need to find.

Reason:

  • Hardening of an existing integration path.

Docs and release impact

  • No docs changes needed

Summary by CodeRabbit

  • Bug Fixes
    • Improved Discord webhook security by preventing unintended mention resolution in messages.
    • Added validation for avatar URLs to reject unsafe or reserved addresses.
    • Content and usernames are now automatically truncated to Discord's character limits for proper delivery.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/2375 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `refactor` ← **Head:** `fix/discord-allowed-mentions` --- ### 📝 Commits (1) - [`a7f6f02`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a7f6f0219b74c3698fdbcd6f8cb1aabb16092523) Suppress mentions in Discord webhook mirror payloads ### 📊 Changes **1 file changed** (+59 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/integrations/discord.rs` (+59 -19) </details> ### 📄 Description ## Linked issue Closes #2369 ## Why this change The Discord mirror built its webhook payload with no `allowed_mentions` field. Discord parses mentions in `content` by default when the field is absent, so any `@everyone` / `@here` / role / user mention in the mirrored model or card output fired real notifications on the target server. ## What changed - Factor payload construction into `build_discord_payload` and always set `allowed_mentions` to `{ "parse": [] }`, disabling all mention resolution while leaving the visible text intact (suppression at the API level, not by mangling content). ## Refactor impact Primary owner: Rust integrations (`src-tauri/src/commands/storage/integrations/discord.rs`) Impact areas reviewed: - Only the webhook send path; the existing webhook-URL and outbound-URL (SSRF) guards are unchanged. Boundary notes: - none Pressure points touched: - none ## Validation - [ ] Matching validation command passes locally - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `cargo clippy --workspace --all-targets -- -D warnings` — clean - `cargo test --workspace` — green, including new `payload_always_suppresses_mentions` and `payload_rejects_reserved_avatar_url`. ## Feature Discoverability - [x] N/A because this PR is a security bugfix and does not add a new thing users need to find. Reason: - Hardening of an existing integration path. ## Docs and release impact - [x] No docs changes needed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved Discord webhook security by preventing unintended mention resolution in messages. * Added validation for avatar URLs to reject unsafe or reserved addresses. * Content and usernames are now automatically truncated to Discord's character limits for proper delivery. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:17:24 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5563
No description provided.