-
Notifications
You must be signed in to change notification settings - Fork 13.1k
[ISSUE##13267] Fix cannot delete service which contains illegal character #13397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
修复因非法字符导致的服务删除失败问题变更文件
💡 小贴士与 lingma-agents 交流的方式📜 直接回复评论
📜 在代码行处标记
📜 在讨论中提问
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 代码评审报告
🎯 评审意见概览
严重度 | 数量 | 说明 |
---|---|---|
🔴 Blocker | 0 | 阻断性问题,需立即修复。例如:系统崩溃、关键功能不可用或严重安全漏洞。 |
🟠 Critical | 0 | 严重问题,高优先级修复。例如:核心功能异常或性能瓶颈影响用户体验。 |
🟡 Major | 1 | 主要问题,建议修复。例如:非核心功能缺陷或代码维护性较差。 |
🟢 Minor | 0 | 次要问题,酌情优化。例如:代码格式不规范或注释缺失。 |
总计: 1 个问题
📋 评审意见详情
💡 单文件建议
以下是文件级别的代码建议,聚焦于代码的可读性、可维护性和潜在问题。
📜 console-ui/src/pages/ServiceManagement/ServiceList/ServiceList.js (1 💬)
- 需要同时对服务组名进行URL编码处理 (L163)
🚀 跨文件建议
以下是对代码架构和设计的综合分析,聚焦于跨文件交互、系统一致性和潜在优化空间。
🔍 1. URL参数编码不一致导致潜在功能缺陷
当前修改仅对serviceName参数进行了URL编码处理,但未对groupName参数进行相同处理。根据RFC 3986规范,URL查询参数中的特殊字符均需进行编码。若服务组名包含非法字符(如空格、&等),会导致API请求参数解析失败,进而引发删除操作失败。该问题可能存在于系统其他API调用中,需检查所有API参数传递是否遵循统一的编码规范。
📌 关键代码:
+ const encodedServiceName = encodeURIComponent(service.name);
...
+ url: `v3/console/ns/service?serviceName=${encodedServiceName}&groupName=${service.groupName}`,
- 系统性参数编码不一致问题可能存在于其他API调用中,增加未来排查问题的难度
- 未编码的参数可能引发URL注入风险(虽概率较低,但不符合安全编码规范)
🔍 2. 缺少跨接口的参数编码规范一致性验证
当前改动未体现对现有API调用的全面审查,可能存在其他接口参数未进行编码处理的情况。建议建立统一的URL参数编码工具函数,并在以下场景进行验证:
- 所有GET请求查询参数
- POST/PUT请求的表单数据
- 路径参数(如/v3/service/{id}中的id字段)
需确认系统是否存在统一的HTTP客户端封装层来强制执行编码规范。
- 新增接口时可能重复出现参数未编码问题
- 安全审计时暴露编码规范不统一的风险
🔍 3. 未覆盖服务组名编码的测试场景
当前单元测试未包含服务组名包含特殊字符的删除测试用例。建议补充以下测试场景:
- 服务名称和组名均包含特殊字符的删除测试
- 仅组名包含特殊字符的删除测试
- 编码边界字符(如%、+等)的测试
需确保测试覆盖所有参数组合情况,避免因编码遗漏导致的测试盲区。
- 测试用例不完整导致问题在生产环境暴露
💡 小贴士
与 lingma-agents 交流的方式
📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:
-
在当前代码中添加详细的注释说明。
-
请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。
📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:
-
@Lingma-Agent 分析这个方法的性能瓶颈并提供优化建议。
-
@Lingma-Agent 对这个方法生成优化代码。
📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:
-
@Lingma-Agent 请总结上述讨论并提出解决方案。
-
@Lingma-Agent 请根据讨论内容生成优化代码。
request({ | ||
method: 'DELETE', | ||
url: `v3/console/ns/service?serviceName=${service.name}&groupName=${service.groupName}`, | ||
url: `v3/console/ns/service?serviceName=${encodedServiceName}&groupName=${service.groupName}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要同时对服务组名进行URL编码处理
🟡 Major | 🐞 Bugs
📋 问题详情
当前仅对服务名称(serviceName)进行了URL编码,但服务组名(groupName)也可能包含特殊字符。未对组名进行编码可能导致URL格式错误,当组名包含空格或特殊字符时会导致请求路径解析失败,从而影响删除操作的可靠性。
💡 解决方案
需要同时对服务组名进行编码处理:
- url: `v3/console/ns/service?serviceName=${encodedServiceName}&groupName=${service.groupName}`,
+ url: `v3/console/ns/service?serviceName=${encodedServiceName}&groupName=${encodeURIComponent(service.groupName)}`,
您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #13397 +/- ##
=============================================
- Coverage 70.41% 70.40% -0.01%
+ Complexity 11717 11716 -1
=============================================
Files 1592 1592
Lines 50977 50977
Branches 5148 5148
=============================================
- Hits 35895 35892 -3
- Misses 12650 12654 +4
+ Partials 2432 2431 -1 see 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
@Saltysth please sign cla |
done |
Please do not create a Pull Request without creating an issue first.
What is the purpose of the change
13267
Brief changelog
对前端请求时的service.name进行utf-8编码,使其符合RFC相关规范
Verifying this change
!({#}*&^>$^5Asldw2/;A