Expdiente_spider: Don't use interpolation for SQL Query #3
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.
Oi,
Interpolar cadenas para armar SQL Statements vulnerable a SQL Injection. Con el código como esta, si alguien logra modificar el environment variable del servidor dónde esta hosteado el Scrapper puede borrar toda la base o modificarla como quisiera.
Para evitar ser vulnerable, debes componer los queries en el lado de la base de datos, usando prepared statements. No conozco muy bien dataset (con psycopg2 es al toque), según @marsam esto haría que dataset use prepared statements. (Aunque tambien recomienda no usar dataset, sino SQLAlchemy directamente)
No he buscado más casos de SQL Injection, sería bueno que veas dónde estas interpolando cadenas de lado de Python para componer SQL statements y lo modifiques.
mis 2c