fix(cli): reject empty or whitespace-only message content before sign… - #7027
fix(cli): reject empty or whitespace-only message content before sign…#7027Adilmohd04 wants to merge 2 commits into
Conversation
…ing (block#5744) `buzz messages send --content -` accepted empty stdin, signed the event, and published a blank message to the relay. Add a `validate_content_not_empty` gate that checks `content.trim().is_empty()` after `read_or_stdin` and before mention resolution, signing, or relay submission. Signed-off-by: Adilmod04 <sadilmohammed0004@gmail.com>
🔐 Codex Security Review
|
There was a problem hiding this comment.
Pull request overview
This PR tightens Buzz CLI input validation to prevent buzz messages send --content - from signing and publishing empty/whitespace-only messages, aligning CLI behavior with the expected “fail fast before signing/sending” contract described in issue #5744.
Changes:
- Add
validate_content_not_empty()to reject empty or whitespace-only message content (with unit tests). - Call the new validation in
cmd_send_messageafterread_or_stdinand before mention resolution/signing/submission. - Additionally, change
cmd_get_messages--kindsparsing to error on invalid values instead of silently dropping them (references #6945).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
crates/buzz-cli/src/validate.rs |
Adds the new non-empty content validator and tests (also includes a formatting regression around a doc comment). |
crates/buzz-cli/src/commands/messages.rs |
Wires the new validator into messages send; also changes --kinds parsing behavior for messages get. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| }/// Validate content does not exceed MAX_CONTENT_BYTES (65,536). | ||
| pub fn validate_content_size(content: &str) -> Result<(), CliError> { |
| // If specific kinds requested, override — reject invalid values rather than | ||
| // silently dropping them (fixes #6945). | ||
| if let Some(k) = kinds { | ||
| let kind_list: Vec<u64> = k.split(',').filter_map(|s| s.trim().parse().ok()).collect(); | ||
| if !kind_list.is_empty() { | ||
| filter["kinds"] = serde_json::json!(kind_list); | ||
| let kind_list: Vec<u64> = k | ||
| .split(',') | ||
| .map(|s| { | ||
| let trimmed = s.trim(); | ||
| trimmed.parse::<u64>().map_err(|_| { | ||
| CliError::Usage(format!("invalid kind value in --kinds: {:?}", trimmed)) | ||
| }) | ||
| }) | ||
| .collect::<Result<Vec<_>, _>>()?; |
…lock#3357) Mobile users opening /invite/<code> were shown "Download it now" linking to GitHub releases (desktop binaries). This adds ios/android detection to buzz-download.ts so iOS users land on the App Store and Android users on Google Play, skipping the GitHub API call entirely. Also fixes the Accept invite button being permanently disabled when the /api/join-policy endpoint is unreachable — the catch handler now sets policy to null instead of undefined, matching the "no policy" state. Signed-off-by: Adilmod04 <sadilmohammed0004@gmail.com>
9ee1e8e to
e51416d
Compare
…ing (#5744)
buzz messages send --content -accepted empty stdin, signed the event, and published a blank message to the relay. Add avalidate_content_not_emptygate that checkscontent.trim().is_empty()afterread_or_stdinand before mention resolution, signing, or relay submission.Summary
Related issue
Testing