Skip to content

fix: replace dynamic form code execution with declarative handlers - #6524

Open
ZH007-s wants to merge 1 commit into
1Panel-dev:v2from
ZH007-s:fix/dynamic-form-code-execution
Open

fix: replace dynamic form code execution with declarative handlers#6524
ZH007-s wants to merge 1 commit into
1Panel-dev:v2from
ZH007-s:fix/dynamic-form-code-execution

Conversation

@ZH007-s

@ZH007-s ZH007-s commented Jul 28, 2026

Copy link
Copy Markdown

此 PR 做了什么 / 为什么需要它?

动态表单的触发器、校验规则和表格渲染此前会通过 new Function()eval() 执行配置中的 JavaScript 字符串,部分表格值还会通过 v-htmlinnerHTML 输出。

这可能使不可信或错误持久化的配置在浏览器中执行代码,带来安全风险。

修改概要

  • 使用受限的 request_actionresponse_type 替代动态触发器脚本。
  • 保留对旧版“加载子表单”配置的兼容:识别并转换为固定逻辑,不执行原始脚本。
  • 使用声明式 validator: 'component' 替代字符串形式的组件校验函数。
  • 使用结构化的 defaultconcatnumber 格式化规则替代表格 eval 表达式。
  • 移除动态表格值中的 v-htmlinnerHTML 渲染。
  • 禁止将 __proto__prototypeconstructor 作为触发器写入目标字段。
  • 更新示例表单配置和 TypeScript 类型定义。

请确认已完成以下事项:

已完成测试,并在需要时补充了覆盖。
npm run type-check
改动文件定向 ESLint 检查
npm run build-only
npm run build-only-chat
动态表单行为断言:触发器、格式化、旧版子表单加载器和危险字段拦截
提交信息符合 Conventional Commits 规范。
已评估文档影响。
不需要新增用户文档;依赖任意脚本执行的旧动态表单配置将不再执行,这是本次安全修复的预期行为。

@ZH007-s ZH007-s changed the title fix::动态表单安全修复 fix:动态表单安全修复 Jul 28, 2026
@ZH007-s ZH007-s changed the title fix:动态表单安全修复 fix:replace dynamic form code execution with declarative handlers Jul 28, 2026
@ZH007-s ZH007-s changed the title fix:replace dynamic form code execution with declarative handlers fix: replace dynamic form code execution with declarative handlers Jul 28, 2026
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.

1 participant