Skip to content

Commit

Permalink
Fix parameter sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanDamron committed Nov 28, 2024
1 parent 75429ef commit 5d705ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ app.get("/registry", async (req, res) => {
})

app.post("/registry", async (req, res) => {
const keyVal = await sanitizeString(key(req.body))
const keyVal = await key(req.body)
const urlVal = sanitizeString(url(req.body))
const titleVal = sanitizeString(checkForBannedWords(req.body, "title"))
const descriptionVal = sanitizeString(checkForBannedWords(req.body, "description"))
Expand Down
3 changes: 2 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export function orderBy(body) {
}

export async function key(body) {
const keyVal = body.hasOwnProperty("key") ? body["key"] : ""
const keyVal = body.hasOwnProperty("key") ? sanitizeString(body["key"]) : ""
if ((await db.result(`SELECT * FROM users WHERE key = '${keyVal}'`, null, r => r.rowCount)) === 0) return ""
return keyVal
}

export function searchByTag(body) {
Expand Down

0 comments on commit 5d705ed

Please # to comment.