Skip to content

Commit 735fe7c

Browse files
committed
Bump version to 1.1.10 in package.json and update SQL queries for parameterized statements to address sql injection concerns
1 parent a5bd0ec commit 735fe7c

2 files changed

Lines changed: 24 additions & 21 deletions

File tree

backend/routes/api.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ router.get("/getRecentlyAdded", async (req, res) => {
226226
and i."ParentId"=$1
227227
order by "DateCreated" desc
228228
limit $2`,
229-
[libraryid, limit]
229+
[libraryid, limit],
230230
);
231231

232232
const { rows: episodes } = await db.query(
@@ -240,7 +240,7 @@ router.get("/getRecentlyAdded", async (req, res) => {
240240
and i."ParentId"=$1
241241
order by e."DateCreated" desc
242242
limit $2`,
243-
[libraryid, limit]
243+
[libraryid, limit],
244244
);
245245

246246
let lastSynctedItemDate;
@@ -258,7 +258,7 @@ router.get("/getRecentlyAdded", async (req, res) => {
258258

259259
if (lastSynctedItemDate !== undefined) {
260260
recentlyAddedFromJellystatMapped = recentlyAddedFromJellystatMapped.filter((item) =>
261-
dayjs(item.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ").isAfter(lastSynctedItemDate)
261+
dayjs(item.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ").isAfter(lastSynctedItemDate),
262262
);
263263
}
264264

@@ -270,7 +270,7 @@ router.get("/getRecentlyAdded", async (req, res) => {
270270
const recentlyAdded = [...recentlyAddedFromJellystatMapped, ...filteredDbRows];
271271
// Sort recentlyAdded by DateCreated in descending order
272272
recentlyAdded.sort(
273-
(a, b) => dayjs(b.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ") - dayjs(a.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ")
273+
(a, b) => dayjs(b.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ") - dayjs(a.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ"),
274274
);
275275

276276
res.send(recentlyAdded);
@@ -282,7 +282,7 @@ router.get("/getRecentlyAdded", async (req, res) => {
282282
where i.archived=false
283283
order by "DateCreated" desc
284284
limit $1`,
285-
[limit]
285+
[limit],
286286
);
287287

288288
const { rows: episodes } = await db.query(
@@ -295,7 +295,7 @@ router.get("/getRecentlyAdded", async (req, res) => {
295295
and e.archived=false
296296
order by e."DateCreated" desc
297297
limit $1`,
298-
[limit]
298+
[limit],
299299
);
300300
let lastSynctedItemDate;
301301
if (items.length > 0 && items[0].DateCreated !== undefined && items[0].DateCreated !== null) {
@@ -312,7 +312,7 @@ router.get("/getRecentlyAdded", async (req, res) => {
312312

313313
if (lastSynctedItemDate !== undefined) {
314314
recentlyAddedFromJellystatMapped = recentlyAddedFromJellystatMapped.filter((item) =>
315-
dayjs(item.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ").isAfter(lastSynctedItemDate)
315+
dayjs(item.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ").isAfter(lastSynctedItemDate),
316316
);
317317
}
318318

@@ -330,7 +330,7 @@ router.get("/getRecentlyAdded", async (req, res) => {
330330

331331
// Sort recentlyAdded by DateCreated in descending order
332332
recentlyAdded.sort(
333-
(a, b) => dayjs(b.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ") - dayjs(a.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ")
333+
(a, b) => dayjs(b.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ") - dayjs(a.DateCreated, "YYYY-MM-DD HH:mm:ss.SSSZ"),
334334
);
335335

336336
res.send(recentlyAdded);
@@ -527,7 +527,7 @@ router.post("/updateCredentials", async (req, res) => {
527527

528528
try {
529529
if (username !== undefined && config.APP_USER !== username) {
530-
await db.query(`UPDATE app_config SET "APP_USER"='${username}' where "ID"=1`);
530+
await db.query(`UPDATE app_config SET "APP_USER"=$1 where "ID"=1`, [username]);
531531
}
532532

533533
if (current_password === undefined && new_password === undefined) {
@@ -541,9 +541,10 @@ router.post("/updateCredentials", async (req, res) => {
541541
result.isValid = false;
542542
result.errorMessage = "New Password cannot be the same as Old Password";
543543
} else {
544-
await db.query(
545-
`UPDATE app_config SET "APP_PASSWORD"='${new_password}' where "ID"=1 AND "APP_PASSWORD"='${current_password}' `
546-
);
544+
await db.query(`UPDATE app_config SET "APP_PASSWORD"=$1 where "ID"=1 AND "APP_PASSWORD"=$2`, [
545+
new_password,
546+
current_password,
547+
]);
547548
}
548549
} else {
549550
result.isValid = false;
@@ -566,17 +567,19 @@ router.post("/updatePassword", async (req, res) => {
566567

567568
try {
568569
const { rows } = await db.query(
569-
`SELECT "JF_HOST","JF_API_KEY","APP_USER" FROM app_config where "ID"=1 AND "APP_PASSWORD"='${current_password}' `
570+
`SELECT "JF_HOST","JF_API_KEY","APP_USER" FROM app_config where "ID"=1 AND "APP_PASSWORD"=$1 `,
571+
[current_password],
570572
);
571573

572574
if (rows && rows.length > 0) {
573575
if (current_password === new_password) {
574576
result.isValid = false;
575577
result.errorMessage = "New Password cannot be the same as Old Password";
576578
} else {
577-
await db.query(
578-
`UPDATE app_config SET "APP_PASSWORD"='${new_password}' where "ID"=1 AND "APP_PASSWORD"='${current_password}' `
579-
);
579+
await db.query(`UPDATE app_config SET "APP_PASSWORD"=$1 where "ID"=1 AND "APP_PASSWORD"=$2`, [
580+
new_password,
581+
current_password,
582+
]);
580583
}
581584
} else {
582585
result.isValid = false;
@@ -923,7 +926,7 @@ router.post("/getUserDetails", async (req, res) => {
923926
return;
924927
}
925928

926-
const { rows } = await db.query(`select * from jf_users where "Id"='${userid}'`);
929+
const { rows } = await db.query(`select * from jf_users where "Id"=$1`, [userid]);
927930
res.send(rows[0]);
928931
} catch (error) {
929932
console.log(error);
@@ -951,7 +954,7 @@ router.post("/getLibrary", async (req, res) => {
951954
return;
952955
}
953956

954-
const { rows } = await db.query(`select * from jf_libraries where "Id"='${libraryid}'`);
957+
const { rows } = await db.query(`select * from jf_libraries where "Id"=$1`, [libraryid]);
955958
res.send(rows[0]);
956959
} catch (error) {
957960
console.log(error);
@@ -989,7 +992,7 @@ router.post("/getSeasons", async (req, res) => {
989992

990993
const { rows } = await db.query(
991994
`SELECT s.*, i."PrimaryImageHash", (select count(e.*) "Episodes" from jf_library_episodes e where e."SeasonId"=s."Id") ,(select sum(ii."Size") "Size" from jf_library_episodes e join jf_item_info ii on ii."Id"=e."EpisodeId" where e."SeasonId"=s."Id") FROM jf_library_seasons s left join jf_library_items i on i."Id"=s."SeriesId" where "SeriesId"=$1`,
992-
[Id]
995+
[Id],
993996
);
994997
res.send(rows);
995998
} catch (error) {
@@ -1009,7 +1012,7 @@ router.post("/getEpisodes", async (req, res) => {
10091012

10101013
const { rows } = await db.query(
10111014
`SELECT e.*, i."PrimaryImageHash", ii."Size" FROM jf_library_episodes e left join jf_library_items i on i."Id"=e."SeriesId" join jf_item_info ii on ii."Id"=e."EpisodeId" where "SeasonId"=$1`,
1012-
[Id]
1015+
[Id],
10131016
);
10141017
res.send(rows);
10151018
} catch (error) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jfstat",
3-
"version": "1.1.9",
3+
"version": "1.1.10",
44
"private": true,
55
"main": "src/index.jsx",
66
"scripts": {

0 commit comments

Comments
 (0)