Skip to content

fix: 同步master分支代码 - #851

Closed
Mianhuatang8 wants to merge 27 commits into
feat/replace_canvas_sdkfrom
master
Closed

fix: 同步master分支代码#851
Mianhuatang8 wants to merge 27 commits into
feat/replace_canvas_sdkfrom
master

Conversation

@Mianhuatang8

Copy link
Copy Markdown
Collaborator

No description provided.

guohelu and others added 27 commits May 14, 2026 12:06
* feat: 流程支持HTTP回调 --story=132632590
# Reviewed, transaction id: 79669

* feat: 补充测试用例 --story=132632590
# Reviewed, transaction id: 79862

* fix: 修改流程http请求review问题 --story=132632590
# Reviewed, transaction id: 80139

* fix: 修复测试用例失败问题 --story=132632590
# Reviewed, transaction id: 80141

* feat: 补充事务逻辑 --story=132632590
# Reviewed, transaction id: 80165
* feat: 增加子流程节点循环执行机制 --story=130003551
# Reviewed, transaction id: 80116

* fix: 修改循环变量输出配置及sdk版本 --story=130003551
# Reviewed, transaction id: 80238

* fix: 修复单侧失败问题 --story=130003551
# Reviewed, transaction id: 80240

* fix: 修改循环次数校验逻辑 --story=130003551
# Reviewed, transaction id: 80269

* fix: 修复代码中硬编码问题 --story=130003551
# Reviewed, transaction id: 80278
#739)

* feat: 支持get_task_list网关接口支持按照task_id_list进行过滤 --story=1070120217134346248
# Reviewed, transaction id: 80423

* fix: task_id_list 传参改为 GET 重复 key 形式 --story=1070120217134346248

- 调整传参方式:?task_id_list=1&task_id_list=3
- 在 GetTaskListSerializer 中通过 to_internal_value 适配 QueryDict.getlist
- 校验 min_length=1, max_length=50
- 同步更新单元测试、接口文档及 api-resources.yml
# Reviewed, transaction id: 80436
* feat: 补充网关接口 --story=130003551
# Reviewed, transaction id: 80881

* fix: 修复单侧失败问题 --story=130003551
# Reviewed, transaction id: 80884

* fix: 修复单侧失败问题 --story=130003551
# Reviewed, transaction id: 80885
新增 MAKO_TEMPLATE_NAME_WHITELIST_MODE 配置(off/warn/enforce,默认 enforce)
与 MAKO_TEMPLATE_NAME_EXTRA_WHITELIST 配置(默认包含 _system / _loop /
_inner_loop),并绑定到 BambooSettings,启用 bamboo-engine 侧的根标识符
白名单 + 危险 attr 链路拦截。

修复风险:
1. ${self.module.cache.util.os.popen("cmd").read()} 通过 Mako 内部命名空间
   reach 到 os 模块。
2. ${os.path.os.popen("cmd").read()}(os.path 内部 import os)以及
   ${datetime.sys.modules["os"].popen("cmd").read()} 等通过白名单根名
   反向引用 os/sys 触达进程原语的攻击面。
3. ${context._kwargs / context._with_template} 等 Mako Context 半私有通道。

灰度建议:
线上先把 BKFLOW_MAKO_WHITELIST_MODE=warn 跑若干天,按日志确认无业务误伤,
再切 enforce。回滚直接将该环境变量改回 off 即可(不需要发版)。

依赖侧需先升级 bamboo-pipeline 到带 ``WhitelistNameVisitor`` 的版本,否则该
配置对运行时无效(仅设置 BambooSettings 属性,不影响其它流程)。

Co-authored-by: Cursor <cursoragent@cursor.com>
* fix: 节点丢失outgoing和incoming导致流程保存失败 --story=134904270
# Reviewed, transaction id: 81469

* fix: 节点丢失outgoing和incoming导致流程保存失败 --story=134904270
# Reviewed, transaction id: 81471
- 新增 prototype-wireframe skill:wiremd 线框 + Mermaid 流程图 + 全页截图 + TAPD 提设计需求
- 新增 .ai/docs/guides/prototyping-workflow.md 操作指南(工具链/语法/渲染/截图/Figma/提设计需求)
- 重写 prototypes/README.md 为 wiremd 产物目录约定
- 删除旧 skill:prototype-generator、ui-prototype(通用设计原则随迁到新 skill)

