Draft
Security hardening: SQL injection prevention, API key memory clearing, WHERE clause fix#2
Conversation
…HERE clause fix Agent-Logs-Url: https://github.com/wherobots/wherobots_qgis/sessions/b3768d99-a1e9-4882-a9de-4908e15d2b0b Co-authored-by: RoboDonut <2329256+RoboDonut@users.noreply.github.com>
… injection Agent-Logs-Url: https://github.com/wherobots/wherobots_qgis/sessions/b3768d99-a1e9-4882-a9de-4908e15d2b0b Co-authored-by: RoboDonut <2329256+RoboDonut@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix hard-coded values in plugin code
Security hardening: SQL injection prevention, API key memory clearing, WHERE clause fix
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The plugin had several security vulnerabilities from unsanitized user inputs being embedded directly into SQL strings, plus a logic bug in the spatial extent filter that produced invalid SQL.
Changes
SQL injection prevention
validate_identifier()inlayer_utils.py— validates SQL identifiers against^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$before any embedding. Error messages never echo back user input.SHOW SCHEMAS IN/SHOW TABLES IN), upload destination table name, andlayer_to_insert_sql().ST_GeomFromWKT()calls now have single quotes defensively escaped.API key memory hygiene
ConnectTask.run()clearsself.api_key = Nonein afinallyblock so the key doesn't persist in the task object (visible to QGIS task manager / Python GC) after the connection attempt completes or fails.WHERE clause bug fix
When the spatial extent filter was added to a query that already contained a
WHEREclause, theANDcondition was appended to the very end of the SQL — after anyORDER BY/LIMIT:The fix mirrors the existing keyword-scan insertion logic used for the no-
WHEREcase.