Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ hashmap.apply = function(_, keyvals) {

exports.assocInM = assocInM
function assocInM(obj, keys, value) {
/*
`Object.create()` to set the object to not have any prototype
to prevent prototype pollution attacks
*/
obj = Object.create(obj)
Object.freeze(obj.prototype);

keys = keys.filter(function(item) {
var protoMod = item.includes("proto")
if (protoMod)
console.log("[!] prototype modification is potentially dangerous.");
return !protoMod;
})

var ret = obj
, key

Expand Down