I have a line of code that looks like
gMapping[userName] = gMapping[userName] || [];
I see Prototype pollution vulnerability raised by Snyk. How can this be resolved ?
Relevant code:
const gMapping: { [user_name: string]: string[] } = {};
// Map records to dictionaries
dbRecs.forEach(rec => {
const userName = rec.user_name;
const groupId = rec.group_id;
gMapping[userName] = gMapping[userName] || [];
gMapping[userName].push(groupId);
}
});