From 10660cb99459f3ec4206d430cb58dd8a141c379a Mon Sep 17 00:00:00 2001 From: Seungpyo1007 Date: Mon, 2 Nov 2026 02:00:45 +0900 Subject: [PATCH] ci(final-check): neutralise mentions and references before the bot posts The check job runs the PR's code, which on a GitHub-hosted runner can rewrite anything later in that job, the report included. Until now only the check job cleaned that report. The comment job now cleans it too before TechEngineBot posts it: - every @ is dropped - #123, GH-123 and issue, PR and discussion links are broken - the body is capped at 65,000 characters So whatever a PR contains, the bot can't be made to mention anyone or cross-reference anything. The token text no longer says "for this repository only". One fine-grained TechEngineBot token now covers every GetTechAPI repo that has a final check. Refs #297 --- .github/workflows/final-check.yml | 23 ++++++++++++++++------- README.md | 3 ++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/final-check.yml b/.github/workflows/final-check.yml index ba1f711dd7fb..fc0335d011f2 100644 --- a/.github/workflows/final-check.yml +++ b/.github/workflows/final-check.yml @@ -7,11 +7,11 @@ name: final-check # comment with the verdict; adding the label again edits that comment. This is # the only place the TechEngineBot account is used. # -# The check job runs PR code, so it gets no secrets and a read-only token. -# Only the comment job sees TECHENGINEBOT_TOKEN, which must be a fine-grained -# token of TechEngineBot for this repository with Pull requests: read and write -# and nothing else; the job refuses any other kind of token or account. Fork -# PRs never get a comment. +# The check job runs PR code, so it gets no secrets and a read-only token, and +# the comment job doesn't trust its report. Only the comment job sees +# TECHENGINEBOT_TOKEN, which must be a fine-grained token of TechEngineBot with +# Pull requests: read and write and nothing else; the job refuses any other +# kind of token or account. Fork PRs never get a comment. on: pull_request: types: [labeled] @@ -190,7 +190,7 @@ jobs: fi case "$TOKEN" in github_pat_*) echo "ok=true" >> "$GITHUB_OUTPUT" ;; - *) echo "::error::TECHENGINEBOT_TOKEN must be a fine-grained token (github_pat_...) of TechEngineBot, for this repository only, with Pull requests: read and write." + *) echo "::error::TECHENGINEBOT_TOKEN must be a fine-grained token (github_pat_...) of TechEngineBot with Pull requests: read and write." exit 1 ;; esac @@ -203,7 +203,16 @@ jobs: github-token: ${{ secrets.TECHENGINEBOT_TOKEN }} script: | const marker = ''; - const body = process.env.BODY || ''; + // The check job ran the PR's code, so its report is untrusted here: + // drop every @ and break issue references and issue/PR links, so the + // comment can neither mention anyone nor cross-reference anything. + const zw = String.fromCharCode(0x200b); // zero-width space + const body = (process.env.BODY || '') + .replace(/@/g, '') + .replace(/(?