Skip to content

[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

Merged
merged 1 commit into from
May 21, 2025

Conversation

Saltysth
Copy link
Contributor

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

  1. 创建一个非法名称的服务例如: !({#}*&^>$^5Asldw2/;A
  2. 点击删除按钮

Copy link

Thanks for your this PR. 🙏
Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration.
If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io


感谢您提交的PR。 🙏
请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。
如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

Copy link

lingma-agents bot commented May 20, 2025

修复因非法字符导致的服务删除失败问题

变更文件

文件路径 变更说明
console-ui/​src/​pages/​ServiceManagement/​ServiceList/​ServiceList.js 在服务删除请求中对serviceName参数进行URI编码,替换原有直接使用未编码名称的方式,解决非法字符导致的删除失败问题

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @Lingma-Agent 分析这个方法的性能瓶颈并提供优化建议。

  • @Lingma-Agent 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @Lingma-Agent 请总结上述讨论并提出解决方案。

  • @Lingma-Agent 请根据讨论内容生成优化代码。

@CLAassistant
Copy link

CLAassistant commented May 20, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

@lingma-agents lingma-agents bot left a 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 💬)

🚀 跨文件建议

以下是对代码架构和设计的综合分析,聚焦于跨文件交互、系统一致性和潜在优化空间。
🔍 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参数编码工具函数,并在以下场景进行验证:

  1. 所有GET请求查询参数
  2. POST/PUT请求的表单数据
  3. 路径参数(如/v3/service/{id}中的id字段)
    需确认系统是否存在统一的HTTP客户端封装层来强制执行编码规范。

⚠️ 潜在风险: - 分散的编码逻辑导致维护成本增加

  • 新增接口时可能重复出现参数未编码问题
  • 安全审计时暴露编码规范不统一的风险
🔍 3. 未覆盖服务组名编码的测试场景

当前单元测试未包含服务组名包含特殊字符的删除测试用例。建议补充以下测试场景:

  1. 服务名称和组名均包含特殊字符的删除测试
  2. 仅组名包含特殊字符的删除测试
  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}`,
Copy link

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-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.40%. Comparing base (bc79756) to head (57d0656).

Additional details and impacted files

Impacted file tree graph

@@              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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc79756...57d0656. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Saltysth Saltysth marked this pull request as ready for review May 20, 2025 09:39
@KomachiSion
Copy link
Collaborator

@Saltysth please sign cla

@Saltysth
Copy link
Contributor Author

@Saltysth please sign cla

done

@KomachiSion KomachiSion merged commit a1246cd into alibaba:develop May 21, 2025
4 checks passed
@KomachiSion KomachiSion added this to the 3.0.1 milestone May 22, 2025
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.

4 participants