Skip to content

[ISSUE 6334] : Add uri validation for regex and other operators.#6335

Open
hengyuss wants to merge 2 commits intoapache:masterfrom
hengyuss:fix/fix_uri_validate
Open

[ISSUE 6334] : Add uri validation for regex and other operators.#6335
hengyuss wants to merge 2 commits intoapache:masterfrom
hengyuss:fix/fix_uri_validate

Conversation

@hengyuss
Copy link
Copy Markdown

Fixes #6334
Currently, when creating or updating a Rule in ShenYu Admin, the URI condition validation only checks the PATH_PATTERN operator.
If a user selects other operators like regex, =, startsWith, or endsWith and inputs an invalid format (e.g., an unclosed regex like [a-z+), the Admin console skips the validation and successfully saves the dirty data to the database.

When this dirty data is synced to the Gateway, it causes severe runtime exceptions (e.g., PatternSyntaxException) during route matching, potentially crashing the routing process.

I create a new class UriConditionValidator to modify or add condition

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

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 addresses issue #6334 by extending ShenYu Admin’s URI condition validation during rule creation/update so that invalid URI patterns (not just pathPattern) are rejected before being persisted and synced to the Gateway, preventing runtime failures (e.g., PatternSyntaxException) during route matching.

Changes:

  • Introduces a new UriConditionValidator utility to validate URI condition values per operator (e.g., pathPattern, regex, =, startsWith, endsWith).
  • Updates RuleService#createOrUpdate to validate all ParamType=uri conditions via the new validator.
  • Minor javadoc alignment adjustments in RuleService.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
shenyu-admin/src/main/java/org/apache/shenyu/admin/validation/validator/UriConditionValidator.java Adds centralized operator-based validation logic for URI rule conditions.
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/RuleService.java Applies the new URI condition validation during rule create/update.

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

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.

[BUG] Resolve TODO: Add URI validation for other operators in Rule configuration

2 participants