Skip to content

Validate temporary file names before processing Excel and CSV import … - #932

Open
zwfxxxxx wants to merge 2 commits into
masterfrom
fix/excel-csv-temp-file-path-traversal
Open

zwfxxxxx wants to merge 2 commits into
masterfrom
fix/excel-csv-temp-file-path-traversal

Conversation

@zwfxxxxx

Copy link
Copy Markdown
Contributor

…tasks

@seafile-dev seafile-dev 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.

审查结论:Comment(非阻塞意见)。

审查版本:65bd16914bdca69e590bd3a926b00baa406cfacd。
阻塞问题:未发现。
警告:后台安全校验没有已提交且纳入 CI 的专项回归测试,详见行内意见。

已读取任务所附分析文档:https://dev.seafile.com/seahub/smart-link/3b27ca0d-7787-4e51-875b-01cff7c25ad8/
四个 JSON 消费函数均在拼接路径及读取、删除文件之前校验文件名,符合文档要求,也覆盖旧队列中的非法任务。与 dtable-web #6439 的字段和命名协议一致,未引入消息格式迁移。

验证:使用精确 head 的真实函数体执行隔离检查,四个 worker 对相对路径、绝对路径、空值和非字符串均在文件操作前抛出 ValueError;合法中文文件名使用 scratch 中的真实 JSON 文件完成读取与删除,并到达替身导入/追加传输。共享校验器、Web 接口及 worker 的五组 unittest 检查全部通过,变更 Python 文件编译通过。GitHub 当前 build 检查为 success。

边界:远端 API、数据库和任务基础设施使用替身,未运行完整服务集成测试;本次 reviewer 探针未提交到仓库,不能替代项目 CI 回归覆盖。



def import_excel_csv_by_dtable_server(username, repo_id, dtable_uuid, dtable_name, included_tables, lang):
if not is_plain_file_name(dtable_name):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Warning] 后台拒绝非法任务缺少回归保护

影响:四个 JSON 导入、追加及更新 worker 已新增前置校验,但没有提交相应测试。尤其是升级前已入队的任务,不会再经过新版 Web 校验;现有 CI 只运行 SQL 与 webhook 测试,无法证明后续改动仍会在读文件和清理前拒绝它们。

建议修复:为四个 worker 增加非法任务参数用例,断言抛出 ValueError 且 open、清理和远端写入均未调用,同时覆盖合法文件正常消费;在 tests/test.sh 中显式执行这组测试。

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