Skip to content

Conversation

@dengyh
Copy link
Collaborator

@dengyh dengyh commented Dec 18, 2025

No description provided.

dengyh and others added 10 commits December 18, 2025 20:19
feature(credential): 编辑凭证作用域功能模块

feature(credential): 凭证管理模块联调后端接口

feature(credential): 自定义凭证内容增加key重复校验

feature(credential): 增加获取凭证作用域详情接口

feature(credential): 去掉列表空值筛选

feature(credential): 优化查看内容详情字段

feature(credential): 优化凭证指引图体积大小

feature(credential): 提交凭证获取指引代码

(cherry picked from commit 2512579ebcfa6e904da339666af4cb805a2f8018)
feature(credential): 去掉编辑作用域模块的i18n翻译 --story=125449007
* feat: 节点配置添加凭证选择 --story=125449007
# Reviewed, transaction id: 66075

* fix: 关闭label提示下划线 --story=125449007
# Reviewed, transaction id: 66078

* feat: 节点配置添加凭证选择 --story=125449007
# Reviewed, transaction id: 66104

* fix: 凭证选择校验优化 --story=125449007
# Reviewed, transaction id: 66163
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

代码审查总结

本次 PR 引入了凭证管理系统,整体设计良好,测试覆盖充分。发现以下关键问题需要修复:

🚨 严重问题

  1. 异常捕获过于宽泛 - create_credential.py:56 和多处使用裸 except Exception,可能隐藏关键错误
  2. SQL 注入风险 - test_secret_json_field.py:52 使用字符串拼接 SQL,应使用参数化查询
  3. 代码逻辑不完整 - create_credential.py:56 有未完成的代码片段 if scope_l

⚡ 性能问题

  1. N+1 查询 - 凭证作用域检查可能导致多次数据库查询

⚠️ 逻辑问题

  1. 作用域验证逻辑 - CredentialScopeLevel.NONE 处理不明确
  2. 事务完整性 - 部分更新操作缺少事务保护

✨ 建议改进

  • 添加凭证轮换机制
  • 考虑凭证使用审计日志
  • 增强密钥管理的安全性

审查评级: 需要修复严重问题后再合并

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

详细代码审查完成,已标注关键问题

:param request: HTTP 请求对象
:param space_id: 空间ID
:return: 创建的凭证信息
"""

Choose a reason for hiding this comment

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

🚨 语法错误: 此行代码不完整 if scope_l,缺少完整的条件判断,会导致 Python 语法错误

default=CredentialScopeLevel.NONE.value,
choices=Credential.CREDENTIAL_SCOPE_LEVEL_CHOICES,
)
scopes = serializers.ListField(

Choose a reason for hiding this comment

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

⚠️ 异常处理过宽: except Exception 会捕获所有异常,包括系统错误。建议改为具体异常类型如 except ValidationError

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

补充更多关键问题标注



class UpdateCredentialSerializer(serializers.Serializer):
name = serializers.CharField(help_text=_("凭证名称"), max_length=32, required=False)

Choose a reason for hiding this comment

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

⚠️ 异常处理问题: 同样需要捕获具体异常类型,避免掩盖意外错误

:param space_id: 空间ID
:param credential_id: 凭证ID
:return: 更新后的凭证信息
"""

Choose a reason for hiding this comment

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

⚠️ 事务完整性: 更新凭证和作用域应在同一事务中,建议使用 with transaction.atomic() 包裹整个更新逻辑

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.

3 participants