@contrast/agentify 1.22.1 → 1.22.3

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/index.js CHANGED
@@ -129,6 +129,12 @@ module.exports = function init(core = {}) {
129
129
  if (core.config._errors?.length) {
130
130
  throw core.config._errors[0];
131
131
  }
132
+ if (!core.config.enable) {
133
+ const errorMessage = 'Contrast agent disabled by configuration (enable: false)';
134
+ console.log(errorMessage);
135
+ throw new IntentionalError(errorMessage);
136
+ }
137
+
132
138
  require('@contrast/logger').default(core);
133
139
  require('@contrast/core/lib/agent-info')(core);
134
140
  require('@contrast/core/lib/system-info')(core);
@@ -18,6 +18,8 @@
18
18
 
19
19
  const Module = require('node:module');
20
20
 
21
+ const rewriteIsDeadzoned = require('./rewrite-is-deadzoned');
22
+
21
23
  /**
22
24
  * @param {import('.').Core & {
23
25
  * rewriteHooks?: import('@contrast/common').Installable;
@@ -47,6 +49,11 @@ module.exports = function init(core) {
47
49
  trim: false,
48
50
  };
49
51
 
52
+ if (rewriteIsDeadzoned(filename)) {
53
+ core.logger.debug('Skipping rewrite-deadzoned file %s', filename);
54
+ return Reflect.apply(_compile, this, [content, filename]);
55
+ }
56
+
50
57
  const result = core.rewriter.rewriteSync(content, options);
51
58
 
52
59
  try {
@@ -74,7 +81,7 @@ module.exports = function init(core) {
74
81
  * @param {string} filename The file path of the module
75
82
  */
76
83
  Module._extensions['.js'] = function (module, filename) {
77
- if (!core.config.agent.node.rewrite.cache.enable) {
84
+ if (!core.config.agent.node.rewrite.cache.enable || rewriteIsDeadzoned(filename)) {
78
85
  return Reflect.apply(js, this, [module, filename]);
79
86
  }
80
87
 
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright: 2024 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
+ 'use strict';
16
+
17
+ // i'm leaving out index.js now because it doesn't really matter and i want
18
+ // to keep this list short. maybe a little bit of experimentation to figure
19
+ // out optimal way to do this lookup.
20
+ const doNotRewriteEndingPaths = [
21
+ //'node_modules/bcryptjs/index.js',
22
+ 'node_modules/bcryptjs/dist/bcrypt.js',
23
+ ];
24
+
25
+ module.exports = function rewriteIsDeadzoned(filename) {
26
+ // make all windows separators into unix separators
27
+ filename = filename.replace(/\\/g, '/');
28
+ for (const endingPath of doNotRewriteEndingPaths) {
29
+ if (filename.endsWith(endingPath)) {
30
+ return true;
31
+ }
32
+
33
+ return false;
34
+ }
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agentify",
3
- "version": "1.22.1",
3
+ "version": "1.22.3",
4
4
  "description": "Configures Contrast agent services and instrumentation within an application",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@contrast/common": "1.19.0",
21
- "@contrast/config": "1.26.1",
21
+ "@contrast/config": "1.26.2",
22
22
  "@contrast/core": "1.30.0",
23
23
  "@contrast/deadzones": "1.1.2",
24
24
  "@contrast/dep-hooks": "1.3.1",
25
- "@contrast/esm-hooks": "2.4.0",
25
+ "@contrast/esm-hooks": "2.4.1",
26
26
  "@contrast/instrumentation": "1.6.0",
27
27
  "@contrast/logger": "1.8.0",
28
28
  "@contrast/metrics": "1.6.0",