Skip to content

Potential fix for code scanning alert no. 2: SQL query built from user-controlled sources #1

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jonath92
Copy link
Owner

Potential fix for https://github.com/jonath92/demo-python/security/code-scanning/2

To fix the problem, we need to use parameterized queries instead of directly concatenating user input into the SQL query. Parameterized queries ensure that user input is properly escaped and treated as data rather than executable code, thus preventing SQL injection attacks.

The best way to fix the problem without changing existing functionality is to modify the cursor.execute calls to use placeholders for user input and pass the user-provided values as parameters. This change should be applied to both the name and author parameters.

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

…r-controlled sources

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@jonath92 jonath92 requested a review from Copilot April 11, 2025 09:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

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.

1 participant