Skip to content

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

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

rudy750
Copy link

@rudy750 rudy750 commented Oct 2, 2024

Fixes https://github.com/clever-org-name/rudy750-advanced-security-python/security/code-scanning/2

To fix the problem, we should use parameterized queries instead of directly concatenating user input into the SQL query strings. Parameterized queries ensure that user input is properly escaped and quoted, preventing SQL injection attacks.

  • Replace the direct string concatenation in the cursor.execute calls with parameterized queries.
  • Use placeholders (%s) in the SQL query strings and pass the user-provided values as a second argument to the cursor.execute method.
  • Ensure that the read parameter is handled correctly, as it is converted to a boolean.

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>
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