Skip to content

Fix code scanning alert no. 3: 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

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

github-cloudlabsuser-128
Copy link
Owner

Fixes https://github.com/github-cloudlabsuser-128/ghas-bootcamp-python/security/code-scanning/3

To fix the SQL injection vulnerability, we should use parameterized queries instead of directly embedding user input into the SQL query string. Parameterized queries ensure that user input is properly escaped and treated as data rather than executable code.

In this specific case, we will modify the cursor.execute call on line 23 to use a parameterized query. This involves replacing the f-string with a query that uses placeholders for parameters and passing the user input as a separate argument to the execute method.

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

…ources

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-cloudlabsuser-128 github-cloudlabsuser-128 marked this pull request as ready for review December 18, 2024 19:51
@github-cloudlabsuser-128 github-cloudlabsuser-128 merged commit 4281f1e into main Dec 18, 2024
3 checks passed
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