Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrates the reporting plugin into the construction process #340

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading