已开启
fix(security): add input file path traversal validation #518
qingfeng创建于 8月29日
fix(security): add input file path traversal validation #518
已开启
合并受阻
10 天前 virtual merging failed, update merge request[project_id: 9483585, iid: 518, target_commit_sha: 54f474aee451cb6e16b78b0c21f5b796b2ec596e], message: Conflict detected
10 天前 virtual merging failed, update merge request[project_id: 9483585, iid: 518, target_commit_sha: 54f474aee451cb6e16b78b0c21f5b796b2ec596e], message: Conflict detected
作者自检
pkg/cmdutil/path_validation.go:ValidateInputFilePath通用路径校验函数 — 拒绝空路径、拒绝 null 字节注入、解析为规范化绝对路径pkg/cmdutil/text_file.go:ReadTextFile在读取前调用ValidateInputFilePath,覆盖所有通过 ReadTextFile 的调用者(--body-file、--notes-file、--description-file、--comment-file、--key-file 等)pkg/cmd/issue/create/create.go:--custom-fields-file在os.ReadFile前添加ValidateInputFilePathpkg/cmd/api/api.go:--input在os.Open前添加ValidateInputFilePathpkg/cmd/release/upload/upload.go: 文件位置参数在os.Open前添加ValidateInputFilePathpkg/cmdutil/path_validation_test.go: 8 个测试用例go test ./pkg/cmdutil/...全部通过(含 8 个新增测试);go test ./pkg/cmd/api/... ./pkg/cmd/issue/create/... ./pkg/cmd/release/upload/... ./pkg/cmd/release/create/... ./pkg/cmd/release/edit/... ./pkg/cmd/issue/edit/... ./pkg/cmd/pr/create/...全部通过go build -o ./gc ./cmd/gc成功CI: 待 PR 创建后补充 GitCode 原生 CI run ID 与结论。
Closes #345