--disallow-code-generation-from-strings does not work as documented
未关闭
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
Doc: https://nodejs.org/docs/latest/api/cli.html#--disallow-code-generation-from-strings
It is advertised to cover built-in language features, but it doesn't cover data imports
No Node.js modules are directly imported here
// run with node and node --disallow-code-generation-from-strings
const payload = 'console.log("evaluated code from string")'
try { eval(payload) } catch (e) { console.log(e.message) }
try { new Function(payload)() } catch (e) { console.log(e.message) }
try { await import('data:text/javascript,' + payload) } catch (e) { console.log(e.message) }
Output:
% node --disallow-code-generation-from-strings 1.js
Code generation from strings disallowed for this context
Code generation from strings disallowed for this context
evaluated code from string
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 Node.js 以及 --disallow-code-generation-from-strings 运行 issue 的 1.js 复现,然后将 eval、new Function 和数据导入的结果与 issue 中链接的 CLI 文档进行比较。跟踪此选项对数据导入的处理;当观察到的行为符合文档所述的覆盖范围,并且三个案例都有回归覆盖时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100