Skip to content

Commit 41fa0b1

Browse files
committed
Merge branch 'main' of github.com:microsoft/react-native-windows into refactor-op-tests
2 parents f2fe822 + ef96601 commit 41fa0b1

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

.github/workflows/perf-comment.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ jobs:
3939
exit 0
4040
fi
4141
PR_NUMBER=$(cat "$PR_FILE" | tr -d '[:space:]')
42+
# Validate: must be a positive integer to prevent injection via artifact poisoning
43+
if ! echo "$PR_NUMBER" | grep -qE '^[1-9][0-9]*$'; then
44+
echo "::error::Invalid PR number in artifact: not a positive integer"
45+
exit 1
46+
fi
4247
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
4348
echo "skip=false" >> "$GITHUB_OUTPUT"
4449
@@ -58,12 +63,20 @@ jobs:
5863
- name: Post or update PR comment
5964
if: steps.pr.outputs.skip != 'true' && steps.report.outputs.skip != 'true'
6065
uses: actions/github-script@v7
66+
env:
67+
REPORT_PATH: ${{ steps.report.outputs.path }}
68+
PR_NUMBER: ${{ steps.pr.outputs.number }}
6169
with:
6270
script: |
6371
const fs = require('fs');
6472
const marker = '<!-- rnw-perf-results -->';
65-
const reportPath = '${{ steps.report.outputs.path }}';
66-
const prNumber = parseInt('${{ steps.pr.outputs.number }}', 10);
73+
const reportPath = process.env.REPORT_PATH;
74+
const prNumber = parseInt(process.env.PR_NUMBER, 10);
75+
76+
if (!Number.isInteger(prNumber) || prNumber <= 0) {
77+
core.setFailed('Invalid PR number from artifact — possible artifact poisoning.');
78+
return;
79+
}
6780
6881
const markdown = fs.readFileSync(reportPath, 'utf-8');
6982
const body = `${marker}\n${markdown}`;

0 commit comments

Comments
 (0)