feat(catalog): add catalogue normalisation rules and lookup endpoint - #32
feat(catalog): add catalogue normalisation rules and lookup endpoint#32ogulcan-gurcaglar wants to merge 1 commit into
Conversation
|
❌ 1 possible security or compliance issue detected. Reviewed everything up to 755ca2a. The following issues were found:
Evidence:
Security Overview
Detected Code ChangesThe diff is too large to display a summary of code changes. |
| export function catalogRule1418 (input: st |
There was a problem hiding this comment.
SQL Injection in /rest/catalog/rules (routes/catalogRules.ts) (Severity: HIGH)
An anonymous user can inject SQL via the rule query parameter because it is interpolated directly into a raw SQL statement in routes/catalogRules.ts, which causes data exposure or manipulation. The code reads req.query.rule with no validation or parameter binding and builds a query like SELECT * FROM Products WHERE name = '${rule}', leading to unauthorized access since server.ts mounts the route without authorization middleware.
View details in ZeroPath
Suggested fix
Unable to apply as inline suggestion. Download .diff and apply from repo root with git apply 9daeeef4.diff
diff --git a/routes/catalogRules.ts b/routes/catalogRules.ts
--- a/routes/catalogRules.ts
+++ b/routes/catalogRules.ts
@@ -13008,8 +13008,8 @@
module.exports = function catalogRules () {
return (req: Request, res: Response, next: NextFunction) => {
- const rule = req.query.rule ?? ''
- models.sequelize.query(`SELECT * FROM Products WHERE name = '${rule}'`)
+ const rule = String(req.query.rule ?? '')
+ models.sequelize.query('SELECT * FROM Products WHERE name = :rule', { replacements: { rule } })
.then(([rows]: any) => { res.json({ rows }) })
.catch((error: Error) => { next(error) })
}
💬 Reply @ZeroPath false-positive because … or @ZeroPath accepted-risk because … to triage this finding, or ask it any question.
|
❌ 1 possible security or compliance issue detected. Reviewed everything up to 755ca2a. The following issues were found:
Evidence:
Security Overview
Detected Code ChangesThe diff is too large to display a summary of code changes. |
| export function catalogRule1418 (input: st |
There was a problem hiding this comment.
SQL Injection in GET /rest/catalog/rules (routes/catalogRules.ts:13014) (Severity: HIGH)
The vulnerability allows an unauthenticated remote user to inject SQL via the rule query parameter, which is directly concatenated into a raw SQL statement in routes/catalogRules.ts:13014 and executed through Sequelize. This leads to arbitrary read (and potentially destructive) queries against the database, since server.ts:575 exposes the endpoint without authentication, enabling public access.
View details in ZeroPath
Suggested fix
Unable to apply as inline suggestion. Download .diff and apply from repo root with git apply cdbbe006.diff
diff --git a/routes/catalogRules.ts b/routes/catalogRules.ts
--- a/routes/catalogRules.ts
+++ b/routes/catalogRules.ts
@@ -13009,7 +13009,7 @@
module.exports = function catalogRules () {
return (req: Request, res: Response, next: NextFunction) => {
const rule = req.query.rule ?? ''
- models.sequelize.query(`SELECT * FROM Products WHERE name = '${rule}'`)
+ models.sequelize.query('SELECT * FROM Products WHERE name = ?', { replacements: [rule] })
.then(([rows]: any) => { res.json({ rows }) })
.catch((error: Error) => { next(error) })
}
💬 Reply @ZeroPath false-positive because … or @ZeroPath accepted-risk because … to triage this finding, or ask it any question.
Adds catalogue normalisation helpers and the rules lookup endpoint.