Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/static/codefixes/unionSqlInjectionChallenge_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = function searchProducts () {
let criteria: any = req.query.q === 'undefined' ? '' : req.query.q ?? ''
criteria = (criteria.length <= 200) ? criteria : criteria.substring(0, 200)
criteria.replace(/"|'|;|and|or/i, "")
models.sequelize.query(`SELECT * FROM Products WHERE ((name LIKE '%${criteria}%' OR description LIKE '%${criteria}%') AND deletedAt IS NULL) ORDER BY name`)
models.sequelize.query("SELECT * FROM Products WHERE ((name LIKE :criteria OR description LIKE :criteria) AND deletedAt IS NULL) ORDER BY name", { replacements: { criteria: `%${criteria}%` } })
.then(([products]: any) => {
const dataString = JSON.stringify(products)
for (let i = 0; i < products.length; i++) {
Expand All @@ -15,4 +15,4 @@ module.exports = function searchProducts () {
next(error.parent)
})
}
}
}
Loading