Skip to content

Commit

Permalink
Merge pull request #33 from ready-research/ready-research-Prototype-P…
Browse files Browse the repository at this point in the history
…ollution

Security Fix for Prototype Pollution
  • Loading branch information
jonschlinkert authored Sep 12, 2021
2 parents 010f017 + 383b72d commit b057b1b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const isUnsafeKey = key => {
};

const validateKey = key => {
if (typeof key !== 'string' && typeof key !== 'number') {
key = String(key)
}
if (isUnsafeKey(key)) {
throw new Error(`Cannot set unsafe key: "${key}"`);
}
Expand Down

0 comments on commit b057b1b

Please sign in to comment.