Replace manual quote escaping with %q format specifier for YAML encoding#11392
Merged
pelikhan merged 2 commits intofix/code-scanning-alert-538-unsafe-quoting-v2-00bd24b6b438b87efrom Jan 22, 2026
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix go/unsafe-quoting: Escape single quotes in JSON data
Replace manual quote escaping with %q format specifier for YAML encoding
Jan 22, 2026
c40a9a9
into
fix/code-scanning-alert-538-unsafe-quoting-v2-00bd24b6b438b87e
This was referenced Jan 22, 2026
pelikhan
added a commit
that referenced
this pull request
Jan 22, 2026
…ON data (#11382) * Fix go/unsafe-quoting: Escape single quotes in JSON data - Add proper shell escaping for JSON data embedded in environment variables - Prevents potential command injection via single quotes in user data - Fixes CodeQL alert #538 (Critical severity) - Uses POSIX-compatible '\''escaping technique Security: Addresses CWE-78, CWE-89, CWE-94 * Replace manual quote escaping with %q format specifier (#11386) * Initial plan * Use %q for JSON escaping in YAML dictionary values Replaced manual single-quote escaping with Go's %q format specifier, which: - Automatically handles all special characters and escaping - Produces cleaner YAML with double quotes instead of single quotes - Follows existing codebase patterns (e.g., add_comment.go) - Simplifies code by removing manual string replacement logic This addresses the feedback to use simpler escaping for JSON data in YAML dictionary values. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> * Replace manual quote escaping with %q format specifier for YAML encoding (#11392) * Initial plan * Recompile workflows after security fix Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> * Add changeset [skip-ci] --------- Co-authored-by: Code Scanning Fixer Bot <code-scanning-bot@github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This was referenced Jan 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The security fix for CodeQL alert #538 (go/unsafe-quoting) was using manual shell-style quote escaping (
'\'') for JSON data embedded in a YAML dictionary value, which is unnecessary and incorrect for YAML context.Changes
%qformat specifier - Go's%qprovides proper quoting and escaping for string literals, handling special characters correctly for YAMLstrings.ReplaceAll()calls for backslashes and quotesBefore/After
Before (manual shell escaping):
After (Go format specifier):
The
%qformat specifier produces a properly quoted Go string literal that is safe for YAML parsing while still preventing injection attacks.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.