@contrast/agent 4.10.5 → 4.12.0

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.
@@ -33,8 +33,11 @@ Copyright: 2022 Contrast Security, Inc
33
33
  * @module lib/core/config/options
34
34
  */
35
35
  'use strict';
36
- const { Command, Option } = require('commander');
36
+ const { Command } = require('commander');
37
+
37
38
  const program = new Command();
39
+ program.allowUnknownOption();
40
+
38
41
  const os = require('os');
39
42
  const url = require('url');
40
43
  const path = require('path');
@@ -42,7 +45,7 @@ const util = require('util');
42
45
  const _ = require('lodash');
43
46
 
44
47
  const configPathEnvVars = {
45
- path: 'CONTRAST_CONFIG_PATH'
48
+ path: 'CONTRAST_CONFIG_PATH',
46
49
  };
47
50
 
48
51
  /**
@@ -111,9 +114,8 @@ const misc = [
111
114
  // special case this guy because it should be settable via ENV
112
115
  env: configPathEnvVars.path,
113
116
  arg: '<path>',
114
- desc:
115
- 'set config file location. defaults to <app_root>/contrast_security.yaml'
116
- }
117
+ desc: 'set config file location. defaults to <app_root>/contrast_security.yaml',
118
+ },
117
119
  ];
118
120
 
119
121
  const api = [
@@ -122,21 +124,21 @@ const api = [
122
124
  arg: '[false]',
123
125
  fn: castBoolean,
124
126
  default: true,
125
- desc: 'set false to disable reporting'
127
+ desc: 'set false to disable reporting',
126
128
  },
127
129
  {
128
130
  name: 'api.api_key',
129
131
  env: 'CONTRASTSECURITY_API_KEY',
130
132
  arg: '<key>',
131
133
  desc: 'the organization API key',
132
- required: true
134
+ required: true,
133
135
  },
134
136
  {
135
137
  name: 'api.service_key',
136
138
  env: 'CONTRASTSECURITY_SECRET_KEY',
137
139
  arg: '<key>',
138
140
  desc: 'account service key',
139
- required: true
141
+ required: true,
140
142
  },
141
143
  {
142
144
  name: 'api.url',
@@ -175,71 +177,66 @@ const api = [
175
177
  return value;
176
178
  },
177
179
  desc: 'url to report on',
178
- required: true
180
+ required: true,
179
181
  },
180
182
  {
181
183
  name: 'api.user_name',
182
184
  env: 'CONTRASTSECURITY_UID',
183
185
  arg: '<name>',
184
186
  desc: 'account user name',
185
- required: true
187
+ required: true,
186
188
  },
187
189
 
188
190
  {
189
191
  name: 'api.certificate.enable',
190
192
  arg: '[false]',
191
193
  default: 'false',
192
- desc:
193
- 'If set to false, the certificate configuration in this section will be ignored.'
194
+ desc: 'If set to false, the certificate configuration in this section will be ignored.',
194
195
  },
195
196
  {
196
197
  name: 'api.certificate.ca_file',
197
198
  arg: '<path>',
198
- desc:
199
- 'Set the absolute or relative path to a CA for communication with Contrast UI using a self-signed certificate.'
199
+ desc: 'Set the absolute or relative path to a CA for communication with Contrast UI using a self-signed certificate.',
200
200
  },
201
201
  {
202
202
  name: 'api.certificate.cert_file',
203
203
  arg: '<path>',
204
- desc:
205
- 'Set the absolute or relative path to the Certificate PEM file for communication with Contrast UI'
204
+ desc: 'Set the absolute or relative path to the Certificate PEM file for communication with Contrast UI',
206
205
  },
207
206
  {
208
207
  name: 'api.certificate.key_file',
209
208
  arg: '<path>',
210
- desc:
211
- 'Set the absolute or relative path to the Key PEM file for communication with Contrast UI'
209
+ desc: 'Set the absolute or relative path to the Key PEM file for communication with Contrast UI',
212
210
  },
213
211
  {
214
212
  name: 'api.certificate.key_password',
215
213
  arg: '<passphrase>',
216
- desc: 'If the Key file requires a password, set it here'
214
+ desc: 'If the Key file requires a password, set it here',
217
215
  },
218
216
  {
219
217
  name: 'api.certificate.ignore_cert_errors',
220
218
  arg: '[true]',
221
219
  default: true,
222
- desc:
223
- 'When set to `true`, the agent ignores certificate verification errors when the agent communicates with the Contrast UI.'
220
+ desc: 'When set to `true`, the agent ignores certificate verification errors when the agent communicates with the Contrast UI.',
224
221
  },
225
222
  {
226
223
  name: 'api.proxy.enable',
227
224
  arg: '[true]',
228
225
  default: false,
229
- desc: 'if false, no proxy is being used for communication of data'
226
+ desc: 'if false, no proxy is being used for communication of data',
230
227
  },
231
228
  {
232
229
  name: 'api.proxy.url',
233
230
  arg: '<url>',
234
- desc: 'url of proxy for communicating agent data'
231
+ desc: 'url of proxy for communicating agent data',
235
232
  },
236
233
  {
237
234
  name: 'api.timeout_ms',
238
235
  arg: '<ms>',
239
236
  default: 10000,
240
237
  fn: parseNum,
241
- desc: 'http timeout value (in ms)'
242
- }
238
+ desc: 'http timeout value (in ms)',
239
+ },
243
240
  ];
244
241
 
245
242
  const agent = [
@@ -248,8 +245,7 @@ const agent = [
248
245
  arg: '[false]',
249
246
  fn: castBoolean,
250
247
  default: true,
251
- desc:
252
- 'if false, create a new log file on startup instead of appending and rolling daily'
248
+ desc: 'if false, create a new log file on startup instead of appending and rolling daily',
253
249
  },
254
250
  {
255
251
  name: 'agent.logger.level',
@@ -257,175 +253,163 @@ const agent = [
257
253
  fn: lowercase,
258
254
  enum: ['error', 'warn', 'info', 'debug', 'trace'],
259
255
  default: 'error',
260
- desc:
261
- 'logging level (error, warn, info, debug, trace). overrides FeatureSet:logLevel'
256
+ desc: 'logging level (error, warn, info, debug, trace). overrides FeatureSet:logLevel',
262
257
  },
263
258
  {
264
259
  name: 'agent.logger.path',
265
260
  default: 'node-contrast',
266
261
  fn: toAbsolutePath,
267
262
  arg: '<path>',
268
- desc: 'where contrast will put its debug log'
263
+ desc: 'where contrast will put its debug log',
269
264
  },
270
265
  {
271
266
  name: 'agent.logger.stdout',
272
267
  arg: '[false]',
273
268
  fn: castBoolean,
274
269
  default: true,
275
- desc: 'if false, suppress output to STDOUT'
270
+ desc: 'if false, suppress output to STDOUT',
276
271
  },
277
272
  {
278
273
  name: 'agent.node.dataflow_monitor',
279
274
  arg: '[true]',
280
275
  default: false,
281
276
  fn: castBoolean,
282
- desc:
283
- 'throw all propagation event details into the AsyncStorage context and spit them to a log file when the request ends'
277
+ desc: 'throw all propagation event details into the AsyncStorage context and spit them to a log file when the request ends',
284
278
  },
285
279
  {
286
280
  name: 'agent.node.array_request_sampling.enable',
287
281
  arg: '[false]',
288
282
  default: false,
289
283
  fn: castBoolean,
290
- desc: 'enable sampling of array members for dataflow'
284
+ desc: 'enable sampling of array members for dataflow',
291
285
  },
292
286
  {
293
287
  name: 'agent.node.array_request_sampling.threshold',
294
288
  arg: '<num>',
295
289
  default: 50,
296
290
  fn: parseNum,
297
- desc:
298
- 'after reaching the threshold, the agent will not continue to track array members for dataflow'
291
+ desc: 'after reaching the threshold, the agent will not continue to track array members for dataflow',
299
292
  },
300
293
  {
301
294
  name: 'agent.node.array_request_sampling.interval',
302
295
  arg: '<num>',
303
296
  default: 5,
304
297
  fn: parseNum,
305
- desc:
306
- 'adjust the array member sampling interval. until the threshold is reached, the agent will track 1 in every <interval> member for dataflow'
298
+ desc: 'adjust the array member sampling interval. until the threshold is reached, the agent will track 1 in every <interval> member for dataflow',
307
299
  },
308
300
  {
309
301
  name: 'agent.node.enable_catch_log',
310
302
  arg: '[true]',
311
303
  fn: castBoolean,
312
304
  default: false,
313
- desc:
314
- 'enable source rewriting of try/catch blocks so that Contrast can log caught errors for debugging'
305
+ desc: 'enable source rewriting of try/catch blocks so that Contrast can log caught errors for debugging',
315
306
  },
316
307
  {
317
308
  name: 'agent.node.enable_property_descriptor_tracking',
318
309
  arg: '[false]',
319
310
  fn: castBoolean,
320
311
  default: false,
321
- desc:
322
- 'enable tracking the value property returned by getOwnPropertyDescriptor'
312
+ desc: 'enable tracking the value property returned by getOwnPropertyDescriptor',
323
313
  },
324
314
  {
325
315
  name: 'agent.node.enable_rewrite',
326
316
  arg: '[false]',
327
317
  fn: castBoolean,
328
318
  default: true,
329
- desc: 'if false, disable source rewriting (not recommended)'
319
+ desc: 'if false, disable source rewriting (not recommended)',
330
320
  },
331
321
  {
332
322
  name: 'agent.node.rewrite_cache.enable',
333
323
  arg: '[true]',
334
324
  fn: castBoolean,
335
325
  default: true,
336
- desc:
337
- 'if false, disable caching source rewriting (degrades startup performance)'
326
+ desc: 'if false, disable caching source rewriting (degrades startup performance)',
338
327
  },
339
328
  {
340
329
  name: 'agent.node.rewrite_cache.path',
341
330
  arg: '<path>',
342
- desc: 'set the location of the source rewriting cache'
331
+ desc: 'set the location of the source rewriting cache',
343
332
  },
344
333
  {
345
334
  name: 'agent.node.enable_source_maps',
346
335
  arg: '[false]',
347
336
  fn: castBoolean,
348
337
  default: true,
349
- desc: 'enable source map support in reporting'
338
+ desc: 'enable source map support in reporting',
350
339
  },
351
340
  {
352
341
  name: 'agent.node.enable_native_rewrite_log',
353
342
  arg: '[true]',
354
343
  fn: castBoolean,
355
344
  default: false,
356
- desc: 'log contents of native modules that have been rewritten'
345
+ desc: 'log contents of native modules that have been rewritten',
357
346
  },
358
347
  {
359
348
  name: 'agent.node.enable_rewrite_log',
360
349
  arg: '[true]',
361
350
  fn: castBoolean,
362
351
  default: false,
363
- desc:
364
- 'log contents of modules that have been rewritten for debugging purposes'
352
+ desc: 'log contents of modules that have been rewritten for debugging purposes',
365
353
  },
366
354
  {
367
355
  name: 'agent.node.enable_sources_in_deadzones',
368
356
  arg: '[false]',
369
357
  fn: castBoolean,
370
358
  default: false,
371
- desc: 'create Source Events in deadzoned code'
359
+ desc: 'create Source Events in deadzoned code',
372
360
  },
373
361
  {
374
362
  name: 'agent.node.library_usage.read_extraneous_libraries',
375
363
  arg: '[true]',
376
364
  fn: castBoolean,
377
365
  default: false,
378
- desc: 'if true, read libraries marked by npm as extraneous'
366
+ desc: 'if true, read libraries marked by npm as extraneous',
379
367
  },
380
368
  {
381
369
  name: 'agent.node.library_usage.reporting.interval',
382
370
  arg: '<num>',
383
371
  fn: parseNum,
384
372
  default: 1,
385
- desc:
386
- 'frequency of collecting code events for library usage in milliseconds, defaults to 1 ms'
373
+ desc: 'frequency of collecting code events for library usage in milliseconds, defaults to 1 ms',
387
374
  },
388
375
  {
389
376
  name: 'agent.node.library_usage.reporting.enable',
390
377
  arg: '[false]',
391
378
  default: true,
392
379
  fn: castBoolean,
393
- desc:
394
- 'add enhanced library usage features (i.e. scanning for composition of dependencies, reporting usage)'
380
+ desc: 'add enhanced library usage features (i.e. scanning for composition of dependencies, reporting usage)',
395
381
  },
396
382
  {
397
383
  name: 'agent.node.app_root',
398
384
  arg: '<path>',
399
- desc: "set location to look for the app's package.json"
385
+ desc: "set location to look for the app's package.json",
400
386
  },
401
387
  {
402
388
  name: 'agent.node.req_perf_logging',
403
389
  arg: '[false]',
404
390
  default: false,
405
- desc:
406
- 'enable debug logging of instrumentation overhead on a per request basis'
391
+ desc: 'enable debug logging of instrumentation overhead on a per request basis',
407
392
  },
408
393
  {
409
394
  name: 'agent.node.skip_nested_tracking',
410
395
  arg: '[true]',
411
396
  fn: castBoolean,
412
397
  default: false,
413
- desc:
414
- 'do not traverse nested properties to look for tracking during propagation (not recommended)'
398
+ desc: 'do not traverse nested properties to look for tracking during propagation (not recommended)',
415
399
  },
416
400
  {
417
401
  name: 'agent.node.speedracer_input_analysis',
418
402
  arg: '[false]',
419
403
  default: true,
420
404
  fn: castBoolean,
421
- desc: 'whether to use speedracer for input analysis when enabled'
405
+ desc: 'whether to use speedracer for input analysis when enabled',
422
406
  },
423
407
  {
424
408
  name: 'agent.node.native_input_analysis',
425
409
  arg: '[true]',
426
410
  default: false,
427
411
  fn: castBoolean,
428
- desc: 'do agent-native input analysis prior to any external analysis'
412
+ desc: 'do agent-native input analysis prior to any external analysis',
429
413
  },
430
414
  {
431
415
  name: 'agent.node.unsafe.deadzones',
@@ -435,91 +419,85 @@ const agent = [
435
419
  return str.split(',').map((s) => s.trim());
436
420
  }
437
421
  },
438
- desc:
439
- 'Add a comma-separated list of values to the deadzone regardless of its presence in the policy file.',
440
- default: ''
422
+ desc: 'Add a comma-separated list of values to the deadzone regardless of its presence in the policy file.',
423
+ default: '',
441
424
  },
442
425
  {
443
426
  name: 'agent.node.unsafe.sr_max_body_size',
444
427
  arg: '<size in mb>',
445
428
  default: 16,
446
- desc:
447
- 'set the maximum body size that will be sent to speedracer for input analysis'
429
+ desc: 'set the maximum body size that will be sent to speedracer for input analysis',
448
430
  },
449
431
  {
450
432
  name: 'agent.heap_dump.enable',
451
433
  arg: '[true]',
452
434
  fn: castBoolean,
453
435
  default: false,
454
- desc: 'Every n seconds create a heap snapshot of the current process'
436
+ desc: 'Every n seconds create a heap snapshot of the current process',
455
437
  },
456
438
  {
457
439
  name: 'agent.heap_dump.path',
458
440
  arg: '<path>',
459
441
  default: 'contrast_heap_dumps',
460
- desc:
461
- "Set the location to which to save the heap dump files. If relative, the path is determined based on the process' working directory."
442
+ desc: "Set the location to which to save the heap dump files. If relative, the path is determined based on the process' working directory.",
462
443
  },
463
444
  {
464
445
  name: 'agent.heap_dump.delay_ms',
465
446
  arg: '<time>',
466
447
  default: 10000,
467
- desc:
468
- 'Set the amount of time to wait, in milliseconds, after agent startup to begin taking heap dumps.'
448
+ desc: 'Set the amount of time to wait, in milliseconds, after agent startup to begin taking heap dumps.',
469
449
  },
470
450
  {
471
451
  name: 'agent.heap_dump.window_ms',
472
452
  arg: '<number>',
473
453
  default: 30000,
474
- desc: 'How frequently the heap snapshot is created'
454
+ desc: 'How frequently the heap snapshot is created',
475
455
  },
476
456
  {
477
457
  name: 'agent.heap_dump.count',
478
458
  arg: '<number>',
479
459
  default: 5,
480
- desc: 'Set the number of heap dumps to take before disabling this feature.'
460
+ desc: 'Set the number of heap dumps to take before disabling this feature.',
481
461
  },
482
462
  {
483
463
  name: 'agent.stack_trace_limit',
484
464
  arg: '<limit>',
485
465
  default: 10,
486
466
  fn: parseNum,
487
- desc:
488
- 'set limit for stack trace size (larger limits will improve accuracy but increase memory usage)'
467
+ desc: 'set limit for stack trace size (larger limits will improve accuracy but increase memory usage)',
489
468
  },
490
469
  {
491
470
  name: 'agent.trust_custom_validators',
492
471
  arg: '<trust-custom-validators>',
493
472
  default: false,
494
- desc: `trust incoming strings when they pass custom validators (Mongoose, Joi)`
473
+ desc: `trust incoming strings when they pass custom validators (Mongoose, Joi)`,
495
474
  },
496
475
  {
497
476
  name: 'agent.traverse_and_track',
498
477
  arg: '<traverse-and-track>',
499
478
  default: false,
500
- desc: 'source membrane alternative'
479
+ desc: 'source membrane alternative',
501
480
  },
502
481
  {
503
482
  name: 'agent.polling.app_activity_ms',
504
483
  arg: '<ms>',
505
484
  default: 30000,
506
485
  fn: parseNum,
507
- desc: 'how often (in ms), application activity messages are sent'
486
+ desc: 'how often (in ms), application activity messages are sent',
508
487
  },
509
488
  {
510
489
  name: 'agent.polling.app_update_ms',
511
490
  arg: '<ms>',
512
491
  default: 60000,
513
492
  fn: parseNum,
514
- desc:
515
- 'how often (in ms), application update messages (libraries, technologies, etc.) are sent'
493
+ desc: 'how often (in ms), application update messages (libraries, technologies, etc.) are sent',
516
494
  },
517
495
  {
518
496
  name: 'agent.route_coverage.enable',
519
497
  arg: '[true]',
520
498
  default: true,
521
499
  fn: castBoolean,
522
- desc: 'if false, do not send coverage data to the Contrast UI'
500
+ desc: 'if false, do not send coverage data to the Contrast UI',
523
501
  },
524
502
  {
525
503
  name: 'agent.security_logger.level',
@@ -529,133 +507,100 @@ const agent = [
529
507
  // set emergency for whatever reason
530
508
  enum: ['alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'],
531
509
  default: 'debug',
532
- desc:
533
- 'security logging level (alert, crit, err, warning, notice, info, debug)'
510
+ desc: 'security logging level (alert, crit, err, warning, notice, info, debug)',
534
511
  },
535
512
  {
536
513
  name: 'agent.security_logger.path',
537
514
  default: 'security',
538
515
  fn: toAbsolutePath,
539
516
  arg: '<path>',
540
- desc: 'where to log security events'
517
+ desc: 'where to log security events',
541
518
  },
542
519
  {
543
520
  name: 'agent.security_logger.syslog.enable',
544
521
  fn: castBoolean,
545
- desc: 'Set to true to enable Syslog logging'
522
+ desc: 'Set to true to enable Syslog logging',
546
523
  },
547
524
  {
548
525
  name: 'agent.security_logger.syslog.ip',
549
- desc:
550
- 'Set the IP address of the Syslog server to which the agent should send messages',
551
- arg: '<ip>'
526
+ desc: 'Set the IP address of the Syslog server to which the agent should send messages',
527
+ arg: '<ip>',
552
528
  },
553
529
  {
554
530
  name: 'agent.security_logger.syslog.port',
555
- desc:
556
- 'Set the port of the Syslog server to which the agent should send messages',
557
- arg: '<port>'
531
+ desc: 'Set the port of the Syslog server to which the agent should send messages',
532
+ arg: '<port>',
558
533
  },
559
534
  {
560
535
  name: 'agent.security_logger.syslog.facility',
561
536
  desc: 'Set the facility code of the messages the agent sends to Syslog',
562
537
  enum: [
563
- 0,
564
- 1,
565
- 2,
566
- 3,
567
- 4,
568
- 5,
569
- 6,
570
- 7,
571
- 8,
572
- 9,
573
- 10,
574
- 11,
575
- 12,
576
- 13,
577
- 14,
578
- 15,
579
- 16,
580
- 17,
581
- 18,
582
- 19,
583
- 20,
584
- 21,
585
- 22,
586
- 23
538
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
539
+ 21, 22, 23,
587
540
  ],
588
- arg: '<facility>'
541
+ arg: '<facility>',
589
542
  },
590
543
  {
591
544
  name: 'agent.security_logger.syslog.severity_exploited',
592
- desc:
593
- 'Set the log level of Exploited attacks. Value options are ALERT/CRIT/ERROR/WARNING/NOTICE/INFO/DEBUG',
545
+ desc: 'Set the log level of Exploited attacks. Value options are ALERT/CRIT/ERROR/WARNING/NOTICE/INFO/DEBUG',
594
546
  enum: ['alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'],
595
547
  arg: '<level>',
596
- fn: lowercase
548
+ fn: lowercase,
597
549
  },
598
550
  {
599
551
  name: 'agent.security_logger.syslog.severity_blocked',
600
- desc:
601
- 'Set the log level of Exploited attacks. Value options are ALERT/CRIT/ERROR/WARNING/NOTICE/INFO/DEBUG',
552
+ desc: 'Set the log level of Exploited attacks. Value options are ALERT/CRIT/ERROR/WARNING/NOTICE/INFO/DEBUG',
602
553
  enum: ['alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'],
603
554
  arg: '<level>',
604
- fn: lowercase
555
+ fn: lowercase,
605
556
  },
606
557
  {
607
558
  name: 'agent.security_logger.syslog.severity_probed',
608
- desc:
609
- 'Set the log level of Probed attacks. Value options are ALERT/CRIT/ERROR/WARNING/NOTICE/INFO/DEBUG',
559
+ desc: 'Set the log level of Probed attacks. Value options are ALERT/CRIT/ERROR/WARNING/NOTICE/INFO/DEBUG',
610
560
  enum: ['alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'],
611
561
  arg: '<level>',
612
- fn: lowercase
562
+ fn: lowercase,
613
563
  },
614
564
  {
615
565
  name: 'agent.logger.log_outbound_http',
616
566
  arg: '[true]',
617
567
  default: false,
618
- desc: 'log all outbound http responses'
568
+ desc: 'log all outbound http responses',
619
569
  },
620
570
  {
621
571
  name: 'agent.logger.backups',
622
572
  arg: '<number>',
623
- desc:
624
- "set the max number of log files or days to keep files. For days, add 'd' after number"
573
+ desc: "set the max number of log files or days to keep files. For days, add 'd' after number",
625
574
  },
626
575
  {
627
576
  name: 'agent.logger.roll_size',
628
577
  arg: '<size>',
629
- desc:
630
- "set the maximum file size in bytes for logs. Add 'k', 'm', 'g' after number for Kb, Mb, Gb"
578
+ desc: "set the maximum file size in bytes for logs. Add 'k', 'm', 'g' after number for Kb, Mb, Gb",
631
579
  },
632
580
  {
633
581
  name: 'agent.service.socket',
634
582
  arg: '<socket>',
635
- desc:
636
- 'If this property is defined, the service is listening on a Unix socket at the defined path'
583
+ desc: 'If this property is defined, the service is listening on a Unix socket at the defined path',
637
584
  },
638
585
  {
639
586
  name: 'agent.service.host',
640
587
  arg: '<host>',
641
588
  default: '127.0.0.1',
642
- desc:
643
- 'set the the hostname or IP address of the Contrast service to which the Contrast agent should report'
589
+ desc: 'set the the hostname or IP address of the Contrast service to which the Contrast agent should report',
644
590
  },
645
591
  {
646
592
  name: 'agent.service.port',
647
593
  arg: '<port>',
648
594
  default: 30555,
649
- desc:
650
- 'set the the port of the Contrast service to which the Contrast agent should report'
595
+ desc: 'set the the port of the Contrast service to which the Contrast agent should report',
651
596
  },
652
597
  {
653
598
  name: 'agent.service.grpc',
654
599
  arg: '[true]',
655
600
  default: false,
656
601
  fn: castBoolean,
657
- desc: 'set to `true` to enable communication to speedracer via GRPC.'
658
- }
602
+ desc: 'set to `true` to enable communication to speedracer via GRPC.',
603
+ },
659
604
  ];
660
605
 
661
606
  const application = [
@@ -674,69 +619,63 @@ const application = [
674
619
 
675
620
  return undefined;
676
621
  },
677
- desc:
678
- 'string containing args to pass verbatim to the application, eg --application.args "-A -S -D -F foo bar"'
622
+ desc: 'string containing args to pass verbatim to the application, eg --application.args "-A -S -D -F foo bar"',
679
623
  },
680
624
  {
681
625
  name: 'application.code',
682
626
  arg: '<code>',
683
- desc:
684
- 'add the application code this application should use in the Contrast UI'
627
+ desc: 'add the application code this application should use in the Contrast UI',
685
628
  },
686
629
  {
687
630
  name: 'application.group',
688
631
  arg: '<tags>',
689
- desc: "how to report the application's group for auto-grouping"
632
+ desc: "how to report the application's group for auto-grouping",
690
633
  },
691
634
  {
692
635
  name: 'application.language',
693
636
  arg: '<language>',
694
637
  default: 'Node',
695
- desc:
696
- "override the reported application language (if different from 'Node')"
638
+ desc: "override the reported application language (if different from 'Node')",
697
639
  },
698
640
  {
699
641
  name: 'application.name',
700
642
  arg: '<name>',
701
643
  env: 'CONTRASTSECURITY_APP_NAME',
702
- desc: 'override the reported application name. (default: package.json:name)'
644
+ desc: 'override the reported application name. (default: package.json:name)',
703
645
  },
704
646
  {
705
647
  name: 'application.path',
706
648
  arg: '<path>',
707
649
  default: '/',
708
- desc: 'override the reported application path'
650
+ desc: 'override the reported application path',
709
651
  },
710
652
  {
711
653
  name: 'application.tags',
712
654
  arg: '<tags>',
713
- desc:
714
- 'comma-separated list of tags to apply to each application reported by the agent'
655
+ desc: 'comma-separated list of tags to apply to each application reported by the agent',
715
656
  },
716
657
  {
717
658
  name: 'application.metadata',
718
659
  args: '<metadata>',
719
- desc:
720
- 'comma-separated list of key=value pairs that are applied to each application reported by the agent.'
660
+ desc: 'comma-separated list of key=value pairs that are applied to each application reported by the agent.',
721
661
  },
722
662
  {
723
663
  name: 'application.version',
724
664
  arg: '<version>',
725
- desc:
726
- "override the reported application version (if different from 'version' field in the application's package.json)"
665
+ desc: "override the reported application version (if different from 'version' field in the application's package.json)",
727
666
  },
728
667
  {
729
668
  name: 'application.session_id',
730
669
  arg: '<session_id>',
731
670
  default: null,
732
- desc: 'provide the ID of a session existing within Contrast UI'
671
+ desc: 'provide the ID of a session existing within Contrast UI',
733
672
  },
734
673
  {
735
674
  name: 'application.session_metadata',
736
675
  arg: '<session_metadata>',
737
676
  default: null,
738
- desc: 'provide metadata used to create a new session within Contrast UI'
739
- }
677
+ desc: 'provide metadata used to create a new session within Contrast UI',
678
+ },
740
679
  ];
741
680
 
742
681
  const inventory = [
@@ -746,22 +685,20 @@ const inventory = [
746
685
  arg: '[false]',
747
686
  fn: castBoolean,
748
687
  default: true,
749
- desc:
750
- 'Set to false to disable reading or reporting libraries used by the application'
688
+ desc: 'Set to false to disable reading or reporting libraries used by the application',
751
689
  },
752
690
  {
753
691
  name: 'inventory.tags',
754
692
  arg: '<tags>',
755
- desc:
756
- 'comma-separated list of tags to apply to each application library reported by the agent'
693
+ desc: 'comma-separated list of tags to apply to each application library reported by the agent',
757
694
  },
758
695
  {
759
696
  name: 'inventory.enable',
760
697
  arg: '[false]',
761
698
  fn: castBoolean,
762
699
  default: true,
763
- desc: 'Set to `false` to disable inventory features in the agent.'
764
- }
700
+ desc: 'Set to `false` to disable inventory features in the agent.',
701
+ },
765
702
  ];
766
703
 
767
704
  const assess = [
@@ -769,43 +706,41 @@ const assess = [
769
706
  name: 'assess.enable',
770
707
  arg: '[false]',
771
708
  fn: castBoolean,
772
- desc:
773
- 'if false, disable assess for this agent. A restart is required to re-enable'
709
+ desc: 'if false, disable assess for this agent. A restart is required to re-enable',
774
710
  },
775
711
  {
776
712
  name: 'assess.enable_preflight',
777
713
  arg: '[false]',
778
714
  fn: castBoolean,
779
715
  default: true,
780
- desc: 'if false, disable preflight spooling of traces (not recommended)'
716
+ desc: 'if false, disable preflight spooling of traces (not recommended)',
781
717
  },
782
718
  {
783
719
  name: 'assess.enable_propagators',
784
720
  arg: '[false]',
785
721
  fn: castBoolean,
786
722
  default: true,
787
- desc: 'if false, disable dataflow propagation (not recommended)'
723
+ desc: 'if false, disable dataflow propagation (not recommended)',
788
724
  },
789
725
  {
790
726
  name: 'assess.sampling.enable',
791
727
  arg: '[false]',
792
728
  fn: castBoolean,
793
729
  default: true,
794
- desc: 'if false, disable sampling'
730
+ desc: 'if false, disable sampling',
795
731
  },
796
732
  {
797
733
  name: 'assess.sampling.baseline',
798
734
  arg: '<rule limit>',
799
735
  fn: parseNum,
800
736
  default: 5,
801
- desc: 'max number of times to report the same rule for a single'
737
+ desc: 'max number of times to report the same rule for a single',
802
738
  },
803
739
  {
804
740
  name: 'assess.tags',
805
741
  arg: '<tags>',
806
- desc:
807
- 'comma-separated list of tags to apply to each application vulnerability reported by the agent'
808
- }
742
+ desc: 'comma-separated list of tags to apply to each application vulnerability reported by the agent',
743
+ },
809
744
  ];
810
745
 
811
746
  const protect = [
@@ -813,112 +748,104 @@ const protect = [
813
748
  name: 'protect.enable',
814
749
  arg: '[false]',
815
750
  fn: castBoolean,
816
- desc: 'if false, disable protect for this agent'
751
+ desc: 'if false, disable protect for this agent',
817
752
  },
818
753
  {
819
754
  name: 'protect.enable_rep',
820
755
  arg: '[false]',
821
756
  default: true,
822
757
  fn: castBoolean,
823
- desc: 'if false, disable Runtime Exploit Prevention(REP) for this agent'
758
+ desc: 'if false, disable Runtime Exploit Prevention(REP) for this agent',
824
759
  },
825
760
  {
826
761
  name: 'protect.auth.mode',
827
762
  arg: '<mode>',
828
763
  default: 'OFF',
829
764
  enum: ['OFF', 'MONITOR'],
830
- desc:
831
- 'whether to report authentication framework login attempts (OFF, MONITOR)'
765
+ desc: 'whether to report authentication framework login attempts (OFF, MONITOR)',
832
766
  },
833
767
  {
834
768
  name: 'protect.samples.blocked',
835
769
  arg: '<count>',
836
770
  fn: parseNum,
837
771
  default: 25,
838
- desc:
839
- 'limit the reporting of "blocked" protect events to this number (per report cycle)'
772
+ desc: 'limit the reporting of "blocked" protect events to this number (per report cycle)',
840
773
  },
841
774
  {
842
775
  name: 'protect.samples.blocked_at_perimeter',
843
776
  arg: '<count>',
844
777
  fn: parseNum,
845
778
  default: 25,
846
- desc:
847
- 'limit the reporting of "blocked-at-perim" protect events to this number (per report cycle)'
779
+ desc: 'limit the reporting of "blocked-at-perim" protect events to this number (per report cycle)',
848
780
  },
849
781
  {
850
782
  name: 'protect.samples.exploited',
851
783
  arg: '<count>',
852
784
  fn: parseNum,
853
785
  default: 100,
854
- desc:
855
- 'limit the reporting of "effective" protect events to this number (per report cycle)'
786
+ desc: 'limit the reporting of "effective" protect events to this number (per report cycle)',
856
787
  },
857
788
  {
858
789
  name: 'protect.samples.probed',
859
790
  arg: '<count>',
860
791
  fn: parseNum,
861
792
  default: 50,
862
- desc:
863
- 'limit the reporting of "ineffective" protect events to this number (per report cycle)'
793
+ desc: 'limit the reporting of "ineffective" protect events to this number (per report cycle)',
864
794
  },
865
795
  {
866
796
  name: 'protect.rules.disabled_rules',
867
797
  arg: '<rules>',
868
798
  default: '',
869
- desc: 'comma-delimited list of rule IDs to disable'
799
+ desc: 'comma-delimited list of rule IDs to disable',
870
800
  },
871
801
  ...Object.values(require('../../constants').RULES).map((ruleId) => ({
872
802
  name: `protect.rules.${ruleId}.mode`,
873
803
  arg: '<mode>',
874
804
  enum: ['monitor', 'block', 'block_at_perimeter', 'off'],
875
- desc: `the mode in which to run the ${ruleId} rule`
876
- }))
805
+ desc: `the mode in which to run the ${ruleId} rule`,
806
+ })),
877
807
  ];
878
808
 
879
809
  const server = [
880
810
  {
881
811
  name: 'server.build',
882
812
  arg: '<version>',
883
- desc: 'set reported server build option'
813
+ desc: 'set reported server build option',
884
814
  },
885
815
  {
886
816
  name: 'server.environment',
887
817
  arg: '<name>',
888
818
  fn: uppercase,
889
819
  // enum: ['QA', 'PRODUCTION', 'DEVELOPMENT'], none of the other agents validate this
890
- desc:
891
- 'environment the server is running in (QA, PRODUCTION, or DEVELOPMENT)'
820
+ desc: 'environment the server is running in (QA, PRODUCTION, or DEVELOPMENT)',
892
821
  },
893
822
  {
894
823
  name: 'server.name',
895
824
  arg: '<name>',
896
825
  default: os.hostname(),
897
- desc: 'override the reported server name'
826
+ desc: 'override the reported server name',
898
827
  },
899
828
  {
900
829
  name: 'server.path',
901
830
  arg: '<name>',
902
- desc: 'override the reported server path'
831
+ desc: 'override the reported server path',
903
832
  },
904
833
  {
905
834
  name: 'server.tags',
906
835
  arg: '<tags>',
907
- desc:
908
- 'comma-separated list of tags to apply to each server reported by the agent'
836
+ desc: 'comma-separated list of tags to apply to each server reported by the agent',
909
837
  },
910
838
  {
911
839
  name: 'server.type',
912
840
  arg: '<type>',
913
841
  default: util.format('node.js %s', process.version),
914
- desc: 'override the reported server type'
842
+ desc: 'override the reported server type',
915
843
  },
916
844
  {
917
845
  name: 'server.version',
918
846
  arg: '<version>',
919
- desc:
920
- "override the reported server version (if different from 'version' field in the application's package.json)"
921
- }
847
+ desc: "override the reported server version (if different from 'version' field in the application's package.json)",
848
+ },
922
849
  ];
923
850
 
924
851
  let dev = [];
@@ -928,68 +855,52 @@ if (process.env.CONTRAST_DEV) {
928
855
  name: 'agent.node.dev.global_agent',
929
856
  arg: '[true]',
930
857
  default: true,
931
- desc:
932
- 'add global.contrast_agent so that apps can reference agent and its emitters'
858
+ desc: 'add global.contrast_agent so that apps can reference agent and its emitters',
933
859
  },
934
860
  {
935
861
  name: 'agent.node.dev.global_tracker',
936
862
  arg: '[true]',
937
863
  default: true,
938
- desc:
939
- 'add global.contrast_tracker so that apps can reference dataflow metadata'
864
+ desc: 'add global.contrast_tracker so that apps can reference dataflow metadata',
940
865
  },
941
866
  {
942
867
  name: 'agent.node.dev.metrics',
943
868
  arg: '[false]',
944
869
  default: false,
945
- desc:
946
- 'add tracking and periodically outputting diagnostic metrics to a file'
870
+ desc: 'add tracking and periodically outputting diagnostic metrics to a file',
947
871
  },
948
872
  {
949
873
  name: 'agent.node.dev.screener.enable',
950
874
  arg: '[false]',
951
875
  default: false,
952
- desc: 'use message queue for (most) reporting rather than send to SR'
876
+ desc: 'use message queue for (most) reporting rather than send to SR',
953
877
  },
954
878
  {
955
879
  name: 'agent.node.dev.screener.mq_location',
956
880
  arg: '<location>',
957
881
  default: 'amqp://localhost',
958
- desc:
959
- 'location of the messaging queue server to which to publish messages'
882
+ desc: 'location of the messaging queue server to which to publish messages',
960
883
  },
961
884
  {
962
885
  name: 'agent.node.dev.screener.exchange_name',
963
886
  arg: '<name>',
964
- desc:
965
- 'name of the exchange to which to publish messages (unique per test run)'
887
+ desc: 'name of the exchange to which to publish messages (unique per test run)',
966
888
  },
967
889
  {
968
890
  name: 'agent.node.dev.custom_policy_path',
969
891
  arg: '<path>',
970
892
  fn: toAbsolutePath,
971
- desc: 'provide an additional, custom policy'
893
+ desc: 'provide an additional, custom policy',
972
894
  },
973
895
  {
974
896
  name: 'agent.node.unsafe.generate_umbrella',
975
897
  arg: '[true]',
976
898
  fn: castBoolean,
977
899
  default: false,
978
- desc:
979
- 'Generate Umbrella test-cases based on what was found by the agent into umbrella_test.json'
980
- }
900
+ desc: 'Generate Umbrella test-cases based on what was found by the agent into umbrella_test.json',
901
+ },
981
902
  ];
982
903
  }
983
- const sails = [
984
- {
985
- name: 'pathToSails',
986
- arg: '<path>'
987
- },
988
- {
989
- name: 'gdsrc',
990
- arg: '<path>'
991
- }
992
- ];
993
904
 
994
905
  const options = [].concat(
995
906
  misc,
@@ -1000,7 +911,7 @@ const options = [].concat(
1000
911
  inventory,
1001
912
  protect,
1002
913
  server,
1003
- dev
914
+ dev,
1004
915
  );
1005
916
 
1006
917
  // run
@@ -1031,19 +942,6 @@ options.forEach((option) => {
1031
942
  program.option(name, option.desc);
1032
943
  });
1033
944
 
1034
- // In NODE-2059 it was discovered that a module was appending config options that the
1035
- // agent didn't recognize and was causing the application to not load properly.
1036
- // The agent doesn't need to do anything with these options. It just needs to not
1037
- // throw an error when it encounters them but we also don't need them displayed on
1038
- // the agent's config option list. The newest version of Commander lets us do exactly this.
1039
- // This is structured so that if anything like this is discovered again, they can be
1040
- // added in easily.
1041
- const hiddenOptions = [].concat(sails);
1042
-
1043
- hiddenOptions.forEach((option) => {
1044
- program.addOption(new Option(`--${option.name} ${option.arg}`).hideHelp());
1045
- });
1046
-
1047
945
  function getDefault(optionName) {
1048
946
  let option;
1049
947
  options.forEach((entry) => {