node-sec-patterns
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -198,17 +198,31 @@ 'use strict' | ||
void ((() => { | ||
const getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors | ||
? Object.getOwnPropertyDescriptors | ||
// Minimal polyfill for node@6 | ||
: (obj) => { | ||
const out = Object.create(null) | ||
Object.getOwnPropertyNames(obj).forEach( | ||
(name) => { | ||
out[name] = Object.getOwnPropertyDescriptor(obj, name) | ||
}) | ||
return out | ||
} | ||
[ Function, RegExp, String ].forEach((builtin) => { | ||
const proto = builtin.prototype | ||
const descriptors = Object.getOwnPropertyDescriptors(proto) | ||
Object.entries(descriptors).forEach( | ||
([ propertyName, descriptor ]) => { | ||
if (descriptor.configurable) { | ||
descriptor.configurable = false | ||
if ('writable' in descriptor) { | ||
descriptor.writable = false | ||
} | ||
} else if (descriptor.writable) { | ||
throw new Error( | ||
`Cannot lock down ${builtin.name}.prototype.${propertyName}`) | ||
const descriptors = getOwnPropertyDescriptors(proto) | ||
for (const propertyName in descriptors) { | ||
if (!Object.hasOwnProperty.call(descriptors, propertyName)) { | ||
continue | ||
} | ||
const descriptor = descriptors[propertyName] | ||
if (descriptor.configurable) { | ||
descriptor.configurable = false | ||
if ('writable' in descriptor) { | ||
descriptor.writable = false | ||
} | ||
}) | ||
} else if (descriptor.writable) { | ||
throw new Error( | ||
`Cannot lock down ${builtin.name}.prototype.${propertyName}`) | ||
} | ||
} | ||
defineProperties(proto, descriptors) | ||
@@ -215,0 +229,0 @@ }) |
{ | ||
"name": "node-sec-patterns", | ||
"description": "Allow projects control over which dependencies can create objects that encapsulate security guarantees.", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "design-patterns", |
@@ -6,2 +6,6 @@ # Node security design patterns | ||
[![Build Status](https://travis-ci.org/mikesamuel/node-sec-patterns.svg?branch=master)](https://travis-ci.org/mikesamuel/node-sec-patterns) | ||
[![Dependencies Status](https://david-dm.org/mikesamuel/node-sec-patterns/status.svg)](https://david-dm.org/mikesamuel/node-sec-patterns) | ||
[![npm](https://img.shields.io/npm/v/node-sec-patterns.svg)](https://www.npmjs.com/package/node-sec-patterns) | ||
## Goal | ||
@@ -8,0 +12,0 @@ Make it easier for project teams to produce code that preserves |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33238
379
213