The psycopg2.sql module is meant to provide a safe way to compose SQL queries dynamically, however it is possible to misuse it in a way that would result in an SQL injection vulnerability, and bandit currently doesn't support detecting this.
Solution: create a new test to detect when a psycopg2.sql.SQL object is being created from a non-literal, e.g. SQL(foo) or SQL('%s AND %s' % (foo, bar)). The severity and confidence levels of this new test would both be at least "medium".
The psycopg2.sql module is meant to provide a safe way to compose SQL queries dynamically, however it is possible to misuse it in a way that would result in an SQL injection vulnerability, and bandit currently doesn't support detecting this.
Solution: create a new test to detect when a psycopg2.sql.SQL object is being created from a non-literal, e.g.
SQL(foo)orSQL('%s AND %s' % (foo, bar)). The severity and confidence levels of this new test would both be at least "medium".