Skip to content

Commit

Permalink
Integrates the reporting plugin into the construction process (#340)
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio <[email protected]>
Co-authored-by: Antonio <[email protected]>
  • Loading branch information
yenienserrano and Desvelao committed Oct 28, 2024
1 parent ad42837 commit 0800bee
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 43 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/build_wazuh_dashboard_with_plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 28 additions & 5 deletions dev-tools/build-packages/base/generate_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ base=""
revision="1"
security=""
version=""
reportPlugin=""

# Paths
current_path="$( cd $(dirname $0) ; pwd -P )"
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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}"
Expand Down
1 change: 0 additions & 1 deletion dev-tools/build-packages/base/plugins
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ customImportMapDashboards
ganttChartDashboards
indexManagementDashboards
notificationsDashboards
reportsDashboards
11 changes: 10 additions & 1 deletion dev-tools/build-packages/build-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ base=""
revision="1"
security=""
version=""
reportPlugin=""
all_platforms="no"
deb="no"
rpm="no"
Expand All @@ -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)

Expand Down Expand Up @@ -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}"
Expand Down
58 changes: 58 additions & 0 deletions dev-tools/build-packages/config-dockerfile/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
38 changes: 6 additions & 32 deletions dev-tools/build-packages/wazuh-dashboard.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,24 @@
# 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
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/

Expand Down

0 comments on commit 0800bee

Please sign in to comment.