/
constants.ts
1872 lines (1804 loc) · 55.2 KB
/
constants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Wazuh app - Wazuh Constants file
* Copyright (C) 2015-2022 Wazuh, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/
import path from 'path';
import { version } from '../package.json';
import { validate as validateNodeCronInterval } from 'node-cron';
import { SettingsValidator } from '../common/services/settings-validator';
// Plugin
export const PLUGIN_VERSION = version;
export const PLUGIN_VERSION_SHORT = version.split('.').splice(0, 2).join('.');
// Index patterns - Wazuh alerts
export const WAZUH_INDEX_TYPE_ALERTS = 'alerts';
export const WAZUH_ALERTS_PREFIX = 'wazuh-alerts-';
export const WAZUH_ALERTS_PATTERN = 'wazuh-alerts-*';
// Job - Wazuh monitoring
export const WAZUH_INDEX_TYPE_MONITORING = 'monitoring';
export const WAZUH_MONITORING_PREFIX = 'wazuh-monitoring-';
export const WAZUH_MONITORING_PATTERN = 'wazuh-monitoring-*';
export const WAZUH_MONITORING_TEMPLATE_NAME = 'wazuh-agent';
export const WAZUH_MONITORING_DEFAULT_INDICES_SHARDS = 1;
export const WAZUH_MONITORING_DEFAULT_INDICES_REPLICAS = 0;
export const WAZUH_MONITORING_DEFAULT_CREATION = 'w';
export const WAZUH_MONITORING_DEFAULT_ENABLED = true;
export const WAZUH_MONITORING_DEFAULT_FREQUENCY = 900;
export const WAZUH_MONITORING_DEFAULT_CRON_FREQ = '0 * * * * *';
// Job - Wazuh statistics
export const WAZUH_INDEX_TYPE_STATISTICS = 'statistics';
export const WAZUH_STATISTICS_DEFAULT_PREFIX = 'wazuh';
export const WAZUH_STATISTICS_DEFAULT_NAME = 'statistics';
export const WAZUH_STATISTICS_PATTERN = `${WAZUH_STATISTICS_DEFAULT_PREFIX}-${WAZUH_STATISTICS_DEFAULT_NAME}-*`;
export const WAZUH_STATISTICS_TEMPLATE_NAME = `${WAZUH_STATISTICS_DEFAULT_PREFIX}-${WAZUH_STATISTICS_DEFAULT_NAME}`;
export const WAZUH_STATISTICS_DEFAULT_INDICES_SHARDS = 1;
export const WAZUH_STATISTICS_DEFAULT_INDICES_REPLICAS = 0;
export const WAZUH_STATISTICS_DEFAULT_CREATION = 'w';
export const WAZUH_STATISTICS_DEFAULT_STATUS = true;
export const WAZUH_STATISTICS_DEFAULT_FREQUENCY = 900;
export const WAZUH_STATISTICS_DEFAULT_CRON_FREQ = '0 */5 * * * *';
// Wazuh vulnerabilities
export const WAZUH_VULNERABILITIES_PATTERN = 'wazuh-states-vulnerabilities';
// Job - Wazuh initialize
export const WAZUH_PLUGIN_PLATFORM_TEMPLATE_NAME = 'wazuh-kibana';
// Permissions
export const WAZUH_ROLE_ADMINISTRATOR_ID = 1;
export const WAZUH_ROLE_ADMINISTRATOR_NAME = 'administrator';
// Sample data
export const WAZUH_SAMPLE_ALERT_PREFIX = 'wazuh-alerts-4.x-';
export const WAZUH_SAMPLE_ALERTS_INDEX_SHARDS = 1;
export const WAZUH_SAMPLE_ALERTS_INDEX_REPLICAS = 0;
export const WAZUH_SAMPLE_ALERTS_CATEGORY_SECURITY = 'security';
export const WAZUH_SAMPLE_ALERTS_CATEGORY_AUDITING_POLICY_MONITORING =
'auditing-policy-monitoring';
export const WAZUH_SAMPLE_ALERTS_CATEGORY_THREAT_DETECTION = 'threat-detection';
export const WAZUH_SAMPLE_ALERTS_DEFAULT_NUMBER_ALERTS = 3000;
export const WAZUH_SAMPLE_ALERTS_CATEGORIES_TYPE_ALERTS = {
[WAZUH_SAMPLE_ALERTS_CATEGORY_SECURITY]: [
{ syscheck: true },
{ aws: true },
{ office: true },
{ gcp: true },
{ authentication: true },
{ ssh: true },
{ apache: true, alerts: 2000 },
{ web: true },
{ windows: { service_control_manager: true }, alerts: 1000 },
{ github: true },
],
[WAZUH_SAMPLE_ALERTS_CATEGORY_AUDITING_POLICY_MONITORING]: [
{ rootcheck: true },
{ audit: true },
{ openscap: true },
{ ciscat: true },
],
[WAZUH_SAMPLE_ALERTS_CATEGORY_THREAT_DETECTION]: [
{ vulnerabilities: true },
{ virustotal: true },
{ osquery: true },
{ docker: true },
{ mitre: true },
],
};
// Security
export const WAZUH_SECURITY_PLUGIN_OPENSEARCH_DASHBOARDS_SECURITY =
'OpenSearch Dashboards Security';
export const WAZUH_SECURITY_PLUGINS = [
WAZUH_SECURITY_PLUGIN_OPENSEARCH_DASHBOARDS_SECURITY,
];
// App configuration
export const WAZUH_CONFIGURATION_CACHE_TIME = 10000; // time in ms;
// Reserved ids for Users/Role mapping
export const WAZUH_API_RESERVED_ID_LOWER_THAN = 100;
export const WAZUH_API_RESERVED_WUI_SECURITY_RULES = [1, 2];
// Wazuh data path
const WAZUH_DATA_PLUGIN_PLATFORM_BASE_PATH = 'data';
export const WAZUH_DATA_PLUGIN_PLATFORM_BASE_ABSOLUTE_PATH = path.join(
__dirname,
'../../../',
WAZUH_DATA_PLUGIN_PLATFORM_BASE_PATH,
);
export const WAZUH_DATA_ABSOLUTE_PATH = path.join(
WAZUH_DATA_PLUGIN_PLATFORM_BASE_ABSOLUTE_PATH,
'wazuh',
);
// Wazuh data path - config
export const WAZUH_DATA_CONFIG_DIRECTORY_PATH = path.join(
WAZUH_DATA_ABSOLUTE_PATH,
'config',
);
export const WAZUH_DATA_CONFIG_APP_PATH = path.join(
WAZUH_DATA_CONFIG_DIRECTORY_PATH,
'wazuh.yml',
);
export const WAZUH_DATA_CONFIG_REGISTRY_PATH = path.join(
WAZUH_DATA_CONFIG_DIRECTORY_PATH,
'wazuh-registry.json',
);
// Wazuh data path - logs
export const MAX_MB_LOG_FILES = 100;
export const WAZUH_DATA_LOGS_DIRECTORY_PATH = path.join(
WAZUH_DATA_ABSOLUTE_PATH,
'logs',
);
export const WAZUH_DATA_LOGS_PLAIN_FILENAME = 'wazuhapp-plain.log';
export const WAZUH_DATA_LOGS_PLAIN_PATH = path.join(
WAZUH_DATA_LOGS_DIRECTORY_PATH,
WAZUH_DATA_LOGS_PLAIN_FILENAME,
);
export const WAZUH_DATA_LOGS_RAW_FILENAME = 'wazuhapp.log';
export const WAZUH_DATA_LOGS_RAW_PATH = path.join(
WAZUH_DATA_LOGS_DIRECTORY_PATH,
WAZUH_DATA_LOGS_RAW_FILENAME,
);
// Wazuh data path - UI logs
export const WAZUH_UI_LOGS_PLAIN_FILENAME = 'wazuh-ui-plain.log';
export const WAZUH_UI_LOGS_RAW_FILENAME = 'wazuh-ui.log';
export const WAZUH_UI_LOGS_PLAIN_PATH = path.join(
WAZUH_DATA_LOGS_DIRECTORY_PATH,
WAZUH_UI_LOGS_PLAIN_FILENAME,
);
export const WAZUH_UI_LOGS_RAW_PATH = path.join(
WAZUH_DATA_LOGS_DIRECTORY_PATH,
WAZUH_UI_LOGS_RAW_FILENAME,
);
// Wazuh data path - downloads
export const WAZUH_DATA_DOWNLOADS_DIRECTORY_PATH = path.join(
WAZUH_DATA_ABSOLUTE_PATH,
'downloads',
);
export const WAZUH_DATA_DOWNLOADS_REPORTS_DIRECTORY_PATH = path.join(
WAZUH_DATA_DOWNLOADS_DIRECTORY_PATH,
'reports',
);
// Queue
export const WAZUH_QUEUE_CRON_FREQ = '*/15 * * * * *'; // Every 15 seconds
// Wazuh errors
export const WAZUH_ERROR_DAEMONS_NOT_READY = 'ERROR3099';
// Agents
export enum WAZUH_AGENTS_OS_TYPE {
WINDOWS = 'windows',
LINUX = 'linux',
SUNOS = 'sunos',
DARWIN = 'darwin',
OTHERS = '',
}
export enum WAZUH_MODULES_ID {
SECURITY_EVENTS = 'general',
INTEGRITY_MONITORING = 'fim',
AMAZON_WEB_SERVICES = 'aws',
OFFICE_365 = 'office',
GOOGLE_CLOUD_PLATFORM = 'gcp',
POLICY_MONITORING = 'pm',
SECURITY_CONFIGURATION_ASSESSMENT = 'sca',
AUDITING = 'audit',
OPEN_SCAP = 'oscap',
VULNERABILITIES = 'vuls',
OSQUERY = 'osquery',
DOCKER = 'docker',
MITRE_ATTACK = 'mitre',
PCI_DSS = 'pci',
HIPAA = 'hipaa',
NIST_800_53 = 'nist',
TSC = 'tsc',
CIS_CAT = 'ciscat',
VIRUSTOTAL = 'virustotal',
GDPR = 'gdpr',
GITHUB = 'github',
}
export enum WAZUH_MENU_MANAGEMENT_SECTIONS_ID {
MANAGEMENT = 'management',
ADMINISTRATION = 'administration',
RULESET = 'ruleset',
RULES = 'rules',
DECODERS = 'decoders',
CDB_LISTS = 'lists',
GROUPS = 'groups',
CONFIGURATION = 'configuration',
STATUS_AND_REPORTS = 'statusReports',
STATUS = 'status',
CLUSTER = 'monitoring',
LOGS = 'logs',
REPORTING = 'reporting',
STATISTICS = 'statistics',
}
export enum WAZUH_MENU_TOOLS_SECTIONS_ID {
API_CONSOLE = 'devTools',
RULESET_TEST = 'logtest',
}
export enum WAZUH_MENU_SECURITY_SECTIONS_ID {
USERS = 'users',
ROLES = 'roles',
POLICIES = 'policies',
ROLES_MAPPING = 'roleMapping',
}
export enum WAZUH_MENU_SETTINGS_SECTIONS_ID {
SETTINGS = 'settings',
API_CONFIGURATION = 'api',
MODULES = 'modules',
SAMPLE_DATA = 'sample_data',
CONFIGURATION = 'configuration',
LOGS = 'logs',
MISCELLANEOUS = 'miscellaneous',
ABOUT = 'about',
}
export const AUTHORIZED_AGENTS = 'authorized-agents';
// Wazuh links
export const WAZUH_LINK_GITHUB = 'https://github.com/wazuh';
export const WAZUH_LINK_GOOGLE_GROUPS =
'https://groups.google.com/forum/#!forum/wazuh';
export const WAZUH_LINK_SLACK = 'https://wazuh.com/community/join-us-on-slack';
export const HEALTH_CHECK = 'health-check';
// Health check
export const HEALTH_CHECK_REDIRECTION_TIME = 300; //ms
// Plugin platform settings
// Default timeFilter set by the app
export const WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER = {
from: 'now-24h',
to: 'now',
};
export const PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER =
'timepicker:timeDefaults';
// Default maxBuckets set by the app
export const WAZUH_PLUGIN_PLATFORM_SETTING_MAX_BUCKETS = 200000;
export const PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS = 'timeline:max_buckets';
// Default metaFields set by the app
export const WAZUH_PLUGIN_PLATFORM_SETTING_METAFIELDS = ['_source', '_index'];
export const PLUGIN_PLATFORM_SETTING_NAME_METAFIELDS = 'metaFields';
// Logger
export const UI_LOGGER_LEVELS = {
WARNING: 'WARNING',
INFO: 'INFO',
ERROR: 'ERROR',
};
export const UI_TOAST_COLOR = {
SUCCESS: 'success',
WARNING: 'warning',
DANGER: 'danger',
};
// Assets
export const ASSETS_BASE_URL_PREFIX = '/plugins/wazuh/assets/';
export const ASSETS_PUBLIC_URL = '/plugins/wazuh/public/assets/';
// Reports
export const REPORTS_LOGO_IMAGE_ASSETS_RELATIVE_PATH =
'images/logo_reports.png';
export const REPORTS_PRIMARY_COLOR = '#256BD1';
export const REPORTS_PAGE_FOOTER_TEXT = 'Copyright © 2023 Wazuh, Inc.';
export const REPORTS_PAGE_HEADER_TEXT = 'info@wazuh.com\nhttps://wazuh.com';
// Plugin platform
export const PLUGIN_PLATFORM_NAME = 'Wazuh dashboard';
export const PLUGIN_PLATFORM_BASE_INSTALLATION_PATH =
'/usr/share/wazuh-dashboard/data/wazuh/';
export const PLUGIN_PLATFORM_INSTALLATION_USER = 'wazuh-dashboard';
export const PLUGIN_PLATFORM_INSTALLATION_USER_GROUP = 'wazuh-dashboard';
export const PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_UPGRADE_PLATFORM =
'upgrade-guide';
export const PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING =
'user-manual/wazuh-dashboard/troubleshooting.html';
export const PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_APP_CONFIGURATION =
'user-manual/wazuh-dashboard/config-file.html';
export const PLUGIN_PLATFORM_URL_GUIDE =
'https://opensearch.org/docs/2.10/about';
export const PLUGIN_PLATFORM_URL_GUIDE_TITLE = 'OpenSearch guide';
export const PLUGIN_PLATFORM_REQUEST_HEADERS = {
'osd-xsrf': 'kibana',
};
// Plugin app
export const PLUGIN_APP_NAME = 'Wazuh dashboard';
// UI
export const API_NAME_AGENT_STATUS = {
ACTIVE: 'active',
DISCONNECTED: 'disconnected',
PENDING: 'pending',
NEVER_CONNECTED: 'never_connected',
} as const;
export const UI_COLOR_AGENT_STATUS = {
[API_NAME_AGENT_STATUS.ACTIVE]: '#007871',
[API_NAME_AGENT_STATUS.DISCONNECTED]: '#BD271E',
[API_NAME_AGENT_STATUS.PENDING]: '#FEC514',
[API_NAME_AGENT_STATUS.NEVER_CONNECTED]: '#646A77',
default: '#000000',
} as const;
export const UI_LABEL_NAME_AGENT_STATUS = {
[API_NAME_AGENT_STATUS.ACTIVE]: 'Active',
[API_NAME_AGENT_STATUS.DISCONNECTED]: 'Disconnected',
[API_NAME_AGENT_STATUS.PENDING]: 'Pending',
[API_NAME_AGENT_STATUS.NEVER_CONNECTED]: 'Never connected',
default: 'Unknown',
} as const;
export const UI_ORDER_AGENT_STATUS = [
API_NAME_AGENT_STATUS.ACTIVE,
API_NAME_AGENT_STATUS.DISCONNECTED,
API_NAME_AGENT_STATUS.PENDING,
API_NAME_AGENT_STATUS.NEVER_CONNECTED,
];
export const AGENT_SYNCED_STATUS = {
SYNCED: 'synced',
NOT_SYNCED: 'not synced',
};
// The status code can be seen here https://github.com/wazuh/wazuh/blob/686068a1f05d806b2e3b3d633a765320ae7ae114/src/wazuh_db/wdb.h#L55-L61
export const AGENT_STATUS_CODE = [
{
STATUS_CODE: 0,
STATUS_DESCRIPTION: 'Agent is connected',
},
{
STATUS_CODE: 1,
STATUS_DESCRIPTION: 'Invalid agent version',
},
{
STATUS_CODE: 2,
STATUS_DESCRIPTION: 'Error retrieving version',
},
{
STATUS_CODE: 3,
STATUS_DESCRIPTION: 'Shutdown message received',
},
{
STATUS_CODE: 4,
STATUS_DESCRIPTION: 'Disconnected because no keepalive received',
},
{
STATUS_CODE: 5,
STATUS_DESCRIPTION: 'Connection reset by manager',
},
];
// Documentation
export const DOCUMENTATION_WEB_BASE_URL = 'https://documentation.wazuh.com';
// Default Elasticsearch user name context
export const ELASTIC_NAME = 'elastic';
// Default Wazuh indexer name
export const WAZUH_INDEXER_NAME = 'Wazuh indexer';
// Not timeFieldName on index pattern
export const NOT_TIME_FIELD_NAME_INDEX_PATTERN =
'not_time_field_name_index_pattern';
// Customization
export const CUSTOMIZATION_ENDPOINT_PAYLOAD_UPLOAD_CUSTOM_FILE_MAXIMUM_BYTES = 1048576;
// Plugin settings
export enum SettingCategory {
GENERAL,
HEALTH_CHECK,
MONITORING,
STATISTICS,
VULNERABILITIES,
SECURITY,
CUSTOMIZATION,
}
type TPluginSettingOptionsTextArea = {
maxRows?: number;
minRows?: number;
maxLength?: number;
};
type TPluginSettingOptionsSelect = {
select: { text: string; value: any }[];
};
type TPluginSettingOptionsEditor = {
editor: {
language: string;
};
};
type TPluginSettingOptionsFile = {
file: {
type: 'image';
extensions?: string[];
size?: {
maxBytes?: number;
minBytes?: number;
};
recommended?: {
dimensions?: {
width: number;
height: number;
unit: string;
};
};
store?: {
relativePathFileSystem: string;
filename: string;
resolveStaticURL: (filename: string) => string;
};
};
};
type TPluginSettingOptionsNumber = {
number: {
min?: number;
max?: number;
integer?: boolean;
};
};
type TPluginSettingOptionsSwitch = {
switch: {
values: {
disabled: { label?: string; value: any };
enabled: { label?: string; value: any };
};
};
};
export enum EpluginSettingType {
text = 'text',
textarea = 'textarea',
switch = 'switch',
number = 'number',
editor = 'editor',
select = 'select',
filepicker = 'filepicker',
}
export type TPluginSetting = {
// Define the text displayed in the UI.
title: string;
// Description.
description: string;
// Category.
category: SettingCategory;
// Type.
type: EpluginSettingType;
// Default value.
defaultValue: any;
// Default value if it is not set. It has preference over `default`.
defaultValueIfNotSet?: any;
// Configurable from the configuration file.
isConfigurableFromFile: boolean;
// Configurable from the UI (Settings/Configuration).
isConfigurableFromUI: boolean;
// Modify the setting requires running the plugin health check (frontend).
requiresRunningHealthCheck?: boolean;
// Modify the setting requires reloading the browser tab (frontend).
requiresReloadingBrowserTab?: boolean;
// Modify the setting requires restarting the plugin platform to take effect.
requiresRestartingPluginPlatform?: boolean;
// Define options related to the `type`.
options?:
| TPluginSettingOptionsEditor
| TPluginSettingOptionsFile
| TPluginSettingOptionsNumber
| TPluginSettingOptionsSelect
| TPluginSettingOptionsSwitch
| TPluginSettingOptionsTextArea;
// Transform the input value. The result is saved in the form global state of Settings/Configuration
uiFormTransformChangedInputValue?: (value: any) => any;
// Transform the configuration value or default as initial value for the input in Settings/Configuration
uiFormTransformConfigurationValueToInputValue?: (value: any) => any;
// Transform the input value changed in the form of Settings/Configuration and returned in the `changed` property of the hook useForm
uiFormTransformInputValueToConfigurationValue?: (value: any) => any;
// Validate the value in the form of Settings/Configuration. It returns a string if there is some validation error.
validate?: (value: any) => string | undefined;
// Validate function creator to validate the setting in the backend. It uses `schema` of the `@kbn/config-schema` package.
validateBackend?: (schema: any) => (value: unknown) => string | undefined;
};
export type TPluginSettingWithKey = TPluginSetting & { key: TPluginSettingKey };
export type TPluginSettingCategory = {
title: string;
description?: string;
documentationLink?: string;
renderOrder?: number;
};
export const PLUGIN_SETTINGS_CATEGORIES: {
[category: number]: TPluginSettingCategory;
} = {
[SettingCategory.HEALTH_CHECK]: {
title: 'Health check',
description: "Checks will be executed by the app's Healthcheck.",
renderOrder: SettingCategory.HEALTH_CHECK,
},
[SettingCategory.GENERAL]: {
title: 'General',
description:
'Basic app settings related to alerts index pattern, hide the manager alerts in the dashboards, logs level and more.',
renderOrder: SettingCategory.GENERAL,
},
[SettingCategory.SECURITY]: {
title: 'Security',
description: 'Application security options such as unauthorized roles.',
renderOrder: SettingCategory.SECURITY,
},
[SettingCategory.MONITORING]: {
title: 'Task:Monitoring',
description:
'Options related to the agent status monitoring job and its storage in indexes.',
renderOrder: SettingCategory.MONITORING,
},
[SettingCategory.STATISTICS]: {
title: 'Task:Statistics',
description:
'Options related to the daemons manager monitoring job and their storage in indexes.',
renderOrder: SettingCategory.STATISTICS,
},
[SettingCategory.VULNERABILITIES]: {
title: 'Vulnerabilities',
description:
'Options related to the agent vulnerabilities monitoring job and its storage in indexes.',
renderOrder: SettingCategory.VULNERABILITIES,
},
[SettingCategory.CUSTOMIZATION]: {
title: 'Custom branding',
description:
'If you want to use custom branding elements such as logos, you can do so by editing the settings below.',
documentationLink: 'user-manual/wazuh-dashboard/white-labeling.html',
renderOrder: SettingCategory.CUSTOMIZATION,
},
};
export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = {
'alerts.sample.prefix': {
title: 'Sample alerts prefix',
description:
'Define the index name prefix of sample alerts. It must match the template used by the index pattern to avoid unknown fields in dashboards.',
category: SettingCategory.GENERAL,
type: EpluginSettingType.text,
defaultValue: WAZUH_SAMPLE_ALERT_PREFIX,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
requiresRunningHealthCheck: true,
// Validation: https://github.com/elastic/elasticsearch/blob/v7.10.2/docs/reference/indices/create-index.asciidoc
validate: SettingsValidator.compose(
SettingsValidator.isNotEmptyString,
SettingsValidator.hasNoSpaces,
SettingsValidator.noStartsWithString('-', '_', '+', '.'),
SettingsValidator.hasNotInvalidCharacters(
'\\',
'/',
'?',
'"',
'<',
'>',
'|',
',',
'#',
'*',
),
),
validateBackend: function (schema) {
return schema.string({ validate: this.validate });
},
},
'checks.api': {
title: 'API connection',
description: 'Enable or disable the API health check when opening the app.',
category: SettingCategory.HEALTH_CHECK,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
switch: {
values: {
disabled: { label: 'false', value: false },
enabled: { label: 'true', value: true },
},
},
},
uiFormTransformChangedInputValue: function (
value: boolean | string,
): boolean {
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function (schema) {
return schema.boolean();
},
},
'checks.fields': {
title: 'Known fields',
description:
'Enable or disable the known fields health check when opening the app.',
category: SettingCategory.HEALTH_CHECK,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
switch: {
values: {
disabled: { label: 'false', value: false },
enabled: { label: 'true', value: true },
},
},
},
uiFormTransformChangedInputValue: function (
value: boolean | string,
): boolean {
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function (schema) {
return schema.boolean();
},
},
'checks.maxBuckets': {
title: 'Set max buckets to 200000',
description:
'Change the default value of the plugin platform max buckets configuration.',
category: SettingCategory.HEALTH_CHECK,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
switch: {
values: {
disabled: { label: 'false', value: false },
enabled: { label: 'true', value: true },
},
},
},
uiFormTransformChangedInputValue: function (
value: boolean | string,
): boolean {
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function (schema) {
return schema.boolean();
},
},
'checks.metaFields': {
title: 'Remove meta fields',
description:
'Change the default value of the plugin platform metaField configuration.',
category: SettingCategory.HEALTH_CHECK,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
switch: {
values: {
disabled: { label: 'false', value: false },
enabled: { label: 'true', value: true },
},
},
},
uiFormTransformChangedInputValue: function (
value: boolean | string,
): boolean {
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function (schema) {
return schema.boolean();
},
},
'checks.pattern': {
title: 'Index pattern',
description:
'Enable or disable the index pattern health check when opening the app.',
category: SettingCategory.HEALTH_CHECK,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
switch: {
values: {
disabled: { label: 'false', value: false },
enabled: { label: 'true', value: true },
},
},
},
uiFormTransformChangedInputValue: function (
value: boolean | string,
): boolean {
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function (schema) {
return schema.boolean();
},
},
'checks.setup': {
title: 'API version',
description:
'Enable or disable the setup health check when opening the app.',
category: SettingCategory.HEALTH_CHECK,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
switch: {
values: {
disabled: { label: 'false', value: false },
enabled: { label: 'true', value: true },
},
},
},
uiFormTransformChangedInputValue: function (
value: boolean | string,
): boolean {
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function (schema) {
return schema.boolean();
},
},
'checks.template': {
title: 'Index template',
description:
'Enable or disable the template health check when opening the app.',
category: SettingCategory.HEALTH_CHECK,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
switch: {
values: {
disabled: { label: 'false', value: false },
enabled: { label: 'true', value: true },
},
},
},
uiFormTransformChangedInputValue: function (
value: boolean | string,
): boolean {
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function (schema) {
return schema.boolean();
},
},
'checks.timeFilter': {
title: 'Set time filter to 24h',
description:
'Change the default value of the plugin platform timeFilter configuration.',
category: SettingCategory.HEALTH_CHECK,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
switch: {
values: {
disabled: { label: 'false', value: false },
enabled: { label: 'true', value: true },
},
},
},
uiFormTransformChangedInputValue: function (
value: boolean | string,
): boolean {
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function (schema) {
return schema.boolean();
},
},
'checks.vulnerabilities.pattern': {
title: 'Vulnerabilities index pattern',
description:
'Enable or disable the vulnerabilities index pattern health check when opening the app.',
category: SettingCategory.HEALTH_CHECK,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
switch: {
values: {
disabled: { label: 'false', value: false },
enabled: { label: 'true', value: true },
},
},
},
uiFormTransformChangedInputValue: function (
value: boolean | string,
): boolean {
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function (schema) {
return schema.boolean();
},
},
'cron.prefix': {
title: 'Cron prefix',
description: 'Define the index prefix of predefined jobs.',
category: SettingCategory.GENERAL,
type: EpluginSettingType.text,
defaultValue: WAZUH_STATISTICS_DEFAULT_PREFIX,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
// Validation: https://github.com/elastic/elasticsearch/blob/v7.10.2/docs/reference/indices/create-index.asciidoc
validate: SettingsValidator.compose(
SettingsValidator.isNotEmptyString,
SettingsValidator.hasNoSpaces,
SettingsValidator.noStartsWithString('-', '_', '+', '.'),
SettingsValidator.hasNotInvalidCharacters(
'\\',
'/',
'?',
'"',
'<',
'>',
'|',
',',
'#',
'*',
),
),
validateBackend: function (schema) {
return schema.string({ validate: this.validate });
},
},
'cron.statistics.apis': {
title: 'Includes APIs',
description:
'Enter the ID of the hosts you want to save data from, leave this empty to run the task on every host.',
category: SettingCategory.STATISTICS,
type: EpluginSettingType.editor,
defaultValue: [],
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: {
editor: {
language: 'json',
},
},
uiFormTransformConfigurationValueToInputValue: function (value: any): any {
return JSON.stringify(value);
},
uiFormTransformInputValueToConfigurationValue: function (
value: string,
): any {
try {
return JSON.parse(value);
} catch (error) {
return value;
}
},
validate: SettingsValidator.json(
SettingsValidator.compose(
SettingsValidator.array(
SettingsValidator.compose(
SettingsValidator.isString,
SettingsValidator.isNotEmptyString,
SettingsValidator.hasNoSpaces,
),
),
),
),
validateBackend: function (schema) {
return schema.arrayOf(
schema.string({
validate: SettingsValidator.compose(
SettingsValidator.isNotEmptyString,
SettingsValidator.hasNoSpaces,
),
}),
);
},
},
'cron.statistics.index.creation': {
title: 'Index creation',
description: 'Define the interval in which a new index will be created.',
category: SettingCategory.STATISTICS,
type: EpluginSettingType.select,
options: {
select: [
{
text: 'Hourly',
value: 'h',
},
{
text: 'Daily',
value: 'd',
},
{
text: 'Weekly',
value: 'w',
},
{
text: 'Monthly',
value: 'm',
},
],
},
defaultValue: WAZUH_STATISTICS_DEFAULT_CREATION,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
requiresRunningHealthCheck: true,
validate: function (value) {
return SettingsValidator.literal(
this.options.select.map(({ value }) => value),
)(value);
},
validateBackend: function (schema) {
return schema.oneOf(
this.options.select.map(({ value }) => schema.literal(value)),
);
},
},
'cron.statistics.index.name': {
title: 'Index name',
description:
'Define the name of the index in which the documents will be saved.',
category: SettingCategory.STATISTICS,
type: EpluginSettingType.text,
defaultValue: WAZUH_STATISTICS_DEFAULT_NAME,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
requiresRunningHealthCheck: true,
// Validation: https://github.com/elastic/elasticsearch/blob/v7.10.2/docs/reference/indices/create-index.asciidoc
validate: SettingsValidator.compose(
SettingsValidator.isNotEmptyString,
SettingsValidator.hasNoSpaces,
SettingsValidator.noStartsWithString('-', '_', '+', '.'),
SettingsValidator.hasNotInvalidCharacters(
'\\',
'/',
'?',