Sanitize props in filterUsersUpdateRequest
MODIFY
src/server/rest/service/CarService.ts
src/server/rest/service/CarService.ts
@@ -506,7 +506,7 @@ export default class CarService {
});
}
}
- const filteredRequest = CarSecurity.filterUsersAssignRequest(req.body);
+ const filteredRequest = CarSecurity.filterUsersUpdateRequest(req.body);
// CarID is mandatory
UtilsService.assertIdIsProvided(action, filteredRequest.carID, MODULE_NAME, 'handleUpdateUsersCar', req.user);
// Check Users

MODIFY
src/server/rest/service/security/CarSecurity.ts
src/server/rest/service/security/CarSecurity.ts
@@ -292,14 +292,14 @@ export default class CarSecurity {
return request.usersCarIDs.map(sanitize);
}
- public static filterUsersAssignRequest(request: any): HttpUsersAssignRequest {
+ public static filterUsersUpdateRequest(request: any): HttpUsersAssignRequest {
const usersCar: UserCar[] = [];
if (!Utils.isEmptyArray(request.usersCar)) {
for (const userCar of request.usersCar) {
usersCar.push({
- userID: userCar.user.id,
- default: userCar.default,
- owner: userCar.owner
+ userID: sanitize(userCar.user.id),
+ default: UtilsSecurity.filterBoolean(userCar.default),
+ owner: UtilsSecurity.filterBoolean(userCar.owner)
} as UserCar);
}
}

Sanitize props in filterUsersUpdateRequest