From b9e79f199334e62ce94ba9d8c8834098f5446bb6 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Thu, 3 Oct 2024 16:22:32 +0200 Subject: [PATCH] Update build_wazuh_dashboard_with_plugins.yml to support building the reporting plugin --- .../build_wazuh_dashboard_with_plugins.yml | 33 ++++++++++++++++--- .../build-packages/base/generate_base.sh | 33 ++++++++++++++++--- dev-tools/build-packages/base/plugins | 1 - dev-tools/build-packages/build-packages.sh | 11 ++++++- 4 files changed, 67 insertions(+), 11 deletions(-) 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/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}"