@contrast/agent 4.32.14 → 4.32.15

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/agent.js CHANGED
@@ -15,7 +15,7 @@ Copyright: 2023 Contrast Security, Inc
15
15
  'use strict';
16
16
 
17
17
  const contrastCluster = require('cluster');
18
- const findCacheDir = require('find-cache-dir');
18
+ const findCacheDir = require('./util/find-cache-dir');
19
19
  const _ = require('lodash');
20
20
  const os = require('os');
21
21
  const path = require('path');
package/lib/telemetry.js CHANGED
@@ -16,7 +16,7 @@ Copyright: 2023 Contrast Security, Inc
16
16
 
17
17
  const { default: axios } = require('axios');
18
18
  const { createHash } = require('crypto');
19
- const findCacheDir = require('find-cache-dir');
19
+ const findCacheDir = require('./util/find-cache-dir');
20
20
  const { promises: fs } = require('fs');
21
21
  const { default: getMac } = require('getmac');
22
22
  const os = require('os');
@@ -0,0 +1,91 @@
1
+ /**
2
+ Copyright: 2023 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
+ * MIT License
17
+ * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
18
+ * Copyright (c) James Talmage <james@talmage.io> (https://github.com/jamestalmage)
19
+
20
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
21
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+ 'use strict';
26
+ const path = require('path');
27
+ const fs = require('fs');
28
+ const commonDir = require('commondir');
29
+ const pkgDir = require('pkg-dir');
30
+ const makeDir = require('make-dir');
31
+
32
+ const { env, cwd } = process;
33
+
34
+ const isWritable = path => {
35
+ try {
36
+ fs.accessSync(path, fs.constants.W_OK);
37
+ return true;
38
+ } catch (_) {
39
+ return false;
40
+ }
41
+ };
42
+
43
+ function useDirectory(directory, options) {
44
+ if (options.create) {
45
+ makeDir.sync(directory);
46
+ }
47
+
48
+ if (options.thunk) {
49
+ return (...arguments_) => path.join(directory, ...arguments_);
50
+ }
51
+
52
+ return directory;
53
+ }
54
+
55
+ function getNodeModuleDirectory(directory) {
56
+ const nodeModules = path.join(directory, 'node_modules');
57
+
58
+ if (
59
+ !isWritable(nodeModules) &&
60
+ (fs.existsSync(nodeModules) || !isWritable(path.join(directory)))
61
+ ) {
62
+ return;
63
+ }
64
+
65
+ return nodeModules;
66
+ }
67
+
68
+ module.exports = (options = {}) => {
69
+ if (env.CACHE_DIR && !['true', 'false', '1', '0'].includes(env.CACHE_DIR)) {
70
+ return useDirectory(path.join(env.CACHE_DIR, options.name), options);
71
+ }
72
+
73
+ let { cwd: directory = cwd() } = options;
74
+
75
+ if (options.files) {
76
+ directory = commonDir(directory, options.files);
77
+ }
78
+
79
+ directory = pkgDir.sync(directory);
80
+
81
+ if (!directory) {
82
+ return;
83
+ }
84
+
85
+ const nodeModules = getNodeModuleDirectory(directory);
86
+ if (!nodeModules) {
87
+ return undefined;
88
+ }
89
+
90
+ return useDirectory(path.join(directory, 'node_modules', '.cache', options.name), options);
91
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agent",
3
- "version": "4.32.14",
3
+ "version": "4.32.15",
4
4
  "description": "Node.js security instrumentation by Contrast Security",
5
5
  "keywords": [
6
6
  "security",
@@ -93,11 +93,12 @@
93
93
  "big-integer": "^1.6.36",
94
94
  "builtin-modules": "^3.2.0",
95
95
  "commander": "^8.3.0",
96
+ "commondir": "^1.0.1",
96
97
  "content-security-policy-parser": "^0.2.0",
97
98
  "cookie": "^0.3.1",
98
99
  "crc-32": "^1.0.0",
100
+ "del": "^4.0.0",
99
101
  "fast-deep-equal": "^3.1.3",
100
- "find-cache-dir": "^3.3.2",
101
102
  "getmac": "^5.20.0",
102
103
  "ipaddr.js": "^1.8.1",
103
104
  "js-yaml": "^4.1.0",
@@ -109,8 +110,10 @@
109
110
  "on-finished": "^2.3.0",
110
111
  "parent-package-json": "^2.0.1",
111
112
  "parseurl": "^1.3.3",
113
+ "pkg-dir": "^4.1.0",
112
114
  "prom-client": "^12.0.0",
113
115
  "semver": "^7.5.3",
116
+ "tempy": "^0.4.0",
114
117
  "uuid": "^8.3.2",
115
118
  "winston": "^3.7.2",
116
119
  "winston-daily-rotate-file": "^4.7.1"