@contrast/config 1.5.0 → 1.5.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.
package/lib/index.d.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * way not consistent with the End User License Agreement.
14
14
  */
15
15
 
16
- import { RulesConfig } from '@contrast/common';
16
+ import { ProtectRuleMode, Rule } from '@contrast/common';
17
17
  import { Level } from 'pino';
18
18
 
19
19
  export type SyslogLevel =
@@ -28,6 +28,9 @@ export type SyslogLevel =
28
28
  export interface Config {
29
29
  configFile: string;
30
30
 
31
+ _default: Record<string, any>;
32
+ _flat: Record<string, any>;
33
+ _sources: Record<string, 'DEFAULT' | 'ENV' | 'YAML' | 'ContrastUI'>;
31
34
  api: {
32
35
  enable: boolean;
33
36
  api_key: string;
@@ -80,33 +83,40 @@ export interface Config {
80
83
  /** Default: `'security'` */
81
84
  path: string;
82
85
 
86
+ /** Default: `false` */
87
+ stdout: boolean;
88
+
83
89
  syslog: {
84
- enable?: boolean;
90
+ /** Default: `false` */
91
+ enable: boolean;
85
92
 
86
- ip?: string;
93
+ /** Default: `'127.0.0.1'` */
94
+ ip: string;
87
95
 
88
- port?: number;
96
+ /** Default: `514` */
97
+ port: number;
89
98
 
90
99
  /**
91
100
  * The facility code of the messages the agent sends to Syslog.
92
101
  * Values: 0-23, inclusive.
102
+ * Default: `19`
93
103
  */
94
- facility?: number;
104
+ facility: number;
95
105
 
96
- /** Log level of 'Blocked' attacks. */
97
- severity_blocked?: SyslogLevel;
106
+ /** Log level of 'Blocked' attacks. Default: `'notice'` */
107
+ severity_blocked: SyslogLevel;
98
108
 
99
- /** Log level of 'Exploited' attacks. */
100
- severity_exploited?: SyslogLevel;
109
+ /** Log level of 'Exploited' attacks. Default: `'alert'` */
110
+ severity_exploited: SyslogLevel;
101
111
 
102
- /** Log level of 'Probed' attacks. */
103
- severity_probed?: SyslogLevel;
112
+ /** Log level of 'Probed' attacks. Default: `'warning'` */
113
+ severity_probed: SyslogLevel;
104
114
 
105
- /** Log level of 'Blocked at Perimeter' attacks. */
106
- severity_blocked_perimeter?: SyslogLevel;
115
+ /** Log level of 'Blocked at Perimeter' attacks. Default: `'notice'` */
116
+ severity_blocked_perimeter: SyslogLevel;
107
117
 
108
- /** Log level of suspcious but not blocked attacks. */
109
- severity_suspicious?: SyslogLevel;
118
+ /** Log level of suspcious but not blocked attacks. Default: `'warning'` */
119
+ severity_suspicious: SyslogLevel;
110
120
  };
111
121
 
112
122
  };
@@ -164,7 +174,7 @@ export interface Config {
164
174
  */
165
175
  disabled_rules: string[];
166
176
 
167
- rules: RulesConfig;
177
+ rules: Record<Rule, { mode: ProtectRuleMode }>;
168
178
  };
169
179
 
170
180
  /** Reported server information overrides */
package/lib/options.js CHANGED
@@ -177,6 +177,25 @@ const api = [
177
177
  ];
178
178
 
179
179
  const agent = [
180
+ {
181
+ name: 'agent.diagnostics.enable',
182
+ arg: '[false]',
183
+ default: true,
184
+ fn: castBoolean,
185
+ desc: 'If true the agent will try to create both diagnostic files at startup',
186
+ },
187
+ {
188
+ name: 'agent.diagnostics.quiet',
189
+ arg: '[true]',
190
+ default: false,
191
+ fn: castBoolean,
192
+ desc: 'If true the agent will print all diagnostic results to stdout as well',
193
+ },
194
+ {
195
+ name: 'agent.diagnostics.report_path',
196
+ arg: '<path>',
197
+ desc: 'path indicating where to report all diagnostics results',
198
+ },
180
199
  {
181
200
  name: 'agent.reporters.file',
182
201
  arg: '<path>',
@@ -212,6 +231,7 @@ const agent = [
212
231
  },
213
232
  {
214
233
  name: 'agent.security_logger.level',
234
+ default: 'debug',
215
235
  arg: '<level>',
216
236
  fn: lowercase,
217
237
  // NOTE: syslog actually specifies 8 levels, starting with 0-emergency, but
@@ -226,33 +246,46 @@ const agent = [
226
246
  arg: '<path>',
227
247
  desc: 'where to log security events',
228
248
  },
249
+ {
250
+ name: 'agent.security_logger.stdout',
251
+ arg: '[false]',
252
+ default: false,
253
+ fn: castBoolean,
254
+ desc: 'if true will output the security_logger loggs to stdout too',
255
+ },
229
256
  {
230
257
  name: 'agent.security_logger.syslog.enable',
258
+ default: false,
231
259
  fn: castBoolean,
232
260
  desc: 'Set to true to enable Syslog logging',
233
261
  },
234
262
  {
235
263
  name: 'agent.security_logger.syslog.ip',
264
+ default: '127.0.0.1',
236
265
  desc: 'Set the IP address of the Syslog server to which the agent should send messages',
237
266
  arg: '<ip>',
238
267
  },
239
268
  {
240
269
  name: 'agent.security_logger.syslog.port',
270
+ default: '514',
241
271
  desc: 'Set the port of the Syslog server to which the agent should send messages',
242
272
  arg: '<port>',
243
273
  fn: parseNum,
244
274
  },
245
275
  {
246
276
  name: 'agent.security_logger.syslog.facility',
277
+ default: '19',
247
278
  desc: 'Set the facility code of the messages the agent sends to Syslog',
248
279
  enum: [
249
280
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
250
281
  21, 22, 23,
251
282
  ],
252
283
  arg: '<facility>',
284
+ fn: parseNum,
253
285
  },
254
286
  {
255
287
  name: 'agent.security_logger.syslog.severity_blocked',
288
+ default: 'notice',
256
289
  desc: 'Set the log level of Blocked attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
257
290
  enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
258
291
  arg: '<level>',
@@ -260,6 +293,7 @@ const agent = [
260
293
  },
261
294
  {
262
295
  name: 'agent.security_logger.syslog.severity_exploited',
296
+ default: 'alert',
263
297
  desc: 'Set the log level of Exploited attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
264
298
  enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
265
299
  arg: '<level>',
@@ -267,20 +301,15 @@ const agent = [
267
301
  },
268
302
  {
269
303
  name: 'agent.security_logger.syslog.severity_probed',
304
+ default: 'warning',
270
305
  desc: 'Set the log level of Probed attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
271
306
  enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
272
307
  arg: '<level>',
273
308
  fn: lowercase,
274
309
  },
275
- {
276
- name: 'agent.security_logger.syslog.severity_blocked_perimeter',
277
- desc: 'Set the log level of Blocked at Perimeter attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
278
- enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
279
- arg: '<level>',
280
- fn: lowercase,
281
- },
282
310
  {
283
311
  name: 'agent.security_logger.syslog.severity_suspicious',
312
+ default: 'warning',
284
313
  desc: 'Set the log level of suspicious but not blocked attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
285
314
  enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
286
315
  arg: '<level>',
@@ -306,6 +335,21 @@ const agent = [
306
335
  desc: "set location to look for the app's package.json",
307
336
  default: process.cwd(),
308
337
  },
338
+ {
339
+ name: 'agent.node.library_usage.reporting.interval',
340
+ arg: '<num>',
341
+ fn: parseNum,
342
+ default: 1,
343
+ desc: 'frequency of collecting code events for library usage in milliseconds, defaults to 1 ms',
344
+ },
345
+ {
346
+ name: 'agent.node.library_usage.reporting.enable',
347
+ arg: '[false]',
348
+ // setting this falsee for now, until feature is complete
349
+ default: true,
350
+ fn: castBoolean,
351
+ desc: 'add enhanced library usage features (i.e. scanning for composition of dependencies, reporting usage)',
352
+ },
309
353
  {
310
354
  name: 'agent.stack_trace_limit',
311
355
  arg: '<limit>',
@@ -399,6 +443,34 @@ const assess = [
399
443
  fn: castBoolean,
400
444
  desc: 'if false, disable assess for this agent'
401
445
  },
446
+ {
447
+ name: 'assess.trust_custom_validators',
448
+ arg: '<trust-custom-validators>',
449
+ default: false,
450
+ desc: 'trust incoming strings when they pass custom validators (Mongoose, Joi)',
451
+ },
452
+ {
453
+ name: 'assess.stacktraces',
454
+ arg: '<level>',
455
+ default: 'ALL',
456
+ fn: uppercase,
457
+ enum: ['ALL', 'SOME', 'NONE'],
458
+ desc: 'Select the level of collected stacktraces. ALL - for all asses events, SOME - for Source and Sink events, NONE - no stacktraces collected'
459
+ },
460
+ {
461
+ name: 'assess.max_propagation_events',
462
+ arg: '<limit>',
463
+ default: 250,
464
+ fn: parseNum,
465
+ desc: 'set limit for maximum number of propagation events created per request',
466
+ },
467
+ {
468
+ name: 'assess.max_context_source_events',
469
+ arg: '<limit>',
470
+ default: 150,
471
+ fn: parseNum,
472
+ desc: 'set limit for maximum number of source events (tracked strings) created per request',
473
+ },
402
474
  ];
403
475
 
404
476
  const server = [
package/lib/util.js CHANGED
@@ -21,19 +21,10 @@ const fs = require('fs');
21
21
  const os = require('os');
22
22
  const yaml = require('yaml');
23
23
 
24
+ const { set } = require('@contrast/common');
24
25
  const { configOptions } = require('./options');
25
26
  const util = module.exports;
26
27
 
27
- function set(obj, name, value) {
28
- const props = name.split('.');
29
- const lastProp = props.pop();
30
- for (const p of props) {
31
- if (!obj[p]) obj[p] = {};
32
- obj = obj[p];
33
- }
34
- obj[lastProp] = value;
35
- }
36
-
37
28
  /**
38
29
  * Sets initial config values to the config.
39
30
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/config",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "An API for discovering Contrast agent configuration data",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -17,7 +17,7 @@
17
17
  "test": "../scripts/test.sh"
18
18
  },
19
19
  "dependencies": {
20
- "@contrast/common": "1.3.0",
20
+ "@contrast/common": "1.3.2",
21
21
  "yaml": "^2.0.1"
22
22
  }
23
- }
23
+ }