Co-authored-by: Cursor <cursoragent@cursor.com>
docs(prototype): 统一原型产出为 wiremd 流程并废弃旧原型工具
# Reviewed, transaction id: 83202
fix(ci): 加固可信贡献者自动代码审查
* feat: 增加循环子画布节点 --story=135418928

* feat: 增加循环子画布节点 --story=135418928
# Reviewed, transaction id: 82268

* fix: 删除调试代码 --story=135418928
# Reviewed, transaction id: 82269

* feat: 增加循环子画布节点 --story=135418928
# Reviewed, transaction id: 82306

* fix: 循环节点配置快照输出参数隐藏 --story=135556123
# Reviewed, transaction id: 82515

* fix: 循环子节点坐标偏移 --story=135572675
# Reviewed, transaction id: 82543

* fix: 子节点任务执行状态未正确渲染 --story=135662854

* fix: 分组内节点快捷面板关闭时机不正确 --story=135662908

* fix: 代码优化 --story=135418928
# Reviewed, transaction id: 82627

* fix: 代码优化 --story=135418928
# Reviewed, transaction id: 82633

* fix: 遍历请求接口更换为批量获取 --story=135722570
# Reviewed, transaction id: 82733

* fix: 自动排版循环节点初始化导致出现无关节点问题修复 --story=135418928
# Reviewed, transaction id: 82738

* feat: 增加循环子画布节点 --story=135418928
# Reviewed, transaction id: 82833

* fix: 增加循环子画布节点 --story=135418928
# Reviewed, transaction id: 83007

* fix: 增加循环子画布节点 --story=135418928
# Reviewed, transaction id: 83008

* fix: 子画布节点配置调整 --story=136067494
# Reviewed, transaction id: 83099

* fix: 子画布节点配置调整 --story=136067494
# Reviewed, transaction id: 83100

* fix: 子画布节点配置调整 --story=136067494
# Reviewed, transaction id: 83145

* fix: 增加循环子画布节点 --story=135418928
# Reviewed, transaction id: 83213

* fix: 增加循环子画布节点 --story=135418928
# Reviewed, transaction id: 83215

* fix: 增加循环子画布节点 --story=135418928
# Reviewed, transaction id: 83230

* fix: 增加循环子画布节点 --story=135418928
# Reviewed, transaction id: 83231

* fix: 补充参数 --story=135418928
# Reviewed, transaction id: 83282

* fix: 测试问题修复 --story=135418928
# Reviewed, transaction id: 83324

* fix: 测试问题修复 --story=135418928
# Reviewed, transaction id: 83341

* fix: 子画布禁止使用子流程节点以及版本管理子流程更新提示问题处理 --story=135418928
# Reviewed, transaction id: 83382

* fix: 遍历获取更改为批量获取版本信息接口 --story=135418928
# Reviewed, transaction id: 83387

* fix: 子流程中使用子画布问题修复 --story=135418928
# Reviewed, transaction id: 83409

* fix: 子流程中使用子画布问题修复 --story=135418928
# Reviewed, transaction id: 83410

* fix: 子流程中使用子画布问题修复 --story=135418928
# Reviewed, transaction id: 83427

* fix: 子流程中使用子画布问题修复 --story=135418928
# Reviewed, transaction id: 83428

* fix: 子流程中使用子画布问题修复 --story=135418928
# Reviewed, transaction id: 83430

* fix: 补充子画布遮挡节点校验 --story=135418928
# Reviewed, transaction id: 83512

* fix: 补充子画布遮挡节点校验 --story=135418928
# Reviewed, transaction id: 83518

* fix: 子画布测试问题修复 --story=135418928
# Reviewed, transaction id: 83635

* fix: 子画布测试问题修复 --story=135418928
# Reviewed, transaction id: 83637

* fix: 循环子流程mock时隐藏输出参数配置 --story=135418928
# Reviewed, transaction id: 83678

* fix: 子流程节点配置输出参数增加提示 --story=135418928
# Reviewed, transaction id: 83691

* fix: 子流程节点配置输出参数增加提示 --story=135418928
# Reviewed, transaction id: 83758

* fix: 代码优化 --story=135418928
# Reviewed, transaction id: 83772
verify_result = verify_webhook_endpoint(verify_data)
except Exception as e:
message = str(e)
return Response({"detail": message}, exception=True)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

PR: fix: 同步master分支代码
Scope: Large sync PR covering webhook integration at template level, loop execution for subprocess plugins, permission model expansion, Mako template name whitelist, multiple new APIGW endpoints, and task message enrichment.

Issues Found


🔴 Critical

