Skip to content

Potential fix for code scanning alert no. 20: Log entries created from user input #13

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

Merged
merged 1 commit into from
Jun 5, 2025

Conversation

elbruno
Copy link
Contributor

@elbruno elbruno commented Jun 5, 2025

Potential fix for https://github.com/Azure-Samples/eShopLite/security/code-scanning/20

To fix the issue, the bingsearchconnectionName value should be sanitized before being logged. This involves removing potentially harmful characters such as newlines (\n, \r) and ensuring the value is safe for inclusion in log entries. The String.Replace method can be used to remove these characters. This approach ensures that the log entry cannot be manipulated by malicious input.

The fix will involve modifying the logging statement on line 52 to use a sanitized version of bingsearchconnectionName. Additionally, the sanitization logic should be applied consistently to other configuration values logged in the same method.

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

…m user input

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copy link

github-actions bot commented Jun 5, 2025

👋 Thanks for contributing @elbruno! We will review the pull request and get back to you soon.

@elbruno elbruno marked this pull request as ready for review June 5, 2025 16:21
Copy link
Contributor Author

@elbruno elbruno left a comment

Choose a reason for hiding this comment

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

looks good!

@elbruno elbruno merged commit 27a0622 into main Jun 5, 2025
7 checks passed
@elbruno elbruno deleted the alert-autofix-20 branch June 5, 2025 17:05
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.

1 participant