Skip to content

Add sanitization-safe metadata channel for body-based safe outputs - #48363

Merged
pelikhan merged 18 commits into
mainfrom
copilot/fix-html-comments-sanitization
Jul 28, 2026
Merged

Add sanitization-safe metadata channel for body-based safe outputs#48363
pelikhan merged 18 commits into
mainfrom
copilot/fix-html-comments-sanitization

Conversation

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Safe-output sanitization intentionally strips HTML/XML comments (<!-- ... -->), which causes silent loss of machine-readable markers embedded in bodies. This change adds a first-class structured metadata path that survives sanitization while keeping existing body sanitization behavior intact.

  • Validator: structured metadata support

    • safe_output_type_validator.cjs now accepts optional top-level metadata (object only).
    • Invalid metadata types are rejected with explicit validation errors.
    • Metadata is normalized and preserved on normalizedItem.metadata.
    • For output types with a body field, metadata is appended as fenced JSON under a stable label (Structured metadata:), so downstream automation can parse it safely.
  • Tool schemas: explicit metadata input

    • Added metadata object support in pkg/workflow/js/safe_outputs_tools.json for body-bearing tools:
      • create_issue
      • add_comment
      • create_pull_request
      • create_pull_request_review_comment
      • submit_pull_request_review
      • reply_to_pull_request_review_comment
  • Docs: sanitizer behavior + recommended pattern

    • Updated safe-outputs reference docs to explicitly call out comment stripping and document metadata as the supported structured channel.
  • Targeted regression coverage

    • Added tests for:
      • metadata object acceptance and preservation
      • fenced-JSON body augmentation
      • rejection of non-object metadata
{
  "type": "add_comment",
  "body": "Review complete. All criteria pass.",
  "metadata": {
    "verdict": "APPROVE",
    "criteria_passed": 5
  }
}

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 8.78 AIC · ⌖ 7.44 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 7.91 AIC · ⌖ 6.69 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.4 AIC · ⌖ 8.09 AIC · ⊞ 7.1K ·
Comment /souschef to run again


pr-sous-chef run: https://github.com/github/gh-aw/actions/runs/30293408015

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 28.1 AIC · ⌖ 8.01 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 15.6 AIC · ⌖ 7.45 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 44.5 AIC · ⌖ 6.75 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix safe-output sanitizer to preserve HTML comments Add sanitization-safe metadata channel for body-based safe outputs Jul 27, 2026
Copilot AI requested a review from pelikhan July 27, 2026 11:59
@github-actions github-actions Bot mentioned this pull request Jul 27, 2026
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot rename "metadata" to "data" to reflect HTML custom data attributes wording.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot rename "metadata" to "data" to reflect HTML custom data attributes wording.

Updated as requested in 9819195: renamed the structured field from metadata to data across validator behavior, schemas, tests, and docs (including the body label now using "Structured data:").

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot create reusable type and typeref in main json type to avoid duplication

@pelikhan
pelikhan marked this pull request as ready for review July 27, 2026 12:54
Copilot AI review requested due to automatic review settings July 27, 2026 12:54

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

Adds a structured safe-output channel intended to survive body sanitization.

Changes:

  • Adds structured data schema fields and validator handling.
  • Appends structured data as fenced JSON.
  • Documents behavior and adds validator tests.
Show a summary per file
File Description
pkg/workflow/js/safe_outputs_tools.json Adds structured-data inputs.
actions/setup/js/safe_output_type_validator.cjs Validates and appends structured data.
actions/setup/js/safe_output_type_validator.test.cjs Adds regression tests.
docs/src/content/docs/reference/safe-outputs.md Documents the structured channel.

Review details

Tip

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Medium

