From 54b2d4ce332bf42055a3b7f5285f4a3ab89e243f Mon Sep 17 00:00:00 2001 From: Carlos Bordon <64099752+c-bordon@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:34:13 -0300 Subject: [PATCH] Revert "Revert merges of 4.9.0 branch into master branch" --- .github/workflows/push.yml | 2 +- README.md | 54 +++--- .../wazuh-dashboard/Dockerfile | 28 +--- .../config/check_repository.sh | 30 ++++ .../wazuh-dashboard/config/dl_base.sh | 25 --- .../config/install_wazuh_app.sh | 35 ---- .../wazuh-dashboard/config/wazuh.yml | 155 ------------------ build-docker-images/wazuh-indexer/Dockerfile | 12 +- .../wazuh-indexer/config/check_repository.sh | 30 ++++ .../wazuh-indexer/config/config.sh | 31 ---- .../config/etc/cont-init.d/0-wazuh-init | 2 +- 11 files changed, 104 insertions(+), 300 deletions(-) create mode 100644 build-docker-images/wazuh-dashboard/config/check_repository.sh delete mode 100644 build-docker-images/wazuh-dashboard/config/dl_base.sh delete mode 100644 build-docker-images/wazuh-dashboard/config/install_wazuh_app.sh delete mode 100644 build-docker-images/wazuh-dashboard/config/wazuh.yml create mode 100644 build-docker-images/wazuh-indexer/config/check_repository.sh diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 18a71dd2b..2c952ef6a 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -291,7 +291,7 @@ jobs: sleep 10 done docs="`curl -XGET "https://0.0.0.0:9200/wazuh-alerts*/_count" -u admin:SecretPassword -k -s | jq -r ".count"`" - if [[ $docs -gt 1 ]]; then + if [[ $docs -gt 0 ]]; then echo "wazuh-alerts index documents: ${docs}" else echo "wazuh-alerts index documents: ${docs}" diff --git a/README.md b/README.md index 34290fc21..d7a34090c 100644 --- a/README.md +++ b/README.md @@ -89,19 +89,23 @@ WAZUH_MONITORING_REPLICAS=0 ## ## Directory structure ├── build-docker-images - │   ├── docker-compose.yml + │   ├── build-images.sh + │   ├── build-images.yml + │   ├── README.md │   ├── wazuh-dashboard │   │   ├── config │   │   │   ├── config.sh │   │   │   ├── config.yml + │   │   │   ├── dl_base.sh │   │   │   ├── entrypoint.sh + │   │   │   ├── install_wazuh_app.sh │   │   │   ├── opensearch_dashboards.yml │   │   │   ├── wazuh_app_config.sh │   │   │   └── wazuh.yml │   │   └── Dockerfile │   ├── wazuh-indexer │   │   ├── config - │ │ │ ├── action_groups.yml + │   │   │   ├── action_groups.yml │   │   │   ├── config.sh │   │   │   ├── config.yml │   │   │   ├── entrypoint.sh @@ -113,6 +117,7 @@ WAZUH_MONITORING_REPLICAS=0 ## │   │   └── Dockerfile │   └── wazuh-manager │   ├── config + │   │   ├── check_repository.sh │   │   ├── create_user.py │   │   ├── etc │   │   │   ├── cont-init.d @@ -125,19 +130,21 @@ WAZUH_MONITORING_REPLICAS=0 ## │   │   │   │   └── run │   │   │   └── ossec-logs │   │   │   └── run + │   │   ├── filebeat_module.sh │   │   ├── filebeat.yml │   │   ├── permanent_data.env - │   │   ├── permanent_data.sh - │   │   └── wazuh.repo + │   │   └── permanent_data.sh │   └── Dockerfile ├── CHANGELOG.md ├── indexer-certs-creator │   ├── config │   │   └── entrypoint.sh - │   └── Dockerfile + │   ├── Dockerfile + │   └── README.md ├── LICENSE ├── multi-node │   ├── config + │   │   ├── certs.yml │   │   ├── nginx │   │   │   └── nginx.conf │   │   ├── wazuh_cluster @@ -146,40 +153,29 @@ WAZUH_MONITORING_REPLICAS=0 ## │   │   ├── wazuh_dashboard │   │   │   ├── opensearch_dashboards.yml │   │   │   └── wazuh.yml - │   │   ├── wazuh_indexer - │   │   │   ├── internal_users.yml - │   │   │   ├── wazuh1.indexer.yml - │   │   │   ├── wazuh2.indexer.yml - │   │   │   └── wazuh3.indexer.yml - │   │   └── wazuh_indexer_ssl_certs - │   │   └── certs.yml + │   │   └── wazuh_indexer + │   │   ├── internal_users.yml + │   │   ├── wazuh1.indexer.yml + │   │   ├── wazuh2.indexer.yml + │   │   └── wazuh3.indexer.yml │   ├── docker-compose.yml - │   ├── generate-certs.yml - │   ├── Migration-to-Wazuh-4.3.md + │   ├── generate-indexer-certs.yml + │   ├── Migration-to-Wazuh-4.4.md + │   ├── README.md │   └── volume-migrator.sh ├── README.md + ├── SECURITY.md ├── single-node │   ├── config + │   │   ├── certs.yml │   │   ├── wazuh_cluster │   │   │   └── wazuh_manager.conf │   │   ├── wazuh_dashboard │   │   │   ├── opensearch_dashboards.yml │   │   │   └── wazuh.yml - │   │   ├── wazuh_indexer - │   │   │   ├── internal_users.yml - │   │   │   └── wazuh.indexer.yml - │   │   └── wazuh_indexer_ssl_certs - │   │   ├── admin-key.pem - │   │   ├── admin.pem - │   │   ├── certs.yml - │   │   ├── root-ca.key - │   │   ├── root-ca.pem - │   │   ├── wazuh.dashboard-key.pem - │   │   ├── wazuh.dashboard.pem - │   │   ├── wazuh.indexer-key.pem - │   │   ├── wazuh.indexer.pem - │   │   ├── wazuh.manager-key.pem - │   │   └── wazuh.manager.pem + │   │   └── wazuh_indexer + │   │   ├── internal_users.yml + │   │   └── wazuh.indexer.yml │   ├── docker-compose.yml │   ├── generate-certs.yml │   └── README.md diff --git a/build-docker-images/wazuh-dashboard/Dockerfile b/build-docker-images/wazuh-dashboard/Dockerfile index 172c98616..50adbb966 100644 --- a/build-docker-images/wazuh-dashboard/Dockerfile +++ b/build-docker-images/wazuh-dashboard/Dockerfile @@ -3,39 +3,23 @@ FROM amazonlinux:2023 AS builder ARG WAZUH_VERSION ARG WAZUH_TAG_REVISION -ARG INSTALL_DIR=/usr/share/wazuh-dashboard ARG WAZUH_UI_REVISION # Update and install dependencies -RUN yum install curl-minimal libcap xz tar openssl -y +RUN yum install curl-minimal libcap openssl -y -# Create Install dir -RUN mkdir -p $INSTALL_DIR +COPY config/check_repository.sh / +RUN chmod 775 /check_repository.sh && \ + source /check_repository.sh -# Download and extract Wazuh dashboard base -COPY config/dl_base.sh . -RUN bash dl_base.sh +RUN yum install wazuh-dashboard-${WAZUH_VERSION}-${WAZUH_TAG_REVISION} -y && \ + yum clean all # Generate certificates COPY config/config.sh . COPY config/config.yml / RUN bash config.sh -COPY config/install_wazuh_app.sh / -RUN chmod 775 /install_wazuh_app.sh -RUN bash /install_wazuh_app.sh - -# Copy and set permissions to config files -RUN cp $INSTALL_DIR/etc/opensearch_dashboards.yml $INSTALL_DIR/config/opensearch_dashboards.yml -COPY config/wazuh.yml $INSTALL_DIR/data/wazuh/config/ -RUN chmod 664 $INSTALL_DIR/config/opensearch_dashboards.yml - -# Create and set permissions to data directories -RUN mkdir -p $INSTALL_DIR/data/wazuh && chmod -R 775 $INSTALL_DIR/data/wazuh -RUN mkdir -p $INSTALL_DIR/data/wazuh/config && chmod -R 775 $INSTALL_DIR/data/wazuh/config -RUN mkdir -p $INSTALL_DIR/data/wazuh/logs && chmod -R 775 $INSTALL_DIR/data/wazuh/logs -RUN mkdir /wazuh-config-mount && chmod -R 775 /wazuh-config-mount - ################################################################################ # Build stage 1 (the current Wazuh dashboard image): # diff --git a/build-docker-images/wazuh-dashboard/config/check_repository.sh b/build-docker-images/wazuh-dashboard/config/check_repository.sh new file mode 100644 index 000000000..5323ec817 --- /dev/null +++ b/build-docker-images/wazuh-dashboard/config/check_repository.sh @@ -0,0 +1,30 @@ +## variables +APT_KEY=https://packages.wazuh.com/key/GPG-KEY-WAZUH +GPG_SIGN="gpgcheck=1\ngpgkey=${APT_KEY}]" +REPOSITORY="[wazuh]\n${GPG_SIGN}\nenabled=1\nname=EL-\$releasever - Wazuh\nbaseurl=https://packages.wazuh.com/4.x/yum/\nprotect=1" +WAZUH_CURRENT_VERSION=$(curl --silent https://api.github.com/repos/wazuh/wazuh/releases/latest | grep '["]tag_name["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 2-) +MAJOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f1) +MID_BUILD=$(echo $WAZUH_VERSION | cut -d. -f2) +MINOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f3) +MAJOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f1) +MID_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f2) +MINOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f3) + +## check version to use the correct repository +if [ "$MAJOR_BUILD" -gt "$MAJOR_CURRENT" ]; then + APT_KEY=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH + REPOSITORY="[wazuh]\n${GPG_SIGN}\nenabled=1\nname=EL-\$releasever - Wazuh\nbaseurl=https://packages-dev.wazuh.com/pre-release/yum/\nprotect=1" +elif [ "$MAJOR_BUILD" -eq "$MAJOR_CURRENT" ]; then + if [ "$MID_BUILD" -gt "$MID_CURRENT" ]; then + APT_KEY=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH + REPOSITORY="[wazuh]\n${GPG_SIGN}\nenabled=1\nname=EL-\$releasever - Wazuh\nbaseurl=https://packages-dev.wazuh.com/pre-release/yum/\nprotect=1" + elif [ "$MID_BUILD" -eq "$MID_CURRENT" ]; then + if [ "$MINOR_BUILD" -gt "$MINOR_CURRENT" ]; then + APT_KEY=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH + REPOSITORY="[wazuh]\n${GPG_SIGN}\nenabled=1\nname=EL-\$releasever - Wazuh\nbaseurl=https://packages-dev.wazuh.com/pre-release/yum/\nprotect=1" + fi + fi +fi + +rpm --import "${APT_KEY}" +echo -e "${REPOSITORY}" | tee /etc/yum.repos.d/wazuh.repo \ No newline at end of file diff --git a/build-docker-images/wazuh-dashboard/config/dl_base.sh b/build-docker-images/wazuh-dashboard/config/dl_base.sh deleted file mode 100644 index 21b234210..000000000 --- a/build-docker-images/wazuh-dashboard/config/dl_base.sh +++ /dev/null @@ -1,25 +0,0 @@ -REPOSITORY="packages.wazuh.com/4.x" -WAZUH_CURRENT_VERSION=$(curl --silent https://api.github.com/repos/wazuh/wazuh/releases/latest | grep '["]tag_name["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 2-) -MAJOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f1) -MID_BUILD=$(echo $WAZUH_VERSION | cut -d. -f2) -MINOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f3) -MAJOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f1) -MID_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f2) -MINOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f3) - -## check version to use the correct repository -if [ "$MAJOR_BUILD" -gt "$MAJOR_CURRENT" ]; then - REPOSITORY="packages-dev.wazuh.com/pre-release" -elif [ "$MAJOR_BUILD" -eq "$MAJOR_CURRENT" ]; then - if [ "$MID_BUILD" -gt "$MID_CURRENT" ]; then - REPOSITORY="packages-dev.wazuh.com/pre-release" - elif [ "$MID_BUILD" -eq "$MID_CURRENT" ]; then - if [ "$MINOR_BUILD" -gt "$MINOR_CURRENT" ]; then - REPOSITORY="packages-dev.wazuh.com/pre-release" - fi - fi -fi - - -curl -o wazuh-dashboard-base.tar.xz https://${REPOSITORY}/stack/dashboard/wazuh-dashboard-base-${WAZUH_VERSION}-${WAZUH_TAG_REVISION}-linux-x64.tar.xz -tar -xf wazuh-dashboard-base.tar.xz --directory $INSTALL_DIR --strip-components=1 diff --git a/build-docker-images/wazuh-dashboard/config/install_wazuh_app.sh b/build-docker-images/wazuh-dashboard/config/install_wazuh_app.sh deleted file mode 100644 index 4e8cb1990..000000000 --- a/build-docker-images/wazuh-dashboard/config/install_wazuh_app.sh +++ /dev/null @@ -1,35 +0,0 @@ -## variables -WAZUH_APP=https://packages.wazuh.com/4.x/ui/dashboard/wazuh-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip -WAZUH_CHECK_UPDATES=https://packages.wazuh.com/4.x/ui/dashboard/wazuhCheckUpdates-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip -WAZUH_CORE=https://packages.wazuh.com/4.x/ui/dashboard/wazuhCore-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip -WAZUH_CURRENT_VERSION=$(curl --silent https://api.github.com/repos/wazuh/wazuh/releases/latest | grep '["]tag_name["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 2-) -MAJOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f1) -MID_BUILD=$(echo $WAZUH_VERSION | cut -d. -f2) -MINOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f3) -MAJOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f1) -MID_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f2) -MINOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f3) - -## check version to use the correct repository -if [ "$MAJOR_BUILD" -gt "$MAJOR_CURRENT" ]; then - WAZUH_APP=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuh-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip - WAZUH_CHECK_UPDATES=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuhCheckUpdates-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip - WAZUH_CORE=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuhCore-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip -elif [ "$MAJOR_BUILD" -eq "$MAJOR_CURRENT" ]; then - if [ "$MID_BUILD" -gt "$MID_CURRENT" ]; then - WAZUH_APP=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuh-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip - WAZUH_CHECK_UPDATES=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuhCheckUpdates-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip - WAZUH_CORE=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuhCore-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip - elif [ "$MID_BUILD" -eq "$MID_CURRENT" ]; then - if [ "$MINOR_BUILD" -gt "$MINOR_CURRENT" ]; then - WAZUH_APP=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuh-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip - WAZUH_CHECK_UPDATES=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuhCheckUpdates-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip - WAZUH_CORE=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuhCore-${WAZUH_VERSION}-${WAZUH_UI_REVISION}.zip - fi - fi -fi - -# Install Wazuh App -$INSTALL_DIR/bin/opensearch-dashboards-plugin install $WAZUH_APP --allow-root -$INSTALL_DIR/bin/opensearch-dashboards-plugin install $WAZUH_CHECK_UPDATES --allow-root -$INSTALL_DIR/bin/opensearch-dashboards-plugin install $WAZUH_CORE --allow-root \ No newline at end of file diff --git a/build-docker-images/wazuh-dashboard/config/wazuh.yml b/build-docker-images/wazuh-dashboard/config/wazuh.yml deleted file mode 100644 index 8e5f9447f..000000000 --- a/build-docker-images/wazuh-dashboard/config/wazuh.yml +++ /dev/null @@ -1,155 +0,0 @@ ---- -# -# Wazuh app - App configuration file -# Copyright (C) 2017, 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. -# -# ======================== Wazuh app configuration file ======================== -# -# Please check the documentation for more information on configuration options: -# https://documentation.wazuh.com/current/installation-guide/index.html -# -# Also, you can check our repository: -# https://github.com/wazuh/wazuh-dashboard-plugins -# -# ------------------------------- Index patterns ------------------------------- -# -# Default index pattern to use. -#pattern: wazuh-alerts-* -# -# ----------------------------------- Checks ----------------------------------- -# -# Defines which checks must to be consider by the healthcheck -# step once the Wazuh app starts. Values must to be true or false. -#checks.pattern : true -#checks.template: true -#checks.api : true -#checks.setup : true -#checks.metaFields: true -# -# --------------------------------- Extensions --------------------------------- -# -# Defines which extensions should be activated when you add a new API entry. -# You can change them after Wazuh app 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 -# -# ---------------------------------- Time out ---------------------------------- -# -# Defines maximum timeout to be used on the Wazuh app 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 Wazuh app top menu. -# Default: true -#api.selector: true -# -# --------------------------- Index pattern selector --------------------------- -# -# Defines if the user is allowed to change the selected -# index pattern directly from the Wazuh app top menu. -# Default: true -#ip.selector: true -# -# List of index patterns to be ignored -#ip.ignore: [] -# -# ------------------------------ wazuh-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 -# -# Custom setting to set the frequency for wazuh-monitoring indices cron task. -# Default: 900 (s) -#wazuh.monitoring.frequency: 900 -# -# Configure wazuh-monitoring-* indices shards and replicas. -#wazuh.monitoring.shards: 2 -#wazuh.monitoring.replicas: 0 -# -# Configure wazuh-monitoring-* indices custom creation interval. -# Values: h (hourly), d (daily), w (weekly), m (monthly) -# Default: d -#wazuh.monitoring.creation: d -# -# Default index pattern to use for Wazuh monitoring -#wazuh.monitoring.pattern: wazuh-monitoring-* -# -# --------------------------------- wazuh-cron ---------------------------------- -# -# Customize the index prefix of predefined jobs -# This change is not retroactive, if you change it new indexes will be created -# cron.prefix: test -# -# ------------------------------ wazuh-statistics ------------------------------- -# -# Custom setting to enable/disable statistics tasks. -#cron.statistics.status: true -# -# 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: [] -# -# Define the frequency of task execution using cron schedule expressions -#cron.statistics.interval: 0 0 * * * * -# -# Define the name of the index in which the documents are to be saved. -#cron.statistics.index.name: statistics -# -# Define the interval in which the index will be created -#cron.statistics.index.creation: w -# -# ------------------------------- App privileges -------------------------------- -#admin: true -# -# ---------------------------- Hide manager alerts ------------------------------ -# Hide the alerts of the manager in all dashboards and discover -#hideManagerAlerts: false -# -# ------------------------------- App logging level ----------------------------- -# Set the logging level for the Wazuh App log files. -# Default value: info -# Allowed values: info, debug -#logs.level: info -# -# -------------------------------- Enrollment DNS ------------------------------- -# Set the variable WAZUH_REGISTRATION_SERVER in agents deployment. -# Default value: '' -#enrollment.dns: '' -# -#-------------------------------- API entries ----------------------------------- -#The following configuration is the default structure to define an API entry. -# -#hosts: -# - : -# url: http(s):// -# port: -# username: -# password: diff --git a/build-docker-images/wazuh-indexer/Dockerfile b/build-docker-images/wazuh-indexer/Dockerfile index e9e759729..0087b14a1 100644 --- a/build-docker-images/wazuh-indexer/Dockerfile +++ b/build-docker-images/wazuh-indexer/Dockerfile @@ -6,6 +6,15 @@ ARG WAZUH_TAG_REVISION RUN yum install curl-minimal openssl xz tar findutils shadow-utils -y +COPY config/check_repository.sh / +RUN chmod 775 /check_repository.sh && \ + source /check_repository.sh + +RUN yum install wazuh-indexer-${WAZUH_VERSION}-${WAZUH_TAG_REVISION} -y && \ + yum clean all + +COPY config/opensearch.yml / + COPY config/config.sh . COPY config/config.yml / @@ -58,7 +67,8 @@ RUN chmod 700 /entrypoint.sh && chmod 700 /securityadmin.sh RUN chown 1000:1000 /*.sh -COPY --from=builder --chown=1000:1000 /debian/wazuh-indexer/usr/share/wazuh-indexer /usr/share/wazuh-indexer +COPY --from=builder --chown=1000:1000 /usr/share/wazuh-indexer /usr/share/wazuh-indexer +COPY --from=builder --chown=1000:1000 /etc/wazuh-indexer /usr/share/wazuh-indexer COPY --from=builder --chown=0:0 /debian/wazuh-indexer/usr/lib/systemd /usr/lib/systemd COPY --from=builder --chown=0:0 /debian/wazuh-indexer/usr/lib/sysctl.d /usr/lib/sysctl.d COPY --from=builder --chown=0:0 /debian/wazuh-indexer/usr/lib/tmpfiles.d /usr/lib/tmpfiles.d diff --git a/build-docker-images/wazuh-indexer/config/check_repository.sh b/build-docker-images/wazuh-indexer/config/check_repository.sh new file mode 100644 index 000000000..5323ec817 --- /dev/null +++ b/build-docker-images/wazuh-indexer/config/check_repository.sh @@ -0,0 +1,30 @@ +## variables +APT_KEY=https://packages.wazuh.com/key/GPG-KEY-WAZUH +GPG_SIGN="gpgcheck=1\ngpgkey=${APT_KEY}]" +REPOSITORY="[wazuh]\n${GPG_SIGN}\nenabled=1\nname=EL-\$releasever - Wazuh\nbaseurl=https://packages.wazuh.com/4.x/yum/\nprotect=1" +WAZUH_CURRENT_VERSION=$(curl --silent https://api.github.com/repos/wazuh/wazuh/releases/latest | grep '["]tag_name["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 2-) +MAJOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f1) +MID_BUILD=$(echo $WAZUH_VERSION | cut -d. -f2) +MINOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f3) +MAJOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f1) +MID_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f2) +MINOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f3) + +## check version to use the correct repository +if [ "$MAJOR_BUILD" -gt "$MAJOR_CURRENT" ]; then + APT_KEY=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH + REPOSITORY="[wazuh]\n${GPG_SIGN}\nenabled=1\nname=EL-\$releasever - Wazuh\nbaseurl=https://packages-dev.wazuh.com/pre-release/yum/\nprotect=1" +elif [ "$MAJOR_BUILD" -eq "$MAJOR_CURRENT" ]; then + if [ "$MID_BUILD" -gt "$MID_CURRENT" ]; then + APT_KEY=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH + REPOSITORY="[wazuh]\n${GPG_SIGN}\nenabled=1\nname=EL-\$releasever - Wazuh\nbaseurl=https://packages-dev.wazuh.com/pre-release/yum/\nprotect=1" + elif [ "$MID_BUILD" -eq "$MID_CURRENT" ]; then + if [ "$MINOR_BUILD" -gt "$MINOR_CURRENT" ]; then + APT_KEY=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH + REPOSITORY="[wazuh]\n${GPG_SIGN}\nenabled=1\nname=EL-\$releasever - Wazuh\nbaseurl=https://packages-dev.wazuh.com/pre-release/yum/\nprotect=1" + fi + fi +fi + +rpm --import "${APT_KEY}" +echo -e "${REPOSITORY}" | tee /etc/yum.repos.d/wazuh.repo \ No newline at end of file diff --git a/build-docker-images/wazuh-indexer/config/config.sh b/build-docker-images/wazuh-indexer/config/config.sh index 299251f25..8283adfa0 100644 --- a/build-docker-images/wazuh-indexer/config/config.sh +++ b/build-docker-images/wazuh-indexer/config/config.sh @@ -19,37 +19,6 @@ export INDEXER_FILE=wazuh-indexer-base.tar.xz export BASE_FILE=wazuh-indexer-base-${VERSION}-linux-x64.tar.xz export REPO_DIR=/unattended_installer -rm -rf ${INSTALLATION_DIR}/ - -## variables -REPOSITORY="packages.wazuh.com/4.x" -WAZUH_CURRENT_VERSION=$(curl --silent https://api.github.com/repos/wazuh/wazuh/releases/latest | grep '["]tag_name["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 2-) -MAJOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f1) -MID_BUILD=$(echo $WAZUH_VERSION | cut -d. -f2) -MINOR_BUILD=$(echo $WAZUH_VERSION | cut -d. -f3) -MAJOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f1) -MID_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f2) -MINOR_CURRENT=$(echo $WAZUH_CURRENT_VERSION | cut -d. -f3) - -## check version to use the correct repository -if [ "$MAJOR_BUILD" -gt "$MAJOR_CURRENT" ]; then - REPOSITORY="packages-dev.wazuh.com/pre-release" -elif [ "$MAJOR_BUILD" -eq "$MAJOR_CURRENT" ]; then - if [ "$MID_BUILD" -gt "$MID_CURRENT" ]; then - REPOSITORY="packages-dev.wazuh.com/pre-release" - elif [ "$MID_BUILD" -eq "$MID_CURRENT" ]; then - if [ "$MINOR_BUILD" -gt "$MINOR_CURRENT" ]; then - REPOSITORY="packages-dev.wazuh.com/pre-release" - fi - fi -fi - - -curl -o ${INDEXER_FILE} https://${REPOSITORY}/stack/indexer/${BASE_FILE} -tar -xf ${INDEXER_FILE} - -## TOOLS - ## Variables CERT_TOOL=wazuh-certs-tool.sh PASSWORD_TOOL=wazuh-passwords-tool.sh diff --git a/build-docker-images/wazuh-manager/config/etc/cont-init.d/0-wazuh-init b/build-docker-images/wazuh-manager/config/etc/cont-init.d/0-wazuh-init index dae0e1f0b..326c46de5 100644 --- a/build-docker-images/wazuh-manager/config/etc/cont-init.d/0-wazuh-init +++ b/build-docker-images/wazuh-manager/config/etc/cont-init.d/0-wazuh-init @@ -199,7 +199,7 @@ main() { # Restore files stored in permanent data that are not permanent (i.e. internal_options.conf) apply_exclusion_data - + # Apply correct permission and ownership set_correct_permOwner