From bb8d6c43357847dca4891ad50f5d14fe16db41a0 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Wed, 1 Jun 2022 13:09:16 -0400 Subject: [PATCH] Sanitize inputs --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 3 +++ functions.js | 12 ++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 { if (err) throw err; functions.download.requests(client); }); }, pasta(pastaData, client) { - const query = `INSERT INTO pastas (name, content) VALUES ('${pastaData.name}','${pastaData.content}')`; + const query = `INSERT INTO pastas (name, content) VALUES ('${db.escape(pastaData.name)}','${db.escape(pastaData.content)}')`; db.query(query, (err, rows, fields) => { if (err) throw err; functions.download.pastas(client); }); }, joint(content, client) { - const query = `INSERT INTO joints (content) VALUES ('${content}')`; + const query = `INSERT INTO joints (content) VALUES ('${db.escape(content)}')`; db.query(query, (err, rows, fields) => { if (err) throw err; functions.download.joints(client); }); }, gif(gifData, client) { - const query = `INSERT INTO gifs (name, embed_url) VALUES ('${gifData.name}', '${gifData.embed_url}')`; + const query = `INSERT INTO gifs (name, embed_url) VALUES ('${db.escape(gifData.name)}', '${db.escape(gifData.embed_url)}')`; db.query(query, (err, rows, fields) => { if (err) throw err; functions.download.gifs(client); @@ -395,7 +395,7 @@ const functions = { }, strain(commandData, message) { const { strainName } = commandData; - const query = `SELECT id, name, type, effects, ailment, flavor FROM strains WHERE name = '${strainName}'`; + const query = `SELECT id, name, type, effects, ailment, flavor FROM strains WHERE name = '${db.escape(strainName)}'`; db.query(query, (err, rows, fields) => { if (rows != undefined) { commandData.strainInfo = { @@ -436,7 +436,7 @@ const functions = { }, // Parent-Level functions (miscellaneuous) closeRequest(requestId, client) { - const query = `UPDATE requests SET status = 'Closed' WHERE id = ${requestId}`; + const query = `UPDATE requests SET status = 'Closed' WHERE id = ${db.escape(requestId)}`; db.query(query, (err, rows, fields) => { if (err) throw err; functions.download.requests(client);