Skip to content

Commit dc74ecd

Browse files
committed
fix: whitelist updateProject fields
1 parent 97f761d commit dc74ecd

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

server/controllers/project.controller.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,18 @@ export async function updateProject(req, res) {
4848
});
4949
return;
5050
}
51+
// only allow whitelisted fields so ownership/slug etc can't be overwritten
52+
const allowedFields = ['name', 'files', 'updatedAt', 'visibility'];
53+
const updateData = {};
54+
allowedFields.forEach((field) => {
55+
if (req.body[field] !== undefined) {
56+
updateData[field] = req.body[field];
57+
}
58+
});
5159
const updatedProject = await Project.findByIdAndUpdate(
5260
req.params.project_id,
5361
{
54-
$set: req.body
62+
$set: updateData
5563
},
5664
{
5765
new: true,

0 commit comments

Comments
 (0)