node-bunyan-lite/test
Martin Gausby c0ca774238 Defend against throwing defined props in stringify
If an object has a defined property, that is enumerable, and this
property throws an error, it will make JSON stringify throw an
error, and potentially bring down the program.

The solution so far is to try-catch with the usual json stringifyer,
that guards against circular references. If this throws an error
we will attempt to guard against defined properties; and return
[Throws] if a property throws an error when accesed.

The following examples illustrate the problem:

```js
var obj = {};
obj.__defineGetter__('foo', function() { throw new Error('ouch!'); });

JSON.stringify(obj.foo); // error thrown
```

And using `Object.defineProperty`:
```js
var obj = {};
Object.defineProperty(obj, 'foo', {
    get: function() { throw new Error('ouch!'); }
    enumerable: true // enumerable is false by default
});

JSON.stringify(obj.foo); // error thrown
```

The cases we have seen in production is third party modules that
has enumerable getters that try to access properties on undefined
objects.

Fixes #182.
2015-01-18 23:27:06 -08:00
..
corpus [issue #139] Fix bunyan crash on a log record with res.header that is an object. 2014-05-29 00:13:01 -07:00
buffer.test.js make check 2013-04-01 17:21:01 -07:00
child-behaviour.test.js style: 4-space indents 2013-03-28 17:42:32 -07:00
cli.test.js Tweak to SIGINT patch from @jnordberg for #161 2014-08-24 23:34:38 -07:00
ctor.test.js 'make check' clean 2014-08-25 00:50:53 -07:00
cycles.test.js style: 4-space indents 2013-03-28 17:42:32 -07:00
dtrace.test.js style: 4-space indents 2013-03-28 17:42:32 -07:00
error-event.test.js style: 4-space indents 2013-03-28 17:42:32 -07:00
level.test.js allow Logger level values outside TRACE..FATAL 2014-11-13 23:15:21 -08:00
log-some.js style: 4-space indents 2013-03-28 17:42:32 -07:00
log.test.js Fix a breakage in log.info(err) on a logger with no serializers. 2014-09-27 21:22:17 -07:00
other-api.test.js style: 4-space indents 2013-03-28 17:42:32 -07:00
process-exit.js 'make check' 2014-05-31 22:25:06 -07:00
process-exit.test.js make check 2014-05-31 23:00:13 -07:00
raw-stream.test.js style: 4-space indents 2013-03-28 17:42:32 -07:00
ringbuffer.test.js style: 4-space indents 2013-03-28 17:42:32 -07:00
safe-json-stringify-1.js Defend against throwing defined props in stringify 2015-01-18 23:27:06 -08:00
safe-json-stringify-2.js Defend against throwing defined props in stringify 2015-01-18 23:27:06 -08:00
safe-json-stringify-3.js Defend against throwing defined props in stringify 2015-01-18 23:27:06 -08:00
safe-json-stringify-4.js Defend against throwing defined props in stringify 2015-01-18 23:27:06 -08:00
safe-json-stringify.test.js Defend against throwing defined props in stringify 2015-01-18 23:27:06 -08:00
serializers.test.js Fix 'make check' 2014-09-27 21:04:34 -07:00
stream-levels.test.js fix 'make check' 2015-01-17 22:04:39 -08:00
tap4nodeunit.js make check 2013-04-01 17:21:01 -07:00