发布失败或中断时,回复正文临时文件可能留在本机
原文依据:4 处流程把回复正文和 JSON 负载写入临时文件,但只在 GitHub 命令之后执行普通的 `rm -f`,没有退出陷阱或失败清理步骤。命令报错、代理终止或进程被中断时,清理命令可能不会运行。
尚未发布的回复、引用的审查内容或用户提供的理由可能继续保存在临时目录中,并受该机器临时目录权限和清理策略保护。
活动流程把回复正文及其 JSON 负载写入临时文件,且删除操作排在网络发布命令之后。若执行在删除前被中断,正文可能残留在系统临时目录;内容可能包含尚未公开的代码审阅说明。源码未展示退出陷阱或等效的保证清理机制。用户可要求使用保证执行的清理机制,并限制临时文件权限和保留时间。
For review comments, post replies with the REST API endpoint. Write the reply body to a temporary JSON file and pass it with `--input` instead of putting the response text directly in command-line arguments:```shREPLY_BODY_FILE="$(mktemp)"cat > "$REPLY_BODY_FILE"REPLY_PAYLOAD_FILE="$(mktemp)"python3 - "$REPLY_BODY_FILE" "$REPLY_PAYLOAD_FILE" <<'PY'import jsonimport sysfrom pathlib import Pathbody_file = Path(sys.argv[1])payload_file = Path(sys.argv[2])payload_file.write_text(json.dumps({"body": body_file.read_text()}))PYGH_PAGER="" gh api \ --method POST \ /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies \ --input "$REPLY_PAYLOAD_FILE"rm -f "$REPLY_BODY_FILE" "$REPLY_PAYLOAD_FILE"```查看另外 3 个位置
For PR-level comments or review-body comments that cannot be directly threaded, post a normal PR comment and quote or link to the original comment:```shREPLY_BODY_FILE="$(mktemp)"cat > "$REPLY_BODY_FILE"GH_PAGER="" gh pr comment {pull_number} --body-file "$REPLY_BODY_FILE"rm -f "$REPLY_BODY_FILE"``````shREPLY_BODY_FILE="$(mktemp)"cat > "$REPLY_BODY_FILE"REPLY_PAYLOAD_FILE="$(mktemp)"python3 - "$REPLY_BODY_FILE" "$REPLY_PAYLOAD_FILE" <<'PY'import jsonimport sysfrom pathlib import Pathbody_file = Path(sys.argv[1])payload_file = Path(sys.argv[2])payload_file.write_text(json.dumps({"body": body_file.read_text()}))PYGH_PAGER="" gh api \ --method POST \ /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies \ --input "$REPLY_PAYLOAD_FILE"rm -f "$REPLY_BODY_FILE" "$REPLY_PAYLOAD_FILE"``````shREPLY_BODY_FILE="$(mktemp)"cat > "$REPLY_BODY_FILE"GH_PAGER="" gh pr comment {pull_number} --body-file "$REPLY_BODY_FILE"rm -f "$REPLY_BODY_FILE"```