Skip to content

Commit

Permalink
Merge branch '4.9.0' into 120-update-github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
yenienserrano authored Dec 5, 2023
2 parents f45a8d7 + 1047ad5 commit c0455fe
Show file tree
Hide file tree
Showing 26 changed files with 254 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.aws-config.json
.signing-config.json
.ackrc
/dev_tools/build_packages/*/output
/dev-tools/build-packages/*/output
/.opensearch
/.chromium
/package.json.bak
Expand Down
2 changes: 1 addition & 1 deletion config/opensearch_dashboards.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ server.ssl.enabled: true
server.ssl.key: "/etc/wazuh-dashboard/certs/dashboard-key.pem"
server.ssl.certificate: "/etc/wazuh-dashboard/certs/dashboard.pem"
opensearch.ssl.certificateAuthorities: ["/etc/wazuh-dashboard/certs/root-ca.pem"]
uiSettings.overrides.defaultRoute: /app/wazuh
uiSettings.overrides.defaultRoute: /app/wz-home

opensearchDashboards.branding:
useExpandedHeader: false
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,63 @@ build() {
# Validate and download files to build the package
valid_url='(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]'
echo
echo "Downloading files..."
echo "Downloading plugins..."
echo
mkdir -p $tmp_dir
cd $tmp_dir
mkdir -p applications
if [[ $app =~ $valid_url ]]; then
if ! curl --output app.zip --silent --fail "${app}"; then
echo "The given URL or Path to the Wazuh App is not working: ${app}"
if ! curl --output applications/app.zip --silent --fail "${app}"; then
echo "The given URL or Path to the Wazuh Apps is not working: ${app}"
clean 1
else
echo "Extracting applications from app.zip"
unzip -q applications/app.zip -d applications
rm applications/app.zip
fi
else
echo "The given URL or Path to the Wazuh App is not valid: ${app}"
clean 1
fi

echo
echo "Downloading dashboards..."
echo

if [[ $base =~ $valid_url ]]; then
if ! curl --output wazuh-dashboard.tar.gz --silent --fail "${base}"; then
echo "The given URL or Path to the Wazuh Dashboard base is not working: ${base}"
clean 1
if [[ $base =~ .*\.zip ]]; then
if ! curl --output wazuh-dashboard.zip --silent --fail "${base}"; then
echo "The given URL or Path to the Wazuh Dashboard base is not working: ${base}"
clean 1
else
echo "Extracting Wazuh Dashboard base"
unzip -q wazuh-dashboard.zip -d .
rm wazuh-dashboard.zip
mv $(ls | grep wazuh-dashboard) wazuh-dashboard.tar.gz
fi
else
if ! curl --output wazuh-dashboard.tar.gz --silent --fail "${base}"; then
echo "The given URL or Path to the Wazuh Dashboard base is not working: ${base}"
clean 1
fi
fi
else
echo "The given URL or Path to the Wazuh Dashboard base is not valid: ${base}"
clean 1
fi

echo
echo "Downloading security plugin..."
echo

if [[ $security =~ $valid_url ]]; then
if ! curl --output security.zip --silent --fail "${security}"; then
if ! curl --output applications/security.zip --silent --fail "${security}"; then
echo "The given URL or Path to the Wazuh Security Plugin is not working: ${security}"
clean 1
else
echo "Extracting Security application"
unzip -q applications/security.zip -d applications
rm applications/security.zip
fi
else
echo "The given URL or Path to the Wazuh Security Plugin is not valid: ${security}"
Expand All @@ -104,8 +133,15 @@ build() {
bin/opensearch-dashboards-plugin install indexManagementDashboards
bin/opensearch-dashboards-plugin install notificationsDashboards
bin/opensearch-dashboards-plugin install reportsDashboards
bin/opensearch-dashboards-plugin install file:../security.zip
bin/opensearch-dashboards-plugin install file:../app.zip
# Install Wazuh apps and Security app
plugins=$(ls $tmp_dir/applications)
echo $plugins
for plugin in $plugins; do
echo $plugin
if [[ $plugin =~ .*\.zip ]]; then
bin/opensearch-dashboards-plugin install file:../applications/$plugin
fi
done

# Enable the default configuration (renaming)
cp $config_path/opensearch_dashboards.prod.yml config/opensearch_dashboards.yml
Expand All @@ -121,8 +157,10 @@ build() {
echo Compressing the package...
echo
cd ..
mkdir -p $out_dir
tar -czvf $out_dir/$working_dir.tar.gz $working_dir
if [ ! -d "$out_dir" ]; then
mkdir -p $out_dir
fi
tar -czf $out_dir/$working_dir.tar.gz $working_dir

echo
echo DONE!
Expand Down
191 changes: 191 additions & 0 deletions dev-tools/build-packages/build-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
#!/bin/bash

app=""
base=""
revision="1"
security=""
version=""
all_platforms="no"
deb="no"
rpm="no"
tar="no"
output="$( cd $(dirname $0) ; pwd -P )/output"

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

name_package_tar=$(ls ./output)

echo "Moving tar package to $output"
mv $current_path/base/output/$name_package_tar $output/$name_package_tar
cd ../
}

build_deb() {
echo "Building deb package..."
name_package_tar=$(find $output -name "*.tar.gz")
cd ./deb
bash ./launcher.sh -v $version -r $revision -p file://$name_package_tar
name_package_tar=$(ls ./output)
echo "Moving deb package to $output/deb"
mv $current_path/deb/output $output/deb
cd ../
}

build_rpm() {
echo "Building rpm package..."
name_package_tar=$(find $output -name "*.tar.gz")
cd ./rpm
bash ./launcher.sh -v $version -r $revision -p file://$name_package_tar
echo "Moving rpm package to $output/rpm"
mv $current_path/rpm/output $output/rpm
cd ../
}


build() {
name_package_tar="wazuh-dashboard-$version-$revision-linux-x64.tar.gz"

if [ ! -d "$output" ]; then
mkdir $output
fi

if [ "$all_platforms" == "yes" ]; then
deb="yes"
rpm="yes"
tar="yes"
fi

build_tar
cd $current_path

if [ $deb == "yes" ]; then
echo "Building deb package..."
build_deb
fi

if [ $rpm == "yes" ]; then
echo "Building rpm package..."
build_rpm
fi

if [ "$tar" == "no" ]; then
echo "Removing tar package..."
rm -r $(find $output -name "*.tar.gz")
fi
}

help() {
echo
echo "Usage: $0 [OPTIONS]"
echo " -a, --app <url/path> Set the location of the .zip file containing the Wazuh plugin."
echo " -b, --base <url/path> Set the location of the .tar.gz file containing the base wazuh-dashboard build."
echo " -s, --security <url/path> Set the location of the .zip file containing the wazuh-security-dashboards-plugin."
echo " -v, --version <version> Set the version of this build."
echo " --all-platforms Build for all platforms."
echo " --deb Build for deb."
echo " --rpm Build for rpm."
echo " --tar Build for tar."
echo " -r, --revision <revision> [Optional] Set the revision of this build. By default, it is set to 1."
echo " -o, --output <path> [Optional] Set the destination path of package. By default, an output folder will be created."
echo " -h, --help Show this help."
echo
exit $1
}

# -----------------------------------------------------------------------------

main() {
while [ -n "${1}" ]; do
case "${1}" in
"-h" | "--help")
help 0
;;
"-a" | "--app")
if [ -n "$2" ]; then
app="$2"
shift 2
else
help 1
fi
;;
"-s" | "--security")
if [ -n "${2}" ]; then
security="${2}"
shift 2
else
help 0
fi
;;
"-b" | "--base")
if [ -n "${2}" ]; then
base="${2}"
shift 2
else
help 0
fi
;;
"-v" | "--version")
if [ -n "${2}" ]; then
version="${2}"
shift 2
else
help 0
fi
;;
"-r" | "--revision")
if [ -n "${2}" ]; then
revision="${2}"
shift 2
fi
;;
"--all-platforms")
all_platforms="yes"
shift 1
;;
"--deb")
deb="yes"
shift 1
;;
"--rpm")
rpm="yes"
shift 1
;;
"--tar")
tar="yes"
shift 1
;;
"-o" | "--output")
if [ -n "${2}" ]; then
output="${2}"
shift 2
fi
;;
*)
echo "help"

