@contrast/core 1.32.1 → 1.32.2

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.
Files changed (2) hide show
  1. package/lib/app-info.js +14 -25
  2. package/package.json +2 -2
package/lib/app-info.js CHANGED
@@ -33,22 +33,12 @@ module.exports = function (core) {
33
33
  const { logger, config } = core;
34
34
  const { app_root, cmd_ignore_list, exclusive_entrypoint } = config.agent.node;
35
35
 
36
- let cmd;
37
- let entrypoint;
38
- let pkgInfo;
39
- let name;
40
- let err;
41
-
42
- try {
43
- cmd = getCommand();
44
- pkgInfo = getPackageInfo();
45
- entrypoint = getEntrypoint();
46
- name = getApplicationName();
47
- } catch (_err) {
48
- err = _err;
49
- }
36
+ const cmd = getCommand();
37
+ const pkgInfo = getPackageInfo();
38
+ const entrypoint = getEntrypoint();
39
+ const name = getApplicationName();
50
40
 
51
- return core.appInfo = !err ? {
41
+ core.appInfo = {
52
42
  // dedupe this? - it's already in systemInfo
53
43
  os: {
54
44
  type: os.type(),
@@ -72,9 +62,10 @@ module.exports = function (core) {
72
62
  serverEnvironment: config.server.environment,
73
63
  group: config.application.group,
74
64
  metadata: config.application.metadata,
75
- } : {
76
- _errors: [err]
77
65
  };
66
+ // by convention return the object
67
+ return core.appInfo;
68
+
78
69
 
79
70
  /**
80
71
  * Generates a command string based on ARGV and process.argv0, which will be used
@@ -87,25 +78,23 @@ module.exports = function (core) {
87
78
  const args = [process.argv0, ...process.argv].map((a) => path.basename(a));
88
79
  const cmd = Array.from(new Set(args)).join(' ');
89
80
  const message = 'application command matches cmd_ignore_list config option';
90
- let err;
91
81
 
92
82
  if (cmd_ignore_list) {
83
+ let err;
93
84
  for (const ignoreCommand of cmd_ignore_list) {
94
- if (err) break;
95
85
 
96
86
  if (ignoreCommand === 'npm*') {
97
87
  if (cmd.includes('npm ')) err = new IntentionalError(message);
98
88
  } else {
99
89
  if (cmd.includes(ignoreCommand)) err = new IntentionalError(message);
100
90
  }
91
+ if (err) {
92
+ logger.trace({ cmd_ignore_list, cmd }, message);
93
+ throw err;
94
+ }
101
95
  }
102
96
  }
103
97
 
104
- if (err) {
105
- logger.trace({ cmd_ignore_list, cmd }, message);
106
- throw err;
107
- }
108
-
109
98
  return cmd;
110
99
  }
111
100
 
@@ -205,7 +194,7 @@ module.exports = function (core) {
205
194
  * @throws {Error} if there is no name identified
206
195
  */
207
196
  function getApplicationName() {
208
- name = config.application.name || pkgInfo.packageData.name;
197
+ const name = config.application.name || pkgInfo.packageData.name;
209
198
  if (!name) {
210
199
  throw new Error(
211
200
  'The application\'s name was not identified. ' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/core",
3
- "version": "1.32.1",
3
+ "version": "1.32.2",
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)",
@@ -16,7 +16,7 @@
16
16
  "test": "../scripts/test.sh"
17
17
  },
18
18
  "dependencies": {
19
- "@contrast/common": "1.21.1",
19
+ "@contrast/common": "1.21.2",
20
20
  "@contrast/find-package-json": "^1.0.0",
21
21
  "@contrast/fn-inspect": "^4.0.0"
22
22
  }