@contrast/core 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/app-info.js CHANGED
@@ -53,6 +53,7 @@ module.exports = function (deps) {
53
53
  appInfo.pkg = pkg;
54
54
  appInfo.name = config.application.name || pkg.name;
55
55
  appInfo.app_dir = path.dirname(appInfo.path);
56
+ appInfo.version = config.application.version || pkg.version;
56
57
  } catch (e) {
57
58
  throw new Error(`Unable to find application's package.json: ${_path}`);
58
59
  }
@@ -19,6 +19,7 @@ const { Event } = require('@contrast/common');
19
19
 
20
20
  module.exports = function(core) {
21
21
  const { messages, config } = core;
22
+ const cfgLogLevel = config.agent.logger.level;
22
23
  core.logger = {
23
24
  pino: require('@contrast/logger').default(core),
24
25
  children: [],
@@ -26,14 +27,14 @@ module.exports = function(core) {
26
27
  const child = {
27
28
  pino: this.pino.child({ name }),
28
29
  setLogLevel: this.setLogLevel
29
- }
30
+ };
30
31
  child.setLogLevel(this.pino.level);
31
32
  this.children.push(child);
32
33
  return child;
33
34
  },
34
35
  setLogLevel(level) {
35
36
  this.pino.level = level;
36
-
37
+
37
38
  const { levelVal, levels: { values } } = this.pino;
38
39
  for (const key in values) {
39
40
  if (levelVal > values[key]) {
@@ -43,18 +44,18 @@ module.exports = function(core) {
43
44
  }
44
45
  }
45
46
  }
46
- }
47
+ };
47
48
 
48
- core.logger.setLogLevel(config.agent.logger.level);
49
+ core.logger.setLogLevel(cfgLogLevel || 'error');
49
50
 
50
51
  messages.on(Event.SERVER_SETTINGS_UPDATE, (settingsMsg) => {
51
52
  const tsLogLevel = settingsMsg?.features?.logLevel.toLowerCase();
52
- if (tsLogLevel && tsLogLevel !== core.logger.level) {
53
+ if (!cfgLogLevel && tsLogLevel && tsLogLevel !== core.logger.level) {
53
54
  core.logger.setLogLevel(tsLogLevel);
54
55
  core.logger.children.forEach((child) => {
55
56
  child.setLogLevel(tsLogLevel);
56
- })
57
+ });
57
58
  core.logger.info('Received new log level: %s from server-features', tsLogLevel);
58
- };
59
+ }
59
60
  });
60
- };
61
+ };
@@ -15,15 +15,10 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { Event, simpleTraverse } = require('@contrast/common');
18
+ const { simpleTraverse } = require('@contrast/common');
19
19
  const { CONTRAST_REDACTED } = require('./constants');
20
20
 
21
21
  module.exports = function(core) {
22
- const {
23
- logger,
24
- messages
25
- } = core;
26
-
27
22
  const idMap = new Map();
28
23
  const keywordSets = [];
29
24
 
@@ -20,15 +20,11 @@ const { Event } = require('@contrast/common');
20
20
 
21
21
  const { CONTRAST_REDACTED } = require('./constants');
22
22
 
23
- module.exports = function(core) {
23
+ module.exports = function (core) {
24
24
  const {
25
25
  messages,
26
26
  logger,
27
- sensitiveDataMasking: {
28
- policy,
29
- getRedactedText,
30
- traverseAndMask,
31
- },
27
+ sensitiveDataMasking: { policy, getRedactedText, traverseAndMask },
32
28
  } = core;
33
29
 
34
30
  messages.on(Event.PROTECT, (msg) => {
@@ -54,7 +50,10 @@ module.exports = function(core) {
54
50
  const redactedText = getRedactedText(key);
55
51
  if (redactedText) {
56
52
  const encoded = encodeURIComponent(value);
57
- msg.protect.reqData.uriPath = msg.protect.reqData.uriPath.replace(encoded, redactedText);
53
+ msg.protect.reqData.uriPath = msg.protect.reqData.uriPath.replace(
54
+ encoded,
55
+ redactedText,
56
+ );
58
57
  msg.protect.parsedParams[key] = redactedText;
59
58
  }
60
59
  }
@@ -74,7 +73,7 @@ module.exports = function(core) {
74
73
  // raw queries
75
74
  if (msg.protect?.reqData?.queries) {
76
75
  const searchParams = new URLSearchParams(msg.protect.reqData.queries);
77
- for (const [key, value] of searchParams) {
76
+ for (const [key] of searchParams) {
78
77
  const redactedText = getRedactedText(key);
79
78
  if (redactedText) {
80
79
  searchParams.set(key, redactedText);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/core",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "Preconfigured Contrast agent core services and models",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -17,16 +17,15 @@
17
17
  "test": "../scripts/test.sh"
18
18
  },
19
19
  "dependencies": {
20
- "@contrast/agentify": "1.1.1",
21
- "@contrast/config": "1.3.1",
20
+ "@contrast/agentify": "1.1.2",
21
+ "@contrast/common": "^1.1.4",
22
+ "@contrast/config": "1.3.2",
22
23
  "@contrast/dep-hooks": "1.0.5",
23
24
  "@contrast/fn-inspect": "^3.2.0",
24
- "@contrast/logger": "1.1.0",
25
- "@contrast/patcher": "1.0.5",
26
- "@contrast/reporter": "1.6.0",
25
+ "@contrast/logger": "1.1.1",
26
+ "@contrast/patcher": "1.0.6",
27
+ "@contrast/reporter": "1.6.1",
27
28
  "@contrast/rewriter": "1.2.0",
28
- "@contrast/scopes": "1.1.2",
29
- "builtin-modules": "^3.2.0",
30
- "semver": "^7.3.7"
29
+ "@contrast/scopes": "1.2.0"
31
30
  }
32
31
  }