help 1
;;
esac
done

if [ -z "$app" ] | [ -z "$base" ] | [ -z "$security" ] | [ -z "$version" ]; then
echo "You must specify the app, base, security and version."
help 1
fi

if [ "$all_platforms" == "no" ] && [ "$deb" == "no" ] && [ "$rpm" == "no" ] && [ "$tar" == "no" ]; then
echo "You must specify at least one package to build."
help 1
fi

build || exit 1

exit 0
}

main "$@"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ deb_file="${target}_${version}-${revision}_${architecture}.deb"
mkdir -p ${source_dir}/debian

# Including spec file
cp -r /root/build_packages/deb/debian/* ${source_dir}/debian/
cp -r /root/build-packages/deb/debian/* ${source_dir}/debian/

# Generating directory structure to build the .deb package
cd ${build_dir}/${target} && tar -czf ${pkg_name}.orig.tar.gz "${pkg_name}"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ build_deb() {
fi

# Build the Debian package with a Docker container
mkdir -p $out_dir
if [ ! -d "$out_dir" ]; then
mkdir -p $out_dir
fi
volumes="-v ${out_dir}/:/tmp:Z -v ${tmp_dir}/wazuh-dashboard.tar.gz:/opt/wazuh-dashboard.tar.gz"
docker run -t --rm ${volumes} \
-v ${current_path}/../..:/root:Z \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mkdir -p ${rpm_build_dir}/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
mkdir ${build_dir}/${pkg_name}

# Including spec file
cp /root/build_packages/rpm/${target}.spec ${rpm_build_dir}/SPECS/${pkg_name}.spec
cp /root/build-packages/rpm/${target}.spec ${rpm_build_dir}/SPECS/${pkg_name}.spec

# Generating source tar.gz
cd ${build_dir} && tar czf "${rpm_build_dir}/SOURCES/${pkg_name}.tar.gz" "${pkg_name}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ build_rpm() {
fi

# Build the RPM package with a Docker container
mkdir -p $out_dir

if [ ! -d "$out_dir" ]; then
mkdir -p $out_dir
fi
volumes="-v ${out_dir}/:/tmp:Z -v ${tmp_dir}/wazuh-dashboard.tar.gz:/opt/wazuh-dashboard.tar.gz"
docker run -t --rm ${volumes} \
-v ${current_path}/../..:/root:Z \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ rm -fr %{buildroot}
%attr(640, %{USER}, %{GROUP}) "%{INSTALL_DIR}/LICENSE.txt"
%attr(640, %{USER}, %{GROUP}) "%{INSTALL_DIR}/NOTICE.txt"
%attr(640, %{USER}, %{GROUP}) "%{INSTALL_DIR}/README.txt"
%attr(750, %{USER}, %{GROUP}) "%{INSTALL_DIR}/bin/use_node"
%attr(750, %{USER}, %{GROUP}) "%{INSTALL_DIR}/bin/opensearch-dashboards"
%attr(750, %{USER}, %{GROUP}) "%{INSTALL_DIR}/bin/opensearch-dashboards-plugin"
%attr(750, %{USER}, %{GROUP}) "%{INSTALL_DIR}/bin/opensearch-dashboards-keystore"
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/dev/precommit_hook/casing_check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const IGNORE_FILE_GLOBS = [
'packages/opensearch-safer-lodash-set/**/*',

// TODO fix file names in APM to remove these

'dev-tools/**/*',
// packages for the ingest manager's api integration tests could be valid semver which has dashes
];

Expand Down Expand Up @@ -102,6 +102,7 @@ export const IGNORE_DIRECTORY_GLOBS = [
'test/functional/fixtures/opensearch_archiver/visualize_source-filters',
'packages/osd-pm/src/utils/__fixtures__/*',
'src/dev/build/tasks/__fixtures__/*',
'dev-tools/*',
];

/**
Expand Down

0 comments on commit c0455fe

Please sign in to comment.