From caf1e626102ce45e9f48b45d1b8c23fa3b3d7511 Mon Sep 17 00:00:00 2001 From: youkunhuang Date: Wed, 11 Jul 2018 20:00:28 +0800 Subject: [PATCH] chore(logger): logger add limit --- bin/tsw/util/auto-report/logReport.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bin/tsw/util/auto-report/logReport.js b/bin/tsw/util/auto-report/logReport.js index 5f434903..7a5c3c90 100644 --- a/bin/tsw/util/auto-report/logReport.js +++ b/bin/tsw/util/auto-report/logReport.js @@ -291,6 +291,30 @@ module.exports.receiveCloud = function(req, res) { return returnJson('get appkey error'); } + if (data.logText) { + return returnJson('logText is invalid'); + } + + if (typeof data.logText !== 'string') { + return returnJson('logText is not string'); + } + + if (data.logText.length >= 64 * 1024) { + return returnJson('logText is large than 64KB'); + } + + if (!data.logJson) { + return returnJson('logJson is invalid'); + } + + if (typeof data.logJson !== 'string') { + return returnJson('logJson is not string'); + } + + if (data.logText.length >= 1024 * 1024) { + return returnJson('logJson is large than 1MB'); + } + const appid = context.appid; const appkey = context.appkey; const reportKey = [appid, data.key].join('/');