diff --git a/.github/workflows/build_wazuh_dashboard_with_plugins.yml b/.github/workflows/build_wazuh_dashboard_with_plugins.yml index 73a622a45e47..187b8858aa1b 100644 --- a/.github/workflows/build_wazuh_dashboard_with_plugins.yml +++ b/.github/workflows/build_wazuh_dashboard_with_plugins.yml @@ -35,6 +35,11 @@ on: description: 'Branch/tag/commit of the wazuh-dashboard-plugins repository to build the main plugins' required: true default: 'master' + reference_report_plugins: + type: string + description: 'Branch/tag/commit of the wazuh-dashboard-reporting repository to build the report plugin' + required: true + default: 'master' is_stage: type: boolean description: 'Set production nomenclature' @@ -72,6 +77,10 @@ on: type: string required: true default: 'master' + reference_report_plugins: + type: string + required: true + default: 'master' is_stage: type: boolean required: true @@ -103,26 +112,33 @@ jobs: build-base: needs: [validate-inputs] name: Build dashboard - uses: wazuh/wazuh-dashboard/.github/workflows/build_base.yml@4.10.0 + uses: wazuh/wazuh-dashboard/.github/workflows/build_base.yml@master with: CHECKOUT_TO: ${{ github.head_ref || github.ref_name }} build-main-plugins: needs: [validate-inputs] name: Build plugins - uses: wazuh/wazuh-dashboard-plugins/.github/workflows/manual-build.yml@4.10.0 + uses: wazuh/wazuh-dashboard-plugins/.github/workflows/manual-build.yml@master with: reference: ${{ inputs.reference_wazuh_plugins }} build-security-plugin: needs: [validate-inputs] name: Build security plugin - uses: wazuh/wazuh-security-dashboards-plugin/.github/workflows/manual-build.yml@4.10.0 + uses: wazuh/wazuh-security-dashboards-plugin/.github/workflows/manual-build.yml@master with: reference: ${{ inputs.reference_security_plugins }} + build-report-plugin: + needs: [validate-inputs] + name: Build reporting plugin + uses: wazuh/wazuh-dashboards-reporting/.github/workflows/manual-build.yml@master + with: + reference: ${{ inputs.reference_report_plugins }} + build-and-test-package: - needs: [build-main-plugins, build-base, build-security-plugin] + needs: [build-main-plugins, build-base, build-security-plugin, build-report-plugin] runs-on: ubuntu-latest name: Generate packages steps: @@ -150,6 +166,7 @@ jobs: echo "WAZUH_DASHBOARD_SLIM=wazuh-dashboard_${{ env.VERSION }}-${{ env.REVISION }}_x64.tar.gz" >> $GITHUB_ENV echo "WAZUH_SECURITY_PLUGIN=wazuh-security-dashboards-plugin_${{ env.VERSION }}-${{ env.REVISION }}_${{ inputs.reference_security_plugins }}.zip" >> $GITHUB_ENV echo "WAZUH_PLUGINS=wazuh-dashboard-plugins_${{ env.VERSION }}-${{ env.REVISION }}_${{ inputs.reference_wazuh_plugins }}.zip" >> $GITHUB_ENV + echo "WAZUH_REPORT_PLUGIN=reports-dashboards_${{ env.VERSION }}-${{ env.REVISION }}_${{ inputs.reference_report_plugins }}.zip" >> $GITHUB_ENV if [ "${{ inputs.system }}" = "deb" ]; then if [ "${{ inputs.is_stage }}" = "true" ]; then echo "PACKAGE_NAME=wazuh-dashboard_${{ env.VERSION }}-${{ inputs.revision }}_${{ inputs.architecture }}.deb" >> $GITHUB_ENV @@ -182,11 +199,18 @@ jobs: name: ${{ env.WAZUH_PLUGINS }} path: ${{ env.CURRENT_DIR }}/artifacts/plugins + - name: Download report plugin artifact + uses: actions/download-artifact@v3 + with: + name: ${{ env.WAZUH_REPORT_PLUGIN }} + path: ${{ env.CURRENT_DIR }}/artifacts/report-plugin + - name: Zip plugins run: | zip -r -j ${{ env.CURRENT_DIR }}/artifacts/wazuh-package.zip ${{ env.CURRENT_DIR }}/artifacts/plugins zip -r -j ${{ env.CURRENT_DIR }}/artifacts/security-package.zip ${{ env.CURRENT_DIR }}/artifacts/security-plugin zip -r -j ${{ env.CURRENT_DIR }}/artifacts/dashboard-package.zip ${{ env.CURRENT_DIR }}/artifacts/dashboard/${{ env.WAZUH_DASHBOARD_SLIM }} + zip -r -j ${{ env.CURRENT_DIR }}/artifacts/report-package.zip ${{ env.CURRENT_DIR }}/artifacts/report-plugin - name: Build package run: | @@ -197,6 +221,7 @@ jobs: -a file://${{env.CURRENT_DIR}}/artifacts/wazuh-package.zip \ -s file://${{env.CURRENT_DIR}}/artifacts/security-package.zip \ -b file://${{env.CURRENT_DIR}}/artifacts/dashboard-package.zip \ + -rp file://${{env.CURRENT_DIR}}/artifacts/report-package.zip \ --${{ inputs.system }} ${{ env.PRODUCTION }} - name: Test package diff --git a/CHANGELOG.md b/CHANGELOG.md index 50cbe451ff52..c4c8e55f3423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to the Wazuh app project will be documented in this file. ## Wazuh dashboard v5.0.0 - OpenSearch Dashboards 2.16.0 - Revision 00 +### Changed + +- Changed the reportingDashboards platform plugin to a customized one and adapt the build tools [#340](https://github.com/wazuh/wazuh-dashboard/pull/340) + ## Wazuh dashboard v4.10.0 - OpenSearch Dashboards 2.16.0 - Revision 00 ### Removed diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index ad59dc776bbb..855660b7ce1e 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -16,6 +16,7 @@ base="" revision="1" security="" version="" +reportPlugin="" # Paths current_path="$( cd $(dirname $0) ; pwd -P )" @@ -116,6 +117,24 @@ build() { clean 1 fi + echo + echo "Downloading report plugin.." + echo + + if [[ $reportPlugin =~ $valid_url ]]; then + if ! curl --output applications/reporting.zip --silent --fail "${reportPlugin}"; then + echo "The given URL or Path to the Wazuh Reporting Plugin is not working: ${reportPlugin}" + clean 1 + else + echo "Extracting Reporting application" + unzip -q applications/reporting.zip -d applications + rm applications/reporting.zip + fi + else + echo "The given URL or Path to the Wazuh Reporting Plugin is not valid: ${reportPlugin}" + clean 1 + fi + tar -zxf wazuh-dashboard.tar.gz directory_name=$(ls -td */ | head -1) working_dir="wazuh-dashboard-$version-$revision-linux-x64" @@ -126,7 +145,7 @@ build() { echo Building the package... echo - # Install Wazuh apps and Security app + # Install Wazuh apps, Reporting app and Security app plugins=$(ls $tmp_dir/applications)' '$(cat $current_path/plugins) for plugin in $plugins; do @@ -150,9 +169,6 @@ build() { category_explore='{id:"explore",label:"Explore",order:100,euiIconType:"search"}' category_dashboard_management='{id:"management",label:"Index management",order:5e3,euiIconType:"managementApp"}' - # Replace app category to Reporting app - sed -i -e "s|category:{id:\"opensearch\",label:_i18n.i18n.translate(\"opensearch.reports.categoryName\",{defaultMessage:\"OpenSearch Plugins\"}),order:2e3}|category:${category_explore}|" ./plugins/reportsDashboards/target/public/reportsDashboards.plugin.js - # Replace app category to Alerting app sed -i -e "s|category:{id:\"opensearch\",label:\"OpenSearch Plugins\",order:2e3}|category:${category_explore}|" ./plugins/alertingDashboards/target/public/alertingDashboards.plugin.js @@ -167,7 +183,6 @@ build() { # Generate compressed files files_to_recreate=( - ./plugins/reportsDashboards/target/public/reportsDashboards.plugin.js ./plugins/alertingDashboards/target/public/alertingDashboards.plugin.js ./plugins/customImportMapDashboards/target/public/customImportMapDashboards.plugin.js ./plugins/notificationsDashboards/target/public/notificationsDashboards.plugin.js @@ -253,6 +268,14 @@ main() { help 0 fi ;; + "-rp" | "--reportPlugin") + if [ -n "${2}" ]; then + reportPlugin="${2}" + shift 2 + else + help 0 + fi + ;; "-v" | "--version") if [ -n "${2}" ]; then version="${2}" diff --git a/dev-tools/build-packages/base/plugins b/dev-tools/build-packages/base/plugins index 6a31dc91f76b..ccb3cc3ec1cb 100644 --- a/dev-tools/build-packages/base/plugins +++ b/dev-tools/build-packages/base/plugins @@ -3,4 +3,3 @@ customImportMapDashboards ganttChartDashboards indexManagementDashboards notificationsDashboards -reportsDashboards diff --git a/dev-tools/build-packages/build-packages.sh b/dev-tools/build-packages/build-packages.sh index bf2d93f22dc3..662b59ad723d 100755 --- a/dev-tools/build-packages/build-packages.sh +++ b/dev-tools/build-packages/build-packages.sh @@ -5,6 +5,7 @@ base="" revision="1" security="" version="" +reportPlugin="" all_platforms="no" deb="no" rpm="no" @@ -16,7 +17,7 @@ current_path="$( cd $(dirname $0) ; pwd -P )" build_tar() { echo "Building tar package..." cd ./base - bash ./generate_base.sh -a $app -b $base -s $security -v $version -r $revision + bash ./generate_base.sh -a $app -b $base -s $security -rp $reportPlugin -v $version -r $revision name_package_tar=$(ls ./output) @@ -130,6 +131,14 @@ main() { help 0 fi ;; + "-rp" | "--reportPlugin") + if [ -n "${2}" ]; then + reportPlugin="${2}" + shift 2 + else + help 0 + fi + ;; "-v" | "--version") if [ -n "${2}" ]; then version="${2}" diff --git a/dev-tools/build-packages/config-dockerfile/entrypoint.sh b/dev-tools/build-packages/config-dockerfile/entrypoint.sh new file mode 100644 index 000000000000..76a7585d83a0 --- /dev/null +++ b/dev-tools/build-packages/config-dockerfile/entrypoint.sh @@ -0,0 +1,58 @@ +#!/bin/bash +set -e + +# Clone wazuh-dashboard +git clone --depth 1 --branch ${WAZUH_DASHBOARDS_BRANCH} https://github.com/wazuh/wazuh-dashboard.git /home/node/wzd +chown node.node /home/node/wzd + +## Install dependencies and build wazuh-dashboard + +cd /home/node/wzd +yarn osd bootstrap --production +yarn build --linux --skip-os-packages --release + +# Clone plugins +cd /home/node/wzd/plugins +git clone --depth 1 --branch ${WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH} https://github.com/wazuh/wazuh-security-dashboards-plugin.git +git clone --depth 1 --branch ${WAZUH_DASHBOARDS_PLUGINS} https://github.com/wazuh/wazuh-dashboard-plugins.git +git clone --depth 1 --branch ${WAZUH_DASHBOARDS_REPORTING_BRANCH} https://github.com/wazuh/wazuh-dashboards-reporting.git + +# Build wazuh-security-dashboards-plugin +cd /home/node/wzd/plugins/wazuh-security-dashboards-plugin +yarn +yarn build + +# Build wazuh-dashboards-reporting +cd /home/node/wzd/plugins/wazuh-dashboards-reporting +yarn +yarn build + +# Move plugins +cd /home/node/wzd/plugins +mv ./wazuh-dashboard-plugins/plugins/main ./wazuh +mv ./wazuh-dashboard-plugins/plugins/wazuh-core ./wazuh-core +mv ./wazuh-dashboard-plugins/plugins/wazuh-check-updates ./wazuh-check-updates + +# Build plugins +cd /home/node/wzd/plugins/wazuh +yarn +yarn build + +cd /home/node/wzd/plugins/wazuh-core +yarn +yarn build + +cd /home/node/wzd/plugins/wazuh-check-updates +yarn +yarn build + +# Zip packages +cd /home/node/ +mkdir packages +cd /home/node/packages +zip -r -j ./dashboard-package.zip ../wzd/target/opensearch-dashboards-${OPENSEARCH_DASHBOARDS_VERSION}-linux-x64.tar.gz +zip -r -j ./security-package.zip ../wzd/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-${OPENSEARCH_DASHBOARDS_VERSION}.0.zip +zip -r -j ./wazuh-package.zip ../wzd/plugins/wazuh-check-updates/build/wazuhCheckUpdates-${OPENSEARCH_DASHBOARDS_VERSION}.zip ../wzd/plugins/wazuh/build/wazuh-${OPENSEARCH_DASHBOARDS_VERSION}.zip ../wzd/plugins/wazuh-core/build/wazuhCore-${OPENSEARCH_DASHBOARDS_VERSION}.zip +zip -r -j ./reporting-package.zip ../wzd/plugins/wazuh-dashboards-reporting/build/reportsDashboards-${OPENSEARCH_DASHBOARDS_VERSION}.zip + +exec "$@" diff --git a/dev-tools/build-packages/wazuh-dashboard.Dockerfile b/dev-tools/build-packages/wazuh-dashboard.Dockerfile index 38406e41ad62..48c0ef50d95e 100644 --- a/dev-tools/build-packages/wazuh-dashboard.Dockerfile +++ b/dev-tools/build-packages/wazuh-dashboard.Dockerfile @@ -1,4 +1,4 @@ -# Usage: docker build --build-arg NODE_VERSION=18.19.0 --build-arg WAZUH_DASHBOARDS_BRANCH=4.10.0 --build-arg WAZUH_DASHBOARDS_PLUGINS=4.10.0 --build-arg WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH=4.10.0 --build-arg OPENSEARCH_DASHBOARDS_VERSION=2.13.0 -t wzd:4.10.0 -f wazuh-dashboard.Dockerfile . +# Usage: docker build --build-arg NODE_VERSION=18.19.0 --build-arg WAZUH_DASHBOARDS_BRANCH=4.10.0 --build-arg WAZUH_DASHBOARDS_REPORTING_BRANCH=4.10.0 --build-arg WAZUH_DASHBOARDS_PLUGINS=4.10.0 --build-arg WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH=4.10.0 --build-arg OPENSEARCH_DASHBOARDS_VERSION=2.13.0 -t wzd:4.10.0 -f wazuh-dashboard.Dockerfile . ARG NODE_VERSION FROM node:${NODE_VERSION} AS base @@ -6,45 +6,19 @@ ARG OPENSEARCH_DASHBOARDS_VERSION ARG WAZUH_DASHBOARDS_BRANCH ARG WAZUH_DASHBOARDS_PLUGINS ARG WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH +ARG WAZUH_DASHBOARDS_REPORTING_BRANCH ENV OPENSEARCH_DASHBOARDS_VERSION=${OPENSEARCH_DASHBOARDS_VERSION} USER root RUN apt-get update && apt-get install -y git zip unzip curl brotli jq USER node -RUN git clone --depth 1 --branch ${WAZUH_DASHBOARDS_BRANCH} https://github.com/wazuh/wazuh-dashboard.git /home/node/wzd -RUN chown node.node /home/node/wzd -WORKDIR /home/node/wzd -RUN yarn osd bootstrap --production -RUN yarn build --linux --skip-os-packages --release +COPY ./config-dockerfile/entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] +RUN bash /entrypoint.sh -WORKDIR /home/node/wzd/plugins -RUN git clone --depth 1 --branch ${WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH} https://github.com/wazuh/wazuh-security-dashboards-plugin.git -RUN git clone --depth 1 --branch ${WAZUH_DASHBOARDS_PLUGINS} https://github.com/wazuh/wazuh-dashboard-plugins.git -WORKDIR /home/node/wzd/plugins/wazuh-security-dashboards-plugin -RUN yarn -RUN yarn build -WORKDIR /home/node/wzd/plugins -RUN mv ./wazuh-dashboard-plugins/plugins/main ./wazuh -RUN mv ./wazuh-dashboard-plugins/plugins/wazuh-core ./wazuh-core -RUN mv ./wazuh-dashboard-plugins/plugins/wazuh-check-updates ./wazuh-check-updates -WORKDIR /home/node/wzd/plugins/wazuh -RUN yarn -RUN yarn build -WORKDIR /home/node/wzd/plugins/wazuh-core -RUN yarn -RUN yarn build -WORKDIR /home/node/wzd/plugins/wazuh-check-updates -RUN yarn -RUN yarn build -WORKDIR /home/node/ -RUN mkdir packages -WORKDIR /home/node/packages -RUN zip -r -j ./dashboard-package.zip ../wzd/target/opensearch-dashboards-${OPENSEARCH_DASHBOARDS_VERSION}-linux-x64.tar.gz -RUN zip -r -j ./security-package.zip ../wzd/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-${OPENSEARCH_DASHBOARDS_VERSION}.0.zip -RUN zip -r -j ./wazuh-package.zip ../wzd/plugins/wazuh-check-updates/build/wazuhCheckUpdates-${OPENSEARCH_DASHBOARDS_VERSION}.zip ../wzd/plugins/wazuh/build/wazuh-${OPENSEARCH_DASHBOARDS_VERSION}.zip ../wzd/plugins/wazuh-core/build/wazuhCore-${OPENSEARCH_DASHBOARDS_VERSION}.zip WORKDIR /home/node/wzd/dev-tools/build-packages/base -RUN ./generate_base.sh -v 4.10.0 -r 1 -a file:///home/node/packages/wazuh-package.zip -s file:///home/node/packages/security-package.zip -b file:///home/node/packages/dashboard-package.zip +RUN ./generate_base.sh -v 4.10.0 -r 1 -a file:///home/node/packages/wazuh-package.zip -s file:///home/node/packages/security-package.zip -b file:///home/node/packages/dashboard-package.zip -rp file:///home/node/packages/reporting-package.zip WORKDIR /home/node/wzd/dev-tools/build-packages/base/output RUN cp ./* /home/node/packages/