From 57316f7a7fd748c7f11102ad4476c16a343ace83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex?= Date: Mon, 8 Aug 2022 15:31:05 +0200 Subject: [PATCH] Fix wazuh.yml link and in-file documentation (#4378) * Review Wazuh.yml documentation Remove unused settings. Centralize documentation. Add missing settings. Programatic file generation. * Add Changelog * Fix indentation for hosts in the wazuh.yml Also fixes some TS warnings * Deep copy the WAZUH_DEFAULT_APP_CONFIG object (cherry picked from commit 1d441096398ed5e34e98048077520c78687788c0) --- CHANGELOG.md | 1 + common/constants.ts | 1 + public/services/resolves/get-config.js | 64 +---- public/utils/config-equivalences.js | 39 +-- server/controllers/wazuh-hosts.ts | 23 +- server/lib/initial-wazuh-config.ts | 372 ++++++++++++++----------- server/lib/manage-hosts.ts | 4 + server/lib/update-registry.ts | 2 + 8 files changed, 264 insertions(+), 242 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f44765707..ff60e0a6e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to the Wazuh app project will be documented in this file. ### Fixed +- Wazuh.yml review: fixed link to web documentation, improved in-file documentation and fixed some grammatical errors. [#4378](https://github.com/wazuh/wazuh-kibana-app/pull/4378) - Fixed an error during the generation of a group's report, if the request to the Wazuh API fails [#4350](https://github.com/wazuh/wazuh-kibana-app/pull/4350) - Fixed a problem with the group's report, when the group has no agents [#4350](https://github.com/wazuh/wazuh-kibana-app/pull/4350) - Fixed path in logo customization section [#4352](https://github.com/wazuh/wazuh-kibana-app/pull/4352) diff --git a/common/constants.ts b/common/constants.ts index 806c70cedc..30e860b093 100644 --- a/common/constants.ts +++ b/common/constants.ts @@ -221,6 +221,7 @@ export const WAZUH_DEFAULT_APP_CONFIG = { hideManagerAlerts: false, 'logs.level': 'info', 'enrollment.dns': '', + 'enrollment.password': '', 'customization.logo.app': '', 'customization.logo.sidebar': '', 'customization.logo.healthcheck':'', diff --git a/public/services/resolves/get-config.js b/public/services/resolves/get-config.js index b5d8e2444d..ba4aa543c1 100644 --- a/public/services/resolves/get-config.js +++ b/public/services/resolves/get-config.js @@ -10,70 +10,10 @@ * Find more information about this on the LICENSE file. */ -import { - WAZUH_ALERTS_PATTERN, - WAZUH_MONITORING_DEFAULT_INDICES_SHARDS, - WAZUH_MONITORING_DEFAULT_INDICES_REPLICAS, - WAZUH_MONITORING_PATTERN, - WAZUH_SAMPLE_ALERT_PREFIX, - WAZUH_STATISTICS_DEFAULT_INDICES_SHARDS, - WAZUH_STATISTICS_DEFAULT_INDICES_REPLICAS, -} from "../../../common/constants"; +import { WAZUH_DEFAULT_APP_CONFIG } from '../../../common/constants'; export async function getWzConfig($q, genericReq, wazuhConfig) { - // Remember to keep this values equal to default wazuh.yml values - const defaultConfig = { - pattern: WAZUH_ALERTS_PATTERN, - 'checks.pattern': true, - 'checks.template': true, - 'checks.api': true, - 'checks.setup': true, - 'checks.fields': true, - 'checks.metaFields': true, - 'checks.timeFilter': true, - 'checks.maxBuckets': true, - 'extensions.pci': true, - 'extensions.gdpr': true, - 'extensions.hipaa': true, - 'extensions.nist': true, - 'extensions.tsc': true, - 'extensions.audit': true, - 'extensions.oscap': false, - 'extensions.ciscat': false, - 'extensions.aws': false, - 'extensions.gcp': false, - 'extensions.virustotal': false, - 'extensions.osquery': false, - 'extensions.docker': false, - 'extensions.office': false, - 'extensions.github': false, - timeout: 20000, - 'ip.selector': true, - 'ip.ignore': [], - 'wazuh.monitoring.enabled': true, - 'wazuh.monitoring.frequency': 900, - 'wazuh.monitoring.shards': WAZUH_MONITORING_DEFAULT_INDICES_SHARDS, - 'wazuh.monitoring.replicas': WAZUH_MONITORING_DEFAULT_INDICES_REPLICAS, - 'wazuh.monitoring.creation': 'w', - 'wazuh.monitoring.pattern': WAZUH_MONITORING_PATTERN, - 'cron.prefix': 'wazuh', - 'cron.statistics.status': true, - 'cron.statistics.apis': [], - 'cron.statistics.interval': '0 */5 * * * *', - 'cron.statistics.index.name': 'statistics', - 'cron.statistics.index.creation': 'w', - 'cron.statistics.index.shards': WAZUH_STATISTICS_DEFAULT_INDICES_SHARDS, - 'cron.statistics.index.replicas': WAZUH_STATISTICS_DEFAULT_INDICES_REPLICAS, - 'alerts.sample.prefix': WAZUH_SAMPLE_ALERT_PREFIX, - hideManagerAlerts: false, - 'logs.level': 'info', - 'enrollment.dns': '', - 'enrollment.password': '', - 'customization.logo.app':'', - 'customization.logo.sidebar':'', - 'customization.logo.healthcheck':'', - 'customization.logo.reports':'' - }; + const defaultConfig = { ...WAZUH_DEFAULT_APP_CONFIG }; try { const config = await genericReq.request('GET', '/utils/configuration', {}); diff --git a/public/utils/config-equivalences.js b/public/utils/config-equivalences.js index 6f23c88434..5604b82bd5 100644 --- a/public/utils/config-equivalences.js +++ b/public/utils/config-equivalences.js @@ -1,11 +1,11 @@ import { ASSETS_PUBLIC_URL, PLUGIN_PLATFORM_NAME } from "../../common/constants"; export const configEquivalences = { - pattern: 'Default index pattern to use on the app.', - 'customization.logo.app':`Define the name of the app logo saved in the path ${ASSETS_PUBLIC_URL}`, - 'customization.logo.sidebar':`Define the name of the sidebar logo saved in the path ${ASSETS_PUBLIC_URL}`, - 'customization.logo.healthcheck':`Define the name of the health-check logo saved in the path ${ASSETS_PUBLIC_URL}`, - 'customization.logo.reports':`Define the name of the reports logo (.png) saved in the path ${ASSETS_PUBLIC_URL}`, + pattern: "Default index pattern to use on the app. If there's no valid index pattern, the app will automatically create one with the name indicated in this option.", + 'customization.logo.app':`Set the name of the app logo stored at ${ASSETS_PUBLIC_URL}`, + 'customization.logo.sidebar':`Set the name of the sidebar logo stored at ${ASSETS_PUBLIC_URL}`, + 'customization.logo.healthcheck':`Set the name of the health-check logo stored at ${ASSETS_PUBLIC_URL}`, + 'customization.logo.reports':`Set the name of the reports logo (.png) stored at ${ASSETS_PUBLIC_URL}`, 'checks.pattern': 'Enable or disable the index pattern health check when opening the app.', 'checks.template': @@ -23,6 +23,9 @@ export const configEquivalences = { `Change the default value of the ${PLUGIN_PLATFORM_NAME} max buckets configuration`, 'extensions.pci': 'Enable or disable the PCI DSS tab on Overview and Agents.', 'extensions.gdpr': 'Enable or disable the GDPR tab on Overview and Agents.', + 'extensions.hipaa': 'Enable or disable the HIPAA tab on Overview and Agents.', + 'extensions.nist': 'Enable or disable the NIST 800-53 tab on Overview and Agents.', + 'extensions.tsc': 'Enable or disable the TSC tab on Overview and Agents.', 'extensions.audit': 'Enable or disable the Audit tab on Overview and Agents.', 'extensions.oscap': 'Enable or disable the Open SCAP tab on Overview and Agents.', @@ -38,41 +41,43 @@ export const configEquivalences = { 'extensions.docker': 'Enable or disable the Docker listener tab on Overview and Agents.', timeout: - 'Defines the maximum time the app will wait for an API response when making requests to it.', + 'Maximum time, in milliseconds, the app will wait for an API response when making requests to it. It will be ignored if the value is set under 1500 milliseconds.', 'ip.selector': - 'Defines if the user is allowed to change the selected index pattern directly from the top menu bar.', + 'Define if the user is allowed to change the selected index pattern directly from the top menu bar.', 'ip.ignore': 'Disable certain index pattern names from being available in index pattern selector from the Wazuh app.', 'wazuh.monitoring.enabled': 'Enable or disable the wazuh-monitoring index creation and/or visualization.', 'wazuh.monitoring.frequency': - 'Define in seconds the frequency the app generates a new document on the wazuh-monitoring index.', + 'Frequency, in seconds, of API requests to get the state of the agents and create a new document in the wazuh-monitoring index with this data.', 'wazuh.monitoring.shards': 'Define the number of shards to use for the wazuh-monitoring-* indices.', 'wazuh.monitoring.replicas': 'Define the number of replicas to use for the wazuh-monitoring-* indices.', 'wazuh.monitoring.creation': - 'Define the interval in which the wazuh-monitoring index will be created.', + 'Define the interval in which a new wazuh-monitoring index will be created.', 'wazuh.monitoring.pattern': - 'Default index pattern to use on the app for Wazuh monitoring.', + 'Default index pattern to use for Wazuh monitoring.', hideManagerAlerts: - 'Hide the alerts of the manager in all dashboards.', + 'Hide the alerts of the manager in every dashboard.', 'logs.level': - 'Set the app logging level, allowed values are info and debug. Default is info.', + 'Logging level of the App.', 'enrollment.dns': - 'Set the Wazuh server address in the agent deployment.', + 'Specifies the Wazuh registration server, used for the agent enrollment.', + 'enrollment.password': + 'Specifies the password used to authenticate during the agent enrollment.', 'cron.prefix': 'Define the index prefix of predefined jobs.', 'cron.statistics.status': 'Enable or disable the statistics tasks.', 'cron.statistics.apis': - 'Enter the ID of the APIs you want to save data from, leave this empty to run the task on all configured APIs.', + 'Enter the ID of the hosts you want to save data from, leave this empty to run the task on every host.', 'cron.statistics.interval': 'Define the frequency of task execution using cron schedule expressions.', - 'cron.statistics.index.name': 'Define the name of the index in which the documents are to be saved.', - 'cron.statistics.index.creation': 'Define the interval in which the index will be created.', + 'cron.statistics.index.name': 'Define the name of the index in which the documents will be saved.', + 'cron.statistics.index.creation': 'Define the interval in which a new index will be created.', 'cron.statistics.index.shards': 'Define the number of shards to use for the statistics indices.', 'cron.statistics.index.replicas': 'Define the number of replicas to use for the statistics indices.', - 'alerts.sample.prefix': 'Define the index name prefix of sample alerts. It must match with the template used by the index pattern to avoid unknown fields in dashboards.', + 'alerts.sample.prefix': 'Define the index name prefix of sample alerts. It must match the template used by the index pattern to avoid unknown fields in dashboards.', }; export const nameEquivalence = { diff --git a/server/controllers/wazuh-hosts.ts b/server/controllers/wazuh-hosts.ts index 53b6094760..9d6a1d1779 100644 --- a/server/controllers/wazuh-hosts.ts +++ b/server/controllers/wazuh-hosts.ts @@ -10,15 +10,26 @@ * Find more information about this on the LICENSE file. */ +import { + OpenSearchDashboardsRequest, + RequestHandlerContext, + OpenSearchDashboardsResponseFactory, +} from 'src/core/server'; +import { + PLUGIN_PLATFORM_INSTALLATION_USER, + PLUGIN_PLATFORM_INSTALLATION_USER_GROUP, + PLUGIN_PLATFORM_NAME, + WAZUH_DATA_PLUGIN_PLATFORM_BASE_ABSOLUTE_PATH, +} from '../../common/constants'; +import { APIUserAllowRunAs } from '../lib/cache-api-user-has-run-as'; +import { ErrorResponse } from '../lib/error-response'; +import { log } from '../lib/logger'; import { ManageHosts } from '../lib/manage-hosts'; import { UpdateRegistry } from '../lib/update-registry'; -import { log } from '../lib/logger'; -import { ErrorResponse } from '../lib/error-response'; -import { APIUserAllowRunAs } from '../lib/cache-api-user-has-run-as'; -import { OpenSearchDashboardsRequest, RequestHandlerContext, OpenSearchDashboardsResponseFactory } from 'src/core/server'; -import { WAZUH_DATA_PLUGIN_PLATFORM_BASE_ABSOLUTE_PATH, PLUGIN_PLATFORM_INSTALLATION_USER, PLUGIN_PLATFORM_INSTALLATION_USER_GROUP, PLUGIN_PLATFORM_NAME } from '../../common/constants'; export class WazuhHostsCtrl { + manageHosts: ManageHosts; + updateRegistry: UpdateRegistry; constructor() { this.manageHosts = new ManageHosts(); this.updateRegistry = new UpdateRegistry(); @@ -34,7 +45,7 @@ export class WazuhHostsCtrl { async getHostsEntries(context: RequestHandlerContext, request: OpenSearchDashboardsRequest, response: OpenSearchDashboardsResponseFactory) { try { const removePassword = true; - const hosts = await this.manageHosts.getHosts(removePassword); + const hosts = await this.manageHosts.getHosts(); const registry = await this.updateRegistry.getHosts(); const result = await this.joinHostRegistry(hosts, registry, removePassword); return response.ok({ diff --git a/server/lib/initial-wazuh-config.ts b/server/lib/initial-wazuh-config.ts index 00aa4ae73e..88dfd95106 100644 --- a/server/lib/initial-wazuh-config.ts +++ b/server/lib/initial-wazuh-config.ts @@ -1,5 +1,5 @@ /* - * Wazuh app - Initial basic configuration file + * Wazuh app - App configuration file * Copyright (C) 2015-2022 Wazuh, Inc. * * This program is free software; you can redistribute it and/or modify @@ -10,8 +10,45 @@ * Find more information about this on the LICENSE file. */ -import { PLUGIN_APP_NAME, ASSETS_PUBLIC_URL, WAZUH_MONITORING_DEFAULT_INDICES_REPLICAS, WAZUH_MONITORING_DEFAULT_INDICES_SHARDS, WAZUH_STATISTICS_DEFAULT_INDICES_REPLICAS, WAZUH_STATISTICS_DEFAULT_INDICES_SHARDS } from "../../common/constants"; -import { webDocumentationLink } from "../../common/services/web_documentation"; +import { + PLUGIN_APP_NAME, + WAZUH_ALERTS_PATTERN, + WAZUH_DEFAULT_APP_CONFIG, + WAZUH_MONITORING_DEFAULT_CREATION, + WAZUH_MONITORING_DEFAULT_ENABLED, + WAZUH_MONITORING_DEFAULT_FREQUENCY, + WAZUH_MONITORING_DEFAULT_INDICES_REPLICAS, + WAZUH_MONITORING_DEFAULT_INDICES_SHARDS, + WAZUH_MONITORING_PATTERN, + WAZUH_SAMPLE_ALERT_PREFIX, + WAZUH_STATISTICS_DEFAULT_CREATION, + WAZUH_STATISTICS_DEFAULT_CRON_FREQ, + WAZUH_STATISTICS_DEFAULT_INDICES_REPLICAS, + WAZUH_STATISTICS_DEFAULT_INDICES_SHARDS, + WAZUH_STATISTICS_DEFAULT_NAME, + WAZUH_STATISTICS_DEFAULT_PREFIX, + WAZUH_STATISTICS_DEFAULT_STATUS, +} from '../../common/constants'; +import { webDocumentationLink } from '../../common/services/web_documentation'; +import { configEquivalences } from '../../public/utils/config-equivalences'; + +/** + * Given a string, this function builds a multine string, each line about 70 + * characters long, splitted at the closest whitespace character to that lentgh. + * + * This function is used to transform the settings description stored in the + * configEquivalences map into a multiline string to be used as the setting + * documentation. + * + * The # character is also appended to the beginning of each line. + * + * @param text + * @returns multine string + */ +function splitDescription(text: string = ''): string { + const lines = text.match(/.{1,80}(?=\s|$)/g) || []; + return lines.map((z) => '# ' + z.trim()).join('\n'); +} export const initialWazuhConfig: string = `--- # @@ -27,205 +64,226 @@ export const initialWazuhConfig: string = `--- # # ======================== ${PLUGIN_APP_NAME} configuration file ======================== # -# Please check the documentation for more information on configuration options: -# ${webDocumentationLink('installation-guide/index.html')} +# Please check the documentation for more information about configuration options: +# ${webDocumentationLink('user-manual/wazuh-dashboard/config-file.html')} # # Also, you can check our repository: # https://github.com/wazuh/wazuh-kibana-app # -# ------------------------------- Disable roles ------------------------------- +# ---------------------------- Unauthorized roles ------------------------------ # -# Defines which Elasticsearch roles disable Wazuh -# disabled_roles: -# - wazuh_disabled +# Disable Wazuh for the Elasticsearch / OpenSearch roles defined here. +# disabled_roles: +# - wazuh_disabled # # ------------------------------- Index patterns ------------------------------- # -# Default index pattern to use. -#pattern: wazuh-alerts-* +${splitDescription(configEquivalences.pattern)} +# pattern: ${WAZUH_ALERTS_PATTERN} # # ----------------------------------- Checks ----------------------------------- # -# Defines which checks must to be consider by the healthcheck -# step once the ${PLUGIN_APP_NAME} starts. Values must to be true or false. -#checks.pattern : true -#checks.template: true -#checks.fields : true -#checks.api : true -#checks.setup : true -#checks.metaFields: true -#checks.timeFilter: true -#checks.maxBuckets: true +# Define which checks will be executed by the App's HealthCheck. +# Allowed values are: true, false +# +${splitDescription(configEquivalences['checks.pattern'])} +# checks.pattern: ${WAZUH_DEFAULT_APP_CONFIG['checks.pattern']} +# +${splitDescription(configEquivalences['checks.template'])} +# checks.template: ${WAZUH_DEFAULT_APP_CONFIG['checks.template']} +# +${splitDescription(configEquivalences['checks.api'])} +# checks.api: ${WAZUH_DEFAULT_APP_CONFIG['checks.api']} +# +${splitDescription(configEquivalences['checks.setup'])} +# checks.setup: ${WAZUH_DEFAULT_APP_CONFIG['checks.setup']} +# +${splitDescription(configEquivalences['checks.fields'])} +# checks.fields: ${WAZUH_DEFAULT_APP_CONFIG['checks.fields']} +# +${splitDescription(configEquivalences['checks.metaFields'])} +# checks.metaFields: ${WAZUH_DEFAULT_APP_CONFIG['checks.metaFields']} +# +${splitDescription(configEquivalences['checks.timeFilter'])} +# checks.timeFilter: ${WAZUH_DEFAULT_APP_CONFIG['checks.timeFilter']} +# +${splitDescription(configEquivalences['checks.maxBuckets'])} +# checks.maxBuckets: ${WAZUH_DEFAULT_APP_CONFIG['checks.maxBuckets']} # # --------------------------------- Extensions --------------------------------- # -# Defines which extensions should be activated when you add a new API entry. -# You can change them after ${PLUGIN_APP_NAME} starts. -# Values must to be true or false. -#extensions.pci : true -#extensions.gdpr : true -#extensions.hipaa : true -#extensions.nist : true -#extensions.tsc : true -#extensions.audit : true -#extensions.oscap : false -#extensions.ciscat : false -#extensions.aws : false -#extensions.gcp : false -#extensions.virustotal: false -#extensions.osquery : false -#extensions.docker : false -# -# ---------------------------------- Timeout ---------------------------------- -# -# Defines maximum timeout to be used on the ${PLUGIN_APP_NAME} requests. -# It will be ignored if it is bellow 1500. -# It means milliseconds before we consider a request as failed. -# Default: 20000 -#timeout: 20000 -# -# -------------------------------- API selector -------------------------------- -# -# Defines if the user is allowed to change the selected -# API directly from the ${PLUGIN_APP_NAME} top menu. -# Default: true -#api.selector: true +# Define the initial state of the extensions (enabled / disabled) for recently +# added hosts. The extensions can be enabled or disabled anytime using the UI. +# Allowed values are: true, false +# +${splitDescription(configEquivalences['extensions.pci'])} +# extensions.pci: ${WAZUH_DEFAULT_APP_CONFIG['extensions.pci']} +# +${splitDescription(configEquivalences['extensions.gdpr'])} +# extensions.gdpr: ${WAZUH_DEFAULT_APP_CONFIG['extensions.gdpr']} +# +${splitDescription(configEquivalences['extensions.hipaa'])} +# extensions.hipaa: ${WAZUH_DEFAULT_APP_CONFIG['extensions.hipaa']} +# +${splitDescription(configEquivalences['extensions.nist'])} +# extensions.nist: ${WAZUH_DEFAULT_APP_CONFIG['extensions.nist']} +# +${splitDescription(configEquivalences['extensions.tsc'])} +# extensions.tsc: ${WAZUH_DEFAULT_APP_CONFIG['extensions.tsc']} +# +${splitDescription(configEquivalences['extensions.audit'])} +# extensions.audit: ${WAZUH_DEFAULT_APP_CONFIG['extensions.audit']} +# +${splitDescription(configEquivalences['extensions.oscap'])} +# extensions.oscap: ${WAZUH_DEFAULT_APP_CONFIG['extensions.oscap']} +# +${splitDescription(configEquivalences['extensions.ciscat'])} +# extensions.ciscat: ${WAZUH_DEFAULT_APP_CONFIG['extensions.ciscat']} +# +${splitDescription(configEquivalences['extensions.aws'])} +# extensions.aws: ${WAZUH_DEFAULT_APP_CONFIG['extensions.aws']} +# +${splitDescription(configEquivalences['extensions.gcp'])} +# extensions.gcp: ${WAZUH_DEFAULT_APP_CONFIG['extensions.gcp']} +# +${splitDescription(configEquivalences['extensions.virustotal'])} +# extensions.virustotal: ${WAZUH_DEFAULT_APP_CONFIG['extensions.virustotal']} +# +${splitDescription(configEquivalences['extensions.osquery'])} +# extensions.osquery: ${WAZUH_DEFAULT_APP_CONFIG['extensions.osquery']} +# +${splitDescription(configEquivalences['extensions.docker'])} +# extensions.docker: ${WAZUH_DEFAULT_APP_CONFIG['extensions.docker']} +# +# ------------------------------- Timeout -------------------------------------- +# +${splitDescription(configEquivalences.timeout)} +# timeout: ${WAZUH_DEFAULT_APP_CONFIG.timeout} # # --------------------------- Index pattern selector --------------------------- # -# Defines if the user is allowed to change the selected -# index pattern directly from the ${PLUGIN_APP_NAME} top menu. -# Default: true -#ip.selector: true +${splitDescription(configEquivalences['ip.selector'])} +# ip.selector: ${WAZUH_DEFAULT_APP_CONFIG['ip.selector']} # -# List of index patterns to be ignored -#ip.ignore: [] +${splitDescription(configEquivalences['ip.ignore'])} +# ip.ignore: ${WAZUH_DEFAULT_APP_CONFIG['ip.ignore']} # -# ------------------------------ wazuh-monitoring ------------------------------ +# ------------------------------ Monitoring ------------------------------------ # -# Custom setting to enable/disable wazuh-monitoring indices. -# Values: true, false, worker -# If worker is given as value, the app will show the Agents status -# visualization but won't insert data on wazuh-monitoring indices. -# Default: true -#wazuh.monitoring.enabled: true +${splitDescription(configEquivalences['wazuh.monitoring.enabled'])} +# wazuh.monitoring.enabled: ${WAZUH_MONITORING_DEFAULT_ENABLED} # -# Custom setting to set the frequency for wazuh-monitoring indices cron task. -# Default: 900 (s) -#wazuh.monitoring.frequency: 900 +${splitDescription(configEquivalences['wazuh.monitoring.frequency'])} +# wazuh.monitoring.frequency: ${WAZUH_MONITORING_DEFAULT_FREQUENCY} # -# Configure wazuh-monitoring-* indices shards and replicas. -#wazuh.monitoring.shards: ${WAZUH_MONITORING_DEFAULT_INDICES_SHARDS} -#wazuh.monitoring.replicas: ${WAZUH_MONITORING_DEFAULT_INDICES_REPLICAS} +${splitDescription(configEquivalences['wazuh.monitoring.shards'])} +# wazuh.monitoring.shards: ${WAZUH_MONITORING_DEFAULT_INDICES_SHARDS} # -# Configure wazuh-monitoring-* indices custom creation interval. -# Values: h (hourly), d (daily), w (weekly), m (monthly) -# Default: w -#wazuh.monitoring.creation: w +${splitDescription(configEquivalences['wazuh.monitoring.replicas'])} +# wazuh.monitoring.replicas: ${WAZUH_MONITORING_DEFAULT_INDICES_REPLICAS} # -# Default index pattern to use for Wazuh monitoring -#wazuh.monitoring.pattern: wazuh-monitoring-* +${splitDescription(configEquivalences['wazuh.monitoring.creation'])} +# Allowed values are: h (hourly), d (daily), w (weekly), m (monthly) +# wazuh.monitoring.creation: ${WAZUH_MONITORING_DEFAULT_CREATION} # -# --------------------------------- wazuh-cron ---------------------------------- +${splitDescription(configEquivalences['wazuh.monitoring.pattern'])} +# wazuh.monitoring.pattern: ${WAZUH_MONITORING_PATTERN} # -# Customize the index prefix of predefined jobs -# This change is not retroactive, if you change it new indexes will be created -# cron.prefix: wazuh +# --------------------------------- Sample data -------------------------------- # -# --------------------------------- wazuh-sample-alerts ------------------------- +${splitDescription(configEquivalences['alerts.sample.prefix'])} +# alerts.sample.prefix: ${WAZUH_SAMPLE_ALERT_PREFIX} # -# Customize the index name prefix of sample alerts -# This change is not retroactive, if you change it new indexes will be created -# It should match with a valid index template to avoid unknown fields on -# dashboards -#alerts.sample.prefix: wazuh-alerts-4.x- +# ------------------------------ Background tasks ------------------------------ # -# ------------------------------ wazuh-statistics ------------------------------- +${splitDescription(configEquivalences['cron.prefix'])} +# cron.prefix: ${WAZUH_STATISTICS_DEFAULT_PREFIX} # -# Custom setting to enable/disable statistics tasks. -#cron.statistics.status: true +# ------------------------------ Wazuh Statistics ------------------------------ # -# Enter the ID of the APIs you want to save data from, leave this empty to run -# the task on all configured APIs -#cron.statistics.apis: [] +${splitDescription(configEquivalences['cron.statistics.status'])} +# cron.statistics.status: ${WAZUH_STATISTICS_DEFAULT_STATUS} # -# Define the frequency of task execution using cron schedule expressions -#cron.statistics.interval: 0 */5 * * * * +${splitDescription(configEquivalences['cron.statistics.apis'])} +# cron.statistics.apis: ${WAZUH_DEFAULT_APP_CONFIG['cron.statistics.apis']} # -# Define the name of the index in which the documents are to be saved. -#cron.statistics.index.name: statistics +${splitDescription(configEquivalences['cron.statistics.interval'])} +# cron.statistics.interval: ${WAZUH_STATISTICS_DEFAULT_CRON_FREQ} # -# Define the interval in which the index will be created -#cron.statistics.index.creation: w +${splitDescription(configEquivalences['cron.statistics.index.name'])} +# cron.statistics.index.name: ${WAZUH_STATISTICS_DEFAULT_NAME} # -# Configure statistics indices shards and replicas. -#cron.statistics.shards: ${WAZUH_STATISTICS_DEFAULT_INDICES_SHARDS} -#cron.statistics.replicas: ${WAZUH_STATISTICS_DEFAULT_INDICES_REPLICAS} +${splitDescription(configEquivalences['cron.statistics.index.creation'])} +# cron.statistics.index.creation: ${WAZUH_STATISTICS_DEFAULT_CREATION} # -# ------------------------------ wazuh-logo-customization ------------------------------- +${splitDescription(configEquivalences['cron.statistics.index.shards'])} +# cron.statistics.shards: ${WAZUH_STATISTICS_DEFAULT_INDICES_SHARDS} # -#Define the name of the app logo saved in the path ${ASSETS_PUBLIC_URL} -#customization.logo.app: '' +${splitDescription(configEquivalences['cron.statistics.index.replicas'])} +# cron.statistics.replicas: ${WAZUH_STATISTICS_DEFAULT_INDICES_REPLICAS} # -#Define the name of the sidebar logo saved in the path ${ASSETS_PUBLIC_URL} -#customization.logo.sidebar: '' +# ------------------------------ Logo customization ---------------------------- # -#Define the name of the health-check logo saved in the path ${ASSETS_PUBLIC_URL} -#customization.logo.healthcheck: '' +${splitDescription(configEquivalences['customization.logo.app'])} +# customization.logo.app: ${WAZUH_DEFAULT_APP_CONFIG['customization.logo.app']} # -#Define the name of the reports logo (.png) saved in the path ${ASSETS_PUBLIC_URL} -#customization.logo.reports: '' +${splitDescription(configEquivalences['customization.logo.sidebar'])} +# customization.logo.sidebar: ${WAZUH_DEFAULT_APP_CONFIG['customization.logo.sidebar']} # -# ---------------------------- Hide manager alerts ------------------------------ -# Hide the alerts of the manager in all dashboards and discover -#hideManagerAlerts: false +${splitDescription(configEquivalences['customization.logo.healthcheck'])} +# customization.logo.healthcheck: ${WAZUH_DEFAULT_APP_CONFIG['customization.logo.healthcheck']} # -# ------------------------------- App logging level ----------------------------- -# Set the logging level for the ${PLUGIN_APP_NAME} log files. -# Default value: info -# Allowed values: info, debug -#logs.level: info +${splitDescription(configEquivalences['customization.logo.reports'])} +# customization.logo.reports: ${WAZUH_DEFAULT_APP_CONFIG['customization.logo.reports']} # -# -------------------------------- Enrollment DNS ------------------------------- -# Set the variable WAZUH_REGISTRATION_SERVER in agents deployment. -# Default value: '' -#enrollment.dns: '' +# ---------------------------- Hide manager alerts ----------------------------- # -# Wazuh registration password -# Default value: '' -#enrollment.password: '' -#-------------------------------- API entries ----------------------------------- -#The following configuration is the default structure to define an API entry. +${splitDescription(configEquivalences.hideManagerAlerts)} +# hideManagerAlerts: ${WAZUH_DEFAULT_APP_CONFIG.hideManagerAlerts} # -#hosts: -# - : - # URL - # API url - # url: http(s):// - - # Port - # API port - # port: - - # Username - # API user's username - # username: - - # Password - # API user's password - # password: +# ------------------------------- App logging level ---------------------------- +# +${splitDescription(configEquivalences['logs.level'])} +# Allowed values are: info, debug +# logs.level: ${WAZUH_DEFAULT_APP_CONFIG['logs.level']} +# +# ------------------------------- Agent enrollment ----------------------------- +# +${splitDescription(configEquivalences['enrollment.dns'])} +# enrollment.dns: ${WAZUH_DEFAULT_APP_CONFIG['enrollment.dns']} +# +${splitDescription(configEquivalences['enrollment.password'])} +# enrollment.password: ${WAZUH_DEFAULT_APP_CONFIG['enrollment.password']} +# +#-------------------------------- Wazuh hosts ---------------------------------- +# +# The following configuration is the default structure to define a host. +# +# hosts: +# # Host ID / name, +# - env-1: +# # Host URL +# url: https://env-1.example +# # Host / API port +# port: 55000 +# # Host / API username +# username: wazuh-wui +# # Host / API password +# password: wazuh-wui +# # Use RBAC or not. If set to true, the username must be "wazuh-wui". +# run_as: true +# - env-2: +# url: https://env-2.example +# port: 55000 +# username: wazuh-wui +# password: wazuh-wui +# run_as: true - # Run as - # Define how the app user gets his/her app permissions. - # Values: - # - true: use his/her authentication context. Require Wazuh API user allows run_as. - # - false or not defined: get same permissions of Wazuh API user. - # run_as: hosts: - default: - url: https://localhost - port: 55000 - username: wazuh-wui - password: wazuh-wui - run_as: false -` + url: https://localhost + port: 55000 + username: wazuh-wui + password: wazuh-wui + run_as: false +`; diff --git a/server/lib/manage-hosts.ts b/server/lib/manage-hosts.ts index b512e534d5..1f4576057d 100644 --- a/server/lib/manage-hosts.ts +++ b/server/lib/manage-hosts.ts @@ -18,6 +18,10 @@ import { WAZUH_DATA_CONFIG_APP_PATH } from '../../common/constants'; import { createDataDirectoryIfNotExists } from '../lib/filesystem'; export class ManageHosts { + busy: boolean; + file: string; + updateRegistry: UpdateRegistry; + initialConfig: string; constructor() { this.busy = false; this.file = WAZUH_DATA_CONFIG_APP_PATH; diff --git a/server/lib/update-registry.ts b/server/lib/update-registry.ts index 0aca1e7ec4..71e76ca627 100644 --- a/server/lib/update-registry.ts +++ b/server/lib/update-registry.ts @@ -14,6 +14,8 @@ import { log } from './logger'; import { WAZUH_DATA_CONFIG_REGISTRY_PATH } from '../../common/constants'; export class UpdateRegistry { + busy: boolean; + file: string; constructor() { this.busy = false; this.file = WAZUH_DATA_CONFIG_REGISTRY_PATH;