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

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