@@ -34,7 +34,7 @@ exports.index = function (req, res, next) {
34
34
} ) ;
35
35
} ;
36
36
37
- // Vulnerable code:
37
+ // Insert new vulnerable code:
38
38
39
39
40
40
exports . loginHandler = function ( req , res , next ) {
@@ -136,6 +136,29 @@ exports.get_account_details = function(req, res, next) {
136
136
return res . render ( 'account.hbs' , profile )
137
137
}
138
138
139
+ // New NoSQL Injection vulnerability - added for Snyk testing
140
+ /*
141
+ exports.getUserById = function(req, res, next) {
142
+ // Get the user ID from query parameters
143
+ const userId = req.query.id;
144
+
145
+ // Directly use user input in MongoDB operator without sanitization
146
+ // This is vulnerable if userId is something like: {"$ne": null}
147
+ User.findOne({_id: userId}, function(err, user) {
148
+ if (err) return next(err);
149
+
150
+ if (!user) {
151
+ return res.status(404).send('User not found');
152
+ }
153
+
154
+ return res.render('user_profile', {
155
+ title: 'User Profile',
156
+ user: user
157
+ });
158
+ });
159
+ };
160
+ */
161
+
139
162
exports . save_account_details = function ( req , res , next ) {
140
163
// get the profile details from the JSON
141
164
const profile = req . body
@@ -238,7 +261,7 @@ exports.create = function (req, res, next) {
238
261
} ;
239
262
240
263
// Insert new vulnerable code:
241
- /*
264
+
242
265
exports . destroy = function ( req , res , next ) {
243
266
Todo . findById ( req . params . id , function ( err , todo ) {
244
267
@@ -279,7 +302,7 @@ exports.update = function (req, res, next) {
279
302
} ) ;
280
303
} ) ;
281
304
} ;
282
- */
305
+
283
306
284
307
// ** express turns the cookie key to lowercase **
285
308
exports . current_user = function ( req , res , next ) {
0 commit comments