📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

bourne

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bourne - npm Package Compare versions

Comparing version

to
1.0.0

lib/index.js

48

package.json
{
"name": "bourne",
"description": "A simple serverless database stored in a JSON file.",
"version": "0.4.0",
"homepage": "https://github.com/andreww8088/bourne",
"author": {
"name": "Andrew Burgess",
"email": "andrew@burgess.io",
"url": "http://andrewburgess.ca"
"description": "JSON parse with prototype poisoning protection",
"version": "1.0.0",
"repository": "git://github.com/hapijs/bourne",
"main": "lib/index.js",
"keywords": [
"JSON",
"parse",
"safe",
"prototype"
],
"dependencies": {
},
"repository": {
"type": "git",
"url": "git://github.com/andreww8088/bourne.git"
"devDependencies": {
"code": "5.x.x",
"lab": "18.x.x"
},
"bugs": {
"url": "https://github.com/andreww8088/bourne/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/andreww8088/bourne/blob/master/LICENSE-MIT"
}
],
"main": "lib/bourne",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt nodeunit"
"test": "lab -a code -t 100 -L",
"test-cov-html": "lab -a code -r html -o coverage.html"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-watch": "~0.5.3",
"grunt": "~0.4.2"
},
"keywords": []
"license": "BSD-3-Clause"
}

@@ -1,27 +0,41 @@

# bourne
# Bourne. JSON Bourne.
A simple serverless database stored in a JSON file.
`JSON.parse()` drop-in replacement with prototype poisoning protection
## Getting Started
Install the module with: `npm install bourne`
## Introduction
```javascript
var bourne = require('bourne');
bourne.awesome(); // "awesome"
Consider this:
```
> const a = '{"__proto__":{ "b":5}}';
'{"__proto__":{ "b":5}}'
## Documentation
_(Coming soon)_
> const b = JSON.parse(a);
{ __proto__: { b: 5 } }
## Examples
_(Coming soon)_
> b.b;
undefined
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
> const c = Object.assign({}, b);
{}
## Release History
_(Nothing yet)_
> c.b
5
```
## License
Copyright (c) 2014 Andrew Burgess
Licensed under the MIT license.
The problem is that `JSON.parse()` retains the `__proto__` property as a plain object key. By
itself, this is not a security issue. However, as soon as that object is assigned to another or
iterated on and values copied, the `__proto__` property leaks and becomes the object's prototype.
## API
### `Bourne.parse(text, [reviver], [options])`
Parses a given JSON-formatted text into an object where:
- `text` - the JSON text string.
- `reviver` - the `JSON.parse()` optional `reviver` argument.
- `options` - optional configuration object where:
- `protoAction` - optional string with one of:
- `'error'` - throw a `SyntaxError` when a `__proto__` key is found. This is the default value.
- `'remove'` - deletes any `__proto__` keys from the result object.
- `'ignore'` - skips all validation (same as calling `JSON.parse()` directly).

Sorry, the diff of this file is not supported yet