@contrast/config 1.43.0 → 1.45.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 +2 -0
- package/lib/config.js +4 -0
- package/lib/index.js +7 -3
- package/lib/options.js +14 -3
- package/package.json +2 -1
package/lib/common.js
CHANGED
|
@@ -104,6 +104,7 @@ const mappings = {
|
|
|
104
104
|
if (!isNaN(baseProbability)) return baseProbability;
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
|
+
'assess.stacktraces': (remoteData) => remoteData.assess?.report_stacktraces,
|
|
107
108
|
'agent.logger.level': coerceLowerCase('logger.level'),
|
|
108
109
|
'agent.logger.path': (remoteData) => remoteData.logger?.path,
|
|
109
110
|
'agent.security_logger.syslog.enable': (remoteData) => remoteData.security_logger?.syslog?.enable,
|
|
@@ -113,6 +114,7 @@ const mappings = {
|
|
|
113
114
|
'agent.security_logger.syslog.severity_exploited': coerceLowerCase('security_logger.syslog.severity_exploited'),
|
|
114
115
|
'agent.security_logger.syslog.severity_blocked': coerceLowerCase('security_logger.syslog.severity_blocked'),
|
|
115
116
|
'agent.security_logger.syslog.severity_probed': coerceLowerCase('security_logger.syslog.severity_probed'),
|
|
117
|
+
'observe.enable': (remoteData) => remoteData.observe?.enable,
|
|
116
118
|
'server.environment': (remoteData) => remoteData.environment,
|
|
117
119
|
|
|
118
120
|
};
|
package/lib/config.js
CHANGED
|
@@ -30,6 +30,7 @@ const {
|
|
|
30
30
|
USER_CONFIGURATION_FILE,
|
|
31
31
|
},
|
|
32
32
|
mappings,
|
|
33
|
+
ConfigSource,
|
|
33
34
|
} = require('./common');
|
|
34
35
|
|
|
35
36
|
const CONTRAST_CONFIG_PATH = 'CONTRAST_CONFIG_PATH';
|
|
@@ -226,6 +227,9 @@ module.exports = class Config {
|
|
|
226
227
|
source,
|
|
227
228
|
});
|
|
228
229
|
}
|
|
230
|
+
|
|
231
|
+
// this is not a common config value
|
|
232
|
+
this.setValue('preinstrument', !!process.env.CONTRAST_PREINSTRUMENT, ConfigSource.ENVIRONMENT_VARIABLE);
|
|
229
233
|
}
|
|
230
234
|
|
|
231
235
|
_redact(name, value) {
|
package/lib/index.js
CHANGED
|
@@ -16,10 +16,14 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const { ConfigSource } = require('./common');
|
|
19
|
+
const { Core } = require('@contrast/core/lib/ioc/core');
|
|
19
20
|
const Config = require('./config');
|
|
20
21
|
|
|
21
|
-
module.exports =
|
|
22
|
-
|
|
23
|
-
}
|
|
22
|
+
module.exports = Core.makeComponent({
|
|
23
|
+
name: 'config',
|
|
24
|
+
factory(core = {}) {
|
|
25
|
+
return core.config = new Config(core);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
24
28
|
|
|
25
29
|
module.exports.ConfigSource = ConfigSource;
|
package/lib/options.js
CHANGED
|
@@ -575,6 +575,7 @@ Example - \`/opt/Contrast/contrast.log\` creates a log in the \`/opt/Contrast\`
|
|
|
575
575
|
// effective based on local config and 'assess.sampling' TeamServer DTM
|
|
576
576
|
name: 'assess.probabilistic_sampling.base_probability',
|
|
577
577
|
arg: '<probability>',
|
|
578
|
+
/** @param {string} val */
|
|
578
579
|
fn: (val) => {
|
|
579
580
|
const p = parseFloat(val);
|
|
580
581
|
if (p >= 0 && p <= 1) return p;
|
|
@@ -585,7 +586,7 @@ Example - \`/opt/Contrast/contrast.log\` creates a log in the \`/opt/Contrast\`
|
|
|
585
586
|
});
|
|
586
587
|
}
|
|
587
588
|
},
|
|
588
|
-
default: 0.
|
|
589
|
+
default: 0.05,
|
|
589
590
|
desc: 'A value p within the range [0, 1]. Each request will share same probability p of being sampled.',
|
|
590
591
|
},
|
|
591
592
|
{
|
|
@@ -754,8 +755,18 @@ Example - \`label1, label2, label3\``,
|
|
|
754
755
|
{
|
|
755
756
|
name: 'server.environment',
|
|
756
757
|
arg: '<environment>',
|
|
757
|
-
|
|
758
|
-
fn:
|
|
758
|
+
/** @param {string} val */
|
|
759
|
+
fn: (val) => {
|
|
760
|
+
if (!val) return val;
|
|
761
|
+
|
|
762
|
+
const valid = new Set(['QA', 'PRODUCTION', 'DEVELOPMENT']);
|
|
763
|
+
const normalized = uppercase(val);
|
|
764
|
+
if (!valid.has(normalized)) {
|
|
765
|
+
throw new Error(`Invalid option: server.environment must be one of ${Array.from(valid)}`);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
return normalized;
|
|
769
|
+
},
|
|
759
770
|
desc: `Set the environment directly to override the default set by the Contrast UI. This allows the user to configure the environment dynamically at startup rather than manually updating the Server in the Contrast UI themselves afterwards.
|
|
760
771
|
Valid values include \`QA\`, \`PRODUCTION\` and \`DEVELOPMENT\`. For example, \`PRODUCTION\` registers this Server as running in a \`PRODUCTION\` environment, regardless of the organization's default environment in the Contrast UI.`,
|
|
761
772
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.45.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)",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@contrast/common": "1.32.0",
|
|
24
|
+
"@contrast/core": "1.50.0",
|
|
24
25
|
"yaml": "^2.2.2"
|
|
25
26
|
}
|
|
26
27
|
}
|