@contrast/agent 4.30.0 → 4.30.1

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/contrast.js CHANGED
@@ -330,6 +330,7 @@ contrastAgent.bootstrap = function(args) {
330
330
  const args = {
331
331
  quiet: (process.env['CONTRAST__AGENT__DIAGNOSTICS__QUIET'] === 'false') ? false : true,
332
332
  output: destination,
333
+ skip: false,
333
334
  };
334
335
 
335
336
  try {
@@ -339,8 +340,9 @@ contrastAgent.bootstrap = function(args) {
339
340
  }
340
341
 
341
342
  if (!(process.env['CONTRAST__AGENT__SYSTEM_DIAGNOSTICS__ENABLE'] === 'false')) {
343
+ args.output = path.join(args.output, '../contrast_system_info.json');
342
344
  const info = fetchSystemInfo();
343
- outputSystemInfo({ skip: false, quiet: true, output: 'contrast_system_info.json' }, info);
345
+ outputSystemInfo(args, info);
344
346
  }
345
347
  }
346
348
  });
@@ -114,7 +114,10 @@ function getProtectValues(option, config, tsData) {
114
114
  Source: 'ContrastUI',
115
115
  };
116
116
  } else if (option.name.includes('protect.rules') && option.name.includes('mode')) {
117
- const apiRule = tsData.protectionRulesList.find(r => r.id == option.name.split('.')[2]);
117
+ let apiRule;
118
+ if (tsData.protectionRulesList) {
119
+ apiRule = tsData.protectionRulesList.find(r => r.id == option.name.split('.')[2]);
120
+ }
118
121
 
119
122
  const apiMode = apiRule ? apiRule.mode : undefined;
120
123
  const ymlMode = config._flat[option.name];
@@ -199,6 +202,14 @@ function outputAgentConfigFile(agent, options, args, err) {
199
202
  effectiveConfig.Config.Status = 'Success';
200
203
  }
201
204
 
205
+ try {
206
+ fs.accessSync(path.join(args.output, '..'), fs.constants.RDWD_OK);
207
+ fs.writeFileSync(args.output, JSON.stringify(effectiveConfig, null, 2), 'utf-8');
208
+ } catch (err) {
209
+ // try to write the file at pwd instead
210
+ args.output = path.join(process.cwd(), 'contrast_effective_config.json');
211
+ }
212
+
202
213
  try {
203
214
  fs.accessSync(path.join(args.output, '..'), fs.constants.RDWD_OK);
204
215
  fs.writeFileSync(args.output, JSON.stringify(effectiveConfig, null, 2), 'utf-8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agent",
3
- "version": "4.30.0",
3
+ "version": "4.30.1",
4
4
  "description": "Node.js security instrumentation by Contrast Security",
5
5
  "keywords": [
6
6
  "security",