1. get_plugin_outputs.py — Missing request body validation (bkflow/apigw/views/get_plugin_outputs.py:42-43)

data = json.loads(request.body)
plugin_id = data["plugin_id"]

Uses raw json.loads + direct dict access without validation. If request.body is empty/malformed or plugin_id key is missing, this produces an unhelpful 500 error (caught by return_json_response decorator, but returns a generic message). Should use a serializer for request body validation to return proper 400 responses with clear error messages.

Suggestion: Define a request body serializer (similar to other APIGW views) to validate plugin_id is present and is a string.


2. template.py & delete_template.py — Bare raise Exception inside transaction (bkflow/template/views/template.py:345, bkflow/apigw/views/delete_template.py:59)

raise Exception(result.get("message", "Failed to clear webhooks"))

Using bare Exception to trigger transaction rollback is an anti-pattern. It bypasses DRF's exception handling (won't produce a structured API response), and makes it impossible for callers to catch specific error types. In delete_template.py this results in the return_json_response decorator catching it and returning a 500 code — but this is actually a business logic failure, not a server error.

Suggestion: Define a custom exception (e.g., WebhookClearError(APIException)) or use an existing one from the project, and handle it appropriately.


🟡 Important

3. v1_0_0.py — No bounds check on self.inner_loop index access (bkflow/pipeline_plugins/components/collections/subprocess_plugin/v1_0_0.py:148,152)

loop_item_value = list(inputs)[self.inner_loop - 1]
# ...
loop_item_value = items[self.inner_loop - 1]

If self.inner_loop exceeds the length of inputs or items, this will raise an IndexError with no meaningful context. While the loop framework presumably calls within bounds, a defensive check with a clear error message would greatly aid debugging in edge cases (e.g., race conditions, data corruption).

Suggestion: Add a bounds check before indexing:

if self.inner_loop > len(inputs):
    raise ValidationError(f"inner_loop({self.inner_loop}) exceeds iterable length({len(inputs)}) for param {param_key}")

4. webhook.pyclear_scope_webhooks performs 3 independent DELETEs without its own transaction (bkflow/utils/webhook.py:87-96)

def clear_scope_webhooks(scope_code: list):
    try:
        WebhookModel.objects.filter(...).delete()
        ScopeModel.objects.filter(...).delete()
        Subscription.objects.filter(...).delete()
    except Exception as e:
  ...
        return {"result": False, ...}
    return {"result": True, ...}

If the second or third DELETE fails after the first succeeds, and this function is called outside a transaction (which is possible since it's a standalone utility), orphaned records will remain. Currently callers wrap it in transaction.atomic(), but the function itself does not enforce transactional safety.

Suggestion: Add @transaction.atomic to clear_scope_webhooks or document that callers must provide a transaction.


5. tasks.pysend_task_message signature change (added node_id) may break existing callers (bkflow/task/celery/tasks.py:100)

def send_task_message(task_id, node_id, msg_type):

The new node_id parameter is positional, inserted between task_id and msg_type. Any existing apply_async or .delay() calls using positional args in the old order (task_id, msg_type) will silently misassign msg_type to node_id. Verify all callers have been updated.


6. space/views.pybroadcast_task_events unconditionally accesses data["template_id"] (bkflow/space/views.py:317)

scopes = [Scope(type=WebhookScopeType.TEMPLATE.value, code=str(data["template_id"]))]

While current callers (celery tasks) always provide template_id, this endpoint is an internal API accessible by any authorized app. If template_id is missing, it raises an unhandled KeyError. Consider using data.get("template_id") with early return or validation.


🔵 Minor

7. get_plugin_outputs.py — Inconsistent error handling for single vs. multiple components (bkflow/apigw/views/get_plugin_outputs.py:48-68)

When plugin_version is provided, ComponentModel.DoesNotExist is caught. But when plugin_version is not provided, ComponentModel.objects.filter(code=plugin_id) returns an empty queryset silently (no error), which may confuse callers who get {"result": True, "data": []} instead of an explicit "not found".


8. config/default.py — Logging propagate changed from True to False

Changing propagate to False for pipeline, bamboo_engine, and pipeline_engine loggers means these logs will no longer bubble up to root logger handlers. Ensure dedicated handlers are configured for these loggers, otherwise log messages may be silently dropped.


Overall Assessment

The code changes are generally well-structured with good use of transactions for delete operations and proper validation on webhook configuration parameters. The main concerns are around defensive error handling (bare exceptions, unvalidated request bodies) and ensuring the function signature change in send_task_message doesn't break callers.

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.

6 participants