@contrast/core 1.8.0 → 1.8.1
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
|
@@ -22,10 +22,10 @@ const process = require('process');
|
|
|
22
22
|
|
|
23
23
|
const MAX_ATTEMPTS = 5;
|
|
24
24
|
|
|
25
|
-
module.exports = function (
|
|
26
|
-
const { logger, config } =
|
|
25
|
+
module.exports = function (core) {
|
|
26
|
+
const { logger, config } = core;
|
|
27
27
|
|
|
28
|
-
const appInfo = (
|
|
28
|
+
const appInfo = (core.appInfo = {
|
|
29
29
|
os: {
|
|
30
30
|
type: os.type(),
|
|
31
31
|
platform: os.platform(),
|
|
@@ -83,7 +83,7 @@ module.exports = function (deps) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
if (packageLocation) {
|
|
86
|
-
|
|
86
|
+
core.logger.info('using package.json at %s', packageLocation);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
return packageLocation;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const featureReaders = {
|
|
19
|
+
'agent.logger.level': (remoteData) => remoteData.features?.logLevel,
|
|
20
|
+
'agent.logger.path': (remoteData) => remoteData.features?.logFile,
|
|
21
|
+
'agent.security_logger.syslog.enable': (remoteData) => remoteData.features?.defend?.syslog?.syslogEnabled,
|
|
22
|
+
'agent.security_logger.syslog.ip': (remoteData) => remoteData.features?.defend?.syslog?.syslogIpAddress,
|
|
23
|
+
'agent.security_logger.syslog.port': (remoteData) => remoteData.features?.defend?.syslog?.syslogPortNumber,
|
|
24
|
+
'agent.security_logger.syslog.facility': (remoteData) => remoteData.features?.defend?.syslog?.syslogFacilityCode,
|
|
25
|
+
'agent.security_logger.syslog.severity_exploited': (remoteData) => remoteData.features?.defend?.syslog?.syslogSeverityExploit,
|
|
26
|
+
'agent.security_logger.syslog.severity_blocked': (remoteData) => remoteData.features?.defend?.syslog?.syslogSeverityBlocke,
|
|
27
|
+
'agent.security_logger.syslog.severity_probed': (remoteData) => remoteData.features?.defend?.syslog?.syslogSeverityProbed,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module.exports = featureReaders;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const { Event } = require('@contrast/common');
|
|
19
|
+
const { configOptions } = require('@contrast/config/lib/options');
|
|
20
|
+
|
|
21
|
+
const settingsReaders = require('./settings-readers');
|
|
22
|
+
const featureReaders = require('./feature-readers');
|
|
23
|
+
|
|
24
|
+
module.exports = function(core) {
|
|
25
|
+
const { config, messages } = core;
|
|
26
|
+
const effectiveConfig = createEffectiveConfig({ config, remoteData: {} });
|
|
27
|
+
|
|
28
|
+
if (core.config?.protect?.enable === true) {
|
|
29
|
+
messages.on(Event.SERVER_SETTINGS_UPDATE, (msg) => {
|
|
30
|
+
msg.features && mergeRemoteData(msg, featureReaders);
|
|
31
|
+
msg.settings && mergeRemoteData(msg, settingsReaders);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
core.getEffectiveConfig = function () {
|
|
36
|
+
return formatEffectiveConfig(effectiveConfig);
|
|
37
|
+
};
|
|
38
|
+
return;
|
|
39
|
+
|
|
40
|
+
function createEffectiveConfig({ config, remoteData }) {
|
|
41
|
+
const list = configOptions.map(({ name }) => ({
|
|
42
|
+
CanonicalName: name,
|
|
43
|
+
Name: name,
|
|
44
|
+
Value: config._flat[name],
|
|
45
|
+
Source: config._sources[name]
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
return new Map(list.map((entry) => [entry.CanonicalName, entry]));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function formatEffectiveConfig(configMap) {
|
|
52
|
+
const values = Array.from(configMap.values()).filter(s => s.Value != undefined);
|
|
53
|
+
|
|
54
|
+
const content = {
|
|
55
|
+
report_create: new Date(),
|
|
56
|
+
status: undefined,
|
|
57
|
+
config: {
|
|
58
|
+
effective_config: values,
|
|
59
|
+
environment: values.filter(v => v.Source === 'ENV'),
|
|
60
|
+
contrast_ui: values.filter(v => v.Source === 'ContrastUI'),
|
|
61
|
+
file: values.filter(v => v.Source === 'YAML'),
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const api = values.filter(v => v.CanonicalName == 'api.enable')[0];
|
|
66
|
+
const apiEnabled = api && api.Value;
|
|
67
|
+
if (apiEnabled) {
|
|
68
|
+
content.status = 'Success!';
|
|
69
|
+
} else {
|
|
70
|
+
content.status = 'Success! Couldn\'t connect to Teamserver, so no Teamserver data will be included!';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return content;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function mergeRemoteData(remoteData, readers) {
|
|
77
|
+
for (const [name, readerFn] of Object.entries(readers)) {
|
|
78
|
+
const remoteValue = readerFn(remoteData);
|
|
79
|
+
if (config._sources[name] === 'DEFAULT' && remoteValue != null) {
|
|
80
|
+
effectiveConfig.set(name, {
|
|
81
|
+
CanonicalName: name,
|
|
82
|
+
Name: name,
|
|
83
|
+
Value: remoteValue,
|
|
84
|
+
Source: 'ContrastUI',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
3
|
+
* Contact: support@contrastsecurity.com
|
|
4
|
+
* License: Commercial
|
|
5
|
+
|
|
6
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
+
* made available through public repositories, use of this Software is subject to
|
|
9
|
+
* the applicable End User Licensing Agreement found at
|
|
10
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
+
* way not consistent with the End User License Agreement.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
ProtectRuleMode: {
|
|
20
|
+
OFF,
|
|
21
|
+
BLOCK,
|
|
22
|
+
MONITOR,
|
|
23
|
+
BLOCK_AT_PERIMETER
|
|
24
|
+
}
|
|
25
|
+
} = require('@contrast/common');
|
|
26
|
+
|
|
27
|
+
const settingsReaders = [
|
|
28
|
+
'protect.rules.cmd-injection.mode',
|
|
29
|
+
'protect.rules.cmd-injection-command-backdoors.mode',
|
|
30
|
+
'protect.rules.cmd-injection-semantic-chained-commands.mode',
|
|
31
|
+
'protect.rules.cmd-injection-semantic-dangerous-paths.mode',
|
|
32
|
+
'protect.rules.method-tampering.mode',
|
|
33
|
+
'protect.rules.nosql-injection.mode',
|
|
34
|
+
'protect.rules.nosql-injection-mongo.mode',
|
|
35
|
+
'protect.rules.path-traversal.mode',
|
|
36
|
+
'protect.rules.path-traversal-semantic-file-security-bypass.mode',
|
|
37
|
+
'protect.rules.reflected-xss.mode',
|
|
38
|
+
'protect.rules.sql-injection.mode',
|
|
39
|
+
'protect.rules.ssjs-injection.mode',
|
|
40
|
+
'protect.rules.unsafe-file-upload.mode',
|
|
41
|
+
'protect.rules.untrusted-deserialization.mode',
|
|
42
|
+
'protect.rules.xxe.mode',
|
|
43
|
+
].reduce((acc, name) => {
|
|
44
|
+
const ruleId = name.split('.')[2];
|
|
45
|
+
return Object.assign(acc, {
|
|
46
|
+
[name]: (remoteData) => {
|
|
47
|
+
const remoteSetting = remoteData.settings?.defend?.protectionRules?.find(r => r.id == ruleId);
|
|
48
|
+
switch (remoteSetting?.mode) {
|
|
49
|
+
case 'OFF': return OFF;
|
|
50
|
+
case 'MONITORING': return MONITOR;
|
|
51
|
+
case 'BLOCKING': return remoteSetting.blockAtEntry ? BLOCK_AT_PERIMETER : BLOCK;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}, {});
|
|
56
|
+
|
|
57
|
+
module.exports = settingsReaders;
|
package/lib/index.js
CHANGED
|
@@ -22,6 +22,7 @@ module.exports = function init(core = {}) {
|
|
|
22
22
|
|
|
23
23
|
require('@contrast/config')(core);
|
|
24
24
|
require('./logger-factory')(core);
|
|
25
|
+
require('./effective-config')(core);
|
|
25
26
|
require('./sensitive-data-masking')(core);
|
|
26
27
|
require('./app-info')(core);
|
|
27
28
|
require('./is-agent-path')(core);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/core",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
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)",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"@contrast/agentify": "1.2.0",
|
|
21
21
|
"@contrast/common": "1.2.0",
|
|
22
22
|
"@contrast/config": "1.4.0",
|
|
23
|
+
"@contrast/deadzones": "1.0.0",
|
|
23
24
|
"@contrast/dep-hooks": "1.0.5",
|
|
24
25
|
"@contrast/fn-inspect": "^3.2.0",
|
|
25
26
|
"@contrast/instrumentation": "1.0.0",
|
|
26
27
|
"@contrast/logger": "1.1.1",
|
|
27
28
|
"@contrast/patcher": "1.1.0",
|
|
28
29
|
"@contrast/reporter": "1.7.0",
|
|
29
|
-
"@contrast/rewriter": "1.
|
|
30
|
-
"@contrast/scopes": "1.2.0"
|
|
31
|
-
"@contrast/deadzones": "1.0.0"
|
|
30
|
+
"@contrast/rewriter": "1.3.0",
|
|
31
|
+
"@contrast/scopes": "1.2.0"
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|