Secure json parsing (#1110)

* Safe json parsing

* Updated test
This commit is contained in:
Tomas Della Vedova
2020-03-12 16:35:45 +01:00
committed by GitHub
parent 41cc8a6d04
commit 6bf04473c9
3 changed files with 72 additions and 2 deletions

View File

@ -6,6 +6,7 @@
const { stringify } = require('querystring')
const debug = require('debug')('elasticsearch')
const sjson = require('secure-json-parse')
const { SerializationError, DeserializationError } = require('./errors')
class Serializer {
@ -22,7 +23,7 @@ class Serializer {
deserialize (json) {
debug('Deserializing', json)
try {
var object = JSON.parse(json)
var object = sjson.parse(json)
} catch (err) {
throw new DeserializationError(err.message)
}