我有這樣一段代碼:pgdb防止注入攻擊嗎?
db = pgdb.connect(
database=connection['database'],
user=connection['user'],
host=connection['host'])
cursor = db.cursor()
# ask database
query = '''
SELECT a, b, c
FROM table
WHERE a ILIKE %s;'''
try:
cursor.execute(query, userInput)
except pgdb.Error, error:
error = str(error)
print json.dumps({
'errorMessage': 'ERROR: %s' % error
})
我已閱讀another forum像MySQLdb的Python模塊都逃脫防止對注入攻擊。我也瀏覽了documentation on pgdb,但它非常薄。最後,我試圖用我自己的測試數據庫來做自己的注射攻擊,但我不確定我的測試是否足夠。什麼是測試這個的好方法?