Comment thread pkg/workflow/js/safe_outputs_tools.json Outdated
Comment on lines +72 to +75
"data": {
"type": "object",
"description": "Optional structured data to carry machine-readable context through sanitization-safe channels. When provided, this object is preserved and appended to the body as fenced JSON.",
"additionalProperties": true
The text output by AI agents is automatically sanitized to prevent injection of malicious content and ensure safe rendering on GitHub. The auto-sanitization applied is: XML escaped, HTTPS only, domain allowlist (GitHub by default), 0.5MB/65k line limits, control char stripping.

HTML/XML comments (`<!-- ... -->`) are removed from sanitized body fields.
If you need a machine-readable channel that survives sanitization, add a top-level `data` object on safe outputs that support `body`. The validator preserves `data` and appends it to the body as fenced JSON:
Comment on lines +737 to +740
// If this safe-output type supports a body field, append structured data
// as fenced JSON so it survives body sanitization.
if (Object.prototype.hasOwnProperty.call(typeConfig.fields, "body")) {
const dataBlock = `${STRUCTURED_DATA_LABEL}\n\`\`\`json\n${dataJSON}\n\`\`\``;
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot create reusable type and typeref in main json type to avoid duplication

Implemented in cd9b343: introduced a reusable structured_data schema in the main create_issue.inputSchema.$defs and switched all data fields to $ref (#/0/inputSchema/$defs/structured_data) to remove duplication across tool definitions.

@pelikhan

Copy link
Copy Markdown
Collaborator

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot create reusable type and typeref in main json type to avoid duplication

Addressed in c844fa9. The reusable shared data schema reference remains in the tool schema, and schema validation tests now resolve $ref properties so shared type/description checks pass without duplicating field definitions.

@copilot run pr-finisher skill

Done — I ran the pr-finisher flow and applied the actionable follow-up fix in c844fa9.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the schema should support specification from a github action expression so validation needs to happen mostly in JavaScript , and go if possible

Implemented in ca5d682.

  • safe-outputs.data now accepts a GitHub Actions expression string in Go config parsing.
  • Go still validates inline/static object schemas when available.
  • Runtime schema enforcement now happens in JavaScript for both ingestion and handlers, including expression-resolved JSON-string schemas.
  • Added a JS schema normalizer/enforcer (Codex-compatible object requirements) and updated tests/docs accordingly.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot add tests and specification w3c style for schema syntax

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add tests and specification w3c style for schema syntax

Implemented in 0b6e32a.

  • Added schema-syntax tests in JavaScript (data_schema_normalizer.test.cjs) covering shorthand object syntax, JSON-string schema syntax, unsupported keywords, and Codex compatibility enforcement.
  • Expanded Go tests in safe_outputs_data_schema_test.go for JSON-string schema acceptance and invalid string syntax rejection.
  • Added a W3C-style normative GP6: data section to safe-outputs-specification.md defining allowed frontmatter forms, simplified schema grammar, Codex constraints, and runtime validation requirements.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category feature
Risk 🟡 medium
Score 59/100 (impact:32 urgency:14 quality:13)
Action fast_track

Adds first-class structured metadata channel to prevent silent loss of machine-readable markers in safe-output sanitization. Substantive but well-scoped (1381 adds, 118 dels, 26 files). AI reviewer approved.

Generated by 🔧 PR Triage Agent · sonnet46 · 63.9 AIC · ⌖ 5.94 AIC · ⊞ 5.7K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot enable data with a simple schema on a few agentic workflows in this repo

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@copilot enable data with a simple schema on a few agentic workflows in this repo

Implemented in 099308d.

Enabled safe-outputs.data with simple inline schemas on these workflows:

  • .github/workflows/pr-triage-agent.md
  • .github/workflows/issue-triage-agent.md
  • .github/workflows/security-review.md

Also updated strict frontmatter schema acceptance for safe-outputs.data and recompiled lock files so these settings compile cleanly.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot update safeoutputs step summary renderers in JavaScript to render data as code region

Copilot AI and others added 2 commits July 28, 2026 01:53
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@copilot update safeoutputs step summary renderers in JavaScript to render data as code region

Implemented in e7e4ac3.

Updated JavaScript safe-output step summary renderers to show data as a JSON code region:

  • safe_output_summary.cjs now renders message.data in fenced json code blocks in per-message summaries.
  • log_parser_shared.cjs now renders entry data in fenced json blocks in markdown safe-outputs preview.
  • Added targeted tests in safe_output_summary.test.cjs and log_parser_shared.test.cjs.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

@pelikhan
pelikhan merged commit b06151b into main Jul 28, 2026
1 check failed
@pelikhan
pelikhan deleted the copilot/fix-html-comments-sanitization branch July 28, 2026 02:07
Copilot stopped work on behalf of pelikhan due to an error July 28, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Safe-output sanitizer strips HTML comments — no structured metadata channel for downstream workflows

4 participants