@contrast/agentify 1.22.2 → 1.23.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.
@@ -17,6 +17,7 @@
17
17
  'use strict';
18
18
 
19
19
  const Module = require('node:module');
20
+ const rewriteIsDeadzoned = require('./rewrite-is-deadzoned');
20
21
 
21
22
  /**
22
23
  * @param {import('.').Core & {
@@ -47,6 +48,11 @@ module.exports = function init(core) {
47
48
  trim: false,
48
49
  };
49
50
 
51
+ if (rewriteIsDeadzoned(filename)) {
52
+ core.logger.debug('Skipping rewrite-deadzoned file %s', filename);
53
+ return Reflect.apply(_compile, this, [content, filename]);
54
+ }
55
+
50
56
  const result = core.rewriter.rewriteSync(content, options);
51
57
 
52
58
  try {
@@ -74,7 +80,7 @@ module.exports = function init(core) {
74
80
  * @param {string} filename The file path of the module
75
81
  */
76
82
  Module._extensions['.js'] = function (module, filename) {
77
- if (!core.config.agent.node.rewrite.cache.enable) {
83
+ if (!core.config.agent.node.rewrite.cache.enable || rewriteIsDeadzoned(filename)) {
78
84
  return Reflect.apply(js, this, [module, filename]);
79
85
  }
80
86
 
@@ -0,0 +1,71 @@
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
+ const { sep } = require('path');
18
+
19
+ // todo: find optimal way to do these lookups
20
+ const DEADZONED_PATHS = [
21
+ 'ast-types', // CONTRAST-33909: `String` injection causes this module to crash.
22
+ 'angular',
23
+ 'acorn',
24
+ 'archiver',
25
+ 'archiver-utils',
26
+ 'bcrypt',
27
+ 'bcrypt-nodejs',
28
+ 'bcryptjs', // node_modules/bcryptjs/index.js, node_modules/bcryptjs/dist/bcrypt.js
29
+ 'babel',
30
+ 'babel-cli',
31
+ 'babel-core',
32
+ 'browserify',
33
+ 'bunyan',
34
+ 'coffee-script',
35
+ 'compression',
36
+ // 'cookie', // todo: verify this doesn't break sources/propagation
37
+ // 'cookie-signature', // ditto
38
+ 'gzippo',
39
+ // 'handlebars', // ditto
40
+ 'handlebars-precompiler',
41
+ // 'hbs', // ditto
42
+ 'html-webpack-plugin',
43
+ 'jquery',
44
+ 'jsrsasign',
45
+ 'iconv-lite',
46
+ 'less',
47
+ 'logger-console',
48
+ 'loopback-datasource-juggler',
49
+ 'node-webpack',
50
+ 'react',
51
+ 'react-dom',
52
+ 'react-dom/server',
53
+ 'requirejs',
54
+ 'semver',
55
+ 'strong-remoting',
56
+ 'uglify-js',
57
+ 'bn.js',
58
+ 'node-forge',
59
+ 'moment',
60
+ 'moment-timezone'
61
+ ].map((pkgName) => ['node_modules', pkgName, ''].join(sep));
62
+
63
+ module.exports = function rewriteIsDeadzoned(filename) {
64
+ // make all windows separators into unix separators
65
+ for (const path of DEADZONED_PATHS) {
66
+ const start = filename.indexOf(path);
67
+ if (start >= 0) return filename.indexOf('node_modules', start + path.length) == -1;
68
+ }
69
+
70
+ return false;
71
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agentify",
3
- "version": "1.22.2",
3
+ "version": "1.23.0",
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)",
@@ -17,18 +17,18 @@
17
17
  "test": "../scripts/test.sh"
18
18
  },
19
19
  "dependencies": {
20
- "@contrast/common": "1.19.0",
21
- "@contrast/config": "1.26.2",
22
- "@contrast/core": "1.30.0",
20
+ "@contrast/common": "1.20.0",
21
+ "@contrast/config": "1.27.0",
22
+ "@contrast/core": "1.31.0",
23
23
  "@contrast/deadzones": "1.1.2",
24
24
  "@contrast/dep-hooks": "1.3.1",
25
- "@contrast/esm-hooks": "2.4.0",
26
- "@contrast/instrumentation": "1.6.0",
25
+ "@contrast/esm-hooks": "2.5.0",
26
+ "@contrast/instrumentation": "1.7.0",
27
27
  "@contrast/logger": "1.8.0",
28
- "@contrast/metrics": "1.6.0",
28
+ "@contrast/metrics": "1.7.0",
29
29
  "@contrast/patcher": "1.7.1",
30
- "@contrast/reporter": "1.25.1",
31
- "@contrast/rewriter": "1.5.0",
30
+ "@contrast/reporter": "1.26.0",
31
+ "@contrast/rewriter": "1.6.0",
32
32
  "@contrast/scopes": "1.4.0"
33
33
  }
34
34
  }