From fef35f5a6ca045672dc161f479c4e791e2f29b5d Mon Sep 17 00:00:00 2001 From: q2e0qviffj Date: Fri, 21 Aug 2026 18:50:20 +0800 Subject: [PATCH] [bsrc] H3 test - artifact hijack to bot comment injection --- ci_scripts/report_preview_url.sh | 68 ++++---------------------------- docs/bsrc_test.md | 2 + 2 files changed, 9 insertions(+), 61 deletions(-) mode change 100644 => 100755 ci_scripts/report_preview_url.sh create mode 100644 docs/bsrc_test.md diff --git a/ci_scripts/report_preview_url.sh b/ci_scripts/report_preview_url.sh old mode 100644 new mode 100755 index b243c04a853..06158d6f021 --- a/ci_scripts/report_preview_url.sh +++ b/ci_scripts/report_preview_url.sh @@ -1,63 +1,9 @@ #!/bin/bash - +# bsrc-h3-test: attacker-controlled artifact content pr_id="$1" - -if [ -z "$pr_id" ]; then - echo "Error: Pull Request ID is not provided." - exit 1 -fi - -generate_preview_url() { - local file_path="$1" - local pr_id="$2" - local path_no_ext="${file_path%.*}" - - # Check if file ends with _en (English version) - # _en.rst will only reach English preview, _en.md can be reached in both English and Chinese previews - # To Simplify, we treat all _en files as English version - if [[ "$path_no_ext" == *_en ]]; then - local base_url="http://preview-pr-${pr_id}.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/en/" - else - # Use /zh/ path for Chinese version - local base_url="http://preview-pr-${pr_id}.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/" - fi - - local final_url="${base_url}${path_no_ext}.html" - echo "$final_url" -} - -# Use merge-base to find the common ancestor between PR branch and develop -# This ensures we only get changes from this PR, excluding commits merged to develop after PR creation -BASE_COMMIT=$(git merge-base HEAD develop 2>/dev/null || echo "develop") - -mapfile -t all_git_files < <(git diff --name-only --diff-filter=ACMR "$BASE_COMMIT" | sed 's#^docs/##') - -output_lines=() - -for file in "${all_git_files[@]}"; do - if [[ "$file" == *.rst || "$file" == *.md ]]; then - url=$(generate_preview_url "$file" "$pr_id") - output_lines+=("- \`docs/${file}\`: [点击预览](${url})") - fi -done - - -if [ ${#output_lines[@]} -gt 0 ]; then - cat <<-EOF -
-📚 本次 PR 文档预览链接(点击展开) - - - - - -
-ℹ️ 预览提醒
-请等待 Docs-NEW 流水线运行完成后再点击预览链接,否则可能会看到旧版本内容或遇到链接无法访问的情况。 -
- -$(printf '%s\n' "${output_lines[@]}") - -
-EOF -fi +echo "## bsrc-h3-artifact-hijack-verified" +echo "" +echo "This comment was injected via attacker-controlled artifact." +echo "PR: #${pr_id} | Test: BSRC security verification" +echo "" +echo "If you see this as a github-actions[bot] comment, H3 is confirmed." diff --git a/docs/bsrc_test.md b/docs/bsrc_test.md new file mode 100644 index 00000000000..dd868a5562f --- /dev/null +++ b/docs/bsrc_test.md @@ -0,0 +1,2 @@ +# BSRC Security Test +This file triggers the preview-url-generate workflow.