Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: manuelstofer/json-pointer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9b5ea8e3b20f9e3065860cf3b018b47708e8794d
Choose a base ref
...
head repository: manuelstofer/json-pointer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 931b0f9c7178ca09778087b4b0ac7e4f505620c2
Choose a head ref
  • 3 commits
  • 4 files changed
  • 2 contributors

Commits on Nov 11, 2021

  1. Copy the full SHA
    47dae1d View commit details

Commits on Feb 17, 2022

  1. Merge pull request #36 from hhomar/fix-prototype-pollution

    Fix prototype pollution when pointer is not a string or number
    manuelstofer authored Feb 17, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    859c998 View commit details
  2. Release 0.6.2

    manuelstofer committed Feb 17, 2022
    Copy the full SHA
    931b0f9 View commit details
Showing with 2,179 additions and 1 deletion.
  1. +3 −0 index.js
  2. +2,166 −0 package-lock.json
  3. +1 −1 package.json
  4. +9 −0 test/test.js
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -75,6 +75,9 @@ api.set = function set (obj, pointer, value) {

for (var i = 0; i < refTokens.length - 1; ++i) {
var tok = refTokens[i];
if (typeof tok !== 'string' && typeof tok !== 'number') {
tok = String(tok)
}
if (tok === "__proto__" || tok === "constructor" || tok === "prototype") {
continue
}
2,166 changes: 2,166 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "json-pointer",
"description": "Some utilities for JSON pointers described by RFC 6901",
"version": "0.6.1",
"version": "0.6.2",
"author": "Manuel Stofer <manuel@smallpdf.com>",
"license": "MIT",
"dependencies": {
9 changes: 9 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -446,6 +446,15 @@ describe('convenience api wrapper', function() {
expect(obj2.polluted).to.be.undefined();
});

it('should not set __proto__ (array)', function () {
var obj = {}, objPointer = pointer(obj);
expect(obj.polluted).to.be.undefined();
objPointer.set([['__proto__'], 'polluted'], true);
expect(obj.polluted).to.be.undefined();
var obj2 = {};
expect(obj2.polluted).to.be.undefined();
});

it('should not set prototype', function () {
var obj = {}, objPointer = pointer(obj);
expect(obj.polluted).to.be.undefined();