Skip to content

Commit da50610

Browse files
authored
Merge pull request #25 from browserstack/cg-field-limiters
feat: Added limiters for CG fields
2 parents b38bcd5 + b64e542 commit da50610

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/chitragupta/field_limits.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
DYNAMIC_DATA: 5000,
3+
HEADERS: 1000,
4+
PARAMS: 10000,
5+
};

lib/chitragupta/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const cls = require('./cls');
22
const categories = require('./categories');
33
const formatVersions = require('./format_versions');
4+
const fieldLimits = require('./field_limits');
45
const os = require('os');
56

67
function populateServerData(dataParam) {
@@ -33,6 +34,7 @@ function populateServerData(dataParam) {
3334
data.data.request.id = data.data.request.id || request.request_id;
3435
data.data.request.user_id = data.data.request.user_id || cls.get('userId');
3536
data.data.request.params = data.data.request.params || params;
37+
data.data.request.params = data.data.request.params.substring(0, fieldLimits.PARAMS) || true;
3638

3739
// Need to check for response.finished as by default the response object
3840
// holds a 200 statusCode till the response is not sent
@@ -103,6 +105,8 @@ function initializeData(message, metaDataParam) {
103105
data.log.kind = data.log.dynamic_data.substring(0, 40);
104106
}
105107

108+
data.log.dynamic_data = data.log.dynamic_data.substring(0, fieldLimits.DYNAMIC_DATA) || true;
109+
106110
data.meta.format = data.meta.format || {};
107111

108112
if (cls.get('server')) populateServerData(data);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chitragupta",
3-
"version": "1.7.2",
3+
"version": "1.7.3",
44
"description": "An easy to install node module to convert unstructured logs into informative structured logs",
55
"main": "lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)