From a8fcee2de7f1301a8257e98f4907de71273ce5b6 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Mon, 6 May 2024 15:20:24 +0200 Subject: [PATCH 1/3] fix bodyParser express limit from iota config --- lib/bindings/HTTPBinding.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/bindings/HTTPBinding.js b/lib/bindings/HTTPBinding.js index 2a4412bde..7055db0ae 100644 --- a/lib/bindings/HTTPBinding.js +++ b/lib/bindings/HTTPBinding.js @@ -51,9 +51,9 @@ let httpBindingServer; const transport = 'HTTP'; const { promisify } = require('util'); -const json = promisify(bodyParser.json({ strict: false })); // accept anything JSON.parse accepts. -const text = promisify(bodyParser.text()); -const raw = promisify(bodyParser.raw()); +const json = promisify(bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit })); // accept anything JSON.parse accepts. +const text = promisify(bodyParser.text({ limit: config.getConfig().iota.expressLimit })); +const raw = promisify(bodyParser.raw({ limit: config.getConfig().iota.expressLimit })); const xml2js = require('xml2js'); const xmlStripPrefix = xml2js.processors.stripPrefix; const xml = promisify( @@ -681,7 +681,7 @@ function start(callback) { httpBindingServer.router.post( config.getConfig().iota.defaultResource || constants.HTTP_MEASURE_PATH, - bodyParser.json({ strict: false }), // accept anything JSON.parse accepts + bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit }), // accept anything JSON.parse accepts checkMandatoryParams(false), parseDataMultipleMeasure, addTimestamp, @@ -704,7 +704,7 @@ function start(callback) { httpBindingServer.router.post( (config.getConfig().iota.defaultResource || constants.HTTP_MEASURE_PATH) + constants.HTTP_COMMANDS_PATH, - bodyParser.json({ strict: false }), // accept anything JSON.parse accepts. + bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit }), // accept anything JSON.parse accepts. checkMandatoryParams(false), parseData, addTimestamp, @@ -715,7 +715,7 @@ function start(callback) { httpBindingServer.router.post( (config.getConfig().iota.defaultResource || constants.HTTP_MEASURE_PATH) + constants.HTTP_CONFIGURATION_PATH, - bodyParser.json({ strict: false }), // accept anything JSON.parse accepts. + bodyParser.json({ strict: false, limit: config.getConfig().iota.expressLimit }), // accept anything JSON.parse accepts. checkMandatoryParams(false), parseData, handleConfigurationRequest From d593c69485a4461cfd27a61e1a31651be1804321 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Mon, 6 May 2024 15:29:58 +0200 Subject: [PATCH 2/3] update CNR --- CHANGES_NEXT_RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 8b1378917..0c08fc5b6 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1 @@ - +- Fix default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (#827) From 67b1587067d6c9597c2f1611d7514d09b8cd3636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Mon, 6 May 2024 16:57:41 +0200 Subject: [PATCH 3/3] Update CHANGES_NEXT_RELEASE --- CHANGES_NEXT_RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 0c08fc5b6..67b4cc840 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1 @@ -- Fix default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (#827) +- Fix: default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (#827)