Skip to content

fix(helios-bot): avoid unchecked CLI and mention slices - #211

Merged
KooshaPari merged 1 commit into
mainfrom
fix/helios-bot-safety-20260830
Aug 30, 2026
Merged

fix(helios-bot): avoid unchecked CLI and mention slices#211
KooshaPari merged 1 commit into
mainfrom
fix/helios-bot-safety-20260830

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Aug 30, 2026

Copy link
Copy Markdown
Owner

User description

Summary

  • parse CLI subcommands and flags through checked slice access
  • extract the @helios suffix with UTF-8-safe string indexing
  • add regression coverage for unknown subcommands and Unicode text before a mention

Verification

  • RED: helper-contract tests initially failed with unresolved parse_command and mention_suffix symbols
  • cargo test -p helios-bot --bin helios-bot -- --nocapture (16 passed)
  • cargo clippy -p helios-bot --all-targets -- -D clippy::string_slice -D clippy::indexing_slicing -D clippy::disallowed_methods
  • cargo fmt --all -- --check
  • git diff --check

Targets the current main Lint Fix failures only; does not alter decoder suppression or Windows test code.


CodeAnt-AI Description

Prevent crashes and incorrect mention extraction in the Helios bot

What Changed

  • CLI parsing now handles missing arguments and unknown subcommands without unchecked access
  • Mention parsing remains correct when Unicode text appears before @helios
  • Added regression coverage for unknown commands and Unicode mention text

Impact

✅ Fewer bot crashes from invalid CLI input
✅ Reliable Unicode mention handling
✅ Clearer errors for unknown commands

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Co-Authored-By: ForgeCode <noreply@forgecode.dev>
Copilot AI lite review requested due to automatic review settings August 30, 2026 07:00
@codeant-ai

codeant-ai Bot commented Aug 30, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 6c626c4 Aug 30, 2026 · 07:00 07:03

@codeant-ai

codeant-ai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codeant-ai codeant-ai Bot added the size:M label Aug 30, 2026
@mergify mergify Bot added the rust label Aug 30, 2026
Comment on lines +65 to +66
let idx = lower.find("@helios")?;
text.get(idx + "@helios".len()..)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: mention_suffix accepts any substring containing @helios, so @heliosaurus or foo@helios.example triggers a bot request and webhook dispatch. [logic error]

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** crates/helios-bot/src/webhook.rs
**Line:** 65:66
**Comment:**
	*Logic Error: `mention_suffix` accepts any substring containing `@helios`, so `@heliosaurus` or `foo@helios.example` triggers a bot request and webhook dispatch.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c626c4eba

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}

#[test]
fn parse_command_rejects_unknown_subcommand_without_indexing() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Put the regression tests on a default-tested target

These new assertions run only when the binary is selected explicitly: crates/helios-bot/Cargo.toml still sets test = false, and the crate has no library target. Cargo's cargo-test(1) documentation says that this setting stops the target from being tested by default, so the workspace test commands in .github/workflows/test.yml, helios-lite-nightly.yml, and platform-tests.yml never execute either new regression test. Re-enable binary tests or move the modules to a library target so CI actually verifies this behavior.

AGENTS.md reference: AGENTS.md:L94-L102

Useful? React with 👍 / 👎.

};
let expected = "unknown subcommand: unknown";

assert_eq!(actual, expected);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the repository's pretty assertion macro

This assertion, and the new assertion in webhook.rs, resolve to the standard-library macro because neither test module imports pretty_assertions::assert_eq. Import the required macro in both modules so the newly added tests follow the repository's assertion convention and retain useful failure diffs.

AGENTS.md reference: AGENTS.md:L13-L26

Useful? React with 👍 / 👎.

Comment on lines +238 to +240
let actual = match parse_command(&fixture) {
Ok(_) => panic!("unknown subcommand should fail"),
Err(err) => err.to_string(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Replace the manual test panic with an error unwrap

The new test manually matches the result and calls panic! on unexpected success, contrary to the repository's requirement to use unwrap() or expect() in tests. Extract the error with an unwrap/expect-based result path instead, which also removes this unnecessary branching boilerplate.

AGENTS.md reference: AGENTS.md:L61-L76

Useful? React with 👍 / 👎.

@KooshaPari
KooshaPari merged commit 52306ab into main Aug 30, 2026
33 of 35 checks passed
@KooshaPari
KooshaPari deleted the fix/helios-bot-safety-20260830 branch August 30, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants