Skip to content

fix: add configurable safe-outputs URL sanitization policy for code-region-safe suggestion handling#39927

Merged
pelikhan merged 8 commits into
mainfrom
copilot/fix-safe-output-sanitizer-issue
Jun 19, 2026
Merged

fix: add configurable safe-outputs URL sanitization policy for code-region-safe suggestion handling#39927
pelikhan merged 8 commits into
mainfrom
copilot/fix-safe-output-sanitizer-issue

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Safe-output URL sanitization is now policy-driven at the safe-outputs frontmatter level, so workflows can choose between strict URL sanitization everywhere and preserving URLs inside code regions (including GitHub suggestion fences) to avoid patch corruption.

Changes

  • New frontmatter field: safe-outputs.urls with supported values:
    • allowed-only (default): sanitize URLs across all content regions
    • allowed-or-code-region: sanitize prose while preserving fenced/inline code regions
  • sanitize_content_core.cjs / sanitize_content.cjs:
    • Added policy-based URL sanitization flow
    • Wired policy via GH_AW_SAFE_OUTPUTS_URLS
    • Preserves suggestion/code-region payloads only when allowed-or-code-region is selected
  • Compiler and schema updates:
    • Added safe-outputs.urls to workflow schema
    • Added parsing, validation, and env propagation in safe-outputs compilation
  • Import/shared workflow support:
    • Added safe-outputs merge behavior so urls policy is preserved through imported/shared agentic workflows
  • Tests:
    • Updated sanitizer regression tests for both policy modes
    • Added Go tests for policy validation, propagation, and import merge behavior

Copilot AI and others added 2 commits June 18, 2026 00:21
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…stion block corruption

Safe-output URL sanitization (protocol filtering and domain filtering) now
uses applyToNonCodeRegions so that content inside fenced code blocks —
including GitHub suggestion blocks — is never rewritten.

Previously, sanitizeUrlProtocols and sanitizeUrlDomains were applied to the
full output string, which could corrupt apply-ready patch payloads inside
```suggestion fences (e.g. custom-protocol docs crosslinks).

Fixes #39793

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix output sanitizer rewriting custom-protocol links fix: preserve fenced code blocks during URL sanitization to prevent suggestion block corruption Jun 18, 2026
Copilot AI requested a review from pelikhan June 18, 2026 00:26
@pelikhan pelikhan marked this pull request as ready for review June 18, 2026 00:27
Copilot AI review requested due to automatic review settings June 18, 2026 00:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes safe-output URL sanitization so it does not rewrite content inside fenced code blocks (including GitHub ```suggestion fences), preventing suggestion patch payload corruption while continuing to sanitize URLs in prose.

Changes:

  • Apply sanitizeUrlProtocols and sanitizeUrlDomains via applyToNonCodeRegions so fenced/inline code is preserved verbatim.
  • Add regression tests covering protocol and domain sanitization behavior for generic fenced blocks and suggestion blocks.
  • Adjust a header comment in the setup CLI install script.
Show a summary per file
File Description
actions/setup/js/sanitize_content_core.cjs Routes URL protocol/domain sanitization through applyToNonCodeRegions to avoid rewriting fenced code content.
actions/setup/js/sanitize_content.test.cjs Adds regression tests ensuring code fences (including suggestion) are preserved while prose is still sanitized.
actions/setup-cli/install.sh Updates a sync note comment (currently becomes self-referential; see review comment).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread actions/setup-cli/install.sh Outdated
set +o histexpand

# Kept in sync with install-gh-aw.sh — edit that file, then copy to this path.
# Kept in sync with actions/setup-cli/install.sh — edit this file, then copy to that path.
@pelikhan

Copy link
Copy Markdown
Collaborator

@lpcox review please

@github-actions github-actions Bot mentioned this pull request Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@copilot review all comments and address unresolved review feedback.

Generated by 👨‍🍳 PR Sous Chef ·

@github-actions

Copy link
Copy Markdown
Contributor

Please fix the self-referential sync note in actions/setup-cli/install.sh and push a follow-up commit.

Generated by 👨‍🍳 PR Sous Chef ·

@github-actions

Copy link
Copy Markdown
Contributor

@copilot review all comments and address unresolved review feedback.

Please summarize the remaining blockers and next steps so this branch can move forward.

Generated by 👨‍🍳 PR Sous Chef ·

@github-actions

Copy link
Copy Markdown
Contributor

@copilot review all comments and address unresolved review feedback.
Please confirm the fenced-code preservation test covers suggestion blocks.

Generated by 👨‍🍳 PR Sous Chef ·

@github-actions

Copy link
Copy Markdown
Contributor

\n@copilot review all comments and address unresolved review feedback.\n\npr-sous-chef: fix the self-referential install.sh comment and reply to the unresolved review comment.

Generated by 👨‍🍳 PR Sous Chef ·

@github-actions

Copy link
Copy Markdown
Contributor

@copilot review all comments and address unresolved review feedback.

Generated by 👨‍🍳 PR Sous Chef · 71.6 AIC · ⌖ 1 AIC · ⊞ 17.2K ·

@github-actions

Copy link
Copy Markdown
Contributor

`
@copilot review all comments and address unresolved review feedback.

Generated by 👨‍🍳 PR Sous Chef · 27.1 AIC · ⌖ 1.07 AIC · ⊞ 17.2K ·

@github-actions

Copy link
Copy Markdown
Contributor

`
Please summarize the remaining blocker and rerun the affected checks once the review thread is addressed.

Generated by 👨‍🍳 PR Sous Chef · 27.1 AIC · ⌖ 1.07 AIC · ⊞ 17.2K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot add a front matter field to define the URL escaping policy at the safe-outputs level

safe-outputs:
urls: allowed-only, allowed-or-code-region

Current mode is "allowed-only", new mode for code region is "allowed-or-code-region"

Must support import shared agentic workflows

Copilot AI and others added 2 commits June 19, 2026 02:09
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI and others added 2 commits June 19, 2026 02:16
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add a front matter field to define the URL escaping policy at the safe-outputs level

safe-outputs:...

Implemented in 33928f0 (plus follow-ups 521697f and 8ca74cb):

  • Added safe-outputs.urls with supported values allowed-only and allowed-or-code-region
  • Wired schema + frontmatter parsing + validation
  • Propagated policy to runtime via GH_AW_SAFE_OUTPUTS_URLS
  • Updated sanitizer behavior to honor policy
  • Added import-merge support so shared/imported agentic workflows carry this setting
  • Added regression tests for policy behavior

Copilot AI changed the title fix: preserve fenced code blocks during URL sanitization to prevent suggestion block corruption fix: add configurable safe-outputs URL sanitization policy for code-region-safe suggestion handling Jun 19, 2026
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot recompile

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot recompile

Ran make recompile on this branch at 33928f0; it completed successfully and produced no diffs (working tree stayed clean).

@github-actions

Copy link
Copy Markdown
Contributor

Generated by 👨‍🍳 PR Sous Chef · 42 AIC · ⌖ 1.36 AIC · ⊞ 17.2K ·

@github-actions

Copy link
Copy Markdown
Contributor

``
@copilot review all comments and address unresolved review feedback.
Please re-run validation and reply with the updated result.

Generated by 👨‍🍳 PR Sous Chef · 42 AIC · ⌖ 1.36 AIC · ⊞ 17.2K ·

@pelikhan pelikhan merged commit ea8a782 into main Jun 19, 2026
45 checks passed
@pelikhan pelikhan deleted the copilot/fix-safe-output-sanitizer-issue branch June 19, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants