@contrast/config 1.46.0 → 1.48.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/common.js CHANGED
@@ -97,6 +97,7 @@ const mappings = {
97
97
  // server features
98
98
  'assess.enable': (remoteData) => remoteData.assess?.enable,
99
99
  'assess.probabilistic_sampling.enable': (remoteData) => remoteData.assess?.sampling?.enable,
100
+ 'assess.probabilistic_sampling.baseline': (remoteData) => remoteData.assess?.sampling?.baseline,
100
101
  'assess.probabilistic_sampling.base_probability': (remoteData) => {
101
102
  const request_frequency = remoteData.assess?.sampling?.request_frequency;
102
103
  if (request_frequency > 0) {
@@ -104,6 +105,7 @@ const mappings = {
104
105
  if (!isNaN(baseProbability)) return baseProbability;
105
106
  }
106
107
  },
108
+ 'assess.probabilistic_sampling.window_ms': (remoteData) => remoteData.assess?.sampling?.window_ms,
107
109
  'assess.stacktraces': (remoteData) => remoteData.assess?.report_stacktraces,
108
110
  'agent.logger.level': coerceLowerCase('logger.level'),
109
111
  'agent.logger.path': (remoteData) => remoteData.logger?.path,
package/lib/config.js CHANGED
@@ -248,27 +248,31 @@ module.exports = class Config {
248
248
  }
249
249
 
250
250
  getReport({ redact = true }) {
251
+ const report = {
252
+ report_create: new Date(),
253
+ config: {
254
+ status: this._status
255
+ }
256
+ };
251
257
  const effective_config = [], environment_variable = [], contrast_ui = [];
252
258
 
253
259
  Array.from(this._effectiveMap.values()).forEach((v) => {
254
- let { value } = v;
255
- if (redact) value = this._redact(v.name, v.value);
260
+ let { value, name, canonical_name, source } = v;
261
+ if (value === null) return;
262
+ if (redact) value = this._redact(name, value);
263
+ value = String(value);
264
+
265
+ effective_config.push({ value, name, canonical_name, source });
256
266
 
257
- const redacted = { ...v, value: value !== null ? String(value) : null };
258
- effective_config.push(redacted);
259
- if (v.source === ENVIRONMENT_VARIABLE) environment_variable.push(redacted);
260
- if (v.source === CONTRAST_UI) contrast_ui.push(redacted);
267
+ if (source === ENVIRONMENT_VARIABLE) environment_variable.push({ value, name, canonical_name });
268
+ if (source === CONTRAST_UI) contrast_ui.push({ value, name, canonical_name });
261
269
  });
262
270
 
263
- return {
264
- report_create: new Date(),
265
- config: {
266
- status: this._status,
267
- effective_config,
268
- environment_variable,
269
- contrast_ui,
270
- }
271
- };
271
+ report.config['effective_config'] = effective_config;
272
+ if (contrast_ui.length) report.config['contrast_ui'] = contrast_ui;
273
+ if (environment_variable.length) report.config['environment_variable'] = environment_variable;
274
+
275
+ return report;
272
276
  }
273
277
 
274
278
  getEffectiveSource(canonicalName) {
package/lib/options.js CHANGED
@@ -578,6 +578,13 @@ Example - \`/opt/Contrast/contrast.log\` creates a log in the \`/opt/Contrast\`
578
578
  fn: castBoolean,
579
579
  desc: 'Set to true to enable sampling of requests for dataflow and other Assess features',
580
580
  },
581
+ {
582
+ name: 'assess.probabilistic_sampling.baseline',
583
+ arg: '<baseline>',
584
+ default: 5,
585
+ fn: parseNum,
586
+ desc: 'This property indicates the number of requests to analyze in each window before sampling begins.',
587
+ },
581
588
  {
582
589
  // effective based on local config and 'assess.sampling' TeamServer DTM
583
590
  name: 'assess.probabilistic_sampling.base_probability',
@@ -596,6 +603,13 @@ Example - \`/opt/Contrast/contrast.log\` creates a log in the \`/opt/Contrast\`
596
603
  default: 0.05,
597
604
  desc: 'A value p within the range [0, 1]. Each request will share same probability p of being sampled.',
598
605
  },
606
+ {
607
+ name: 'assess.probabilistic_sampling.window_ms',
608
+ arg: '<window_ms>',
609
+ default: 180_000,
610
+ fn: parseNum,
611
+ desc: 'This property indicates the duration for which a sample set is valid.',
612
+ },
599
613
  {
600
614
  name: 'assess.probabilistic_sampling.event_detail',
601
615
  arg: '<level>',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/config",
3
- "version": "1.46.0",
3
+ "version": "1.48.0",
4
4
  "description": "An API for discovering Contrast agent configuration data",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -17,11 +17,11 @@
17
17
  "node": ">= 16.9.1"
18
18
  },
19
19
  "scripts": {
20
- "test": "../scripts/test.sh"
20
+ "test": "bash ../scripts/test.sh"
21
21
  },
22
22
  "dependencies": {
23
- "@contrast/common": "1.32.0",
24
- "@contrast/core": "1.51.0",
23
+ "@contrast/common": "1.33.0",
24
+ "@contrast/core": "1.53.0",
25
25
  "yaml": "^2.2.2"
26
26
  }
27
27
  }