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

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