Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential fix for code scanning alert no. 13: Potentially unsafe quoting #913

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

wolf31o2
Copy link
Member

Potential fix for https://github.com/blinklabs-io/gouroboros/security/code-scanning/13

To fix the problem, we should avoid manually constructing JSON strings and instead use a structured API that handles quoting and escaping automatically. This can be achieved by using the json.Marshal function to serialize the key-value pairs into JSON format.

  • Replace the manual string construction with json.Marshal to ensure proper escaping of quotes and other special characters.
  • Update the generateAstJsonMap function to use json.Marshal for constructing the JSON string.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

CodeQL always complained about this code and Copilot had a suggestion which solves it even though it wasn't really a problem in practice.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@wolf31o2 wolf31o2 marked this pull request as ready for review February 27, 2025 15:17
@wolf31o2 wolf31o2 requested a review from a team as a code owner February 27, 2025 15:17
@wolf31o2 wolf31o2 merged commit ca737df into main Feb 27, 2025
9 checks passed
@wolf31o2 wolf31o2 deleted the fix/unsafe-quoting-skynet branch February 27, 2025 18:25
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.

None yet

2 participants