【发布时间】:2021-08-09 01:46:58
【问题描述】:
我有一行代码看起来像
gMapping[userName] = gMapping[userName] || [];
我看到了 Snyk 提出的 Prototype 污染漏洞。如何解决?
相关代码:
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);
}
});
【问题讨论】:
-
什么是
glMapping?userName来自哪里?您能否更具体地了解 Snyk 警告消息? -
@Bergi :用户名来自数据库。在问题中添加了有关 gMapping 的详细信息
标签: javascript node.js object security prototype