diff --git a/build-docker-images/README.md b/build-docker-images/README.md index 13f1c9bf..a62978ac 100644 --- a/build-docker-images/README.md +++ b/build-docker-images/README.md @@ -9,3 +9,24 @@ $ build-docker-images/build-images.sh ``` This script initializes the environment variables needed to build each of the images. + +The script allows you to build images from other versions of Wazuh, to do this you must use the -v or --version argument: + +``` +$ build-docker-images/build-images.sh -v 4.5.2 +``` + +To get all the available script options use the -h or --help option: + +``` +$ build-docker-images/build-images.sh -h + +Usage: build-docker-images/build-images.sh [OPTIONS] + + -d, --dev [Optional] Set the development stage you want to build, example rc1 or beta1, not used by default. + -f, --filebeat-module [Optional] Set Filebeat module version. By default 0.2. + -r, --revision [Optional] Package revision. By default 1 + -v, --version [Optional] Set the Wazuh version should be builded. By default, 4.6.0. + -h, --help Show this help. + +``` \ No newline at end of file diff --git a/build-docker-images/build-images.sh b/build-docker-images/build-images.sh index 16c9d074..092cdc67 100755 --- a/build-docker-images/build-images.sh +++ b/build-docker-images/build-images.sh @@ -4,8 +4,141 @@ WAZUH_TAG_REVISION=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- | sed -e 's/\.//g') IMAGE_VERSION=${WAZUH_IMAGE_VERSION} -echo WAZUH_VERSION=$WAZUH_IMAGE_VERSION > .env -echo WAZUH_IMAGE_VERSION=$IMAGE_VERSION >> .env -echo WAZUH_TAG_REVISION=$WAZUH_TAG_REVISION >> .env +# Wazuh package generator +# Copyright (C) 2023, Wazuh Inc. +# +# This program is a free software; you can redistribute it +# and/or modify it under the terms of the GNU General Public +# License (version 2) as published by the FSF - Free Software +# Foundation. -docker-compose -f build-docker-images/build-images.yml --env-file .env build --no-cache \ No newline at end of file +WAZUH_IMAGE_VERSION="4.6.0" +WAZUH_TAG_REVISION="1" +WAZUH_DEV_STAGE="" +FILEBEAT_MODULE_VERSION="0.2" + +# ----------------------------------------------------------------------------- + +trap ctrl_c INT + +clean() { + exit_code=$1 + + exit ${exit_code} +} + +ctrl_c() { + clean 1 +} + +# ----------------------------------------------------------------------------- + + +build() { + + WAZUH_VERSION="$(echo $WAZUH_IMAGE_VERSION | sed -e 's/\.//g')" + FILEBEAT_TEMPLATE_BRANCH="${WAZUH_IMAGE_VERSION}" + WAZUH_FILEBEAT_MODULE="wazuh-filebeat-${FILEBEAT_MODULE_VERSION}.tar.gz" + WAZUH_UI_REVISION="${WAZUH_TAG_REVISION}" + + if [ "${WAZUH_DEV_STAGE}" ];then + FILEBEAT_TEMPLATE_BRANCH="v${FILEBEAT_TEMPLATE_BRANCH}-${WAZUH_DEV_STAGE,,}" + if ! curl --output /dev/null --silent --head --fail "https://github.com/wazuh/wazuh/tree/${FILEBEAT_TEMPLATE_BRANCH}"; then + echo "The indicated branch does not exist in the wazuh/wazuh repository: ${FILEBEAT_TEMPLATE_BRANCH}" + clean 1 + fi + else + if curl --output /dev/null --silent --head --fail "https://github.com/wazuh/wazuh/tree/v${FILEBEAT_TEMPLATE_BRANCH}"; then + FILEBEAT_TEMPLATE_BRANCH="v${FILEBEAT_TEMPLATE_BRANCH}" + elif curl --output /dev/null --silent --head --fail "https://github.com/wazuh/wazuh/tree/${FILEBEAT_TEMPLATE_BRANCH}"; then + FILEBEAT_TEMPLATE_BRANCH="${FILEBEAT_TEMPLATE_BRANCH}" + else + WAZUH_MASTER_VERSION="$(curl -s https://raw.githubusercontent.com/wazuh/wazuh/master/src/VERSION | sed -e 's/v//g')" + if [ "${FILEBEAT_TEMPLATE_BRANCH}" == "${WAZUH_MASTER_VERSION}" ]; then + FILEBEAT_TEMPLATE_BRANCH="master" + else + echo "The indicated branch does not exist in the wazuh/wazuh repository: ${FILEBEAT_TEMPLATE_BRANCH}" + clean 1 + fi + fi + fi + + echo WAZUH_VERSION=$WAZUH_IMAGE_VERSION > .env + echo WAZUH_IMAGE_VERSION=$WAZUH_IMAGE_VERSION >> .env + echo WAZUH_TAG_REVISION=$WAZUH_TAG_REVISION >> .env + echo FILEBEAT_TEMPLATE_BRANCH=$FILEBEAT_TEMPLATE_BRANCH >> .env + echo WAZUH_FILEBEAT_MODULE=$WAZUH_FILEBEAT_MODULE >> .env + echo WAZUH_UI_REVISION=$WAZUH_UI_REVISION >> .env + + docker-compose -f build-docker-images/build-images.yml --env-file .env build --no-cache + + return 0 +} + +# ----------------------------------------------------------------------------- + +help() { + echo + echo "Usage: $0 [OPTIONS]" + echo + echo " -d, --dev [Optional] Set the development stage you want to build, example rc1 or beta1, not used by default." + echo " -f, --filebeat-module [Optional] Set Filebeat module version. By default ${FILEBEAT_MODULE_VERSION}." + echo " -r, --revision [Optional] Package revision. By default ${WAZUH_TAG_REVISION}" + echo " -v, --version [Optional] Set the Wazuh version should be builded. By default, ${WAZUH_IMAGE_VERSION}." + echo " -h, --help Show this help." + echo + exit $1 +} + +# ----------------------------------------------------------------------------- + +main() { + while [ -n "${1}" ] + do + case "${1}" in + "-h"|"--help") + help 0 + ;; + "-d"|"--dev") + if [ -n "${2}" ]; then + WAZUH_DEV_STAGE="${2}" + shift 2 + else + help 1 + fi + ;; + "-f"|"--filebeat-module") + if [ -n "${2}" ]; then + FILEBEAT_MODULE_VERSION="${2}" + shift 2 + else + help 1 + fi + ;; + "-r"|"--revision") + if [ -n "${2}" ]; then + WAZUH_TAG_REVISION="${2}" + shift 2 + else + help 1 + fi + ;; + "-v"|"--version") + if [ -n "$2" ]; then + WAZUH_IMAGE_VERSION="$2" + shift 2 + else + help 1 + fi + ;; + *) + help 1 + esac + done + + build || clean 1 + + clean 0 +} + +main "$@" diff --git a/build-docker-images/build-images.yml b/build-docker-images/build-images.yml index 52984bf9..90fbb897 100644 --- a/build-docker-images/build-images.yml +++ b/build-docker-images/build-images.yml @@ -8,6 +8,8 @@ services: args: WAZUH_VERSION: ${WAZUH_VERSION} WAZUH_TAG_REVISION: ${WAZUH_TAG_REVISION} + FILEBEAT_TEMPLATE_BRANCH: ${FILEBEAT_TEMPLATE_BRANCH} + WAZUH_FILEBEAT_MODULE: ${WAZUH_FILEBEAT_MODULE} image: wazuh/wazuh-manager:${WAZUH_IMAGE_VERSION} hostname: wazuh.manager restart: always @@ -61,6 +63,7 @@ services: args: WAZUH_VERSION: ${WAZUH_VERSION} WAZUH_TAG_REVISION: ${WAZUH_TAG_REVISION} + WAZUH_UI_REVISION: ${WAZUH_UI_REVISION} image: wazuh/wazuh-dashboard:${WAZUH_IMAGE_VERSION} hostname: wazuh.dashboard restart: always diff --git a/build-docker-images/wazuh-dashboard/Dockerfile b/build-docker-images/wazuh-dashboard/Dockerfile index e8263e6e..e47303ee 100644 --- a/build-docker-images/wazuh-dashboard/Dockerfile +++ b/build-docker-images/wazuh-dashboard/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:jammy AS builder ARG WAZUH_VERSION ARG WAZUH_TAG_REVISION ARG INSTALL_DIR=/usr/share/wazuh-dashboard -ARG WAZUH_UI_REVISION=1 +ARG WAZUH_UI_REVISION # Update and install dependencies RUN apt-get update && apt install curl libcap2-bin xz-utils -y @@ -104,6 +104,10 @@ RUN chown 1000:1000 /*.sh # Copy Install dir from builder to current image COPY --from=builder --chown=1000:1000 $INSTALL_DIR $INSTALL_DIR +# Create custom directory +RUN mkdir -p /usr/share/wazuh-dashboard/plugins/wazuh/public/assets/custom +RUN chown 1000:1000 /usr/share/wazuh-dashboard/plugins/wazuh/public/assets/custom + # Set workdir and user WORKDIR $INSTALL_DIR USER wazuh-dashboard diff --git a/build-docker-images/wazuh-indexer/config/config.sh b/build-docker-images/wazuh-indexer/config/config.sh index a01b761c..0b953fc5 100644 --- a/build-docker-images/wazuh-indexer/config/config.sh +++ b/build-docker-images/wazuh-indexer/config/config.sh @@ -133,6 +133,14 @@ cp -pr /wazuh-certificates/admin-key.pem ${TARGET_DIR}${CONFIG_DIR}/certs/admin- # Delete xms and xmx parameters in jvm.options sed '/-Xms/d' -i ${TARGET_DIR}${CONFIG_DIR}/jvm.options sed '/-Xmx/d' -i ${TARGET_DIR}${CONFIG_DIR}/jvm.options +sed -i 's/-Djava.security.policy=file:\/\/\/etc\/wazuh-indexer\/opensearch-performance-analyzer\/opensearch_security.policy/-Djava.security.policy=file:\/\/\/usr\/share\/wazuh-indexer\/opensearch-performance-analyzer\/opensearch_security.policy/g' ${TARGET_DIR}${CONFIG_DIR}/jvm.options + chmod -R 500 ${TARGET_DIR}${CONFIG_DIR}/certs -chmod -R 400 ${TARGET_DIR}${CONFIG_DIR}/certs/* \ No newline at end of file +chmod -R 400 ${TARGET_DIR}${CONFIG_DIR}/certs/* + +find ${TARGET_DIR} -type d -exec chmod 750 {} \; +find ${TARGET_DIR} -type f -perm 644 -exec chmod 640 {} \; +find ${TARGET_DIR} -type f -perm 664 -exec chmod 660 {} \; +find ${TARGET_DIR} -type f -perm 755 -exec chmod 750 {} \; +find ${TARGET_DIR} -type f -perm 744 -exec chmod 740 {} \; diff --git a/build-docker-images/wazuh-manager/Dockerfile b/build-docker-images/wazuh-manager/Dockerfile index d9cb9ab8..7bcd3455 100644 --- a/build-docker-images/wazuh-manager/Dockerfile +++ b/build-docker-images/wazuh-manager/Dockerfile @@ -8,7 +8,7 @@ ARG WAZUH_TAG_REVISION ARG TEMPLATE_VERSION=v4.8.0 ARG FILEBEAT_CHANNEL=filebeat-oss ARG FILEBEAT_VERSION=7.10.2 -ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.2.tar.gz" +ARG WAZUH_FILEBEAT_MODULE RUN apt-get update && apt install curl apt-transport-https lsb-release gnupg -y @@ -24,8 +24,6 @@ RUN curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/${FILEBEAT_ dpkg -i ${FILEBEAT_CHANNEL}-${FILEBEAT_VERSION}-amd64.deb && rm -f ${FILEBEAT_CHANNEL}-${FILEBEAT_VERSION}-amd64.deb && \ curl -s https://packages.wazuh.com/4.x/filebeat/${WAZUH_FILEBEAT_MODULE} | tar -xvz -C /usr/share/filebeat/module -RUN curl -L https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64 -o /usr/local/bin/goss && chmod +rx /usr/local/bin/goss - ARG S6_VERSION="v2.2.0.3" RUN curl --fail --silent -L https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz \ -o /tmp/s6-overlay-amd64.tar.gz && \ @@ -40,7 +38,7 @@ COPY config/filebeat.yml /etc/filebeat/ RUN chmod go-w /etc/filebeat/filebeat.yml -ADD https://raw.githubusercontent.com/wazuh/wazuh/$TEMPLATE_VERSION/extensions/elasticsearch/7.x/wazuh-template.json /etc/filebeat +ADD https://raw.githubusercontent.com/wazuh/wazuh/$FILEBEAT_TEMPLATE_BRANCH/extensions/elasticsearch/7.x/wazuh-template.json /etc/filebeat RUN chmod go-w /etc/filebeat/wazuh-template.json # Prepare permanent data diff --git a/build-docker-images/wazuh-manager/config/permanent_data.env b/build-docker-images/wazuh-manager/config/permanent_data.env index 0a3ebd35..5d797624 100644 --- a/build-docker-images/wazuh-manager/config/permanent_data.env +++ b/build-docker-images/wazuh-manager/config/permanent_data.env @@ -21,6 +21,8 @@ PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/slack" PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/slack.py" PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/virustotal" PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/virustotal.py" +PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/shuffle" +PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/shuffle.py" PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/default-firewall-drop" PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/disable-account" PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/firewalld-drop" diff --git a/multi-node/docker-compose.yml b/multi-node/docker-compose.yml index ec1f29f1..a72fd4f5 100644 --- a/multi-node/docker-compose.yml +++ b/multi-node/docker-compose.yml @@ -168,8 +168,9 @@ services: - ./config/wazuh_indexer_ssl_certs/wazuh.dashboard-key.pem:/usr/share/wazuh-dashboard/certs/wazuh-dashboard-key.pem - ./config/wazuh_indexer_ssl_certs/root-ca.pem:/usr/share/wazuh-dashboard/certs/root-ca.pem - ./config/wazuh_dashboard/opensearch_dashboards.yml:/usr/share/wazuh-dashboard/config/opensearch_dashboards.yml - - wazuh-dashboard-config:/usr/share/wazuh-dashboard/data/wazuh/config - ./config/wazuh_dashboard/wazuh.yml:/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml + - wazuh-dashboard-config:/usr/share/wazuh-dashboard/data/wazuh/config + - wazuh-dashboard-custom:/usr/share/wazuh-dashboard/plugins/wazuh/public/assets/custom depends_on: - wazuh1.indexer links: @@ -220,3 +221,4 @@ volumes: wazuh-indexer-data-2: wazuh-indexer-data-3: wazuh-dashboard-config: + wazuh-dashboard-custom: diff --git a/single-node/docker-compose.yml b/single-node/docker-compose.yml index df2348d7..45a8feb7 100644 --- a/single-node/docker-compose.yml +++ b/single-node/docker-compose.yml @@ -89,8 +89,9 @@ services: - ./config/wazuh_indexer_ssl_certs/wazuh.dashboard-key.pem:/usr/share/wazuh-dashboard/certs/wazuh-dashboard-key.pem - ./config/wazuh_indexer_ssl_certs/root-ca.pem:/usr/share/wazuh-dashboard/certs/root-ca.pem - ./config/wazuh_dashboard/opensearch_dashboards.yml:/usr/share/wazuh-dashboard/config/opensearch_dashboards.yml - - wazuh-dashboard-config:/usr/share/wazuh-dashboard/data/wazuh/config - ./config/wazuh_dashboard/wazuh.yml:/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml + - wazuh-dashboard-config:/usr/share/wazuh-dashboard/data/wazuh/config + - wazuh-dashboard-custom:/usr/share/wazuh-dashboard/plugins/wazuh/public/assets/custom depends_on: - wazuh.indexer links: @@ -111,3 +112,4 @@ volumes: filebeat_var: wazuh-indexer-data: wazuh-dashboard-config: + wazuh-dashboard-custom: