wazuh / wazuh-packages

Wazuh - Tools for packages creation
https://wazuh.com
GNU General Public License v2.0
105 stars 97 forks source link

Wazuh installation assistant should use a GitHub tag instead of a branch in the release tests #3092

Closed rauldpm closed 2 months ago

rauldpm commented 2 months ago
Wazuh version Install type Action performed Platform
v4.9.0-rc2 Wazuh installation assistant Resource download Amazon Linux 2023

The Wazuh installation assistant is using the wrong GitHub reference to download the Filebeat template, as it is using the 4.9.0 branch instead of the v4.9.0-rc2 tag, this could lead to an undesired situation if the branch is updated with a fix when the script is being used, invalidating the testing

02/09/2024 16:47:10 INFO: The resource https://raw.githubusercontent.com/wazuh/wazuh/4.9.0/extensions/elasticsearch/7.x/wazuh-template.json was downloaded.

We should change the script to use the tag instead of a branch like the production script does when the script is generated with a repository tag

Related issue: https://github.com/wazuh/wazuh/issues/25502

Enaraque commented 2 months ago

Update report

The only way to meet this requirement is to add a new variable reflecting the current version tag.

[!IMPORTANT] With this, whenever we have to bump a version we will need to change the new tag reference.

Enaraque commented 2 months ago

Update report

After adding the corresponding variable to the tag and building the wazuh-install.sh with the development option (-d), tests have been done to check its correct functioning. As we can see, when trying to download the template, it works correctly:

$ ./wazuh-install.sh -dw rpm
04/09/2024 10:21:27 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0
04/09/2024 10:21:27 INFO: Verbose logging redirected to /var/log/wazuh-install.log
04/09/2024 10:21:28 INFO: --- Dependencies ---
04/09/2024 10:21:28 INFO: Installing curl.
04/09/2024 10:21:29 INFO: Verifying that your system meets the recommended minimum hardware requirements.
04/09/2024 10:21:29 INFO: --- Download Packages ---
04/09/2024 10:21:29 INFO: Starting Wazuh packages download.
04/09/2024 10:21:29 INFO: Downloading Wazuh rpm packages for x86_64.
04/09/2024 10:21:38 INFO: The manager package was downloaded.
04/09/2024 10:21:39 INFO: The filebeat package was downloaded.
04/09/2024 10:21:43 INFO: The indexer package was downloaded.
04/09/2024 10:21:50 INFO: The dashboard package was downloaded.
04/09/2024 10:21:50 INFO: The packages are in wazuh-offline/wazuh-packages
04/09/2024 10:21:50 INFO: Downloading configuration files and assets.
04/09/2024 10:21:51 INFO: The resource https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH was downloaded.
04/09/2024 10:21:51 INFO: The resource https://packages-dev.wazuh.com/4.9/tpl/wazuh/filebeat/filebeat.yml was downloaded.
04/09/2024 10:21:51 INFO: The resource https://raw.githubusercontent.com/wazuh/wazuh/v4.9.0-rc2/extensions/elasticsearch/7.x/wazuh-template.json was downloaded.
04/09/2024 10:21:51 INFO: The resource https://packages-dev.wazuh.com/pre-release/filebeat/wazuh-filebeat-0.4.tar.gz was downloaded.
04/09/2024 10:21:51 INFO: The configuration files and assets are in wazuh-offline.tar.gz
04/09/2024 10:23:11 INFO: You can follow the installation guide here https://documentation.wazuh.com/current/deployment-options/offline-installation.html
04/09/2024 10:21:51 INFO: The resource https://raw.githubusercontent.com/wazuh/wazuh/v4.9.0-rc2/extensions/elasticsearch/7.x/wazuh-template.json was downloaded.

When doing the installation, it installs successfully.

Installation logs ```console $ ./wazuh-install.sh -g 04/09/2024 10:28:06 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0 04/09/2024 10:28:06 INFO: Verbose logging redirected to /var/log/wazuh-install.log 04/09/2024 10:28:06 INFO: Verifying that your system meets the recommended minimum hardware requirements. 04/09/2024 10:28:06 INFO: --- Configuration files --- 04/09/2024 10:28:06 INFO: Generating configuration files. 04/09/2024 10:28:06 INFO: Generating the root certificate. 04/09/2024 10:28:07 INFO: Generating Admin certificates. 04/09/2024 10:28:07 INFO: Generating Wazuh indexer certificates. 04/09/2024 10:28:08 INFO: Generating Filebeat certificates. 04/09/2024 10:28:09 INFO: Generating Wazuh dashboard certificates. 04/09/2024 10:28:10 INFO: Created wazuh-install-files.tar. It contains the Wazuh cluster key, certificates, and passwords necessary for installation. $ ./wazuh-install.sh --offline-installation --wazuh-indexer node-1 04/09/2024 10:28:37 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0 04/09/2024 10:28:37 INFO: Verbose logging redirected to /var/log/wazuh-install.log 04/09/2024 10:28:37 INFO: Checking installed dependencies for Offline installation. 04/09/2024 10:28:40 INFO: Verifying that your system meets the recommended minimum hardware requirements. 04/09/2024 10:28:40 INFO: Checking prerequisites for Offline installation. 04/09/2024 10:28:41 INFO: Checking wazuh-offline.tar.gz file. 04/09/2024 10:28:54 INFO: --- Wazuh indexer --- 04/09/2024 10:28:54 INFO: Starting Wazuh indexer installation. 04/09/2024 10:29:14 INFO: Wazuh indexer installation finished. 04/09/2024 10:29:14 INFO: Wazuh indexer post-install configuration finished. 04/09/2024 10:29:14 INFO: Starting service wazuh-indexer. 04/09/2024 10:29:39 INFO: wazuh-indexer service started. 04/09/2024 10:29:39 INFO: Initializing Wazuh indexer cluster security settings. 04/09/2024 10:29:40 INFO: Wazuh indexer cluster initialized. 04/09/2024 10:29:40 INFO: Installation finished. $ bash wazuh-install.sh --offline-installation --start-cluster 04/09/2024 10:30:06 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0 04/09/2024 10:30:06 INFO: Verbose logging redirected to /var/log/wazuh-install.log 04/09/2024 10:30:06 INFO: Checking installed dependencies for Offline installation. 04/09/2024 10:30:09 INFO: Verifying that your system meets the recommended minimum hardware requirements. 04/09/2024 10:30:09 INFO: Checking wazuh-offline.tar.gz file. 04/09/2024 10:30:16 INFO: Wazuh indexer cluster security configuration initialized. 04/09/2024 10:30:22 INFO: Updating the internal users. 04/09/2024 10:30:27 INFO: A backup of the internal users has been saved in the /etc/wazuh-indexer/internalusers-backup folder. 04/09/2024 10:30:46 INFO: Wazuh indexer cluster started. $ tar -axf wazuh-install-files.tar wazuh-install-files/wazuh-passwords.txt -O | grep -P "\'admin\'" -A 1 indexer_username: 'admin' indexer_password: 'xxxxx' $ curl -k -u admin:xxxxx https://127.0.0.1:9200 { "name" : "node-1", "cluster_name" : "wazuh-indexer-cluster", "cluster_uuid" : "05WP6gpRQJig-UJlrnFRog", "version" : { "number" : "7.10.2", "build_type" : "rpm", "build_hash" : "9fd1835bba77ae04d48550eb4dc9be4787070806", "build_date" : "2024-08-30T10:04:33.447803Z", "build_snapshot" : false, "lucene_version" : "9.10.0", "minimum_wire_compatibility_version" : "7.10.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "The OpenSearch Project: https://opensearch.org/" } $ curl -k -u admin:xxxxx https://127.0.0.1:9200/_cat/nodes?v ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role node.roles cluster_manager name 127.0.0.1 58 71 11 0.01 0.26 0.21 dimr data,ingest,master,remote_cluster_client * node-1 $ bash wazuh-install.sh --offline-installation --wazuh-server wazuh-1 04/09/2024 10:35:33 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0 04/09/2024 10:35:33 INFO: Verbose logging redirected to /var/log/wazuh-install.log 04/09/2024 10:35:33 INFO: Checking installed dependencies for Offline installation. 04/09/2024 10:35:36 INFO: Verifying that your system meets the recommended minimum hardware requirements. 04/09/2024 10:35:36 INFO: Checking wazuh-offline.tar.gz file. 04/09/2024 10:35:37 INFO: --- Wazuh server --- 04/09/2024 10:35:37 INFO: Starting the Wazuh manager installation. 04/09/2024 10:36:49 INFO: Wazuh manager installation finished. 04/09/2024 10:36:49 INFO: Wazuh manager vulnerability detection configuration finished. 04/09/2024 10:36:49 INFO: Starting service wazuh-manager. 04/09/2024 10:37:10 INFO: wazuh-manager service started. 04/09/2024 10:37:10 INFO: Starting Filebeat installation. 04/09/2024 10:37:21 INFO: Filebeat installation finished. 04/09/2024 10:37:22 INFO: Filebeat post-install configuration finished. 04/09/2024 10:37:24 INFO: The filebeat.yml file has been updated to use the Filebeat Keystore username and password. 04/09/2024 10:37:53 INFO: Starting service filebeat. 04/09/2024 10:37:54 INFO: filebeat service started. 04/09/2024 10:37:54 INFO: Installation finished. $ bash wazuh-install.sh --offline-installation --wazuh-dashboard dashboard 04/09/2024 10:43:36 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0 04/09/2024 10:43:36 INFO: Verbose logging redirected to /var/log/wazuh-install.log 04/09/2024 10:43:36 INFO: Checking installed dependencies for Offline installation. 04/09/2024 10:43:38 INFO: Verifying that your system meets the recommended minimum hardware requirements. 04/09/2024 10:43:38 INFO: Wazuh web interface port will be 443. 04/09/2024 10:43:39 INFO: Checking prerequisites for Offline installation. 04/09/2024 10:43:39 INFO: Checking wazuh-offline.tar.gz file. 04/09/2024 10:43:39 INFO: --- Wazuh dashboard ---- 04/09/2024 10:43:39 INFO: Starting Wazuh dashboard installation. 04/09/2024 10:45:49 INFO: Wazuh dashboard installation finished. 04/09/2024 10:45:49 INFO: Wazuh dashboard post-install configuration finished. 04/09/2024 10:45:49 INFO: Starting service wazuh-dashboard. 04/09/2024 10:45:50 INFO: wazuh-dashboard service started. 04/09/2024 10:45:51 INFO: The filebeat.yml file has been updated to use the Filebeat Keystore username and password. 04/09/2024 10:46:39 INFO: Initializing Wazuh dashboard web application. 04/09/2024 10:46:40 INFO: Wazuh dashboard web application initialized. 04/09/2024 10:46:40 INFO: --- Summary --- 04/09/2024 10:46:40 INFO: You can access the web interface https://:443 User: admin Password: xxxxx 04/09/2024 10:46:40 INFO: Installation finished. ```
Dashboard landing page ![Captura de pantalla 2024-09-04 a las 12 59 37](https://github.com/user-attachments/assets/9ded37f1-c2bd-4869-adbe-b5d2fa81181f) ![Captura de pantalla 2024-09-04 a las 12 59 47](https://github.com/user-attachments/assets/f8ff4e90-8f07-4626-979f-7ce9d9cba7c8)
Enaraque commented 2 months ago

Update report

The way the Filebeat URL is evaluated has been changed. Previously a variable was created so that a tag was used instead of a branch. After discussion with the team, we have come to the conclusion that there may be times when it is necessary to use the branch instead of the tag.

For that, a condition has been added inside builder.sh where, if in the source_branch variable of installVariables.sh, the character - exists, it is concluded that its value refers to a tag. This means that the value of that variable, when building, changes from v{wazuh_version} to {wazuh_version} only when we are not testing a stage.

We have also changed the value of the source_branch variable in builder.sh so that instead of referring to a branch, it refers to a tag. This variable was used to know the path to the dist-detect.sh script. Previously the branch was used as a reference, but as with the Filebeat path, it is better to use the tag instead.

Tests

After these changes everything is still working correctly.

$ ./wazuh-install.sh -dw rpm
05/09/2024 11:12:52 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0
05/09/2024 11:12:52 INFO: Verbose logging redirected to /var/log/wazuh-install.log
05/09/2024 11:12:52 INFO: --- Dependencies ---
05/09/2024 11:12:52 INFO: Installing curl.
05/09/2024 11:12:53 INFO: Verifying that your system meets the recommended minimum hardware requirements.
05/09/2024 11:12:53 INFO: --- Download Packages ---
05/09/2024 11:12:53 INFO: Starting Wazuh packages download.
05/09/2024 11:12:53 INFO: Downloading Wazuh rpm packages for x86_64.
05/09/2024 11:12:57 INFO: The manager package was downloaded.
05/09/2024 11:12:57 INFO: The filebeat package was downloaded.
05/09/2024 11:13:01 INFO: The indexer package was downloaded.
05/09/2024 11:13:02 INFO: The dashboard package was downloaded.
05/09/2024 11:13:02 INFO: The packages are in wazuh-offline/wazuh-packages
05/09/2024 11:13:02 INFO: Downloading configuration files and assets.
05/09/2024 11:13:03 INFO: The resource https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH was downloaded.
05/09/2024 11:13:03 INFO: The resource https://packages-dev.wazuh.com/4.9/tpl/wazuh/filebeat/filebeat.yml was downloaded.
05/09/2024 11:13:03 INFO: The resource https://raw.githubusercontent.com/wazuh/wazuh/v4.9.0-rc2/extensions/elasticsearch/7.x/wazuh-template.json was downloaded.
05/09/2024 11:13:04 INFO: The resource https://packages-dev.wazuh.com/pre-release/filebeat/wazuh-filebeat-0.4.tar.gz was downloaded.
05/09/2024 11:13:04 INFO: The configuration files and assets are in wazuh-offline.tar.gz
05/09/2024 11:14:24 INFO: You can follow the installation guide here https://documentation.wazuh.com/current/deployment-options/offline-installation.html
05/09/2024 11:13:03 INFO: The resource https://raw.githubusercontent.com/wazuh/wazuh/v4.9.0-rc2/extensions/elasticsearch/7.x/wazuh-template.json

Captura de pantalla 2024-09-05 a las 13 42 10