Skip to content

Commit c0ce6af

Browse files
authored
Merge pull request #896 from finos/alert-autofix-83
fix: Database query built from user-controlled sources
2 parents 1cf3ec1 + 791c5e5 commit c0ce6af

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/db/mongo/pushes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ 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+
if (typeof data.id !== 'string') {
61+
throw new Error('Invalid id');
62+
}
63+
await collection.updateOne({ id: { $eq: data.id } }, { $set: data }, options);
6164
return action;
6265
};
6366

0 commit comments

Comments
 (0)