Skip to content

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

Draft
fba223 wants to merge 1 commit into
mainfrom
fix-sql-injection1
Draft

Fix code scanning alert no. 1: SQL query built from user-controlled sources#2
fba223 wants to merge 1 commit into
mainfrom
fix-sql-injection1

Conversation

@fba223

@fba223 fba223 commented Oct 14, 2024

Copy link
Copy Markdown
Owner

Fixes https://github.com/fba223/demo-python/security/code-scanning/1

To fix the SQL injection vulnerability, we should use parameterized queries. This approach ensures that user input is properly escaped and treated as data rather than executable code.

In the provided code, we need to modify the SQL queries on lines 16 and 22 to use parameterized queries. This can be done by using placeholders (%s) in the SQL string and passing the user-provided values as parameters to the cursor.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>
@fba223

fba223 commented Oct 14, 2024

Copy link
Copy Markdown
Owner Author

yets

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