Skip to content

fix(alias): reject malformed RC_HOST credentials#184

Open
overtrue wants to merge 2 commits intomainfrom
codex/test-env-alias-errors
Open

fix(alias): reject malformed RC_HOST credentials#184
overtrue wants to merge 2 commits intomainfrom
codex/test-env-alias-errors

Conversation

@overtrue
Copy link
Copy Markdown
Contributor

@overtrue overtrue commented May 7, 2026

Related Issue(s)

None.

Problem Background and User Impact

Recent RC_HOST_* environment alias support lets users configure aliases without writing credentials to disk. The happy path was covered, but malformed environment alias values could still regress without a user-facing test. In particular, invalid percent escapes inside credentials were accepted as literal secret text, and some validation messages were classified as generic JSON errors instead of usage errors.

Root Cause Summary

The credential decoder delegated directly to urlencoding::decode, which tolerates malformed percent triplets such as %ZZ. The JSON error metadata inference also did not treat messages using “must use” or “must include” as usage errors.

Solution Overview

This PR adds strict percent-triplet validation before decoding RC_HOST credentials and keeps invalid credential values out of errors. It also broadens JSON error metadata inference for validation messages that say a value must use or include something. The CLI integration tests now cover malformed RC_HOST percent encoding and unsupported schemes while asserting credentials are not echoed.

Test Status

  • cargo test -p rc-core test_parse_rc_host_alias_rejects_invalid_percent_encoding --lib
  • cargo test -p rustfs-cli --test env_alias
  • cargo fmt --all --check
  • git diff --check
  • make pre-commit

@overtrue overtrue marked this pull request as ready for review May 7, 2026 12:20
Copilot AI review requested due to automatic review settings May 7, 2026 12:20
Copy link
Copy Markdown

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

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: 4ca6b0c6f2

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cli/tests/env_alias.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens validation and improves user-facing error classification for RC_HOST_* environment aliases, ensuring malformed percent-encoding is rejected and that JSON error output correctly categorizes common validation messages as usage errors.

Changes:

  • Add strict percent-triplet validation for env alias credentials before decoding, rejecting malformed %.. sequences.
  • Add unit + CLI integration tests to cover invalid percent-encoding and unsupported URL schemes, asserting credentials are not echoed.
  • Broaden JSON error metadata inference to treat “must use” / “must include” validation messages as usage_error.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/core/src/alias.rs Adds strict percent-encoding validation for RC_HOST credentials and a unit test for malformed escapes.
crates/cli/tests/env_alias.rs Adds integration tests ensuring malformed RC_HOST aliases fail without leaking credentials and are classified as usage errors.
crates/cli/src/output/formatter.rs Expands heuristic classification so “must use/include” validation messages map to usage_error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overtrue overtrue changed the title test(alias): cover RC_HOST error handling fix(alias): reject malformed RC_HOST credentials May 7, 2026
@overtrue overtrue force-pushed the codex/test-env-alias-errors branch from 73ccb48 to 326b46a Compare May 7, 2026 13:52
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