Skip to content

fix(validation): avoid token false positives in pre-publish check#253

Merged
wowo-zZ merged 1 commit intomainfrom
fix/prepublish-token-false-positive
Apr 9, 2026
Merged

fix(validation): avoid token false positives in pre-publish check#253
wowo-zZ merged 1 commit intomainfrom
fix/prepublish-token-false-positive

Conversation

@dongmucat
Copy link
Copy Markdown
Collaborator

概述

修复预发布校验器将函数调用/普通标识符赋值误判为泄露 token 的问题。

变更内容

后端实现

  • 收紧 BasicPrePublishValidator 的敏感赋值检测逻辑,先识别敏感键赋值,再只对真实字面量进行告警。
  • 显式跳过函数调用、普通标识符、属性访问等表达式,避免 token = extract_group_token_value(...) 这类代码被误判。
  • 保持对明显硬编码凭据的拦截,并覆盖带尾注释的引号字面量场景。

前端实现

  • 本次无前端改动。

测试覆盖

  • 后端单测:补充 BasicPrePublishValidatorTest,覆盖函数调用赋值、普通标识符赋值、带尾注释的真实 secret。
  • 前端单测:无。
  • E2E 测试:无,本次未修改前端页面交互。

质量门禁

  • make test-backend-app 通过
  • make typecheck-web 通过(未执行,本次无前端改动)
  • make lint-web 通过(未执行,本次无前端改动)
  • make test-frontend 通过(未执行,本次无前端改动)
  • Playwright E2E(web/e2e)关键路径通过(未执行,本次无 UI 变更)
  • make generate-api 已执行且 schema.d.ts 已提交(不适用,本次无 Controller 变更)

安全考虑

  • 本次变更不涉及鉴权/授权逻辑调整。
  • 修复后仍会拦截明显硬编码 secret,同时减少对正常代码的误报。

相关 Issue

Closes #234

测试说明

本地验证步骤

  1. 在任意技能包文本文件中加入 token = extract_group_token_value(response, group_choice.group_id)
  2. 执行技能发布前校验或运行 BasicPrePublishValidatorTest
  3. 预期:上述函数调用赋值不再被判定为 secret;真实硬编码 token 仍会被拦截。

回归测试范围

  • 预发布 secret 检测逻辑
  • 技能发布前校验链路

截图/录屏(如有 UI 变更)

@wowo-zZ wowo-zZ merged commit 0497f86 into main Apr 9, 2026
3 of 4 checks passed
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.

[Bug] False positive in pre-publish validator: function-call assignment to token variable is treated as leaked secret

2 participants