Skip to content

Conversation

@wyyalt
Copy link
Collaborator

@wyyalt wyyalt commented Apr 1, 2025

No description provided.

@wyyalt wyyalt force-pushed the dev_multi_tenant branch 4 times, most recently from 602d20b to b7f5fa3 Compare April 4, 2025 03:43
zhouwe1 and others added 26 commits April 14, 2025 12:07
fix: 标准运维多租户改造CMDB插件 --story=122659210
fix: 标准运维多租户改造变量和CMDB插件 --story=122659384
fix: 消息通知插件多租户测试并修复 --story=121994365
fix: 标准运维多租户改造变量和CMDB插件 --story=122659384
# Reviewed, transaction id: 39634
feat: 通知中心周边系统接入联调——标准运维 --story=123610405
# Reviewed, transaction id: 39851
* fix: 修复子流程输入参数名称显示为插件表单名称的问题 --story=123583484
# Reviewed, transaction id: 39373

* fix: 修复任务执行快照表单项名称不正确问题 --story=123583484
# Reviewed, transaction id: 40013

* fix: 修复子流程批量更新、任务重试、执行详情表单项名称不正确问题 --story=123583484
# Reviewed, transaction id: 40027
# Reviewed, transaction id: 40079
fix: 多租户部署体验测试--story=123610576
# Reviewed, transaction id: 40158
fix: 多租户部署体验测试--story=123610576
# Reviewed, transaction id: 40348
# Reviewed, transaction id: 40637
fix: 多租户部署体验测试 --story=123610576
wyyalt and others added 18 commits September 12, 2025 16:38
* fix: 多租户日期时间保存格式修改 --story=129095153
# Reviewed, transaction id: 67740

* fix: 保持配置文件的独立性 --story=129095153
# Reviewed, transaction id: 67836

* fix: 保持配置文件的独立性 --story=129095153
# Reviewed, transaction id: 67875

* fix: 删除暂不处理内容 --story=129095153
# Reviewed, transaction id: 67881
# Reviewed, transaction id: 67929
fix: 时区不加空格 --story=129095153
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 的核心变更,发现 6 个关键问题需要处理:

🔒 安全问题(必须修复)

  1. 认证检查被注释 - gcloud/utils/middleware.py:42-43
    • 允许未验证请求绕过认证
  2. 敏感日志泄漏 - gcloud/core/middlewares.py:160-161
    • 使用 logger.error() 输出完整请求元数据

⚡ 破坏性变更

  1. API 签名改变 - api/utils/request.py:37
    • batch_request 函数调用方式变更,需确认所有调用方已更新

⚠️ 逻辑风险

  1. 租户 ID 弱回退 - gcloud/core/middlewares.py:171-173
    • 缺失 tenant_id 时默认为 "default",可能导致跨租户数据泄漏
  2. 缓存键不安全 - gcloud/core/middlewares.py:41
    • 时区缓存键未包含 tenant_id,可能返回错误租户的数据
  3. IAM 环境配置 - config/default.py:767
    • 默认连接生产环境,测试环境可能误调用

建议: 问题 #1#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.

File: gcloud/utils/middleware.py
Line: 42-43

🔒 CRITICAL: 认证检查被注释

# if not verified:
#     return self.make_anonymous_user(bk_username=bk_username)

问题: 所有未验证的请求都能绕过认证,被当作已认证用户处理

修复: 取消注释此安全检查,或提供明确文档说明为何禁用

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.

File: gcloud/core/middlewares.py
Line: 160-161

🚨 敏感信息日志泄漏

logger.error("+++++++++++{}: {}++++++++++".format(header, header_value))
logger.error("+++++++++++request meta: {}++++++++++".format(request.META))

问题: 生产环境日志会包含敏感 header、token、IP 地址

修复: 删除这些调试日志,或改用 logger.debug()

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.

File: gcloud/core/middlewares.py
Line: 171-173

⚠️ 租户 ID 弱回退逻辑

if not tenant_id:
    tenant_id = "default"

问题: 缺失 tenant_id 时静默回退到 "default",可能导致跨租户数据访问

修复: 在多租户模式下,缺失 tenant_id 应返回 403 或抛出异常

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.

File: gcloud/core/middlewares.py
Line: 41

⚠️ 缓存键缺少租户隔离

user_time_zone_cache_key = f"{request.user.username}_time_zone"

问题: 租户 X 的用户 A 可能获取到租户 Y 的用户 A 的时区设置

修复: 包含 tenant_id:f"{request.user.tenant_id}_{request.user.username}_time_zone"

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.

File: api/utils/request.py
Line: 37

破坏性 API 变更

- return target_func(**request_params)
+ return target_func(request_params, path_params=path_params, headers=headers)

问题: 函数签名从关键字参数变为位置参数,所有调用方需要更新

修复: 确认所有调用代码已更新,或保持向后兼容

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.

10 participants