Skip to content

Commit bb5ba8b

Browse files
Potential fix for code scanning alert no. 83: Database query built from user-controlled sources
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 6da3e86 commit bb5ba8b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/db/mongo/pushes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const writeAudit = async (action) => {
5757
const options = { upsert: true };
5858
const collection = await connect(cnName);
5959
delete data._id;
60-
await collection.updateOne({ id: data.id }, { $set: data }, options);
60+
await collection.updateOne({ id: { $eq: data.id } }, { $set: data }, options);
6161
return action;
6262
};
6363

src/service/routes/push.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ router.post('/:id/authorise', async (req, res) => {
9191

9292
if (req.user && attestationComplete) {
9393
const id = req.params.id;
94+
if (typeof id !== "string") {
95+
res.status(400).send({ message: "Invalid ID format" });
96+
return;
97+
}
9498
console.log({ id });
9599

96100
// Get the push request

0 commit comments

Comments
 (0)