Blame SOURCES/deps-npm-ini-do-not-allow-invalid-hazardous-string-as-section-name.patch

710ffe
From b91d5c56210c8d7728c77d0f6a640a13b220fc3e Mon Sep 17 00:00:00 2001
710ffe
From: isaacs <i@izs.me>
710ffe
Date: Tue, 8 Dec 2020 14:21:50 -0800
710ffe
Subject: [PATCH] do not allow invalid hazardous string as section name
710ffe
710ffe
Signed-off-by: rpm-build <rpm-build>
710ffe
---
710ffe
 deps/npm/node_modules/ini/ini.js        |  8 +++++
710ffe
 deps/npm/node_modules/ini/test/proto.js | 45 +++++++++++++++++++++++++
710ffe
 2 files changed, 53 insertions(+)
710ffe
 create mode 100644 deps/npm/node_modules/ini/test/proto.js
710ffe
710ffe
diff --git a/deps/npm/node_modules/ini/ini.js b/deps/npm/node_modules/ini/ini.js
710ffe
index 590195d..0401258 100644
710ffe
--- a/deps/npm/node_modules/ini/ini.js
710ffe
+++ b/deps/npm/node_modules/ini/ini.js
710ffe
@@ -80,6 +80,12 @@ function decode (str) {
710ffe
     if (!match) return
710ffe
     if (match[1] !== undefined) {
710ffe
       section = unsafe(match[1])
710ffe
+      if (section === '__proto__') {
710ffe
+        // not allowed
710ffe
+        // keep parsing the section, but don't attach it.
710ffe
+        p = {}
710ffe
+        return
710ffe
+      }
710ffe
       p = out[section] = out[section] || {}
710ffe
       return
710ffe
     }
710ffe
@@ -94,6 +100,7 @@ function decode (str) {
710ffe
     // Convert keys with '[]' suffix to an array
710ffe
     if (key.length > 2 && key.slice(-2) === '[]') {
710ffe
       key = key.substring(0, key.length - 2)
710ffe
+      if (key === '__proto__') return
710ffe
       if (!p[key]) {
710ffe
         p[key] = []
710ffe
       } else if (!Array.isArray(p[key])) {
710ffe
@@ -125,6 +132,7 @@ function decode (str) {
710ffe
     var l = parts.pop()
710ffe
     var nl = l.replace(/\\\./g, '.')
710ffe
     parts.forEach(function (part, _, __) {
710ffe
+      if (part === '__proto__') return
710ffe
       if (!p[part] || typeof p[part] !== 'object') p[part] = {}
710ffe
       p = p[part]
710ffe
     })
710ffe
diff --git a/deps/npm/node_modules/ini/test/proto.js b/deps/npm/node_modules/ini/test/proto.js
710ffe
new file mode 100644
710ffe
index 0000000..ab35533
710ffe
--- /dev/null
710ffe
+++ b/deps/npm/node_modules/ini/test/proto.js
710ffe
@@ -0,0 +1,45 @@
710ffe
+var ini = require('../')
710ffe
+var t = require('tap')
710ffe
+
710ffe
+var data = `
710ffe
+__proto__ = quux
710ffe
+foo = baz
710ffe
+[__proto__]
710ffe
+foo = bar
710ffe
+[other]
710ffe
+foo = asdf
710ffe
+[kid.__proto__.foo]
710ffe
+foo = kid
710ffe
+[arrproto]
710ffe
+hello = snyk
710ffe
+__proto__[] = you did a good job
710ffe
+__proto__[] = so you deserve arrays
710ffe
+thanks = true
710ffe
+`
710ffe
+var res = ini.parse(data)
710ffe
+t.deepEqual(res, {
710ffe
+  foo: 'baz',
710ffe
+  other: {
710ffe
+    foo: 'asdf',
710ffe
+  },
710ffe
+  kid: {
710ffe
+    foo: {
710ffe
+      foo: 'kid',
710ffe
+    },
710ffe
+  },
710ffe
+  arrproto: {
710ffe
+    hello: 'snyk',
710ffe
+    thanks: true,
710ffe
+  },
710ffe
+})
710ffe
+t.equal(res.__proto__, Object.prototype)
710ffe
+t.equal(res.kid.__proto__, Object.prototype)
710ffe
+t.equal(res.kid.foo.__proto__, Object.prototype)
710ffe
+t.equal(res.arrproto.__proto__, Object.prototype)
710ffe
+t.equal(Object.prototype.foo, undefined)
710ffe
+t.equal(Object.prototype[0], undefined)
710ffe
+t.equal(Object.prototype['0'], undefined)
710ffe
+t.equal(Object.prototype[1], undefined)
710ffe
+t.equal(Object.prototype['1'], undefined)
710ffe
+t.equal(Array.prototype[0], undefined)
710ffe
+t.equal(Array.prototype[1], undefined)
710ffe
-- 
710ffe
2.29.2
710ffe