Skip to content

Commit 5582f1a

Browse files
Potential fix for code scanning alert no. 1232
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 200adfe commit 5582f1a

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

backend/src/controllers/survey.controller.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@ class SurveyController {
99
async updateSurveyGitHub(req: Request, res: Response): Promise<void> {
1010
let survey: SurveyType;
1111
try {
12-
const _survey = await surveyService.updateSurvey({
13-
...req.body,
12+
const sanitizedBody = {
13+
id: req.body.id,
14+
userId: req.body.userId,
15+
org: req.body.org,
16+
repo: req.body.repo,
17+
prNumber: req.body.prNumber,
18+
usedCopilot: req.body.usedCopilot,
19+
percentTimeSaved: req.body.percentTimeSaved,
20+
reason: req.body.reason,
21+
timeUsedFor: req.body.timeUsedFor,
22+
kudos: req.body.kudos,
1423
hits: 0,
1524
status: 'completed'
16-
});
25+
};
26+
const _survey = await surveyService.updateSurvey(sanitizedBody);
1727
if (!_survey) throw new Error('Survey not found');
1828
survey = _survey;
1929
res.status(201).json(survey);

backend/src/services/survey.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SurveyService {
3333
throw new Error('Invalid survey data provided');
3434
}
3535
const Survey = mongoose.model('Survey');
36-
const result = await Survey.updateOne({ id: survey.id }, { $set: survey });
36+
const result = await Survey.updateOne({ id: { $eq: survey.id } }, { $set: survey });
3737

3838
// Check if the update modified any document.
3939
if (result.modifiedCount === 0) {

0 commit comments

Comments
 (0)