| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6eeb06f commit 0f7c06e
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -199,14 +199,11 @@ exports.translatePeerCertificate = function translatePeerCertificate(c) { | |||
| 199 | 199 | if (c.subject != null) c.subject = tls.parseCertString(c.subject); | |
| 200 | 200 | if (c.infoAccess != null) { | |
| 201 | 201 | var info = c.infoAccess; | |
| 202 | - c.infoAccess = {}; | ||
| 202 | + c.infoAccess = Object.create(null); | ||
| 203 | 203 | ||
| 204 | 204 | // XXX: More key validation? | |
| 205 | 205 | info.replace(/([^\n:]*):([^\n]*)(?:\n|$)/g, function(all, key, val) { | |
| 206 | - if (key === '__proto__') | ||
| 207 | - return; | ||
| 208 | - | ||
| 209 | - if (c.infoAccess.hasOwnProperty(key)) | ||
| 206 | + if (key in c.infoAccess) | ||
| 210 | 207 | c.infoAccess[key].push(val); | |
| 211 | 208 | else | |
| 212 | 209 | c.infoAccess[key] = [val]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -231,7 +231,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { | |||
| 231 | 231 | // Example: | |
| 232 | 232 | // C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org | |
| 233 | 233 | exports.parseCertString = function parseCertString(s) { | |
| 234 | - var out = {}; | ||
| 234 | + var out = Object.create(null); | ||
| 235 | 235 | var parts = s.split('\n'); | |
| 236 | 236 | for (var i = 0, len = parts.length; i < len; i++) { | |
| 237 | 237 | var sepIndex = parts[i].indexOf('='); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + /* eslint-disable no-proto */ | ||
| 1 | 2 | 'use strict'; | |
| 2 | 3 | const common = require('../common'); | |
| 3 | 4 | if (!common.hasCrypto) | |
@@ -11,6 +12,7 @@ const tls = require('tls'); | |||
| 11 | 12 | 'CN=ca1\nemailAddress=ry@clouds.org'; | |
| 12 | 13 | const singlesOut = tls.parseCertString(singles); | |
| 13 | 14 | assert.deepStrictEqual(singlesOut, { | |
| 15 | + __proto__: null, | ||
| 14 | 16 | C: 'US', | |
| 15 | 17 | ST: 'CA', | |
| 16 | 18 | L: 'SF', | |
@@ -26,6 +28,7 @@ const tls = require('tls'); | |||
| 26 | 28 | 'CN=*.nodejs.org'; | |
| 27 | 29 | const doublesOut = tls.parseCertString(doubles); | |
| 28 | 30 | assert.deepStrictEqual(doublesOut, { | |
| 31 | + __proto__: null, | ||
| 29 | 32 | OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ], | |
| 30 | 33 | CN: '*.nodejs.org' | |
| 31 | 34 | }); | |
@@ -34,5 +37,13 @@ const tls = require('tls'); | |||
| 34 | 37 | { | |
| 35 | 38 | const invalid = 'fhqwhgads'; | |
| 36 | 39 | const invalidOut = tls.parseCertString(invalid); | |
| 37 | - assert.deepStrictEqual(invalidOut, {}); | ||
| 40 | + assert.deepStrictEqual(invalidOut, { __proto__: null }); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + { | ||
| 44 | + const input = '__proto__=mostly harmless\nhasOwnProperty=not a function'; | ||
| 45 | + const expected = Object.create(null); | ||
| 46 | + expected.__proto__ = 'mostly harmless'; | ||
| 47 | + expected.hasOwnProperty = 'not a function'; | ||
| 48 | + assert.deepStrictEqual(tls.parseCertString(input), expected); | ||
| 38 | 49 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + /* eslint-disable no-proto */ | ||
| 1 | 2 | 'use strict'; | |
| 2 | 3 | const common = require('../common'); | |
| 3 | 4 | ||
@@ -7,8 +8,12 @@ if (!common.hasCrypto) | |||
| 7 | 8 | const { strictEqual, deepStrictEqual } = require('assert'); | |
| 8 | 9 | const { translatePeerCertificate } = require('_tls_common'); | |
| 9 | 10 | ||
| 10 | - const certString = 'A=1\nB=2\nC=3'; | ||
| 11 | - const certObject = { A: '1', B: '2', C: '3' }; | ||
| 11 | + const certString = '__proto__=42\nA=1\nB=2\nC=3'; | ||
| 12 | + const certObject = Object.create(null); | ||
| 13 | + certObject.__proto__ = '42'; | ||
| 14 | + certObject.A = '1'; | ||
| 15 | + certObject.B = '2'; | ||
| 16 | + certObject.C = '3'; | ||
| 12 | 17 | ||
| 13 | 18 | strictEqual(translatePeerCertificate(null), null); | |
| 14 | 19 | strictEqual(translatePeerCertificate(undefined), null); | |
@@ -19,14 +24,14 @@ strictEqual(translatePeerCertificate(1), 1); | |||
| 19 | 24 | deepStrictEqual(translatePeerCertificate({}), {}); | |
| 20 | 25 | ||
| 21 | 26 | deepStrictEqual(translatePeerCertificate({ issuer: '' }), | |
| 22 | - { issuer: {} }); | ||
| 27 | + { issuer: Object.create(null) }); | ||
| 23 | 28 | deepStrictEqual(translatePeerCertificate({ issuer: null }), | |
| 24 | 29 | { issuer: null }); | |
| 25 | 30 | deepStrictEqual(translatePeerCertificate({ issuer: certString }), | |
| 26 | 31 | { issuer: certObject }); | |
| 27 | 32 | ||
| 28 | 33 | deepStrictEqual(translatePeerCertificate({ subject: '' }), | |
| 29 | - { subject: {} }); | ||
| 34 | + { subject: Object.create(null) }); | ||
| 30 | 35 | deepStrictEqual(translatePeerCertificate({ subject: null }), | |
| 31 | 36 | { subject: null }); | |
| 32 | 37 | deepStrictEqual(translatePeerCertificate({ subject: certString }), | |
@@ -47,9 +52,18 @@ deepStrictEqual( | |||
| 47 | 52 | } | |
| 48 | 53 | ||
| 49 | 54 | deepStrictEqual(translatePeerCertificate({ infoAccess: '' }), | |
| 50 | - { infoAccess: {} }); | ||
| 55 | + { infoAccess: Object.create(null) }); | ||
| 51 | 56 | deepStrictEqual(translatePeerCertificate({ infoAccess: null }), | |
| 52 | 57 | { infoAccess: null }); | |
| 53 | - deepStrictEqual( | ||
| 54 | - translatePeerCertificate({ infoAccess: 'OCSP - URI:file:///etc/passwd' }), | ||
| 55 | - { infoAccess: { 'OCSP - URI': ['file:///etc/passwd'] } }); | ||
| 58 | + { | ||
| 59 | + const input = | ||
| 60 | + '__proto__:mostly harmless\n' + | ||
| 61 | + 'hasOwnProperty:not a function\n' + | ||
| 62 | + 'OCSP - URI:file:///etc/passwd\n'; | ||
| 63 | + const expected = Object.create(null); | ||
| 64 | + expected.__proto__ = ['mostly harmless']; | ||
| 65 | + expected.hasOwnProperty = ['not a function']; | ||
| 66 | + expected['OCSP - URI'] = ['file:///etc/passwd']; | ||
| 67 | + deepStrictEqual(translatePeerCertificate({ infoAccess: input }), | ||
| 68 | + { infoAccess: expected }); | ||
| 69 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments