Skip to content

Commit

Permalink
✨ (CodeQL) Fixed finding: "js/code-injection"
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeebot[bot] authored Aug 16, 2024
1 parent bc9cef1 commit eb6cc86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion routes/showProductReviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function productReviews () {

// Measure how long the query takes, to check if there was a nosql dos attack
const t0 = new Date().getTime()
db.reviews.find({ $where: 'this.product == ' + id }).then((reviews: Review[]) => {
db.reviews.find({ $expr: { $eq: ['$product', id] } }).then((reviews: Review[]) => {
const t1 = new Date().getTime()
challengeUtils.solveIf(challenges.noSqlCommandChallenge, () => { return (t1 - t0) > 2000 })
const user = security.authenticatedUsers.from(req)
Expand Down
2 changes: 1 addition & 1 deletion routes/trackOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function trackOrder () {
const id = utils.disableOnContainerEnv() ? String(req.params.id).replace(/[^\w-]+/g, '') : req.params.id

challengeUtils.solveIf(challenges.reflectedXssChallenge, () => { return utils.contains(id, '<iframe src="javascript:alert(`xss`)">') })
db.orders.find({ $where: `this.orderId === '${id}'` }).then((order: any) => {
db.orders.find({ $expr: { $eq: ['$orderId', id] } }).then((order: any) => {
const result = utils.queryResultToJson(order)
challengeUtils.solveIf(challenges.noSqlOrdersChallenge, () => { return result.data.length > 1 })
if (result.data[0] === undefined) {
Expand Down

0 comments on commit eb6cc86

Please sign in to comment.