Skip to content

Commit a31a519

Browse files
heiskrCopilotCopilot
authored
Fix unsafe template interpolation in changelog-agent workflow (#61485)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 1252517 commit a31a519

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

.github/workflows/changelog-agent.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ jobs:
112112
if: steps.check_team.outputs.is_team_member == 'true'
113113
id: extract_issue
114114
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
115+
env:
116+
PR_BODY: ${{ steps.resolve_pr.outputs.pr_body }}
115117
with:
116118
github-token: ${{ secrets.DOCS_BOT_PAT_BASE }}
117119
script: |
118-
const body = `${{ steps.resolve_pr.outputs.pr_body }}`;
120+
const body = process.env.PR_BODY || '';
119121
120122
// Match closing keywords followed by docs-content issue references.
121123
// Supports: closes github/docs-content#123, fixes https://github.com/github/docs-content/issues/123
@@ -224,6 +226,10 @@ jobs:
224226
if: steps.check_parent.outputs.has_parent == 'true'
225227
id: gather_context
226228
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
229+
env:
230+
PR_TITLE: ${{ steps.resolve_pr.outputs.pr_title }}
231+
PR_BODY: ${{ steps.resolve_pr.outputs.pr_body }}
232+
PR_URL: ${{ steps.resolve_pr.outputs.pr_url }}
227233
with:
228234
github-token: ${{ secrets.DOCS_BOT_PAT_BASE }}
229235
script: |
@@ -254,9 +260,9 @@ jobs:
254260
const changedFiles = files.map(f => f.filename);
255261
256262
core.setOutput('pr_author', prAuthor);
257-
core.setOutput('pr_title', '${{ steps.resolve_pr.outputs.pr_title }}');
258-
core.setOutput('pr_body', `${{ steps.resolve_pr.outputs.pr_body }}`);
259-
core.setOutput('pr_url', '${{ steps.resolve_pr.outputs.pr_url }}');
263+
core.setOutput('pr_title', process.env.PR_TITLE || '');
264+
core.setOutput('pr_body', process.env.PR_BODY || '');
265+
core.setOutput('pr_url', process.env.PR_URL || '');
260266
core.setOutput('pr_number', prNumber.toString());
261267
core.setOutput('approved_reviewers', approvedReviewers.join(','));
262268
core.setOutput('changed_files', changedFiles.join('\n'));
@@ -421,14 +427,19 @@ jobs:
421427
- name: Dry run summary
422428
if: steps.generate_draft.outputs.response != '' && inputs.dry_run == true
423429
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
430+
env:
431+
PR_AUTHOR: ${{ steps.gather_context.outputs.pr_author }}
432+
PR_URL: ${{ steps.gather_context.outputs.pr_url }}
433+
PARENT_TITLE: ${{ steps.check_parent.outputs.parent_title }}
434+
DRAFT: ${{ steps.generate_draft.outputs.response }}
424435
with:
425436
script: |
426437
core.info('=== DRY RUN — no PR will be created, no Slack DM sent ===');
427-
core.info(`PR author: ${{ steps.gather_context.outputs.pr_author }}`);
428-
core.info(`Source PR: ${{ steps.gather_context.outputs.pr_url }}`);
429-
core.info(`Parent issue: ${{ steps.check_parent.outputs.parent_title }}`);
438+
core.info(`PR author: ${process.env.PR_AUTHOR || ''}`);
439+
core.info(`Source PR: ${process.env.PR_URL || ''}`);
440+
core.info(`Parent issue: ${process.env.PARENT_TITLE || ''}`);
430441
core.info('--- Generated changelog draft ---');
431-
core.info(`${{ steps.generate_draft.outputs.response }}`);
442+
core.info((process.env.DRAFT || '').replace(/^::/gm, ': :'));
432443
core.info('--- End of draft ---');
433444
434445
- name: Create changelog PR in docs-content

0 commit comments

Comments
 (0)