@contrast/protect 1.57.0 → 1.58.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/error-handlers/install/express.js +3 -0
- package/lib/get-source-context.js +2 -0
- package/lib/index.js +12 -2
- package/lib/input-analysis/handlers.js +581 -578
- package/lib/input-analysis/index.js +1 -1
- package/lib/input-tracing/handlers/index.js +1 -1
- package/lib/input-tracing/install/fs.js +1 -1
- package/lib/make-source-context.js +7 -1
- package/package.json +10 -10
|
@@ -59,6 +59,9 @@ module.exports = function (core) {
|
|
|
59
59
|
name: 'finalHandler',
|
|
60
60
|
patchType,
|
|
61
61
|
post(data) {
|
|
62
|
+
// no need to perform this runtime patch if protect is disabled
|
|
63
|
+
if (!core.config.getEffectiveValue('protect.enable')) return;
|
|
64
|
+
|
|
62
65
|
data.result = patcher.patch(data.result, {
|
|
63
66
|
name: 'finalHandler.returnedFunction',
|
|
64
67
|
patchType,
|
|
@@ -19,6 +19,8 @@ module.exports = function init(core) {
|
|
|
19
19
|
const { scopes: { sources } } = core;
|
|
20
20
|
|
|
21
21
|
function getSourceContext() {
|
|
22
|
+
if (!core.config.getEffectiveValue('protect.enable')) return null;
|
|
23
|
+
|
|
22
24
|
const sourceContext = sources.getStore()?.protect;
|
|
23
25
|
return sourceContext?.allowed ? null : sourceContext;
|
|
24
26
|
}
|
package/lib/index.js
CHANGED
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const { isMainThread } = require('node:worker_threads');
|
|
19
|
-
|
|
20
19
|
const { callChildComponentMethodsSync } = require('@contrast/common');
|
|
20
|
+
const { ConfigSource } = require('@contrast/config');
|
|
21
21
|
|
|
22
22
|
module.exports = function(core) {
|
|
23
|
+
const { config } = core;
|
|
24
|
+
|
|
23
25
|
const protect = core.protect = {
|
|
24
26
|
agentLib: module.exports.instantiateAgentLib(),
|
|
25
27
|
};
|
|
@@ -36,7 +38,15 @@ module.exports = function(core) {
|
|
|
36
38
|
require('./semantic-analysis')(core);
|
|
37
39
|
|
|
38
40
|
protect.install = function() {
|
|
39
|
-
if
|
|
41
|
+
// only force instrumentation if assess is explicitly enabled in local config
|
|
42
|
+
const forceInstrumentation =
|
|
43
|
+
config.preinstrument &&
|
|
44
|
+
config.getEffectiveSource('protect.enable') !== ConfigSource.DEFAULT_VALUE;
|
|
45
|
+
|
|
46
|
+
if (
|
|
47
|
+
!forceInstrumentation &&
|
|
48
|
+
!core.config.getEffectiveValue('protect.enable')
|
|
49
|
+
) {
|
|
40
50
|
core.logger.debug('protect is disabled, skipping installation');
|
|
41
51
|
return;
|
|
42
52
|
}
|