Is there an existing issue for this?
Current Behavior
Description
I found a // todo comment in the source code regarding the URI validation of RuleConditionDTO.
Currently, the createOrUpdate method in org/apache/shenyu/admin/service/RuleService.java only validates the URI format when the operator is PATH_PATTERN, and leaves a TODO for other matching modes:
// now, only check rule uri condition in pathPattern mode
// todo check uri in other modes
I propose to resolve this TODO by implementing strict validations for the remaining operators.
My plan is to introduce a UriConditionValidator using the Strategy Pattern to map different operators (regex, =, startsWith, endsWith) to their specific validation logic. This will make the validation robust and keep the main flow clean.
I am working on this and will submit a Pull Request shortly.
Expected Behavior
When the URI does not conform to the rules, it should throw an error instead of saving to the database.
Steps To Reproduce
- Go to ShenYu Admin Console -> Plugin List -> Add a Rule.
- Add a condition: ParamType
uri, Operator regex.
- Input an invalid regex value, for example:
[a-z+
- Click Save.
- Observe: The rule is saved successfully without any error prompt.
- Send a request to the Gateway matching this plugin.
- Observe: Gateway throws
java.util.regex.PatternSyntaxException.
Environment
ShenYu version(s):2.7.1-SNAPSHOT
Debug logs
No response
Anything else?
No response
Is there an existing issue for this?
Current Behavior
Description
I found a
// todocomment in the source code regarding the URI validation ofRuleConditionDTO.Currently, the
createOrUpdatemethod in org/apache/shenyu/admin/service/RuleService.java only validates the URI format when the operator isPATH_PATTERN, and leaves a TODO for other matching modes:I propose to resolve this TODO by implementing strict validations for the remaining operators.
My plan is to introduce a UriConditionValidator using the Strategy Pattern to map different operators (regex, =, startsWith, endsWith) to their specific validation logic. This will make the validation robust and keep the main flow clean.
I am working on this and will submit a Pull Request shortly.
Expected Behavior
When the URI does not conform to the rules, it should throw an error instead of saving to the database.
Steps To Reproduce
uri, Operatorregex.[a-z+java.util.regex.PatternSyntaxException.Environment
Debug logs
No response
Anything else?
No response