@contrast/config 1.2.0 → 1.3.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.
- package/lib/index.d.ts +51 -2
- package/lib/options.js +126 -50
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,15 @@
|
|
|
16
16
|
import { RulesConfig } from '@contrast/common';
|
|
17
17
|
import { Level } from 'pino';
|
|
18
18
|
|
|
19
|
+
type SyslogLevel =
|
|
20
|
+
| 'alert'
|
|
21
|
+
| 'critical'
|
|
22
|
+
| 'error'
|
|
23
|
+
| 'warning'
|
|
24
|
+
| 'notice'
|
|
25
|
+
| 'info'
|
|
26
|
+
| 'debug';
|
|
27
|
+
|
|
19
28
|
export interface Config {
|
|
20
29
|
configFile: string;
|
|
21
30
|
|
|
@@ -31,13 +40,14 @@ export interface Config {
|
|
|
31
40
|
proxy: {
|
|
32
41
|
enable: boolean;
|
|
33
42
|
url: string;
|
|
34
|
-
}
|
|
43
|
+
};
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
agent: {
|
|
38
47
|
polling: {
|
|
39
48
|
app_activity_ms: number;
|
|
40
|
-
}
|
|
49
|
+
};
|
|
50
|
+
|
|
41
51
|
reporters: {
|
|
42
52
|
/** Path indicating where to report all agent findings. */
|
|
43
53
|
file?: string | number;
|
|
@@ -63,6 +73,44 @@ export interface Config {
|
|
|
63
73
|
stdout: boolean;
|
|
64
74
|
};
|
|
65
75
|
|
|
76
|
+
security_logger: {
|
|
77
|
+
/** Default: `'debug'` */
|
|
78
|
+
level: SyslogLevel;
|
|
79
|
+
|
|
80
|
+
/** Default: `'security'` */
|
|
81
|
+
path: string;
|
|
82
|
+
|
|
83
|
+
syslog: {
|
|
84
|
+
enable: boolean;
|
|
85
|
+
|
|
86
|
+
ip: string;
|
|
87
|
+
|
|
88
|
+
/** Default: UDP `514` */
|
|
89
|
+
port: number;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The facility code of the messages the agent sends to Syslog.
|
|
93
|
+
* Values: 0-23, inclusive. Default: `19`
|
|
94
|
+
*/
|
|
95
|
+
facility: number;
|
|
96
|
+
|
|
97
|
+
/** Log level of 'Blocked' attacks. Default: `'notice'` */
|
|
98
|
+
severity_blocked: SyslogLevel;
|
|
99
|
+
|
|
100
|
+
/** Log level of 'Exploited' attacks. Default: `'alert'` */
|
|
101
|
+
severity_exploited: SyslogLevel;
|
|
102
|
+
|
|
103
|
+
/** Log level of 'Probed' attacks. Default: `'warning'` */
|
|
104
|
+
severity_probed: SyslogLevel;
|
|
105
|
+
|
|
106
|
+
/** Log level of 'Blocked at Perimeter' attacks. Default: `'notice'` */
|
|
107
|
+
severity_blocked_perimeter: SyslogLevel;
|
|
108
|
+
|
|
109
|
+
/** Log level of suspcious but not blocked attacks. Default: `'warning'` */
|
|
110
|
+
severity_suspicious: SyslogLevel;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
|
|
66
114
|
node: {
|
|
67
115
|
/** Default: `true` */
|
|
68
116
|
enable_rewrite: boolean;
|
|
@@ -122,6 +170,7 @@ export interface Config {
|
|
|
122
170
|
/** Reported server information overrides */
|
|
123
171
|
server: {
|
|
124
172
|
environment?: string;
|
|
173
|
+
tags?: string;
|
|
125
174
|
/** Default: `os.hostname()` */
|
|
126
175
|
name: string;
|
|
127
176
|
version?: string;
|
package/lib/options.js
CHANGED
|
@@ -52,11 +52,11 @@ function castBoolean(value) {
|
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
value = value.toString().toLowerCase();
|
|
55
|
-
return
|
|
55
|
+
return value === 'true' || value === 't'
|
|
56
56
|
? true
|
|
57
|
-
:
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
: value === 'false' || value === 'f'
|
|
58
|
+
? false
|
|
59
|
+
: undefined;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -96,9 +96,8 @@ const config = [
|
|
|
96
96
|
// special case this guy because it should be settable via ENV
|
|
97
97
|
env: 'CONTRAST_CONFIG_PATH',
|
|
98
98
|
arg: '<path>',
|
|
99
|
-
desc:
|
|
100
|
-
|
|
101
|
-
}
|
|
99
|
+
desc: 'set config file location. defaults to <app_root>/contrast_security.yaml',
|
|
100
|
+
},
|
|
102
101
|
];
|
|
103
102
|
|
|
104
103
|
const api = [
|
|
@@ -107,19 +106,19 @@ const api = [
|
|
|
107
106
|
arg: '[false]',
|
|
108
107
|
fn: castBoolean,
|
|
109
108
|
default: true,
|
|
110
|
-
desc: 'set false to disable reporting'
|
|
109
|
+
desc: 'set false to disable reporting',
|
|
111
110
|
},
|
|
112
111
|
{
|
|
113
112
|
name: 'api.api_key',
|
|
114
113
|
env: 'CONTRASTSECURITY_API_KEY',
|
|
115
114
|
arg: '<key>',
|
|
116
|
-
desc: 'the organization API key'
|
|
115
|
+
desc: 'the organization API key',
|
|
117
116
|
},
|
|
118
117
|
{
|
|
119
118
|
name: 'api.service_key',
|
|
120
119
|
env: 'CONTRASTSECURITY_SECRET_KEY',
|
|
121
120
|
arg: '<key>',
|
|
122
|
-
desc: 'account service key'
|
|
121
|
+
desc: 'account service key',
|
|
123
122
|
},
|
|
124
123
|
{
|
|
125
124
|
name: 'api.url',
|
|
@@ -156,13 +155,13 @@ const api = [
|
|
|
156
155
|
}
|
|
157
156
|
return value;
|
|
158
157
|
},
|
|
159
|
-
desc: 'url to report on'
|
|
158
|
+
desc: 'url to report on',
|
|
160
159
|
},
|
|
161
160
|
{
|
|
162
161
|
name: 'api.user_name',
|
|
163
162
|
env: 'CONTRASTSECURITY_UID',
|
|
164
163
|
arg: '<name>',
|
|
165
|
-
desc: 'account user name'
|
|
164
|
+
desc: 'account user name',
|
|
166
165
|
},
|
|
167
166
|
{
|
|
168
167
|
name: 'api.proxy.enable',
|
|
@@ -181,15 +180,14 @@ const agent = [
|
|
|
181
180
|
{
|
|
182
181
|
name: 'agent.reporters.file',
|
|
183
182
|
arg: '<path>',
|
|
184
|
-
desc: 'path indicating where to report all agent findings'
|
|
183
|
+
desc: 'path indicating where to report all agent findings',
|
|
185
184
|
},
|
|
186
185
|
{
|
|
187
186
|
name: 'agent.logger.append',
|
|
188
187
|
arg: '[false]',
|
|
189
188
|
fn: castBoolean,
|
|
190
189
|
default: true,
|
|
191
|
-
desc:
|
|
192
|
-
'if false, create a new log file on startup instead of appending and rolling daily'
|
|
190
|
+
desc: 'if false, create a new log file on startup instead of appending and rolling daily',
|
|
193
191
|
},
|
|
194
192
|
{
|
|
195
193
|
name: 'agent.logger.level',
|
|
@@ -197,57 +195,139 @@ const agent = [
|
|
|
197
195
|
fn: lowercase,
|
|
198
196
|
enum: ['error', 'warn', 'info', 'debug', 'trace'],
|
|
199
197
|
default: 'error',
|
|
200
|
-
desc:
|
|
201
|
-
'logging level (error, warn, info, debug, trace). overrides FeatureSet:logLevel'
|
|
198
|
+
desc: 'logging level (error, warn, info, debug, trace). overrides FeatureSet:logLevel',
|
|
202
199
|
},
|
|
203
200
|
{
|
|
204
201
|
name: 'agent.logger.path',
|
|
205
202
|
default: 'contrast.log',
|
|
206
203
|
fn: toAbsolutePath,
|
|
207
204
|
arg: '<path>',
|
|
208
|
-
desc: 'where contrast will put its debug log'
|
|
205
|
+
desc: 'where contrast will put its debug log',
|
|
209
206
|
},
|
|
210
207
|
{
|
|
211
208
|
name: 'agent.logger.stdout',
|
|
212
209
|
arg: '[false]',
|
|
213
210
|
fn: castBoolean,
|
|
214
211
|
default: true,
|
|
215
|
-
desc: 'if false, suppress output to STDOUT'
|
|
212
|
+
desc: 'if false, suppress output to STDOUT',
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'agent.security_logger.level',
|
|
216
|
+
arg: '<level>',
|
|
217
|
+
fn: lowercase,
|
|
218
|
+
// NOTE: syslog actually specifies 8 levels, starting with 0-emergency, but
|
|
219
|
+
// we do not let the user set emergency for whatever reason
|
|
220
|
+
enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
|
|
221
|
+
default: 'debug',
|
|
222
|
+
desc: 'security logging level (alert, crit, err, warning, notice, info, debug)',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'agent.security_logger.path',
|
|
226
|
+
// default: 'security',
|
|
227
|
+
fn: toAbsolutePath,
|
|
228
|
+
arg: '<path>',
|
|
229
|
+
desc: 'where to log security events',
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: 'agent.security_logger.syslog.enable',
|
|
233
|
+
fn: castBoolean,
|
|
234
|
+
desc: 'Set to true to enable Syslog logging',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: 'agent.security_logger.syslog.ip',
|
|
238
|
+
desc: 'Set the IP address of the Syslog server to which the agent should send messages',
|
|
239
|
+
arg: '<ip>',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: 'agent.security_logger.syslog.port',
|
|
243
|
+
desc: 'Set the port of the Syslog server to which the agent should send messages',
|
|
244
|
+
default: 514,
|
|
245
|
+
arg: '<port>',
|
|
246
|
+
fn: parseNum,
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: 'agent.security_logger.syslog.facility',
|
|
250
|
+
desc: 'Set the facility code of the messages the agent sends to Syslog',
|
|
251
|
+
enum: [
|
|
252
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
|
253
|
+
21, 22, 23,
|
|
254
|
+
],
|
|
255
|
+
default: 19,
|
|
256
|
+
arg: '<facility>',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: 'agent.security_logger.syslog.severity_blocked',
|
|
260
|
+
desc: 'Set the log level of Blocked attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
|
|
261
|
+
enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
|
|
262
|
+
default: 'notice',
|
|
263
|
+
arg: '<level>',
|
|
264
|
+
fn: lowercase,
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: 'agent.security_logger.syslog.severity_exploited',
|
|
268
|
+
desc: 'Set the log level of Exploited attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
|
|
269
|
+
enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
|
|
270
|
+
default: 'alert',
|
|
271
|
+
arg: '<level>',
|
|
272
|
+
fn: lowercase,
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: 'agent.security_logger.syslog.severity_probed',
|
|
276
|
+
desc: 'Set the log level of Probed attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
|
|
277
|
+
enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
|
|
278
|
+
default: 'warning',
|
|
279
|
+
arg: '<level>',
|
|
280
|
+
fn: lowercase,
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: 'agent.security_logger.syslog.severity_blocked_perimeter',
|
|
284
|
+
desc: 'Set the log level of Blocked at Perimeter attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
|
|
285
|
+
enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
|
|
286
|
+
default: 'notice',
|
|
287
|
+
arg: '<level>',
|
|
288
|
+
fn: lowercase,
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: 'agent.security_logger.syslog.severity_suspicious',
|
|
292
|
+
desc: 'Set the log level of suspicious but not blocked attacks. Value options are ALERT/CRITICAL/ERROR/WARNING/NOTICE/INFO/DEBUG',
|
|
293
|
+
enum: ['alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
|
|
294
|
+
default: 'warning',
|
|
295
|
+
arg: '<level>',
|
|
296
|
+
fn: lowercase,
|
|
216
297
|
},
|
|
217
298
|
{
|
|
218
299
|
name: 'agent.node.enable_rewrite',
|
|
219
300
|
arg: '[false]',
|
|
220
301
|
fn: castBoolean,
|
|
221
302
|
default: true,
|
|
222
|
-
desc: 'if false, disable source rewriting (not recommended)'
|
|
303
|
+
desc: 'if false, disable source rewriting (not recommended)',
|
|
223
304
|
},
|
|
224
305
|
{
|
|
225
306
|
name: 'agent.node.enable_source_maps',
|
|
226
307
|
arg: '[false]',
|
|
227
308
|
fn: castBoolean,
|
|
228
309
|
default: true,
|
|
229
|
-
desc: 'enable source map support in reporting'
|
|
310
|
+
desc: 'enable source map support in reporting',
|
|
230
311
|
},
|
|
231
312
|
{
|
|
232
313
|
name: 'agent.node.app_root',
|
|
233
314
|
arg: '<path>',
|
|
234
315
|
desc: "set location to look for the app's package.json",
|
|
235
|
-
default: process.cwd()
|
|
316
|
+
default: process.cwd(),
|
|
236
317
|
},
|
|
237
318
|
{
|
|
238
319
|
name: 'agent.stack_trace_limit',
|
|
239
320
|
arg: '<limit>',
|
|
240
321
|
default: 10,
|
|
241
322
|
fn: parseNum,
|
|
242
|
-
desc:
|
|
243
|
-
'set limit for stack trace size (larger limits will improve accuracy but increase memory usage)'
|
|
323
|
+
desc: 'set limit for stack trace size (larger limits will improve accuracy but increase memory usage)',
|
|
244
324
|
},
|
|
245
325
|
{
|
|
246
326
|
name: 'agent.stack_trace_filters',
|
|
247
327
|
arg: '<list,of,filters>',
|
|
248
328
|
default: 'agent-,@contrast,node-agent',
|
|
249
329
|
fn: split,
|
|
250
|
-
desc: 'comma-separated list of patterns to ignore within stack traces'
|
|
330
|
+
desc: 'comma-separated list of patterns to ignore within stack traces',
|
|
251
331
|
},
|
|
252
332
|
{
|
|
253
333
|
name: 'agent.polling.app_activity_ms',
|
|
@@ -263,32 +343,31 @@ const application = [
|
|
|
263
343
|
name: 'application.name',
|
|
264
344
|
arg: '<name>',
|
|
265
345
|
env: 'CONTRASTSECURITY_APP_NAME',
|
|
266
|
-
desc: 'override the reported application name. (default: package.json:name)'
|
|
346
|
+
desc: 'override the reported application name. (default: package.json:name)',
|
|
267
347
|
},
|
|
268
348
|
{
|
|
269
349
|
name: 'application.path',
|
|
270
350
|
arg: '<path>',
|
|
271
351
|
default: '/',
|
|
272
|
-
desc: 'override the reported application path'
|
|
352
|
+
desc: 'override the reported application path',
|
|
273
353
|
},
|
|
274
354
|
{
|
|
275
355
|
name: 'application.version',
|
|
276
356
|
arg: '<version>',
|
|
277
|
-
desc:
|
|
278
|
-
"override the reported application version (if different from 'version' field in the application's package.json)"
|
|
357
|
+
desc: "override the reported application version (if different from 'version' field in the application's package.json)",
|
|
279
358
|
},
|
|
280
359
|
{
|
|
281
360
|
name: 'application.session_id',
|
|
282
361
|
arg: '<session_id>',
|
|
283
362
|
default: null,
|
|
284
|
-
desc: 'provide the ID of a session existing within Contrast UI'
|
|
363
|
+
desc: 'provide the ID of a session existing within Contrast UI',
|
|
285
364
|
},
|
|
286
365
|
{
|
|
287
366
|
name: 'application.session_metadata',
|
|
288
367
|
arg: '<session_metadata>',
|
|
289
368
|
default: null,
|
|
290
|
-
desc: 'provide metadata used to create a new session within Contrast UI'
|
|
291
|
-
}
|
|
369
|
+
desc: 'provide metadata used to create a new session within Contrast UI',
|
|
370
|
+
},
|
|
292
371
|
];
|
|
293
372
|
|
|
294
373
|
const protect = [
|
|
@@ -296,14 +375,14 @@ const protect = [
|
|
|
296
375
|
name: 'protect.enable',
|
|
297
376
|
arg: '[false]',
|
|
298
377
|
fn: castBoolean,
|
|
299
|
-
desc: 'if false, disable protect for this agent'
|
|
378
|
+
desc: 'if false, disable protect for this agent',
|
|
300
379
|
},
|
|
301
380
|
{
|
|
302
381
|
name: 'protect.disabled_rules',
|
|
303
382
|
arg: '<list,of,rules>',
|
|
304
383
|
fn: split,
|
|
305
384
|
default: '',
|
|
306
|
-
desc: 'comma-separated list of rule ids to disable'
|
|
385
|
+
desc: 'comma-separated list of rule ids to disable',
|
|
307
386
|
},
|
|
308
387
|
{
|
|
309
388
|
name: 'protect.probe_analysis.enable',
|
|
@@ -316,41 +395,38 @@ const protect = [
|
|
|
316
395
|
name: `protect.rules.${ruleId}.mode`,
|
|
317
396
|
arg: '<mode>',
|
|
318
397
|
enum: ['monitor', 'block', 'block_at_perimeter', 'off'],
|
|
319
|
-
desc: `the mode in which to run the ${ruleId} rule
|
|
320
|
-
}))
|
|
398
|
+
desc: `the mode in which to run the ${ruleId} rule`,
|
|
399
|
+
})),
|
|
321
400
|
];
|
|
322
401
|
|
|
323
402
|
const server = [
|
|
324
403
|
{
|
|
325
404
|
name: 'server.environment',
|
|
326
|
-
arg: '<
|
|
405
|
+
arg: '<environment>',
|
|
327
406
|
fn: uppercase,
|
|
328
407
|
// enum: ['QA', 'PRODUCTION', 'DEVELOPMENT'], none of the other agents validate this
|
|
408
|
+
desc: 'environment the server is running in (QA, PRODUCTION, or DEVELOPMENT)',
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: 'server.tags',
|
|
412
|
+
arg: '<tags>',
|
|
329
413
|
desc:
|
|
330
|
-
'
|
|
414
|
+
'server tags provided by the user to the agent that instrumented this server.',
|
|
331
415
|
},
|
|
332
416
|
{
|
|
333
417
|
name: 'server.name',
|
|
334
418
|
arg: '<name>',
|
|
335
419
|
default: os.hostname(),
|
|
336
|
-
desc: 'override the reported server name'
|
|
420
|
+
desc: 'override the reported server name',
|
|
337
421
|
},
|
|
338
422
|
{
|
|
339
423
|
name: 'server.version',
|
|
340
424
|
arg: '<version>',
|
|
341
|
-
desc:
|
|
342
|
-
|
|
343
|
-
}
|
|
425
|
+
desc: "override the reported server version (if different from 'version' field in the application's package.json)",
|
|
426
|
+
},
|
|
344
427
|
];
|
|
345
428
|
|
|
346
|
-
const options = [].concat(
|
|
347
|
-
config,
|
|
348
|
-
api,
|
|
349
|
-
agent,
|
|
350
|
-
application,
|
|
351
|
-
protect,
|
|
352
|
-
server
|
|
353
|
-
);
|
|
429
|
+
const options = [].concat(config, api, agent, application, protect, server);
|
|
354
430
|
|
|
355
431
|
module.exports.configOptions = options;
|
|
356
432
|
module.exports.clearBaseCase = clearBaseCase;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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.1.
|
|
20
|
+
"@contrast/common": "1.1.3",
|
|
21
21
|
"yaml": "^2.0.1"
|
|
22
22
|
}
|
|
23
23
|
}
|