Skip to content

Commit 364c3e3

Browse files
committed
ci(final-check): sanitise the report where it is posted
The check job runs the PR's code with sudo on the runner, so the body it outputs cannot be trusted to be clean. The comment job now drops every @ and breaks issue references and issue/PR links before posting, and caps the body below GitHub's comment limit. The health check allows TECHENGINEBOT_TOKEN for TechEngine, game-catalog and cpu-engineering-samples too, whose label-triggered final checks read it.
1 parent 77e5e2a commit 364c3e3

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎.github/workflows/final-check.yml‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,16 @@ jobs:
189189
github-token: ${{ secrets.TECHENGINEBOT_TOKEN }}
190190
script: |
191191
const marker = '<!-- techmachine-final-check -->';
192-
const body = process.env.BODY || '';
192+
// The check job ran the PR's code, so its report is untrusted here:
193+
// drop every @ and break issue references and issue/PR links, so the
194+
// comment can neither mention anyone nor cross-reference anything.
195+
const zw = '​';
196+
const body = (process.env.BODY || '')
197+
.replace(/@/g, '')
198+
.replace(/(?<!&)#(?=\d+\b)/g, `#${zw}`)
199+
.replace(/\bgh-(?=\d+\b)/gi, `$&${zw}`)
200+
.replace(/\/(issues|pull|discussions)\/(?=\d)/g, `/$1/${zw}`)
201+
.slice(0, 65000);
193202
if (!body.startsWith(marker)) {
194203
core.setFailed('The check job produced no report; nothing posted.');
195204
return;

‎machine/repos.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,29 @@
1414
"name": "GetTechAPI/TechEngine",
1515
"branches": [
1616
"main"
17+
],
18+
"allowed_secrets": [
19+
"TECHENGINEBOT_TOKEN"
1720
]
1821
},
1922
{
2023
"name": "GetTechAPI/game-catalog",
2124
"branches": [
2225
"develop",
2326
"main"
27+
],
28+
"allowed_secrets": [
29+
"TECHENGINEBOT_TOKEN"
2430
]
2531
},
2632
{
2733
"name": "GetTechAPI/cpu-engineering-samples",
2834
"branches": [
2935
"develop",
3036
"main"
37+
],
38+
"allowed_secrets": [
39+
"TECHENGINEBOT_TOKEN"
3140
]
3241
}
3342
],

0 commit comments

Comments
 (0)