Skip to content

fix(api): 使用 ast.literal_eval 代替 eval,取消不正确的计算属性值返回。#688

Merged
pycook merged 2 commits intoveops:masterfrom
thexqn:fix_api_eval
Apr 4, 2025
Merged

fix(api): 使用 ast.literal_eval 代替 eval,取消不正确的计算属性值返回。#688
pycook merged 2 commits intoveops:masterfrom
thexqn:fix_api_eval

Conversation

@thexqn
Copy link
Copy Markdown
Contributor

@thexqn thexqn commented Mar 31, 2025

原有的代码中,eval的本意可能是将jinja2返回的str变成合适的类型,但实际上会带来如下问题:

  1. 安全隐患太大,相对于_compute_attr_value_from_script,_compute_attr_value_from_expr是可以接受普通用户输入的(导入CI时填充高危命令)),如果传入 高危命令,影响比较大
  2. 优化处理效率
    但本次修改也可能带来一定影响,主要是取消了eval兜底,原先配置的,不符合jinja2规范的代码没有办法继续生效了。

@thexqn thexqn closed this Apr 1, 2025
@thexqn thexqn reopened this Apr 2, 2025
@pycook pycook merged commit 435bb2a into veops:master Apr 4, 2025
3 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.

2 participants