@contrast/agent 4.32.7 → 4.32.9

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.
@@ -18,6 +18,7 @@ const patcher = require('../../../hooks/patcher');
18
18
  const { PATCH_TYPES } = require('../../../constants');
19
19
  const moduleHook = require('../../../hooks/require');
20
20
  const { propagate } = require('./common');
21
+ const { isString } = require('../../../util/is-string');
21
22
 
22
23
  const NAMESPACE_PREFIX = '\\\\?\\';
23
24
  const UNC_STR = 'UNC\\';
@@ -30,7 +31,7 @@ module.exports.handle = function handle() {
30
31
  post(data) {
31
32
  const { result } = data;
32
33
  // If the result doesn't start with \\? then no namespace was prepended.
33
- if (!result.startsWith(NAMESPACE_PREFIX)) return;
34
+ if (!result || !isString(result) || !result.startsWith(NAMESPACE_PREFIX)) return;
34
35
  const resultMeta = {
35
36
  evaluator: (segmentOffset) => segmentOffset > -1,
36
37
  method: 'path.toNamespacedPath',
@@ -44,10 +44,6 @@ const path = require('path');
44
44
  const util = require('util');
45
45
  const _ = require('lodash');
46
46
 
47
- const configPathEnvVars = {
48
- path: 'CONTRAST_CONFIG_PATH',
49
- };
50
-
51
47
  /**
52
48
  * Takes strings "true"|"t" or "false"|"f" (case insensitive) and return the appropriate boolean.
53
49
  * If we can't match one of the two words, return true;
@@ -112,7 +108,7 @@ const misc = [
112
108
  name: 'configFile',
113
109
  abbrev: 'c',
114
110
  // special case this guy because it should be settable via ENV
115
- env: configPathEnvVars.path,
111
+ env: 'CONTRAST_CONFIG_PATH',
116
112
  arg: '<path>',
117
113
  desc: 'set config file location. defaults to <app_root>/contrast_security.yaml',
118
114
  },
@@ -541,11 +537,9 @@ const agent = [
541
537
  name: 'agent.security_logger.level',
542
538
  arg: '<level>',
543
539
  fn: lowercase,
544
- // NOTE: syslog actually specifies 8 levels, starting with 0-emergency, but we do not let the user
545
- // set emergency for whatever reason
546
- enum: ['alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'],
547
- default: 'debug',
548
- desc: 'security logging level (alert, crit, err, warning, notice, info, debug)',
540
+ enum: ['error', 'warn', 'debug', 'info', 'trace'],
541
+ default: 'error',
542
+ desc: 'security logging level (error, warn, debug, info, trace)',
549
543
  },
550
544
  {
551
545
  name: 'agent.security_logger.path',
@@ -580,23 +574,26 @@ const agent = [
580
574
  },
581
575
  {
582
576
  name: 'agent.security_logger.syslog.severity_exploited',
583
- desc: 'Set the log level of Exploited attacks. Value options are ALERT/CRIT/ERROR/WARNING/NOTICE/INFO/DEBUG',
584
- enum: ['alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'],
577
+ desc: 'Set the log level of Exploited attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
578
+ enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
585
579
  arg: '<level>',
580
+ default: 'notice',
586
581
  fn: lowercase,
587
582
  },
588
583
  {
589
584
  name: 'agent.security_logger.syslog.severity_blocked',
590
- desc: 'Set the log level of Exploited attacks. Value options are ALERT/CRIT/ERROR/WARNING/NOTICE/INFO/DEBUG',
591
- enum: ['alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'],
585
+ desc: 'Set the log level of Exploited attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
586
+ enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
592
587
  arg: '<level>',
588
+ default: 'notice',
593
589
  fn: lowercase,
594
590
  },
595
591
  {
596
592
  name: 'agent.security_logger.syslog.severity_probed',
597
- desc: 'Set the log level of Probed attacks. Value options are ALERT/CRIT/ERROR/WARNING/NOTICE/INFO/DEBUG',
598
- enum: ['alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'],
593
+ desc: 'Set the log level of Probed attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
594
+ enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
599
595
  arg: '<level>',
596
+ default: 'warning',
600
597
  fn: lowercase,
601
598
  },
602
599
  {
@@ -1019,7 +1016,6 @@ function getDefault(optionName) {
1019
1016
  return option.default;
1020
1017
  }
1021
1018
 
1022
- module.exports.configPathEnvVars = configPathEnvVars;
1023
1019
  module.exports.options = options;
1024
1020
  module.exports.program = program;
1025
1021
  module.exports.clearBaseCase = clearBaseCase;
@@ -24,7 +24,6 @@ const stringify = require('json-stable-stringify');
24
24
 
25
25
  const common = require('./options');
26
26
  const configOptions = common.options;
27
- const { configPathEnvVars } = common;
28
27
  const util = module.exports;
29
28
 
30
29
  /**
@@ -175,8 +174,7 @@ function checkConfigPath() {
175
174
  function getConfigPath(cliOptions) {
176
175
  return (
177
176
  cliOptions.configFile ||
178
- process.env[configPathEnvVars.path] ||
179
- process.env[configPathEnvVars.deprecated] ||
177
+ process.env['CONTRAST_CONFIG_PATH'] ||
180
178
  checkConfigPath()
181
179
  );
182
180
  }
@@ -372,9 +370,11 @@ util.Config = Config;
372
370
  util.setup = function setup(cliOptions, logger) {
373
371
  mergePM2Envs();
374
372
 
373
+ const { script, configFile } = cliOptions;
375
374
  const mergedCliOptions = mergeCliOptions(cliOptions, logger);
376
- mergedCliOptions.script = cliOptions.script;
377
- mergedCliOptions.configFile = cliOptions.configFile;
375
+ if (script) mergedCliOptions.script = script;
376
+ if (configFile) mergedCliOptions.configFile = configFile;
377
+
378
378
  mergedCliOptions.validate();
379
379
 
380
380
  return mergedCliOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agent",
3
- "version": "4.32.7",
3
+ "version": "4.32.9",
4
4
  "description": "Node.js security instrumentation by Contrast Security",
5
5
  "keywords": [
6
6
  "security",
@@ -120,7 +120,7 @@
120
120
  "@bmacnaughton/string-generator": "^1.0.0",
121
121
  "@contrast/eslint-config": "^3.0.2",
122
122
  "@contrast/fake-module": "file:test/mock/contrast-fake",
123
- "@contrast/screener-service": "^1.12.13",
123
+ "@contrast/screener-service": "^1.12.14",
124
124
  "@hapi/boom": "file:test/mock/boom",
125
125
  "@hapi/hapi": "file:test/mock/hapi",
126
126
  "@ls-lint/ls-lint": "^1.11.2",