From d8b186aa52e77ea0de36716ba3b165dd5bc59346 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 18 Aug 2020 16:29:55 +0200
Subject: [PATCH 01/50] Add wazuh image using filebeat-oss
---
wazuh-opendistro/Dockerfile | 59 +++++
.../config/etc/cont-init.d/0-wazuh-init | 232 ++++++++++++++++++
.../config/etc/cont-init.d/1-config-filebeat | 29 +++
.../config/etc/cont-init.d/2-manager | 3 +
.../config/etc/services.d/api/finish | 6 +
.../config/etc/services.d/api/run | 4 +
.../config/etc/services.d/filebeat/finish | 6 +
.../config/etc/services.d/filebeat/run | 4 +
wazuh-opendistro/config/filebeat.yml | 21 ++
wazuh-opendistro/config/permanent_data.env | 74 ++++++
wazuh-opendistro/config/permanent_data.sh | 40 +++
wazuh-opendistro/config/wazuh.repo | 7 +
12 files changed, 485 insertions(+)
create mode 100644 wazuh-opendistro/Dockerfile
create mode 100644 wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init
create mode 100644 wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
create mode 100644 wazuh-opendistro/config/etc/cont-init.d/2-manager
create mode 100644 wazuh-opendistro/config/etc/services.d/api/finish
create mode 100644 wazuh-opendistro/config/etc/services.d/api/run
create mode 100644 wazuh-opendistro/config/etc/services.d/filebeat/finish
create mode 100644 wazuh-opendistro/config/etc/services.d/filebeat/run
create mode 100644 wazuh-opendistro/config/filebeat.yml
create mode 100644 wazuh-opendistro/config/permanent_data.env
create mode 100644 wazuh-opendistro/config/permanent_data.sh
create mode 100644 wazuh-opendistro/config/wazuh.repo
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
new file mode 100644
index 00000000..1add03c0
--- /dev/null
+++ b/wazuh-opendistro/Dockerfile
@@ -0,0 +1,59 @@
+# Wazuh Docker Copyright (C) 2020 Wazuh Inc. (License GPLv2)
+FROM centos:7
+
+ARG FILEBEAT_VERSION=7.8.0
+ARG WAZUH_VERSION=3.13.1-1
+ARG TEMPLATE_VERSION="v3.13.1"
+ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.1.tar.gz"
+
+ENV API_USER="foo" \
+ API_PASS="bar"
+
+
+# Set repositories.
+RUN rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
+
+COPY config/wazuh.repo /etc/yum.repos.d/wazuh.repo
+
+RUN yum --enablerepo=updates clean metadata && \
+ yum -y install openssl which && yum -y install wazuh-manager-${WAZUH_VERSION} -y && \
+ curl --silent --location https://rpm.nodesource.com/setup_10.x | bash - && \
+ yum -y install nodejs && yum -y install wazuh-api-${WAZUH_VERSION} && \
+ sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo && \
+ yum clean all && rm -rf /var/cache/yum
+
+RUN curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm &&\
+ rpm -i filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm && rm -f filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm
+
+RUN curl -so /etc/filebeat/wazuh-template.json https://raw.githubusercontent.com/wazuh/wazuh/${TEMPLATE_VERSION}/extensions/elasticsearch/7.x/wazuh-template.json &&\
+ chmod go+r /etc/filebeat/wazuh-template.json
+
+RUN curl -s https://packages.wazuh.com/3.x/filebeat/${WAZUH_FILEBEAT_MODULE} | tar -xvz -C /usr/share/filebeat/module
+
+ARG S6_VERSION="v2.0.0.1"
+RUN curl --fail --silent -L https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz \
+ -o /tmp/s6-overlay-amd64.tar.gz && \
+ tar xzf /tmp/s6-overlay-amd64.tar.gz -C / --exclude="./bin" && \
+ tar xzf /tmp/s6-overlay-amd64.tar.gz -C /usr ./bin && \
+ rm /tmp/s6-overlay-amd64.tar.gz
+
+COPY config/filebeat.yml /etc/filebeat/
+
+RUN chmod go-w /etc/filebeat/filebeat.yml
+
+ADD https://raw.githubusercontent.com/wazuh/wazuh/$TEMPLATE_VERSION/extensions/elasticsearch/7.x/wazuh-template.json /etc/filebeat
+RUN chmod go-w /etc/filebeat/wazuh-template.json
+
+COPY config/etc/ /etc/
+
+# Prepare permanent data
+# Sync calls are due to https://github.com/docker/docker/issues/9547
+COPY config/permanent_data.env config/permanent_data.sh /
+RUN chmod 755 /permanent_data.sh && \
+ sync && /permanent_data.sh && \
+ sync && rm /permanent_data.sh
+
+# Services ports
+EXPOSE 55000/tcp 1514/udp 1515/tcp 514/udp 1516/tcp
+
+ENTRYPOINT [ "/init" ]
diff --git a/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init
new file mode 100644
index 00000000..b0cbd001
--- /dev/null
+++ b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init
@@ -0,0 +1,232 @@
+#!/usr/bin/with-contenv bash
+# Wazuh App Copyright (C) 2020 Wazuh Inc. (License GPLv2)
+
+# Variables
+source /permanent_data.env
+
+WAZUH_INSTALL_PATH=/var/ossec
+WAZUH_CONFIG_MOUNT=/wazuh-config-mount
+AUTO_ENROLLMENT_ENABLED=${AUTO_ENROLLMENT_ENABLED:-true}
+API_GENERATE_CERTS=${API_GENERATE_CERTS:-true}
+
+
+##############################################################################
+# Aux functions
+##############################################################################
+print() {
+ echo -e $1
+}
+
+error_and_exit() {
+ echo "Error executing command: '$1'."
+ echo 'Exiting.'
+ exit 1
+}
+
+exec_cmd() {
+ eval $1 > /dev/null 2>&1 || error_and_exit "$1"
+}
+
+exec_cmd_stdout() {
+ eval $1 2>&1 || error_and_exit "$1"
+}
+
+
+##############################################################################
+# Edit configuration
+##############################################################################
+
+edit_configuration() { # $1 -> setting, $2 -> value
+ sed -i "s/^config.$1\s=.*/config.$1 = \"$2\";/g" "${WAZUH_INSTALL_PATH}/api/configuration/config.js" || error_and_exit "sed (editing configuration)"
+}
+
+##############################################################################
+# This function will attempt to mount every directory in PERMANENT_DATA
+# into the respective path.
+# If the path is empty means permanent data volume is also empty, so a backup
+# will be copied into it. Otherwise it will not be copied because there is
+# already data inside the volume for the specified path.
+##############################################################################
+
+mount_permanent_data() {
+ for permanent_dir in "${PERMANENT_DATA[@]}"; do
+ # Check if the path is not empty
+ if find ${permanent_dir} -mindepth 1 | read; then
+ print "The path ${permanent_dir} is already mounted"
+ else
+ print "Installing ${permanent_dir}"
+ exec_cmd "cp -a ${WAZUH_INSTALL_PATH}/data_tmp/permanent${permanent_dir}/. ${permanent_dir}"
+ fi
+ done
+}
+
+##############################################################################
+# This function will replace from the permanent data volume every file
+# contained in PERMANENT_DATA_EXCP
+# Some files as 'internal_options.conf' are saved as permanent data, but
+# they must be updated to work properly if wazuh version is changed.
+##############################################################################
+
+apply_exclusion_data() {
+ for exclusion_file in "${PERMANENT_DATA_EXCP[@]}"; do
+ if [ -e ${WAZUH_INSTALL_PATH}/data_tmp/exclusion/${exclusion_file} ]
+ then
+ DIR=$(dirname "${exclusion_file}")
+ if [ ! -e ${DIR} ]
+ then
+ mkdir -p ${DIR}
+ fi
+
+ print "Updating ${exclusion_file}"
+ exec_cmd "cp -p ${WAZUH_INSTALL_PATH}/data_tmp/exclusion/${exclusion_file} ${exclusion_file}"
+ fi
+ done
+}
+
+##############################################################################
+# This function will delete from the permanent data volume every file
+# contained in PERMANENT_DATA_DEL
+##############################################################################
+
+remove_data_files() {
+ for del_file in "${PERMANENT_DATA_DEL[@]}"; do
+ if [ -e ${del_file} ]
+ then
+ print "Removing ${del_file}"
+ exec_cmd "rm ${del_file}"
+ fi
+ done
+}
+
+##############################################################################
+# Create certificates: Manager
+##############################################################################
+
+create_ossec_key_cert() {
+ print "Creating ossec-authd key and cert"
+ exec_cmd "openssl genrsa -out ${WAZUH_INSTALL_PATH}/etc/sslmanager.key 4096"
+ exec_cmd "openssl req -new -x509 -key ${WAZUH_INSTALL_PATH}/etc/sslmanager.key -out ${WAZUH_INSTALL_PATH}/etc/sslmanager.cert -days 3650 -subj /CN=${HOSTNAME}/"
+}
+
+##############################################################################
+# Create certificates: API
+##############################################################################
+
+create_api_key_cert() {
+ print "Enabling Wazuh API HTTPS"
+ edit_configuration "https" "yes"
+ print "Create Wazuh API key and cert"
+ exec_cmd "openssl genrsa -out ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.key 4096"
+ exec_cmd "openssl req -new -x509 -key ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.key -out ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.crt -days 3650 -subj /CN=${HOSTNAME}/"
+
+ # Granting proper permissions
+ chmod 400 ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.key
+ chmod 400 ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.crt
+}
+
+##############################################################################
+# Copy all files from $WAZUH_CONFIG_MOUNT to $WAZUH_INSTALL_PATH and respect
+# destination files permissions
+#
+# For example, to mount the file /var/ossec/data/etc/ossec.conf, mount it at
+# $WAZUH_CONFIG_MOUNT/etc/ossec.conf in your container and this code will
+# replace the ossec.conf file in /var/ossec/data/etc with yours.
+##############################################################################
+
+mount_files() {
+ if [ -e "$WAZUH_CONFIG_MOUNT" ]
+ then
+ print "Identified Wazuh configuration files to mount..."
+ exec_cmd_stdout "cp --verbose -r $WAZUH_CONFIG_MOUNT/* $WAZUH_INSTALL_PATH"
+ else
+ print "No Wazuh configuration files to mount..."
+ fi
+}
+
+##############################################################################
+# Stop OSSEC
+##############################################################################
+
+function ossec_shutdown(){
+ ${WAZUH_INSTALL_PATH}/bin/ossec-control stop;
+}
+
+##############################################################################
+# Interpret any passed arguments (via docker command to this entrypoint) as
+# paths or commands, and execute them.
+#
+# This can be useful for actions that need to be run before the services are
+# started, such as "/var/ossec/bin/ossec-control enable agentless".
+##############################################################################
+
+docker_custom_args() {
+ for CUSTOM_COMMAND in "$@"
+ do
+ echo "Executing command \`${CUSTOM_COMMAND}\`"
+ exec_cmd_stdout "${CUSTOM_COMMAND}"
+ done
+}
+
+##############################################################################
+# Change Wazuh API user credentials.
+##############################################################################
+
+change_api_user_credentials() {
+ pushd /var/ossec/api/configuration/auth/
+ echo "Change Wazuh API user credentials"
+ change_user="node htpasswd -b -c user $API_USER $API_PASS"
+ eval $change_user
+ popd
+}
+
+
+##############################################################################
+# Main function
+##############################################################################
+
+main() {
+ # Mount permanent data (i.e. ossec.conf)
+ mount_permanent_data
+
+ # Restore files stored in permanent data that are not permanent (i.e. internal_options.conf)
+ apply_exclusion_data
+
+ # Remove some files in permanent_data (i.e. .template.db)
+ remove_data_files
+
+ # Generate ossec-authd certs if AUTO_ENROLLMENT_ENABLED is true and does not exist
+ if [ $AUTO_ENROLLMENT_ENABLED == true ]
+ then
+ if [ ! -e ${WAZUH_INSTALL_PATH}/etc/sslmanager.key ]
+ then
+ create_ossec_key_cert
+ fi
+ fi
+
+ # Generate API certs if API_GENERATE_CERTS is true and does not exist
+ if [ $API_GENERATE_CERTS == true ]
+ then
+ if [ ! -e ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.crt ]
+ then
+ create_api_key_cert
+ fi
+ fi
+
+ # Mount selected files (WAZUH_CONFIG_MOUNT) to container
+ mount_files
+
+ # Trap exit signals and do a proper shutdown
+ trap "ossec_shutdown; exit" SIGINT SIGTERM
+
+ # Execute custom args
+ docker_custom_args
+
+ # Change API user credentials
+ change_api_user_credentials
+
+ # Delete temporary data folder
+ rm -rf ${WAZUH_INSTALL_PATH}/data_tmp
+
+}
+
+main
diff --git a/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat b/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
new file mode 100644
index 00000000..2f744915
--- /dev/null
+++ b/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
@@ -0,0 +1,29 @@
+#!/usr/bin/with-contenv bash
+# Wazuh App Copyright (C) 2020 Wazuh Inc. (License GPLv2)
+
+set -e
+
+if [ "$ELASTICSEARCH_URL" != "" ]; then
+ >&2 echo "Customize Elasticsearch ouput IP"
+ sed -i 's|http://elasticsearch:9200|'$ELASTICSEARCH_URL'|g' /etc/filebeat/filebeat.yml
+fi
+
+# Configure filebeat.yml security settings
+
+if [ "$SSL_CERTIFICATE_AUTHORITIES" != "" ]; then
+ >&2 echo "Configuring Certificate Authorities."
+ sed -i 's|#ssl.certificate_authorities:|'ssl.certificate_authorities:\ [\"$SSL_CERTIFICATE_AUTHORITIES\"]'|g' /etc/filebeat/filebeat.yml
+fi
+
+if [ "$USERNAME" != "" ]; then
+ >&2 echo "Configuring username."
+ sed -i 's|#username:|'username:\ \"$USERNAME\"'|g' /etc/filebeat/filebeat.yml
+fi
+
+if [ "$PASSWORD" != "" ]; then
+ >&2 echo "Configuring password."
+ sed -i 's|#password:|'password:\ \"$PASSWORD\"'|g' /etc/filebeat/filebeat.yml
+fi
+
+chmod go-w /etc/filebeat/filebeat.yml || true
+chown root: /etc/filebeat/filebeat.yml || true
diff --git a/wazuh-opendistro/config/etc/cont-init.d/2-manager b/wazuh-opendistro/config/etc/cont-init.d/2-manager
new file mode 100644
index 00000000..e548e8b1
--- /dev/null
+++ b/wazuh-opendistro/config/etc/cont-init.d/2-manager
@@ -0,0 +1,3 @@
+#!/usr/bin/with-contenv bash
+
+/var/ossec/bin/ossec-control start
diff --git a/wazuh-opendistro/config/etc/services.d/api/finish b/wazuh-opendistro/config/etc/services.d/api/finish
new file mode 100644
index 00000000..38d744d1
--- /dev/null
+++ b/wazuh-opendistro/config/etc/services.d/api/finish
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+echo >&2 "API exited. code=${1}"
+
+# terminate other services to exit from the container
+exec s6-svscanctl -t /var/run/s6/services
+
diff --git a/wazuh-opendistro/config/etc/services.d/api/run b/wazuh-opendistro/config/etc/services.d/api/run
new file mode 100644
index 00000000..e6e3e831
--- /dev/null
+++ b/wazuh-opendistro/config/etc/services.d/api/run
@@ -0,0 +1,4 @@
+#!/usr/bin/with-contenv sh
+echo >&2 "starting API"
+
+exec /bin/node /var/ossec/api/app.js
diff --git a/wazuh-opendistro/config/etc/services.d/filebeat/finish b/wazuh-opendistro/config/etc/services.d/filebeat/finish
new file mode 100644
index 00000000..8813eb67
--- /dev/null
+++ b/wazuh-opendistro/config/etc/services.d/filebeat/finish
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+echo >&2 "Filebeat exited. code=${1}"
+
+# terminate other services to exit from the container
+exec s6-svscanctl -t /var/run/s6/services
+
diff --git a/wazuh-opendistro/config/etc/services.d/filebeat/run b/wazuh-opendistro/config/etc/services.d/filebeat/run
new file mode 100644
index 00000000..706ee5af
--- /dev/null
+++ b/wazuh-opendistro/config/etc/services.d/filebeat/run
@@ -0,0 +1,4 @@
+#!/usr/bin/with-contenv sh
+echo >&2 "starting Filebeat"
+
+exec /usr/share/filebeat/bin/filebeat -e -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat
diff --git a/wazuh-opendistro/config/filebeat.yml b/wazuh-opendistro/config/filebeat.yml
new file mode 100644
index 00000000..0d04bac8
--- /dev/null
+++ b/wazuh-opendistro/config/filebeat.yml
@@ -0,0 +1,21 @@
+
+# Wazuh - Filebeat configuration file
+filebeat.modules:
+ - module: wazuh
+ alerts:
+ enabled: true
+ archives:
+ enabled: false
+
+setup.template.json.enabled: true
+setup.template.json.path: '/etc/filebeat/wazuh-template.json'
+setup.template.json.name: 'wazuh'
+setup.template.overwrite: true
+setup.ilm.enabled: false
+output.elasticsearch:
+ hosts: ['http://elasticsearch:9200']
+ #ssl.certificate_authorities:
+ #ssl.certificate:
+ #ssl.key:
+ #username:
+ #password:
diff --git a/wazuh-opendistro/config/permanent_data.env b/wazuh-opendistro/config/permanent_data.env
new file mode 100644
index 00000000..ca461d63
--- /dev/null
+++ b/wazuh-opendistro/config/permanent_data.env
@@ -0,0 +1,74 @@
+# Permanent data mounted in volumes
+i=0
+PERMANENT_DATA[((i++))]="/var/ossec/api/configuration"
+PERMANENT_DATA[((i++))]="/var/ossec/etc"
+PERMANENT_DATA[((i++))]="/var/ossec/logs"
+PERMANENT_DATA[((i++))]="/var/ossec/queue"
+PERMANENT_DATA[((i++))]="/var/ossec/agentless"
+PERMANENT_DATA[((i++))]="/var/ossec/var/multigroups"
+PERMANENT_DATA[((i++))]="/var/ossec/integrations"
+PERMANENT_DATA[((i++))]="/var/ossec/active-response/bin"
+PERMANENT_DATA[((i++))]="/var/ossec/wodles"
+PERMANENT_DATA[((i++))]="/etc/filebeat"
+export PERMANENT_DATA
+
+# Files mounted in a volume that should not be permanent
+i=0
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/etc/internal_options.conf"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/pagerduty"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/slack"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/slack.py"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/virustotal"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/integrations/virustotal.py"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/default-firewall-drop.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/disable-account.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/firewalld-drop.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/firewall-drop.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/host-deny.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/ip-customblock.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/ipfw_mac.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/ipfw.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/kaspersky.py"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/kaspersky.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/npf.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/ossec-slack.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/ossec-tweeter.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/pf.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/restart-ossec.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/restart.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/active-response/bin/route-null.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/sshlogin.exp"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/ssh_pixconfig_diff"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/ssh_asa-fwsmconfig_diff"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/ssh_integrity_check_bsd"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/main.exp"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/su.exp"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/ssh_integrity_check_linux"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/register_host.sh"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/ssh_generic_diff"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/ssh_foundry_diff"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/ssh_nopass.exp"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/agentless/ssh.exp"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/aws/aws-s3"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/aws/aws-s3.py"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/azure/azure-logs"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/azure/azure-logs.py"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/docker/DockerListener"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/docker/DockerListener.py"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/oscap"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/oscap.py"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/template_oval.xsl"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/template_xccdf.xsl"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/cve-redhat-6-ds.xml"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/cve-redhat-7-ds.xml"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-centos-6-ds.xml"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-centos-7-ds.xml"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-fedora-24-ds.xml"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-rhel-6-ds.xml"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-rhel-7-ds.xml"
+export PERMANENT_DATA_EXCP
+
+# Files mounted in a volume that should be deleted
+i=0
+PERMANENT_DATA_DEL[((i++))]="/var/ossec/queue/db/.template.db"
+export PERMANENT_DATA_DEL
diff --git a/wazuh-opendistro/config/permanent_data.sh b/wazuh-opendistro/config/permanent_data.sh
new file mode 100644
index 00000000..7dfaa647
--- /dev/null
+++ b/wazuh-opendistro/config/permanent_data.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# Wazuh App Copyright (C) 2020 Wazuh Inc. (License GPLv2)
+
+# Variables
+source /permanent_data.env
+
+WAZUH_INSTALL_PATH=/var/ossec
+DATA_TMP_PATH=${WAZUH_INSTALL_PATH}/data_tmp
+mkdir ${DATA_TMP_PATH}
+
+# Move exclusion files to EXCLUSION_PATH
+EXCLUSION_PATH=${DATA_TMP_PATH}/exclusion
+mkdir ${EXCLUSION_PATH}
+
+for exclusion_file in "${PERMANENT_DATA_EXCP[@]}"; do
+ # Create the directory for the exclusion file if it does not exist
+ DIR=$(dirname "${exclusion_file}")
+ if [ ! -e ${EXCLUSION_PATH}/${DIR} ]
+ then
+ mkdir -p ${EXCLUSION_PATH}/${DIR}
+ fi
+
+ mv ${exclusion_file} ${EXCLUSION_PATH}/${exclusion_file}
+done
+
+# Move permanent files to PERMANENT_PATH
+PERMANENT_PATH=${DATA_TMP_PATH}/permanent
+mkdir ${PERMANENT_PATH}
+
+for permanent_dir in "${PERMANENT_DATA[@]}"; do
+ # Create the directory for the permanent file if it does not exist
+ DIR=$(dirname "${permanent_dir}")
+ if [ ! -e ${PERMANENT_PATH}${DIR} ]
+ then
+ mkdir -p ${PERMANENT_PATH}${DIR}
+ fi
+
+ mv ${permanent_dir} ${PERMANENT_PATH}${permanent_dir}
+
+done
diff --git a/wazuh-opendistro/config/wazuh.repo b/wazuh-opendistro/config/wazuh.repo
new file mode 100644
index 00000000..ae462c62
--- /dev/null
+++ b/wazuh-opendistro/config/wazuh.repo
@@ -0,0 +1,7 @@
+[wazuh_repo]
+gpgcheck=1
+gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
+enabled=1
+name=Wazuh repository
+baseurl=https://packages.wazuh.com/3.x/yum/
+protect=1
From 9e87c1b597e31192beb08181e262f3073d87b13d Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 18 Aug 2020 17:04:12 +0200
Subject: [PATCH 02/50] Add initial support for kibana-opendistro
---
kibana-opendistro/Dockerfile | 60 ++++++++++++++++
kibana-opendistro/config/entrypoint.sh | 53 ++++++++++++++
kibana-opendistro/config/kibana_settings.sh | 76 ++++++++++++++++++++
kibana-opendistro/config/wazuh_app_config.sh | 67 +++++++++++++++++
kibana-opendistro/config/welcome_wazuh.sh | 24 +++++++
5 files changed, 280 insertions(+)
create mode 100644 kibana-opendistro/Dockerfile
create mode 100644 kibana-opendistro/config/entrypoint.sh
create mode 100644 kibana-opendistro/config/kibana_settings.sh
create mode 100644 kibana-opendistro/config/wazuh_app_config.sh
create mode 100644 kibana-opendistro/config/welcome_wazuh.sh
diff --git a/kibana-opendistro/Dockerfile b/kibana-opendistro/Dockerfile
new file mode 100644
index 00000000..4b4ba99f
--- /dev/null
+++ b/kibana-opendistro/Dockerfile
@@ -0,0 +1,60 @@
+# Wazuh Docker Copyright (C) 2020 Wazuh Inc. (License GPLv2)
+FROM amazon/opendistro-for-elasticsearch-kibana:1.9.0
+USER kibana
+ARG ELASTIC_VERSION=7.8.0
+ARG WAZUH_VERSION=3.13.1
+ARG WAZUH_APP_VERSION="${WAZUH_VERSION}_${ELASTIC_VERSION}"
+
+WORKDIR /usr/share/kibana
+RUN ./bin/kibana-plugin install https://packages.wazuh.com/wazuhapp/wazuhapp-${WAZUH_APP_VERSION}.zip
+
+WORKDIR /
+USER root
+COPY config/entrypoint.sh ./entrypoint.sh
+RUN chmod 755 ./entrypoint.sh
+
+ENV PATTERN="" \
+ CHECKS_PATTERN="" \
+ CHECKS_TEMPLATE="" \
+ CHECKS_API="" \
+ CHECKS_SETUP="" \
+ EXTENSIONS_PCI="" \
+ EXTENSIONS_GDPR="" \
+ EXTENSIONS_AUDIT="" \
+ EXTENSIONS_OSCAP="" \
+ EXTENSIONS_CISCAT="" \
+ EXTENSIONS_AWS="" \
+ EXTENSIONS_VIRUSTOTAL="" \
+ EXTENSIONS_OSQUERY="" \
+ APP_TIMEOUT="" \
+ WAZUH_SHARDS="" \
+ WAZUH_REPLICAS="" \
+ WAZUH_VERSION_SHARDS="" \
+ WAZUH_VERSION_REPLICAS="" \
+ IP_SELECTOR="" \
+ IP_IGNORE="" \
+ WAZUH_MONITORING_ENABLED="" \
+ WAZUH_MONITORING_FREQUENCY="" \
+ WAZUH_MONITORING_SHARDS="" \
+ WAZUH_MONITORING_REPLICAS="" \
+ ADMIN_PRIVILEGES=""
+
+ARG CHANGE_WELCOME="false"
+
+COPY --chown=kibana:kibana ./config/wazuh_app_config.sh ./
+
+RUN chmod +x ./wazuh_app_config.sh
+
+COPY --chown=kibana:kibana ./config/kibana_settings.sh ./
+
+RUN chmod +x ./kibana_settings.sh
+
+COPY --chown=kibana:kibana ./config/welcome_wazuh.sh ./
+
+RUN chmod +x ./welcome_wazuh.sh
+
+RUN ./welcome_wazuh.sh
+USER kibana
+RUN NODE_OPTIONS="--max-old-space-size=2048" /usr/local/bin/kibana-docker --optimize
+
+ENTRYPOINT ./entrypoint.sh
diff --git a/kibana-opendistro/config/entrypoint.sh b/kibana-opendistro/config/entrypoint.sh
new file mode 100644
index 00000000..79039afc
--- /dev/null
+++ b/kibana-opendistro/config/entrypoint.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+# Wazuh Docker Copyright (C) 2020 Wazuh Inc. (License GPLv2)
+
+set -e
+
+##############################################################################
+# Waiting for elasticsearch
+##############################################################################
+
+if [ "x${ELASTICSEARCH_URL}" = "x" ]; then
+ el_url="http://elasticsearch:9200"
+else
+ el_url="${ELASTICSEARCH_URL}"
+fi
+
+auth=""
+
+until curl -XGET $el_url ${auth}; do
+ >&2 echo "Elastic is unavailable - sleeping"
+ sleep 5
+done
+
+sleep 2
+
+>&2 echo "Elasticsearch is up."
+
+
+##############################################################################
+# Waiting for wazuh alerts template
+##############################################################################
+
+strlen=0
+
+while [[ $strlen -eq 0 ]]
+do
+ template=$(curl $el_url/_cat/templates/wazuh -s)
+ strlen=${#template}
+ >&2 echo "Wazuh alerts template not loaded - sleeping."
+ sleep 2
+done
+
+sleep 2
+
+>&2 echo "Wazuh alerts template is loaded."
+
+
+./wazuh_app_config.sh
+
+sleep 5
+
+./kibana_settings.sh &
+
+/usr/local/bin/kibana-docker
diff --git a/kibana-opendistro/config/kibana_settings.sh b/kibana-opendistro/config/kibana_settings.sh
new file mode 100644
index 00000000..0f624725
--- /dev/null
+++ b/kibana-opendistro/config/kibana_settings.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+# Wazuh Docker Copyright (C) 2020 Wazuh Inc. (License GPLv2)
+
+WAZUH_MAJOR=3
+
+##############################################################################
+# Wait for the Kibana API to start. It is necessary to do it in this container
+# because the others are running Elastic Stack and we can not interrupt them.
+#
+# The following actions are performed:
+#
+# Add the wazuh alerts index as default.
+# Set the Discover time interval to 24 hours instead of 15 minutes.
+# Do not ask user to help providing usage statistics to Elastic.
+##############################################################################
+
+##############################################################################
+# Customize elasticsearch ip
+##############################################################################
+if [ "$ELASTICSEARCH_KIBANA_IP" != "" ]; then
+ sed -i "s:#elasticsearch.hosts:elasticsearch.hosts:g" /usr/share/kibana/config/kibana.yml
+ sed -i 's|http://elasticsearch:9200|'$ELASTICSEARCH_KIBANA_IP'|g' /usr/share/kibana/config/kibana.yml
+fi
+
+# If KIBANA_INDEX was set, then change the default index in kibana.yml configuration file. If there was an index, then delete it and recreate.
+if [ "$KIBANA_INDEX" != "" ]; then
+ if grep -q 'kibana.index' /usr/share/kibana/config/kibana.yml; then
+ sed -i '/kibana.index/d' /usr/share/kibana/config/kibana.yml
+ fi
+ echo "kibana.index: $KIBANA_INDEX" >> /usr/share/kibana/config/kibana.yml
+fi
+
+if [ "$KIBANA_IP" != "" ]; then
+ kibana_ip="$KIBANA_IP"
+else
+ kibana_ip="kibana"
+fi
+
+# Add auth headers if required
+if [ "$ELASTICSEARCH_USERNAME" != "" ] && [ "$ELASTICSEARCH_PASSWORD" != "" ]; then
+ curl_auth="-u $ELASTICSEARCH_USERNAME:$ELASTICSEARCH_PASSWORD"
+fi
+
+while [[ "$(curl $curl_auth -XGET -I -s -o /dev/null -w ''%{http_code}'' $kibana_ip:5601/status)" != "200" ]]; do
+ echo "Waiting for Kibana API. Sleeping 5 seconds"
+ sleep 5
+done
+
+# Prepare index selection.
+echo "Kibana API is running"
+
+default_index="/tmp/default_index.json"
+
+cat > ${default_index} << EOF
+{
+ "changes": {
+ "defaultIndex": "wazuh-alerts-${WAZUH_MAJOR}.x-*"
+ }
+}
+EOF
+
+sleep 5
+# Add the wazuh alerts index as default.
+curl -POST "http://$kibana_ip:5601/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d@${default_index}
+rm -f ${default_index}
+
+sleep 5
+# Configuring Kibana TimePicker.
+curl -POST "http://$kibana_ip:5601/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d \
+'{"changes":{"timepicker:timeDefaults":"{\n \"from\": \"now-24h\",\n \"to\": \"now\",\n \"mode\": \"quick\"}"}}'
+
+sleep 5
+# Do not ask user to help providing usage statistics to Elastic
+curl -POST "http://$kibana_ip:5601/api/telemetry/v2/optIn" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d '{"enabled":false}'
+
+echo "End settings"
diff --git a/kibana-opendistro/config/wazuh_app_config.sh b/kibana-opendistro/config/wazuh_app_config.sh
new file mode 100644
index 00000000..6d9f05eb
--- /dev/null
+++ b/kibana-opendistro/config/wazuh_app_config.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+# Wazuh Docker Copyright (C) 2020 Wazuh Inc. (License GPLv2)
+
+wazuh_url="${WAZUH_API_URL:-https://wazuh}"
+wazuh_port="${API_PORT:-55000}"
+api_user="${API_USER:-foo}"
+api_password="${API_PASS:-bar}"
+
+kibana_config_file="/usr/share/kibana/optimize/wazuh/config/wazuh.yml"
+mkdir -p /usr/share/kibana/optimize/wazuh/config/
+touch $kibana_config_file
+
+declare -A CONFIG_MAP=(
+ [pattern]=$PATTERN
+ [checks.pattern]=$CHECKS_PATTERN
+ [checks.template]=$CHECKS_TEMPLATE
+ [checks.api]=$CHECKS_API
+ [checks.setup]=$CHECKS_SETUP
+ [extensions.pci]=$EXTENSIONS_PCI
+ [extensions.gdpr]=$EXTENSIONS_GDPR
+ [extensions.audit]=$EXTENSIONS_AUDIT
+ [extensions.oscap]=$EXTENSIONS_OSCAP
+ [extensions.ciscat]=$EXTENSIONS_CISCAT
+ [extensions.aws]=$EXTENSIONS_AWS
+ [extensions.virustotal]=$EXTENSIONS_VIRUSTOTAL
+ [extensions.osquery]=$EXTENSIONS_OSQUERY
+ [timeout]=$APP_TIMEOUT
+ [wazuh.shards]=$WAZUH_SHARDS
+ [wazuh.replicas]=$WAZUH_REPLICAS
+ [wazuh-version.shards]=$WAZUH_VERSION_SHARDS
+ [wazuh-version.replicas]=$WAZUH_VERSION_REPLICAS
+ [ip.selector]=$IP_SELECTOR
+ [ip.ignore]=$IP_IGNORE
+ [wazuh.monitoring.enabled]=$WAZUH_MONITORING_ENABLED
+ [wazuh.monitoring.frequency]=$WAZUH_MONITORING_FREQUENCY
+ [wazuh.monitoring.shards]=$WAZUH_MONITORING_SHARDS
+ [wazuh.monitoring.replicas]=$WAZUH_MONITORING_REPLICAS
+ [admin]=$ADMIN_PRIVILEGES
+)
+
+for i in "${!CONFIG_MAP[@]}"
+do
+ if [ "${CONFIG_MAP[$i]}" != "" ]; then
+ sed -i 's/.*#'"$i"'.*/'"$i"': '"${CONFIG_MAP[$i]}"'/' $kibana_config_file
+ fi
+done
+
+# remove default API entry (new in 3.11.0_7.5.1)
+sed -ie '/- default:/,+4d' $kibana_config_file
+
+CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/_doc/1513629884013 ${auth})
+
+grep -q 1513629884013 $kibana_config_file
+_config_exists=$?
+
+if [[ "x$CONFIG_CODE" != "x200" && $_config_exists -ne 0 ]]; then
+cat << EOF > $kibana_config_file
+hosts:
+ - 1513629884013:
+ url: $wazuh_url
+ port: $wazuh_port
+ user: $api_user
+ password: $api_password
+EOF
+else
+ echo "Wazuh APP already configured"
+fi
diff --git a/kibana-opendistro/config/welcome_wazuh.sh b/kibana-opendistro/config/welcome_wazuh.sh
new file mode 100644
index 00000000..98306871
--- /dev/null
+++ b/kibana-opendistro/config/welcome_wazuh.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Wazuh Docker Copyright (C) 2020 Wazuh Inc. (License GPLv2)
+
+if [[ $CHANGE_WELCOME == "true" ]]
+then
+
+ rm -rf ./optimize/bundles
+
+ kibana_path="/usr/share/kibana"
+ # Set Wazuh app as the default landing page
+ echo "Set Wazuh app as the default landing page"
+ echo "server.defaultRoute: /app/wazuh" >> /usr/share/kibana/config/kibana.yml
+
+ # Redirect Kibana welcome screen to Discover
+ echo "Redirect Kibana welcome screen to Discover"
+ sed -i "s:'/app/kibana#/home':'/app/wazuh':g" $kibana_path/src/ui/public/chrome/directives/global_nav/global_nav.html
+ sed -i "s:'/app/kibana#/home':'/app/wazuh':g" $kibana_path/src/ui/public/chrome/directives/header_global_nav/header_global_nav.js
+
+ # Redirect Kibana welcome screen to Discover
+ echo "Hide undesired links"
+ sed -i 's#visible: true#visible: false#g' $kibana_path/node_modules/x-pack/plugins/rollup/public/crud_app/index.js
+ sed -i 's#visible: true#visible: false#g' $kibana_path/node_modules/x-pack/plugins/license_management/public/management_section.js
+fi
+
From 09a6e9bc1d3e74909a99923876b9a23993976c2b Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 18 Aug 2020 17:04:58 +0200
Subject: [PATCH 03/50] Switch to opendistro images
---
docker-compose.yml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index cd8f90ff..e548edb7 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,7 +3,8 @@ version: '3.7'
services:
wazuh:
- build: wazuh
+ build: wazuh-opendistro/
+ image: wazuh-opendistro
hostname: wazuh-manager
restart: always
ports:
@@ -25,24 +26,23 @@ services:
- filebeat_var:/var/lib/filebeat
elasticsearch:
- image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0
+ image: amazon/opendistro-for-elasticsearch:1.9.0
hostname: elasticsearch
restart: always
ports:
- "9200:9200"
environment:
- - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- - bootstrap.memory_lock=true
- discovery.type=single-node
+ - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
+ - bootstrap.memory_lock=true
ulimits:
memlock:
soft: -1
hard: -1
- volumes:
- - ./elastic_conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
kibana:
- build: kibana
+ build: kibana-opendistro/
+ image: wazuh-kibana-opendistro
hostname: kibana
restart: always
depends_on:
From 746cffc5496942c19ebefebbdc56b96c73a08ac7 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 19 Aug 2020 16:19:27 +0200
Subject: [PATCH 04/50] Update compose
---
docker-compose.yml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/docker-compose.yml b/docker-compose.yml
index e548edb7..893e2b8f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -33,8 +33,12 @@ services:
- "9200:9200"
environment:
- discovery.type=single-node
+ - cluster.name=wazuh-cluster
+ - network.host=0.0.0.0
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- bootstrap.memory_lock=true
+ volumes:
+ - ./elastic_opendistro/internal_users.yml:/usr/share/elasticsearch/plugins/opendistro_security/securityconfig/internal_users.yml
ulimits:
memlock:
soft: -1
@@ -45,6 +49,10 @@ services:
image: wazuh-kibana-opendistro
hostname: kibana
restart: always
+ environment:
+ - ELASTICSEARCH_USERNAME=admin
+ - ELASTICSEARCH_PASSWORD=SecretPass
+ - ELASTICSEARCH_KIBANA_IP="https://elasticsearch:9200"
depends_on:
- elasticsearch
links:
From 95473050615074346100c05ae2ad64624c6d6a95 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 19 Aug 2020 16:19:49 +0200
Subject: [PATCH 05/50] Add custom welcome
---
.../custom_welcome/security-login.style.css | 118 ++++++++++++++++++
.../config/custom_welcome/template.js.hbs | 112 +++++++++++++++++
.../custom_welcome/wazuh_logo_circle.svg | 1 +
.../config/custom_welcome/wazuh_wazuh_bg.svg | 1 +
4 files changed, 232 insertions(+)
create mode 100644 kibana-opendistro/config/custom_welcome/security-login.style.css
create mode 100644 kibana-opendistro/config/custom_welcome/template.js.hbs
create mode 100644 kibana-opendistro/config/custom_welcome/wazuh_logo_circle.svg
create mode 100644 kibana-opendistro/config/custom_welcome/wazuh_wazuh_bg.svg
diff --git a/kibana-opendistro/config/custom_welcome/security-login.style.css b/kibana-opendistro/config/custom_welcome/security-login.style.css
new file mode 100644
index 00000000..6648df2b
--- /dev/null
+++ b/kibana-opendistro/config/custom_welcome/security-login.style.css
@@ -0,0 +1,118 @@
+#security-login-app .content {
+ background: url(./wazuh_wazuh_bg.svg) !important;
+ width: 100% !important;
+ height: 100% !important;
+ background-size: cover !important;
+}
+
+.app-wrapper {
+ left: 0;
+}
+
+.global-nav.is-global-nav-open+.app-wrapper {
+ left: 0;
+}
+
+.btn-default {
+ background-color: #00a9e5!important;
+ border-color: #00a0e5!important;
+ color: #ffffff;
+ padding: 8px;
+}
+
+.btn-default:hover {
+ background-color: #00a9e5!important;
+ border-color: #00a0e5!important;
+ color: #ffffff;
+}
+
+.brand-image-container {
+ text-align: center;
+}
+
+.brand-image {
+ display: none;
+}
+
+.login-wrapper {
+ position: absolute;
+ width: 430px;
+ top: 55px;
+ border-radius: 1px;
+ padding: 1em;
+}
+
+.login-wrapper .login-title {
+ text-align: center;
+ padding-bottom: 10px;
+ color: #ffffff !important;
+ font-size: 35px !important;
+ font-weight: 300;
+}
+
+.login-wrapper .login-subtitle {
+ text-align: center;
+ padding-bottom: 15px;
+ color: #ffffff !important;
+ font-size: 16px !important;
+}
+
+.login-wrapper .login-form {
+ padding: 16px;
+ box-shadow: 0 2px 2px -1px rgba(152, 162, 179, 0.3), 0 1px 5px -2px rgba(152, 162, 179, 0.3);
+ background-color: #FFF;
+ border: 1px solid #D3DAE6;
+ border-radius: 4px;
+ -webkit-box-flex: 1;
+ -ms-flex-positive: 1;
+ flex-grow: 1;
+ margin-top: 32px;
+}
+
+.login-wrapper .login-form .input-group {
+ margin-bottom: 1em;
+}
+
+.login-wrapper .login-form .kuiTextInput {
+ cursor: initial;
+}
+
+.login-wrapper .login-form .kuiTextInput:invalid:not(.ng-touched) {
+ border-color: #D9D9D9;
+}
+
+.login-wrapper .login-form .kuiTextInput.has-error {
+ border-color: #A30000;
+}
+
+.login-wrapper .login-form .btn-login {
+ width: 100%;
+}
+
+.login-wrapper .error-message {
+ color: #b4251d;
+ font-size: 14px;
+ margin-top: 16px;
+ margin-bottom: 0;
+ background-color: #f8e9e9;
+ padding: 8px;
+ font-weight: 400;
+ border-left: 2px solid #BD271E;
+}
+
+.loginWelcome__logo {
+ display: inline-block;
+ width: 80px;
+ height: 80px;
+ line-height: 80px;
+ text-align: center;
+ background-color: #FFF;
+ border-radius: 100%;
+ padding: 16px;
+ box-shadow: 0 6px 12px -1px rgba(152, 162, 179, 0.2), 0 4px 4px -1px rgba(152, 162, 179, 0.2), 0 2px 2px 0 rgba(152, 162, 179, 0.2);
+ margin-bottom: 32px;
+}
+
+.loginWelcome__logo {
+ background: url(./wazuh_logo_circle.svg) center center no-repeat !important;
+}
\ No newline at end of file
diff --git a/kibana-opendistro/config/custom_welcome/template.js.hbs b/kibana-opendistro/config/custom_welcome/template.js.hbs
new file mode 100644
index 00000000..54255bca
--- /dev/null
+++ b/kibana-opendistro/config/custom_welcome/template.js.hbs
@@ -0,0 +1,112 @@
+var kbnCsp = JSON.parse(document.querySelector('kbn-csp').getAttribute('data'));
+window.__kbnStrictCsp__ = kbnCsp.strictCsp;
+window.__kbnDarkMode__ = {{darkMode}};
+window.__kbnPublicPath__ = {{publicPathMap}};
+
+if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) {
+ var legacyBrowserError = document.getElementById('kbn_legacy_browser_error');
+ legacyBrowserError.style.display = 'flex';
+} else {
+ if (!window.__kbnCspNotEnforced__ && window.console) {
+ window.console.log("^ A single error about an inline script not firing due to content security policy is expected!");
+ }
+ var loadingMessage = document.getElementById('kbn_loading_message');
+ loadingMessage.style.display = 'flex';
+
+ window.onload = function () {
+ //WAZUH
+ var interval = setInterval(() => {
+ var title = document.getElementsByClassName('login-title');
+ if ((title || []).length) {
+ clearInterval(interval);
+ title[0].textContent = "Welcome to Wazuh";
+ var subtitle = document.getElementsByClassName('login-subtitle');
+ subtitle[0].textContent = "The Open Source Security Platform";
+ var logo = document.getElementsByClassName('brand-image-container');
+ $(logo).append('');
+ }
+ })
+ //
+
+ function failure() {
+ // make subsequent calls to failure() noop
+ failure = function () {};
+
+ var err = document.createElement('h1');
+ err.style['color'] = 'white';
+ err.style['font-family'] = 'monospace';
+ err.style['text-align'] = 'center';
+ err.style['background'] = '#F44336';
+ err.style['padding'] = '25px';
+ err.innerText = document.querySelector('[data-error-message]').dataset.errorMessage;
+
+ document.body.innerHTML = err.outerHTML;
+ }
+
+var stylesheetTarget = document.querySelector('head meta[name="add-styles-here"]')
+ function loadStyleSheet(url, cb) {
+ var dom = document.createElement('link');
+ dom.rel = 'stylesheet';
+ dom.type = 'text/css';
+ dom.href = url;
+ dom.addEventListener('error', failure);
+ dom.addEventListener('load', cb);
+ document.head.insertBefore(dom, stylesheetTarget);
+ }
+
+ var scriptsTarget = document.querySelector('head meta[name="add-scripts-here"]')
+ function loadScript(url, cb) {
+ var dom = document.createElement('script');
+ {{!-- NOTE: async = false is used to trigger async-download/ordered-execution as outlined here: https://www.html5rocks.com/en/tutorials/speed/script-loading/ --}}
+ dom.async = false;
+ dom.src = url;
+ dom.addEventListener('error', failure);
+ dom.addEventListener('load', cb);
+ document.head.insertBefore(dom, scriptsTarget);
+ }
+
+ function load(urls, cb) {
+ var pending = urls.length;
+ urls.forEach(function (url) {
+ var innerCb = function () {
+ pending = pending - 1;
+ if (pending === 0 && typeof cb === 'function') {
+ cb();
+ }
+ }
+
+ if (typeof url !== 'string') {
+ load(url, innerCb);
+ } else if (url.slice(-4) === '.css') {
+ loadStyleSheet(url, innerCb);
+ } else {
+ loadScript(url, innerCb);
+ }
+ });
+ }
+
+ load([
+ {{#each jsDependencyPaths}}
+ '{{this}}',
+ {{/each}}
+ ], function () {
+ {{#unless legacyBundlePath}}
+ if (!__kbnBundles__ || !__kbnBundles__['entry/core'] || typeof __kbnBundles__['entry/core'].__kbnBootstrap__ !== 'function') {
+ console.error('entry/core bundle did not load correctly');
+ failure();
+ } else {
+ __kbnBundles__['entry/core'].__kbnBootstrap__()
+ }
+ {{/unless}}
+
+ load([
+ {{#if legacyBundlePath}}
+ '{{legacyBundlePath}}',
+ {{/if}}
+ {{#each styleSheetPaths}}
+ '{{this}}',
+ {{/each}}
+ ]);
+ });
+ }
+}
\ No newline at end of file
diff --git a/kibana-opendistro/config/custom_welcome/wazuh_logo_circle.svg b/kibana-opendistro/config/custom_welcome/wazuh_logo_circle.svg
new file mode 100644
index 00000000..45a61d74
--- /dev/null
+++ b/kibana-opendistro/config/custom_welcome/wazuh_logo_circle.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/kibana-opendistro/config/custom_welcome/wazuh_wazuh_bg.svg b/kibana-opendistro/config/custom_welcome/wazuh_wazuh_bg.svg
new file mode 100644
index 00000000..0c49c5c6
--- /dev/null
+++ b/kibana-opendistro/config/custom_welcome/wazuh_wazuh_bg.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
From 5079a68fb051e353fe964dadc0d2b72946843e58 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 19 Aug 2020 16:20:44 +0200
Subject: [PATCH 06/50] Copy custom welcome files
---
kibana-opendistro/Dockerfile | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/kibana-opendistro/Dockerfile b/kibana-opendistro/Dockerfile
index 4b4ba99f..7dd86ede 100644
--- a/kibana-opendistro/Dockerfile
+++ b/kibana-opendistro/Dockerfile
@@ -39,21 +39,18 @@ ENV PATTERN="" \
WAZUH_MONITORING_REPLICAS="" \
ADMIN_PRIVILEGES=""
-ARG CHANGE_WELCOME="false"
-
COPY --chown=kibana:kibana ./config/wazuh_app_config.sh ./
-
RUN chmod +x ./wazuh_app_config.sh
COPY --chown=kibana:kibana ./config/kibana_settings.sh ./
-
RUN chmod +x ./kibana_settings.sh
+COPY ./config/custom_welcome /tmp/custom_welcome
COPY --chown=kibana:kibana ./config/welcome_wazuh.sh ./
-
RUN chmod +x ./welcome_wazuh.sh
-
+ARG CHANGE_WELCOME="false"
RUN ./welcome_wazuh.sh
+
USER kibana
RUN NODE_OPTIONS="--max-old-space-size=2048" /usr/local/bin/kibana-docker --optimize
From 9dc2c0f82a84f0f44dec525288d54ed4b86d9819 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 20 Aug 2020 17:02:00 +0200
Subject: [PATCH 07/50] Add extra ssl settings
---
wazuh-opendistro/config/filebeat.yml | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/wazuh-opendistro/config/filebeat.yml b/wazuh-opendistro/config/filebeat.yml
index 0d04bac8..8a627bf9 100644
--- a/wazuh-opendistro/config/filebeat.yml
+++ b/wazuh-opendistro/config/filebeat.yml
@@ -13,9 +13,10 @@ setup.template.json.name: 'wazuh'
setup.template.overwrite: true
setup.ilm.enabled: false
output.elasticsearch:
- hosts: ['http://elasticsearch:9200']
+ hosts: ['https://elasticsearch:9200']
+ #username:
+ #password:
+ #ssl.verification_mode:
#ssl.certificate_authorities:
#ssl.certificate:
#ssl.key:
- #username:
- #password:
From 727560b2d1d19e00e8cfffc347dc5713bd935a3a Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 20 Aug 2020 17:02:28 +0200
Subject: [PATCH 08/50] Fix logic to setup filebeat.yml
---
.../config/etc/cont-init.d/1-config-filebeat | 28 +++++++++++--------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat b/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
index 2f744915..dae9947f 100644
--- a/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
+++ b/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
@@ -5,25 +5,31 @@ set -e
if [ "$ELASTICSEARCH_URL" != "" ]; then
>&2 echo "Customize Elasticsearch ouput IP"
- sed -i 's|http://elasticsearch:9200|'$ELASTICSEARCH_URL'|g' /etc/filebeat/filebeat.yml
+ sed -i "s|hosts:.*|hosts: ['$ELASTICSEARCH_URL']|g" /etc/filebeat/filebeat.yml
fi
# Configure filebeat.yml security settings
+if [ "$ELASTIC_USERNAME" != "" ]; then
+ >&2 echo "Configuring username."
+ sed -i "s|#username:.*|username: '$ELASTIC_USERNAME'|g" /etc/filebeat/filebeat.yml
+fi
+
+if [ "$ELASTIC_PASSWORD" != "" ]; then
+ >&2 echo "Configuring password."
+ sed -i "s|#password:.*|password: '$ELASTIC_PASSWORD'|g" /etc/filebeat/filebeat.yml
+fi
+
+if [ "$FILEBEAT_SSL_VERIFICATION_MODE" != "" ]; then
+ >&2 echo "Configuring SSL verification mode."
+ sed -i "s|#ssl.verification_mode:.*|ssl.verification_mode: $FILEBEAT_SSL_VERIFICATION_MODE|g" /etc/filebeat/filebeat.yml
+fi
+
if [ "$SSL_CERTIFICATE_AUTHORITIES" != "" ]; then
>&2 echo "Configuring Certificate Authorities."
- sed -i 's|#ssl.certificate_authorities:|'ssl.certificate_authorities:\ [\"$SSL_CERTIFICATE_AUTHORITIES\"]'|g' /etc/filebeat/filebeat.yml
+ sed -i "s|#ssl.certificate_authorities:.*|ssl.certificate_authorities: ['$SSL_CERTIFICATE_AUTHORITIES']|g" /etc/filebeat/filebeat.yml
fi
-if [ "$USERNAME" != "" ]; then
- >&2 echo "Configuring username."
- sed -i 's|#username:|'username:\ \"$USERNAME\"'|g' /etc/filebeat/filebeat.yml
-fi
-
-if [ "$PASSWORD" != "" ]; then
- >&2 echo "Configuring password."
- sed -i 's|#password:|'password:\ \"$PASSWORD\"'|g' /etc/filebeat/filebeat.yml
-fi
chmod go-w /etc/filebeat/filebeat.yml || true
chown root: /etc/filebeat/filebeat.yml || true
From c1bcdaf5fb9da13e08190b99f9b02dd58e0bb766 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 20 Aug 2020 17:11:07 +0200
Subject: [PATCH 09/50] Update filebeat config vars
---
docker-compose.yml | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index 893e2b8f..e6f23646 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -12,6 +12,11 @@ services:
- "1515:1515"
- "514:514/udp"
- "55000:55000"
+ environment:
+ - ELASTICSEARCH_URL=https://elasticsearch:9200
+ - ELASTIC_USERNAME=admin
+ - ELASTIC_PASSWORD=admin
+ - FILEBEAT_SSL_VERIFICATION_MODE=none
volumes:
- ossec_api_configuration:/var/ossec/api/configuration
- ossec_etc:/var/ossec/etc
@@ -37,8 +42,6 @@ services:
- network.host=0.0.0.0
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- bootstrap.memory_lock=true
- volumes:
- - ./elastic_opendistro/internal_users.yml:/usr/share/elasticsearch/plugins/opendistro_security/securityconfig/internal_users.yml
ulimits:
memlock:
soft: -1
From 8af39e3a568920ab3bfa0c2cf956ddfdb9720363 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 20 Aug 2020 19:01:30 +0200
Subject: [PATCH 10/50] Export variables to share with sub-shell
---
kibana-opendistro/config/entrypoint.sh | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/kibana-opendistro/config/entrypoint.sh b/kibana-opendistro/config/entrypoint.sh
index 79039afc..cca7c3da 100644
--- a/kibana-opendistro/config/entrypoint.sh
+++ b/kibana-opendistro/config/entrypoint.sh
@@ -7,13 +7,23 @@ set -e
# Waiting for elasticsearch
##############################################################################
-if [ "x${ELASTICSEARCH_URL}" = "x" ]; then
- el_url="http://elasticsearch:9200"
+if [ "x${ELASTICSEARCH_URL}" == "x" ]; then
+ if [[ ${ENABLED_SECURITY} == "false" ]]; then
+ export el_url="http://elasticsearch:9200"
+ else
+ export el_url="https://elasticsearch:9200"
+ fi
else
- el_url="${ELASTICSEARCH_URL}"
+ export el_url="${ELASTICSEARCH_URL}"
fi
-auth=""
+if [[ ${ENABLED_SECURITY} == "false" || "x${ELASTICSEARCH_USERNAME}" == "x" || "x${ELASTICSEARCH_PASSWORD}" == "x" ]]; then
+ auth=""
+ # remove security plugin from kibana if elasticsearch is not using it either
+ /usr/share/kibana/bin/kibana-plugin remove opendistro_security
+else
+ export auth="--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} -k"
+fi
until curl -XGET $el_url ${auth}; do
>&2 echo "Elastic is unavailable - sleeping"
@@ -33,7 +43,7 @@ strlen=0
while [[ $strlen -eq 0 ]]
do
- template=$(curl $el_url/_cat/templates/wazuh -s)
+ template=$(curl ${auth} $el_url/_cat/templates/wazuh -s)
strlen=${#template}
>&2 echo "Wazuh alerts template not loaded - sleeping."
sleep 2
From b1e0f9b35e0b9d3a1e300901192aa615a3a1b802 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 20 Aug 2020 19:02:04 +0200
Subject: [PATCH 11/50] Move auth
---
kibana-opendistro/config/wazuh_app_config.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kibana-opendistro/config/wazuh_app_config.sh b/kibana-opendistro/config/wazuh_app_config.sh
index 6d9f05eb..ec16a336 100644
--- a/kibana-opendistro/config/wazuh_app_config.sh
+++ b/kibana-opendistro/config/wazuh_app_config.sh
@@ -48,7 +48,7 @@ done
# remove default API entry (new in 3.11.0_7.5.1)
sed -ie '/- default:/,+4d' $kibana_config_file
-CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/_doc/1513629884013 ${auth})
+CONFIG_CODE=$(curl ${auth} -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/_doc/1513629884013)
grep -q 1513629884013 $kibana_config_file
_config_exists=$?
From 6e82f67a9d4e361e47c5a9c9e3b236c59afdd13f Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Fri, 21 Aug 2020 15:39:45 +0200
Subject: [PATCH 12/50] Use default password
---
docker-compose.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index e6f23646..fa2690cc 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -54,8 +54,7 @@ services:
restart: always
environment:
- ELASTICSEARCH_USERNAME=admin
- - ELASTICSEARCH_PASSWORD=SecretPass
- - ELASTICSEARCH_KIBANA_IP="https://elasticsearch:9200"
+ - ELASTICSEARCH_PASSWORD=admin
depends_on:
- elasticsearch
links:
From 0c6114698615da12dd6abb7d4245d5be728700a7 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Fri, 21 Aug 2020 15:40:35 +0200
Subject: [PATCH 13/50] Customize login styles
---
kibana-opendistro/config/welcome_wazuh.sh | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/kibana-opendistro/config/welcome_wazuh.sh b/kibana-opendistro/config/welcome_wazuh.sh
index 98306871..46aaddfa 100644
--- a/kibana-opendistro/config/welcome_wazuh.sh
+++ b/kibana-opendistro/config/welcome_wazuh.sh
@@ -3,22 +3,12 @@
if [[ $CHANGE_WELCOME == "true" ]]
then
-
- rm -rf ./optimize/bundles
-
- kibana_path="/usr/share/kibana"
- # Set Wazuh app as the default landing page
echo "Set Wazuh app as the default landing page"
echo "server.defaultRoute: /app/wazuh" >> /usr/share/kibana/config/kibana.yml
- # Redirect Kibana welcome screen to Discover
- echo "Redirect Kibana welcome screen to Discover"
- sed -i "s:'/app/kibana#/home':'/app/wazuh':g" $kibana_path/src/ui/public/chrome/directives/global_nav/global_nav.html
- sed -i "s:'/app/kibana#/home':'/app/wazuh':g" $kibana_path/src/ui/public/chrome/directives/header_global_nav/header_global_nav.js
-
- # Redirect Kibana welcome screen to Discover
- echo "Hide undesired links"
- sed -i 's#visible: true#visible: false#g' $kibana_path/node_modules/x-pack/plugins/rollup/public/crud_app/index.js
- sed -i 's#visible: true#visible: false#g' $kibana_path/node_modules/x-pack/plugins/license_management/public/management_section.js
+ echo "Set custom welcome styles"
+ cp -f /tmp/custom_welcome/template.js.hbs /usr/share/kibana/src/legacy/ui/ui_render/bootstrap/template.js.hbs
+ cp -f /tmp/custom_welcome/security-login.style.css /usr/share/kibana/optimize/bundles/security-login.style.css
+ cp -f /tmp/custom_welcome/*svg /usr/share/kibana/optimize/bundles/
fi
From e93e67ed6e81feaa699d32c25f7688ba9de786bc Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Fri, 21 Aug 2020 15:41:08 +0200
Subject: [PATCH 14/50] Add auth to kibana_settings
---
kibana-opendistro/config/kibana_settings.sh | 28 +++++++--------------
1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/kibana-opendistro/config/kibana_settings.sh b/kibana-opendistro/config/kibana_settings.sh
index 0f624725..514727a6 100644
--- a/kibana-opendistro/config/kibana_settings.sh
+++ b/kibana-opendistro/config/kibana_settings.sh
@@ -17,10 +17,9 @@ WAZUH_MAJOR=3
##############################################################################
# Customize elasticsearch ip
##############################################################################
-if [ "$ELASTICSEARCH_KIBANA_IP" != "" ]; then
- sed -i "s:#elasticsearch.hosts:elasticsearch.hosts:g" /usr/share/kibana/config/kibana.yml
- sed -i 's|http://elasticsearch:9200|'$ELASTICSEARCH_KIBANA_IP'|g' /usr/share/kibana/config/kibana.yml
-fi
+sed -i "s|elasticsearch.hosts:.*|elasticsearch.hosts: $el_url|g" /usr/share/kibana/config/kibana.yml
+# disable multitenancy
+sed -i "s|opendistro_security.multitenancy.enabled:.*|opendistro_security.multitenancy.enabled: false|g" /usr/share/kibana/config/kibana.yml
# If KIBANA_INDEX was set, then change the default index in kibana.yml configuration file. If there was an index, then delete it and recreate.
if [ "$KIBANA_INDEX" != "" ]; then
@@ -31,17 +30,12 @@ if [ "$KIBANA_INDEX" != "" ]; then
fi
if [ "$KIBANA_IP" != "" ]; then
- kibana_ip="$KIBANA_IP"
+ kibana_url="$KIBANA_IP"
else
- kibana_ip="kibana"
+ kibana_url="kibana"
fi
-# Add auth headers if required
-if [ "$ELASTICSEARCH_USERNAME" != "" ] && [ "$ELASTICSEARCH_PASSWORD" != "" ]; then
- curl_auth="-u $ELASTICSEARCH_USERNAME:$ELASTICSEARCH_PASSWORD"
-fi
-
-while [[ "$(curl $curl_auth -XGET -I -s -o /dev/null -w ''%{http_code}'' $kibana_ip:5601/status)" != "200" ]]; do
+while [[ "$(curl -XGET -I -s -o /dev/null -w '%{http_code}' $kibana_url:5601/login)" != "200" ]]; do
echo "Waiting for Kibana API. Sleeping 5 seconds"
sleep 5
done
@@ -61,16 +55,12 @@ EOF
sleep 5
# Add the wazuh alerts index as default.
-curl -POST "http://$kibana_ip:5601/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d@${default_index}
+curl ${auth} -POST $kibana_url:5601/api/kibana/settings -H "Content-Type: application/json" -H "kbn-xsrf: true" -d@${default_index}
rm -f ${default_index}
sleep 5
# Configuring Kibana TimePicker.
-curl -POST "http://$kibana_ip:5601/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d \
-'{"changes":{"timepicker:timeDefaults":"{\n \"from\": \"now-24h\",\n \"to\": \"now\",\n \"mode\": \"quick\"}"}}'
-
-sleep 5
-# Do not ask user to help providing usage statistics to Elastic
-curl -POST "http://$kibana_ip:5601/api/telemetry/v2/optIn" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d '{"enabled":false}'
+curl ${auth} -POST "http://$kibana_url:5601/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d \
+'{"changes":{"timepicker:timeDefaults":"{\n \"from\": \"now-12h\",\n \"to\": \"now\",\n \"mode\": \"quick\"}"}}'
echo "End settings"
From 81aeac1570520f9cede1b08f307796fb4c3090ed Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Fri, 21 Aug 2020 15:42:08 +0200
Subject: [PATCH 15/50] Customize welcome after kibana optimize
---
kibana-opendistro/Dockerfile | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kibana-opendistro/Dockerfile b/kibana-opendistro/Dockerfile
index 7dd86ede..3694dbcf 100644
--- a/kibana-opendistro/Dockerfile
+++ b/kibana-opendistro/Dockerfile
@@ -45,13 +45,13 @@ RUN chmod +x ./wazuh_app_config.sh
COPY --chown=kibana:kibana ./config/kibana_settings.sh ./
RUN chmod +x ./kibana_settings.sh
-COPY ./config/custom_welcome /tmp/custom_welcome
-COPY --chown=kibana:kibana ./config/welcome_wazuh.sh ./
-RUN chmod +x ./welcome_wazuh.sh
-ARG CHANGE_WELCOME="false"
-RUN ./welcome_wazuh.sh
-
USER kibana
RUN NODE_OPTIONS="--max-old-space-size=2048" /usr/local/bin/kibana-docker --optimize
+COPY ./config/custom_welcome /tmp/custom_welcome
+COPY --chown=kibana:kibana ./config/welcome_wazuh.sh ./
+RUN chmod +x ./welcome_wazuh.sh
+ARG CHANGE_WELCOME="true"
+RUN ./welcome_wazuh.sh
+
ENTRYPOINT ./entrypoint.sh
From 131115c2384df82b22f2803b01aed93dc56b7c57 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Fri, 21 Aug 2020 16:03:45 +0200
Subject: [PATCH 16/50] Make sure kibana starts after config changes
---
kibana-opendistro/config/entrypoint.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kibana-opendistro/config/entrypoint.sh b/kibana-opendistro/config/entrypoint.sh
index cca7c3da..f2c017f1 100644
--- a/kibana-opendistro/config/entrypoint.sh
+++ b/kibana-opendistro/config/entrypoint.sh
@@ -60,4 +60,6 @@ sleep 5
./kibana_settings.sh &
+sleep 2
+
/usr/local/bin/kibana-docker
From 3f0e908a2b92d5f0c86f1249eea67e1913c57298 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Mon, 24 Aug 2020 15:38:04 +0200
Subject: [PATCH 17/50] Use API new default user
---
kibana-opendistro/config/wazuh_app_config.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kibana-opendistro/config/wazuh_app_config.sh b/kibana-opendistro/config/wazuh_app_config.sh
index ec16a336..afa3d71d 100644
--- a/kibana-opendistro/config/wazuh_app_config.sh
+++ b/kibana-opendistro/config/wazuh_app_config.sh
@@ -3,8 +3,8 @@
wazuh_url="${WAZUH_API_URL:-https://wazuh}"
wazuh_port="${API_PORT:-55000}"
-api_user="${API_USER:-foo}"
-api_password="${API_PASS:-bar}"
+api_user="${API_USER:-wazuh}"
+api_password="${API_PASS:-wazuh}"
kibana_config_file="/usr/share/kibana/optimize/wazuh/config/wazuh.yml"
mkdir -p /usr/share/kibana/optimize/wazuh/config/
From 65327f8032e029908bd4c3fd25bdf4b584f164e8 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Mon, 24 Aug 2020 15:38:24 +0200
Subject: [PATCH 18/50] Install wazuhapp 4
---
kibana-opendistro/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kibana-opendistro/Dockerfile b/kibana-opendistro/Dockerfile
index 3694dbcf..3f72a444 100644
--- a/kibana-opendistro/Dockerfile
+++ b/kibana-opendistro/Dockerfile
@@ -6,7 +6,7 @@ ARG WAZUH_VERSION=3.13.1
ARG WAZUH_APP_VERSION="${WAZUH_VERSION}_${ELASTIC_VERSION}"
WORKDIR /usr/share/kibana
-RUN ./bin/kibana-plugin install https://packages.wazuh.com/wazuhapp/wazuhapp-${WAZUH_APP_VERSION}.zip
+RUN ./bin/kibana-plugin install https://s3-us-west-1.amazonaws.com/packages-dev.wazuh.com/staging/ui/kibana/wazuhapp-4.0.0_7.8.0_0.0.0.todelete.zip
WORKDIR /
USER root
From 4de5401144daa3e37a549447501b119d47d91f98 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Mon, 24 Aug 2020 15:39:03 +0200
Subject: [PATCH 19/50] Remove wazuh-api s6-overlay calls
---
wazuh-opendistro/config/etc/services.d/api/finish | 6 ------
wazuh-opendistro/config/etc/services.d/api/run | 4 ----
2 files changed, 10 deletions(-)
delete mode 100644 wazuh-opendistro/config/etc/services.d/api/finish
delete mode 100644 wazuh-opendistro/config/etc/services.d/api/run
diff --git a/wazuh-opendistro/config/etc/services.d/api/finish b/wazuh-opendistro/config/etc/services.d/api/finish
deleted file mode 100644
index 38d744d1..00000000
--- a/wazuh-opendistro/config/etc/services.d/api/finish
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env sh
-echo >&2 "API exited. code=${1}"
-
-# terminate other services to exit from the container
-exec s6-svscanctl -t /var/run/s6/services
-
diff --git a/wazuh-opendistro/config/etc/services.d/api/run b/wazuh-opendistro/config/etc/services.d/api/run
deleted file mode 100644
index e6e3e831..00000000
--- a/wazuh-opendistro/config/etc/services.d/api/run
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/with-contenv sh
-echo >&2 "starting API"
-
-exec /bin/node /var/ossec/api/app.js
From e7acb70b6f2cd6515c84b6f1389f0bbf77a98a33 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Mon, 24 Aug 2020 15:39:36 +0200
Subject: [PATCH 20/50] Install wazuh-manager v4 from staging
---
wazuh-opendistro/Dockerfile | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
index 1add03c0..f8173987 100644
--- a/wazuh-opendistro/Dockerfile
+++ b/wazuh-opendistro/Dockerfile
@@ -2,7 +2,7 @@
FROM centos:7
ARG FILEBEAT_VERSION=7.8.0
-ARG WAZUH_VERSION=3.13.1-1
+ARG WAZUH_VERSION=4.0.0-1
ARG TEMPLATE_VERSION="v3.13.1"
ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.1.tar.gz"
@@ -13,14 +13,15 @@ ENV API_USER="foo" \
# Set repositories.
RUN rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
-COPY config/wazuh.repo /etc/yum.repos.d/wazuh.repo
+# COPY config/wazuh.repo /etc/yum.repos.d/wazuh.repo
RUN yum --enablerepo=updates clean metadata && \
- yum -y install openssl which && yum -y install wazuh-manager-${WAZUH_VERSION} -y && \
- curl --silent --location https://rpm.nodesource.com/setup_10.x | bash - && \
- yum -y install nodejs && yum -y install wazuh-api-${WAZUH_VERSION} && \
- sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo && \
+ curl --fail --silent https://s3-us-west-1.amazonaws.com/packages-dev.wazuh.com/warehouse/test/4.0/rpm/var/wazuh-manager-4.0.0-braulio.test.x86_64.rpm \
+ -o wazuh-manager.rpm && \
+ yum -y install openssl which && yum -y install wazuh-manager.rpm -y && \
yum clean all && rm -rf /var/cache/yum
+ # sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo && \
+
RUN curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm &&\
rpm -i filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm && rm -f filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm
From da14494144e1a9f2f24bfe1787c8cd2b47f3c3c2 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Mon, 24 Aug 2020 16:21:16 +0200
Subject: [PATCH 21/50] Use staging repo
---
wazuh-opendistro/config/wazuh.repo | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wazuh-opendistro/config/wazuh.repo b/wazuh-opendistro/config/wazuh.repo
index ae462c62..8be8a18e 100644
--- a/wazuh-opendistro/config/wazuh.repo
+++ b/wazuh-opendistro/config/wazuh.repo
@@ -3,5 +3,5 @@ gpgcheck=1
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
name=Wazuh repository
-baseurl=https://packages.wazuh.com/3.x/yum/
+baseurl=https://packages-dev.wazuh.com/staging/yum/
protect=1
From 139ac79463d1d9b34bdc7d569526262d5afe2255 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Mon, 24 Aug 2020 16:28:04 +0200
Subject: [PATCH 22/50] Parametrize version
---
wazuh-opendistro/Dockerfile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
index f8173987..80ae4a76 100644
--- a/wazuh-opendistro/Dockerfile
+++ b/wazuh-opendistro/Dockerfile
@@ -2,7 +2,7 @@
FROM centos:7
ARG FILEBEAT_VERSION=7.8.0
-ARG WAZUH_VERSION=4.0.0-1
+ARG WAZUH_VERSION=4.0.0-braulio.test
ARG TEMPLATE_VERSION="v3.13.1"
ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.1.tar.gz"
@@ -16,7 +16,7 @@ RUN rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
# COPY config/wazuh.repo /etc/yum.repos.d/wazuh.repo
RUN yum --enablerepo=updates clean metadata && \
- curl --fail --silent https://s3-us-west-1.amazonaws.com/packages-dev.wazuh.com/warehouse/test/4.0/rpm/var/wazuh-manager-4.0.0-braulio.test.x86_64.rpm \
+ curl --fail --silent https://s3-us-west-1.amazonaws.com/packages-dev.wazuh.com/warehouse/test/4.0/rpm/var/wazuh-manager-${WAZUH_VERSION}.x86_64.rpm \
-o wazuh-manager.rpm && \
yum -y install openssl which && yum -y install wazuh-manager.rpm -y && \
yum clean all && rm -rf /var/cache/yum
From 5bb1127cf23357533efd7b52d934b279d9fa57e3 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Mon, 24 Aug 2020 16:57:38 +0200
Subject: [PATCH 23/50] Update username param
---
kibana-opendistro/config/wazuh_app_config.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kibana-opendistro/config/wazuh_app_config.sh b/kibana-opendistro/config/wazuh_app_config.sh
index afa3d71d..db1d8f82 100644
--- a/kibana-opendistro/config/wazuh_app_config.sh
+++ b/kibana-opendistro/config/wazuh_app_config.sh
@@ -59,7 +59,7 @@ hosts:
- 1513629884013:
url: $wazuh_url
port: $wazuh_port
- user: $api_user
+ username: $api_user
password: $api_password
EOF
else
From eb089e80116d98776c1154577b73aea326d11d81 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 25 Aug 2020 13:07:18 +0200
Subject: [PATCH 24/50] Switch to new filebeat module and template
---
wazuh-opendistro/Dockerfile | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
index 80ae4a76..25788066 100644
--- a/wazuh-opendistro/Dockerfile
+++ b/wazuh-opendistro/Dockerfile
@@ -3,8 +3,8 @@ FROM centos:7
ARG FILEBEAT_VERSION=7.8.0
ARG WAZUH_VERSION=4.0.0-braulio.test
-ARG TEMPLATE_VERSION="v3.13.1"
-ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.1.tar.gz"
+ARG TEMPLATE_VERSION="develop"
+ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.2.tar.gz"
ENV API_USER="foo" \
API_PASS="bar"
@@ -26,10 +26,7 @@ RUN yum --enablerepo=updates clean metadata && \
RUN curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm &&\
rpm -i filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm && rm -f filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm
-RUN curl -so /etc/filebeat/wazuh-template.json https://raw.githubusercontent.com/wazuh/wazuh/${TEMPLATE_VERSION}/extensions/elasticsearch/7.x/wazuh-template.json &&\
- chmod go+r /etc/filebeat/wazuh-template.json
-
-RUN curl -s https://packages.wazuh.com/3.x/filebeat/${WAZUH_FILEBEAT_MODULE} | tar -xvz -C /usr/share/filebeat/module
+RUN curl -s https://packages-dev.wazuh.com/utils/${WAZUH_FILEBEAT_MODULE} | tar -xvz -C /usr/share/filebeat/module
ARG S6_VERSION="v2.0.0.1"
RUN curl --fail --silent -L https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz \
From 325c191b68ec7d028fb0ed089263b774495dde7c Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 25 Aug 2020 13:30:31 +0200
Subject: [PATCH 25/50] Bump to recent package
---
wazuh-opendistro/Dockerfile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
index 25788066..7fd4787a 100644
--- a/wazuh-opendistro/Dockerfile
+++ b/wazuh-opendistro/Dockerfile
@@ -2,7 +2,7 @@
FROM centos:7
ARG FILEBEAT_VERSION=7.8.0
-ARG WAZUH_VERSION=4.0.0-braulio.test
+ARG WAZUH_VERSION=4.0.0-c6test
ARG TEMPLATE_VERSION="develop"
ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.2.tar.gz"
@@ -16,7 +16,7 @@ RUN rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
# COPY config/wazuh.repo /etc/yum.repos.d/wazuh.repo
RUN yum --enablerepo=updates clean metadata && \
- curl --fail --silent https://s3-us-west-1.amazonaws.com/packages-dev.wazuh.com/warehouse/test/4.0/rpm/var/wazuh-manager-${WAZUH_VERSION}.x86_64.rpm \
+ curl --fail --silent https://packages-dev.wazuh.com/warehouse/test/4.0/rpm/var/wazuh-manager-${WAZUH_VERSION}.x86_64.rpm \
-o wazuh-manager.rpm && \
yum -y install openssl which && yum -y install wazuh-manager.rpm -y && \
yum clean all && rm -rf /var/cache/yum
From d7133df0f3022756c08553b670e64edfdf25ba6a Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 25 Aug 2020 13:40:24 +0200
Subject: [PATCH 26/50] Clean downloaded package
---
wazuh-opendistro/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
index 7fd4787a..f17b6d21 100644
--- a/wazuh-opendistro/Dockerfile
+++ b/wazuh-opendistro/Dockerfile
@@ -18,7 +18,7 @@ RUN rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
RUN yum --enablerepo=updates clean metadata && \
curl --fail --silent https://packages-dev.wazuh.com/warehouse/test/4.0/rpm/var/wazuh-manager-${WAZUH_VERSION}.x86_64.rpm \
-o wazuh-manager.rpm && \
- yum -y install openssl which && yum -y install wazuh-manager.rpm -y && \
+ yum -y install openssl which && yum -y install wazuh-manager.rpm -y && rm -f wazuh-manager.rpm \
yum clean all && rm -rf /var/cache/yum
# sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo && \
From 248b769688f422c01baacb02ebd4e69d170ff726 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 25 Aug 2020 14:30:27 +0200
Subject: [PATCH 27/50] Remove API tweaks
---
.../config/etc/cont-init.d/0-wazuh-init | 70 +++----------------
1 file changed, 10 insertions(+), 60 deletions(-)
diff --git a/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init
index b0cbd001..f3fbd1a4 100644
--- a/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init
+++ b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init
@@ -7,7 +7,6 @@ source /permanent_data.env
WAZUH_INSTALL_PATH=/var/ossec
WAZUH_CONFIG_MOUNT=/wazuh-config-mount
AUTO_ENROLLMENT_ENABLED=${AUTO_ENROLLMENT_ENABLED:-true}
-API_GENERATE_CERTS=${API_GENERATE_CERTS:-true}
##############################################################################
@@ -33,18 +32,10 @@ exec_cmd_stdout() {
##############################################################################
-# Edit configuration
-##############################################################################
-
-edit_configuration() { # $1 -> setting, $2 -> value
- sed -i "s/^config.$1\s=.*/config.$1 = \"$2\";/g" "${WAZUH_INSTALL_PATH}/api/configuration/config.js" || error_and_exit "sed (editing configuration)"
-}
-
-##############################################################################
-# This function will attempt to mount every directory in PERMANENT_DATA
-# into the respective path.
-# If the path is empty means permanent data volume is also empty, so a backup
-# will be copied into it. Otherwise it will not be copied because there is
+# This function will attempt to mount every directory in PERMANENT_DATA
+# into the respective path.
+# If the path is empty means permanent data volume is also empty, so a backup
+# will be copied into it. Otherwise it will not be copied because there is
# already data inside the volume for the specified path.
##############################################################################
@@ -61,9 +52,9 @@ mount_permanent_data() {
}
##############################################################################
-# This function will replace from the permanent data volume every file
+# This function will replace from the permanent data volume every file
# contained in PERMANENT_DATA_EXCP
-# Some files as 'internal_options.conf' are saved as permanent data, but
+# Some files as 'internal_options.conf' are saved as permanent data, but
# they must be updated to work properly if wazuh version is changed.
##############################################################################
@@ -76,7 +67,7 @@ apply_exclusion_data() {
then
mkdir -p ${DIR}
fi
-
+
print "Updating ${exclusion_file}"
exec_cmd "cp -p ${WAZUH_INSTALL_PATH}/data_tmp/exclusion/${exclusion_file} ${exclusion_file}"
fi
@@ -84,14 +75,14 @@ apply_exclusion_data() {
}
##############################################################################
-# This function will delete from the permanent data volume every file
+# This function will delete from the permanent data volume every file
# contained in PERMANENT_DATA_DEL
##############################################################################
remove_data_files() {
for del_file in "${PERMANENT_DATA_DEL[@]}"; do
if [ -e ${del_file} ]
- then
+ then
print "Removing ${del_file}"
exec_cmd "rm ${del_file}"
fi
@@ -108,22 +99,6 @@ create_ossec_key_cert() {
exec_cmd "openssl req -new -x509 -key ${WAZUH_INSTALL_PATH}/etc/sslmanager.key -out ${WAZUH_INSTALL_PATH}/etc/sslmanager.cert -days 3650 -subj /CN=${HOSTNAME}/"
}
-##############################################################################
-# Create certificates: API
-##############################################################################
-
-create_api_key_cert() {
- print "Enabling Wazuh API HTTPS"
- edit_configuration "https" "yes"
- print "Create Wazuh API key and cert"
- exec_cmd "openssl genrsa -out ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.key 4096"
- exec_cmd "openssl req -new -x509 -key ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.key -out ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.crt -days 3650 -subj /CN=${HOSTNAME}/"
-
- # Granting proper permissions
- chmod 400 ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.key
- chmod 400 ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.crt
-}
-
##############################################################################
# Copy all files from $WAZUH_CONFIG_MOUNT to $WAZUH_INSTALL_PATH and respect
# destination files permissions
@@ -153,7 +128,7 @@ function ossec_shutdown(){
##############################################################################
# Interpret any passed arguments (via docker command to this entrypoint) as
-# paths or commands, and execute them.
+# paths or commands, and execute them.
#
# This can be useful for actions that need to be run before the services are
# started, such as "/var/ossec/bin/ossec-control enable agentless".
@@ -167,19 +142,6 @@ docker_custom_args() {
done
}
-##############################################################################
-# Change Wazuh API user credentials.
-##############################################################################
-
-change_api_user_credentials() {
- pushd /var/ossec/api/configuration/auth/
- echo "Change Wazuh API user credentials"
- change_user="node htpasswd -b -c user $API_USER $API_PASS"
- eval $change_user
- popd
-}
-
-
##############################################################################
# Main function
##############################################################################
@@ -203,15 +165,6 @@ main() {
fi
fi
- # Generate API certs if API_GENERATE_CERTS is true and does not exist
- if [ $API_GENERATE_CERTS == true ]
- then
- if [ ! -e ${WAZUH_INSTALL_PATH}/api/configuration/ssl/server.crt ]
- then
- create_api_key_cert
- fi
- fi
-
# Mount selected files (WAZUH_CONFIG_MOUNT) to container
mount_files
@@ -221,9 +174,6 @@ main() {
# Execute custom args
docker_custom_args
- # Change API user credentials
- change_api_user_credentials
-
# Delete temporary data folder
rm -rf ${WAZUH_INSTALL_PATH}/data_tmp
From 7badd1bdec38d178ba407f6196f2f3e6145140f9 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 25 Aug 2020 14:30:50 +0200
Subject: [PATCH 28/50] Fix package cleanup
---
wazuh-opendistro/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
index f17b6d21..b81723c6 100644
--- a/wazuh-opendistro/Dockerfile
+++ b/wazuh-opendistro/Dockerfile
@@ -18,7 +18,7 @@ RUN rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
RUN yum --enablerepo=updates clean metadata && \
curl --fail --silent https://packages-dev.wazuh.com/warehouse/test/4.0/rpm/var/wazuh-manager-${WAZUH_VERSION}.x86_64.rpm \
-o wazuh-manager.rpm && \
- yum -y install openssl which && yum -y install wazuh-manager.rpm -y && rm -f wazuh-manager.rpm \
+ yum -y install openssl which && yum -y install wazuh-manager.rpm -y && rm -f wazuh-manager.rpm && \
yum clean all && rm -rf /var/cache/yum
# sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo && \
From 1608474bdffd37dd9b2417c006b4146dc9d39225 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 25 Aug 2020 14:36:49 +0200
Subject: [PATCH 29/50] Update wodles
---
wazuh-opendistro/config/permanent_data.env | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/wazuh-opendistro/config/permanent_data.env b/wazuh-opendistro/config/permanent_data.env
index ca461d63..9c2556d8 100644
--- a/wazuh-opendistro/config/permanent_data.env
+++ b/wazuh-opendistro/config/permanent_data.env
@@ -55,20 +55,13 @@ PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/azure/azure-logs"
PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/azure/azure-logs.py"
PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/docker/DockerListener"
PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/docker/DockerListener.py"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/oscap"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/oscap.py"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/template_oval.xsl"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/template_xccdf.xsl"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/cve-redhat-6-ds.xml"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/cve-redhat-7-ds.xml"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-centos-6-ds.xml"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-centos-7-ds.xml"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-fedora-24-ds.xml"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-rhel-6-ds.xml"
-PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-rhel-7-ds.xml"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/gcloud/gcloud"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/gcloud/gcloud.py"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/gcloud/integration.py"
+PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/gcloud/tools.py"
export PERMANENT_DATA_EXCP
-# Files mounted in a volume that should be deleted
+# Files mounted in a volume that should be deleted
i=0
PERMANENT_DATA_DEL[((i++))]="/var/ossec/queue/db/.template.db"
export PERMANENT_DATA_DEL
From bbabf9bb3b7945cc046141fb9029775d20479ea1 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 25 Aug 2020 15:09:49 +0200
Subject: [PATCH 30/50] Bump default index to 4
---
kibana-opendistro/config/kibana_settings.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kibana-opendistro/config/kibana_settings.sh b/kibana-opendistro/config/kibana_settings.sh
index 514727a6..c3239f25 100644
--- a/kibana-opendistro/config/kibana_settings.sh
+++ b/kibana-opendistro/config/kibana_settings.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# Wazuh Docker Copyright (C) 2020 Wazuh Inc. (License GPLv2)
-WAZUH_MAJOR=3
+WAZUH_MAJOR=4
##############################################################################
# Wait for the Kibana API to start. It is necessary to do it in this container
From 274342e24dca43b5d09202d05d59e07f1f3449b5 Mon Sep 17 00:00:00 2001
From: manuasir
Date: Tue, 25 Aug 2020 16:47:11 +0200
Subject: [PATCH 31/50] Disabled basic auth
---
nginx_conf/kibana-web.conf | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/nginx_conf/kibana-web.conf b/nginx_conf/kibana-web.conf
index b3821747..9ac5b667 100644
--- a/nginx_conf/kibana-web.conf
+++ b/nginx_conf/kibana-web.conf
@@ -10,11 +10,11 @@ server {
ssl_certificate /etc/nginx/conf.d/ssl/kibana-access.pem;
ssl_certificate_key /etc/nginx/conf.d/ssl/kibana-access.key;
location / {
- auth_basic "Restricted Access";
- auth_basic_user_file /etc/nginx/conf.d/kibana.htpasswd;
+ # auth_basic "Restricted Access";
+ # auth_basic_user_file /etc/nginx/conf.d/kibana.htpasswd;
proxy_pass http://kibana:5601/;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
}
-}
+}
From 033600101233eee46f22b5f39defbdc3108072a4 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 25 Aug 2020 17:03:33 +0200
Subject: [PATCH 32/50] Remove KIBANA_IP variable
---
kibana-opendistro/config/kibana_settings.sh | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/kibana-opendistro/config/kibana_settings.sh b/kibana-opendistro/config/kibana_settings.sh
index c3239f25..d536e24f 100644
--- a/kibana-opendistro/config/kibana_settings.sh
+++ b/kibana-opendistro/config/kibana_settings.sh
@@ -29,13 +29,7 @@ if [ "$KIBANA_INDEX" != "" ]; then
echo "kibana.index: $KIBANA_INDEX" >> /usr/share/kibana/config/kibana.yml
fi
-if [ "$KIBANA_IP" != "" ]; then
- kibana_url="$KIBANA_IP"
-else
- kibana_url="kibana"
-fi
-
-while [[ "$(curl -XGET -I -s -o /dev/null -w '%{http_code}' $kibana_url:5601/login)" != "200" ]]; do
+while [[ "$(curl -XGET -I -s -o /dev/null -w '%{http_code}' https://127.0.0.1/login)" != "200" ]]; do
echo "Waiting for Kibana API. Sleeping 5 seconds"
sleep 5
done
@@ -55,12 +49,12 @@ EOF
sleep 5
# Add the wazuh alerts index as default.
-curl ${auth} -POST $kibana_url:5601/api/kibana/settings -H "Content-Type: application/json" -H "kbn-xsrf: true" -d@${default_index}
+curl ${auth} -POST https://127.0.0.1/api/kibana/settings -H "Content-Type: application/json" -H "kbn-xsrf: true" -d@${default_index}
rm -f ${default_index}
sleep 5
# Configuring Kibana TimePicker.
-curl ${auth} -POST "http://$kibana_url:5601/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d \
+curl ${auth} -POST "https://127.0.0.1/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d \
'{"changes":{"timepicker:timeDefaults":"{\n \"from\": \"now-12h\",\n \"to\": \"now\",\n \"mode\": \"quick\"}"}}'
echo "End settings"
From a9ee1f7e2901df6792389ec7e32160aebf5c4e0a Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 26 Aug 2020 13:18:01 +0200
Subject: [PATCH 33/50] Update staging app
---
kibana-opendistro/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kibana-opendistro/Dockerfile b/kibana-opendistro/Dockerfile
index 3f72a444..a897acdc 100644
--- a/kibana-opendistro/Dockerfile
+++ b/kibana-opendistro/Dockerfile
@@ -6,7 +6,7 @@ ARG WAZUH_VERSION=3.13.1
ARG WAZUH_APP_VERSION="${WAZUH_VERSION}_${ELASTIC_VERSION}"
WORKDIR /usr/share/kibana
-RUN ./bin/kibana-plugin install https://s3-us-west-1.amazonaws.com/packages-dev.wazuh.com/staging/ui/kibana/wazuhapp-4.0.0_7.8.0_0.0.0.todelete.zip
+RUN ./bin/kibana-plugin install https://packages-dev.wazuh.com/warehouse/test/4.0/ui/kibana/wazuhapp-4.0.0_7.8.0_0.0.0.todelete.zip
WORKDIR /
USER root
From 3deb80d6a099d25f8c3fdf6507aa01e41212b3d0 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 26 Aug 2020 15:29:06 +0200
Subject: [PATCH 34/50] Add temporary fix for node dependencies
---
kibana-opendistro/Dockerfile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kibana-opendistro/Dockerfile b/kibana-opendistro/Dockerfile
index a897acdc..0f4605a8 100644
--- a/kibana-opendistro/Dockerfile
+++ b/kibana-opendistro/Dockerfile
@@ -7,6 +7,8 @@ ARG WAZUH_APP_VERSION="${WAZUH_VERSION}_${ELASTIC_VERSION}"
WORKDIR /usr/share/kibana
RUN ./bin/kibana-plugin install https://packages-dev.wazuh.com/warehouse/test/4.0/ui/kibana/wazuhapp-4.0.0_7.8.0_0.0.0.todelete.zip
+RUN cp -Rf ./plugins/wazuh/node_modules/brace ./node_modules/
+RUN rm -Rf plugins/wazuh/node_modules/brace
WORKDIR /
USER root
From a24fd2fbce1997038cff365fc95fce80e5796eff Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 26 Aug 2020 15:29:53 +0200
Subject: [PATCH 35/50] Add SSL_CERTIFICATE and SSL_KEY support to
config-filebeat
---
.../config/etc/cont-init.d/1-config-filebeat | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat b/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
index dae9947f..04be44bb 100644
--- a/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
+++ b/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
@@ -30,6 +30,16 @@ if [ "$SSL_CERTIFICATE_AUTHORITIES" != "" ]; then
sed -i "s|#ssl.certificate_authorities:.*|ssl.certificate_authorities: ['$SSL_CERTIFICATE_AUTHORITIES']|g" /etc/filebeat/filebeat.yml
fi
+if [ "$SSL_CERTIFICATE" != "" ]; then
+ >&2 echo "Configuring SSL Certificate."
+ sed -i "s|#ssl.certificate:.*|ssl.certificate: ['$SSL_CERTIFICATE']|g" /etc/filebeat/filebeat.yml
+fi
+
+if [ "$SSL_KEY" != "" ]; then
+ >&2 echo "Configuring SSL Key."
+ sed -i "s|#ssl.key:.*|ssl.key: ['$SSL_KEY']|g" /etc/filebeat/filebeat.yml
+fi
+
chmod go-w /etc/filebeat/filebeat.yml || true
chown root: /etc/filebeat/filebeat.yml || true
From 6ebc52467bdad89548197327c774ab4603c2e243 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 26 Aug 2020 16:27:10 +0200
Subject: [PATCH 36/50] Optimize Docker layer caching
---
kibana-opendistro/Dockerfile | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kibana-opendistro/Dockerfile b/kibana-opendistro/Dockerfile
index 0f4605a8..8d066505 100644
--- a/kibana-opendistro/Dockerfile
+++ b/kibana-opendistro/Dockerfile
@@ -41,12 +41,6 @@ ENV PATTERN="" \
WAZUH_MONITORING_REPLICAS="" \
ADMIN_PRIVILEGES=""
-COPY --chown=kibana:kibana ./config/wazuh_app_config.sh ./
-RUN chmod +x ./wazuh_app_config.sh
-
-COPY --chown=kibana:kibana ./config/kibana_settings.sh ./
-RUN chmod +x ./kibana_settings.sh
-
USER kibana
RUN NODE_OPTIONS="--max-old-space-size=2048" /usr/local/bin/kibana-docker --optimize
@@ -56,4 +50,10 @@ RUN chmod +x ./welcome_wazuh.sh
ARG CHANGE_WELCOME="true"
RUN ./welcome_wazuh.sh
+COPY --chown=kibana:kibana ./config/wazuh_app_config.sh ./
+RUN chmod +x ./wazuh_app_config.sh
+
+COPY --chown=kibana:kibana ./config/kibana_settings.sh ./
+RUN chmod +x ./kibana_settings.sh
+
ENTRYPOINT ./entrypoint.sh
From 68a02f1f388bf4a3cfcdaa98a48ef6871dfba3e3 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 26 Aug 2020 16:27:47 +0200
Subject: [PATCH 37/50] Switch back to port 5601 on kibana
---
kibana-opendistro/config/kibana_settings.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kibana-opendistro/config/kibana_settings.sh b/kibana-opendistro/config/kibana_settings.sh
index d536e24f..63535605 100644
--- a/kibana-opendistro/config/kibana_settings.sh
+++ b/kibana-opendistro/config/kibana_settings.sh
@@ -29,7 +29,7 @@ if [ "$KIBANA_INDEX" != "" ]; then
echo "kibana.index: $KIBANA_INDEX" >> /usr/share/kibana/config/kibana.yml
fi
-while [[ "$(curl -XGET -I -s -o /dev/null -w '%{http_code}' https://127.0.0.1/login)" != "200" ]]; do
+while [[ "$(curl -XGET -I -s -o /dev/null -w '%{http_code}' http://127.0.0.1:5601/login)" != "200" ]]; do
echo "Waiting for Kibana API. Sleeping 5 seconds"
sleep 5
done
@@ -49,12 +49,12 @@ EOF
sleep 5
# Add the wazuh alerts index as default.
-curl ${auth} -POST https://127.0.0.1/api/kibana/settings -H "Content-Type: application/json" -H "kbn-xsrf: true" -d@${default_index}
+curl ${auth} -POST http://127.0.0.1:5601/api/kibana/settings -H "Content-Type: application/json" -H "kbn-xsrf: true" -d@${default_index}
rm -f ${default_index}
sleep 5
# Configuring Kibana TimePicker.
-curl ${auth} -POST "https://127.0.0.1/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d \
+curl ${auth} -POST "http://127.0.0.1:5601/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d \
'{"changes":{"timepicker:timeDefaults":"{\n \"from\": \"now-12h\",\n \"to\": \"now\",\n \"mode\": \"quick\"}"}}'
echo "End settings"
From 98273c1e27d2789a82d7204f9523ca232eb079a8 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Fri, 28 Aug 2020 14:36:55 +0200
Subject: [PATCH 38/50] Enable HTTPS for status checks
---
kibana-opendistro/config/kibana_settings.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kibana-opendistro/config/kibana_settings.sh b/kibana-opendistro/config/kibana_settings.sh
index 63535605..19cae116 100644
--- a/kibana-opendistro/config/kibana_settings.sh
+++ b/kibana-opendistro/config/kibana_settings.sh
@@ -29,7 +29,7 @@ if [ "$KIBANA_INDEX" != "" ]; then
echo "kibana.index: $KIBANA_INDEX" >> /usr/share/kibana/config/kibana.yml
fi
-while [[ "$(curl -XGET -I -s -o /dev/null -w '%{http_code}' http://127.0.0.1:5601/login)" != "200" ]]; do
+while [[ "$(curl -XGET -I -s -o /dev/null -w '%{http_code}' -k https://127.0.0.1:5601/login)" != "200" ]]; do
echo "Waiting for Kibana API. Sleeping 5 seconds"
sleep 5
done
@@ -49,12 +49,12 @@ EOF
sleep 5
# Add the wazuh alerts index as default.
-curl ${auth} -POST http://127.0.0.1:5601/api/kibana/settings -H "Content-Type: application/json" -H "kbn-xsrf: true" -d@${default_index}
+curl ${auth} -POST -k https://127.0.0.1:5601/api/kibana/settings -H "Content-Type: application/json" -H "kbn-xsrf: true" -d@${default_index}
rm -f ${default_index}
sleep 5
# Configuring Kibana TimePicker.
-curl ${auth} -POST "http://127.0.0.1:5601/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d \
+curl ${auth} -POST -k "https://127.0.0.1:5601/api/kibana/settings" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d \
'{"changes":{"timepicker:timeDefaults":"{\n \"from\": \"now-12h\",\n \"to\": \"now\",\n \"mode\": \"quick\"}"}}'
echo "End settings"
From 8fb7110af5f76b91caf78175625a98b80593fa45 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Fri, 28 Aug 2020 14:37:21 +0200
Subject: [PATCH 39/50] Enable SSL on Kibana by default
Nginx container was disabled but left commented as an example
---
docker-compose.yml | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index fa2690cc..3e17716e 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -52,28 +52,34 @@ services:
image: wazuh-kibana-opendistro
hostname: kibana
restart: always
+ ports:
+ - 443:5601
environment:
- ELASTICSEARCH_USERNAME=admin
- ELASTICSEARCH_PASSWORD=admin
+ - SERVER_SSL_ENABLED=true
+ - SERVER_SSL_CERTIFICATE=/usr/share/kibana/config/opendistroforelasticsearch.example.org.cert
+ - SERVER_SSL_KEY=/usr/share/kibana/config/opendistroforelasticsearch.example.org.key
+
depends_on:
- elasticsearch
links:
- elasticsearch:elasticsearch
- wazuh:wazuh
- nginx:
- image: nginx:stable
- hostname: nginx
- restart: always
- ports:
- - "80:80"
- - "443:443"
- depends_on:
- - kibana
- links:
- - kibana:kibana
- volumes:
- - ./nginx_conf:/etc/nginx/conf.d:ro
+ # nginx:
+ # image: nginx:stable
+ # hostname: nginx
+ # restart: always
+ # ports:
+ # - "80:80"
+ # - "443:443"
+ # depends_on:
+ # - kibana
+ # links:
+ # - kibana:kibana
+ # volumes:
+ # - ./nginx_conf:/etc/nginx/conf.d:ro
volumes:
ossec_api_configuration:
From 8657266ffda68f56dcde588ff24f150ea63a7d12 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Tue, 1 Sep 2020 17:23:49 +0200
Subject: [PATCH 40/50] Bump package version
---
wazuh-opendistro/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
index b81723c6..672ec2d6 100644
--- a/wazuh-opendistro/Dockerfile
+++ b/wazuh-opendistro/Dockerfile
@@ -2,7 +2,7 @@
FROM centos:7
ARG FILEBEAT_VERSION=7.8.0
-ARG WAZUH_VERSION=4.0.0-c6test
+ARG WAZUH_VERSION=4.0.0-0.0.0.developtestingaugust
ARG TEMPLATE_VERSION="develop"
ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.2.tar.gz"
From e45c0f3c4df4493d25a02704597ee129689e2c18 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 2 Sep 2020 10:07:56 +0200
Subject: [PATCH 41/50] Switch 1514 to TCP
---
docker-compose.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index 3e17716e..3545d480 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -8,7 +8,7 @@ services:
hostname: wazuh-manager
restart: always
ports:
- - "1514:1514/udp"
+ - "1514:1514"
- "1515:1515"
- "514:514/udp"
- "55000:55000"
From 32cd19f344180657bde135b31d7e61b9793d6975 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 3 Sep 2020 12:55:59 +0200
Subject: [PATCH 42/50] Enable pre-release package
---
wazuh-opendistro/Dockerfile | 11 ++++-------
wazuh-opendistro/config/wazuh.repo | 2 +-
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
index 672ec2d6..1bab9f3c 100644
--- a/wazuh-opendistro/Dockerfile
+++ b/wazuh-opendistro/Dockerfile
@@ -2,7 +2,7 @@
FROM centos:7
ARG FILEBEAT_VERSION=7.8.0
-ARG WAZUH_VERSION=4.0.0-0.0.0.developtestingaugust
+ARG WAZUH_VERSION=4.0.0-1
ARG TEMPLATE_VERSION="develop"
ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.2.tar.gz"
@@ -13,15 +13,12 @@ ENV API_USER="foo" \
# Set repositories.
RUN rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
-# COPY config/wazuh.repo /etc/yum.repos.d/wazuh.repo
+COPY config/wazuh.repo /etc/yum.repos.d/wazuh.repo
RUN yum --enablerepo=updates clean metadata && \
- curl --fail --silent https://packages-dev.wazuh.com/warehouse/test/4.0/rpm/var/wazuh-manager-${WAZUH_VERSION}.x86_64.rpm \
- -o wazuh-manager.rpm && \
- yum -y install openssl which && yum -y install wazuh-manager.rpm -y && rm -f wazuh-manager.rpm && \
+ yum -y install openssl which && yum -y install wazuh-manager-${WAZUH_VERSION} -y && \
+ sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo && \
yum clean all && rm -rf /var/cache/yum
- # sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo && \
-
RUN curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm &&\
rpm -i filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm && rm -f filebeat-oss-${FILEBEAT_VERSION}-x86_64.rpm
diff --git a/wazuh-opendistro/config/wazuh.repo b/wazuh-opendistro/config/wazuh.repo
index 8be8a18e..15e1b822 100644
--- a/wazuh-opendistro/config/wazuh.repo
+++ b/wazuh-opendistro/config/wazuh.repo
@@ -3,5 +3,5 @@ gpgcheck=1
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
name=Wazuh repository
-baseurl=https://packages-dev.wazuh.com/staging/yum/
+baseurl=https://packages-dev.wazuh.com/pre-release/yum/
protect=1
From b6cc7d20bbf2f612039e39d9d43776e1ad49e679 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 3 Sep 2020 12:56:14 +0200
Subject: [PATCH 43/50] Use latest app version from pre-release
---
kibana-opendistro/Dockerfile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kibana-opendistro/Dockerfile b/kibana-opendistro/Dockerfile
index 8d066505..530316a6 100644
--- a/kibana-opendistro/Dockerfile
+++ b/kibana-opendistro/Dockerfile
@@ -2,11 +2,11 @@
FROM amazon/opendistro-for-elasticsearch-kibana:1.9.0
USER kibana
ARG ELASTIC_VERSION=7.8.0
-ARG WAZUH_VERSION=3.13.1
+ARG WAZUH_VERSION=4.0.0
ARG WAZUH_APP_VERSION="${WAZUH_VERSION}_${ELASTIC_VERSION}"
WORKDIR /usr/share/kibana
-RUN ./bin/kibana-plugin install https://packages-dev.wazuh.com/warehouse/test/4.0/ui/kibana/wazuhapp-4.0.0_7.8.0_0.0.0.todelete.zip
+RUN ./bin/kibana-plugin install https://packages-dev.wazuh.com/pre-release/ui/kibana/wazuh_kibana-${WAZUH_APP_VERSION}-1.zip
RUN cp -Rf ./plugins/wazuh/node_modules/brace ./node_modules/
RUN rm -Rf plugins/wazuh/node_modules/brace
From e598cc7712b37c4db232ce84191f284ca813287c Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 3 Sep 2020 17:12:15 +0200
Subject: [PATCH 44/50] Remove temporary brace fix
---
kibana-opendistro/Dockerfile | 2 --
1 file changed, 2 deletions(-)
diff --git a/kibana-opendistro/Dockerfile b/kibana-opendistro/Dockerfile
index 530316a6..82631ca2 100644
--- a/kibana-opendistro/Dockerfile
+++ b/kibana-opendistro/Dockerfile
@@ -7,8 +7,6 @@ ARG WAZUH_APP_VERSION="${WAZUH_VERSION}_${ELASTIC_VERSION}"
WORKDIR /usr/share/kibana
RUN ./bin/kibana-plugin install https://packages-dev.wazuh.com/pre-release/ui/kibana/wazuh_kibana-${WAZUH_APP_VERSION}-1.zip
-RUN cp -Rf ./plugins/wazuh/node_modules/brace ./node_modules/
-RUN rm -Rf plugins/wazuh/node_modules/brace
WORKDIR /
USER root
From 37ba48d56d552099da39668e1e70422efd317edd Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 16 Sep 2020 17:59:54 +0200
Subject: [PATCH 45/50] Update ulimits
---
docker-compose.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/docker-compose.yml b/docker-compose.yml
index 3545d480..c7a846db 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -46,6 +46,9 @@ services:
memlock:
soft: -1
hard: -1
+ nofile:
+ soft: 65536
+ hard: 65536
kibana:
build: kibana-opendistro/
From 3d7807d27b59d701d9d43cf1ed214aa461b38def Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 16 Sep 2020 18:00:36 +0200
Subject: [PATCH 46/50] Update expose instruction to use TCP for logging
---
wazuh-opendistro/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wazuh-opendistro/Dockerfile b/wazuh-opendistro/Dockerfile
index 1bab9f3c..dd76e266 100644
--- a/wazuh-opendistro/Dockerfile
+++ b/wazuh-opendistro/Dockerfile
@@ -49,6 +49,6 @@ RUN chmod 755 /permanent_data.sh && \
sync && rm /permanent_data.sh
# Services ports
-EXPOSE 55000/tcp 1514/udp 1515/tcp 514/udp 1516/tcp
+EXPOSE 55000/tcp 1514/tcp 1515/tcp 514/udp 1516/tcp
ENTRYPOINT [ "/init" ]
From ac0c85bb64b44973711a405d466dd29a1fd87b23 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 16 Sep 2020 18:01:19 +0200
Subject: [PATCH 47/50] Fix filebeat.yml format
---
wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat b/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
index 04be44bb..ce033aa5 100644
--- a/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
+++ b/wazuh-opendistro/config/etc/cont-init.d/1-config-filebeat
@@ -32,12 +32,12 @@ fi
if [ "$SSL_CERTIFICATE" != "" ]; then
>&2 echo "Configuring SSL Certificate."
- sed -i "s|#ssl.certificate:.*|ssl.certificate: ['$SSL_CERTIFICATE']|g" /etc/filebeat/filebeat.yml
+ sed -i "s|#ssl.certificate:.*|ssl.certificate: '$SSL_CERTIFICATE'|g" /etc/filebeat/filebeat.yml
fi
if [ "$SSL_KEY" != "" ]; then
>&2 echo "Configuring SSL Key."
- sed -i "s|#ssl.key:.*|ssl.key: ['$SSL_KEY']|g" /etc/filebeat/filebeat.yml
+ sed -i "s|#ssl.key:.*|ssl.key: '$SSL_KEY'|g" /etc/filebeat/filebeat.yml
fi
From a2e780525112f340a3f05a8c2084859a7777d3af Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Wed, 16 Sep 2020 18:08:38 +0200
Subject: [PATCH 48/50] Remove deprecated nginx section
---
docker-compose.yml | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index c7a846db..4e859267 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -70,20 +70,6 @@ services:
- elasticsearch:elasticsearch
- wazuh:wazuh
- # nginx:
- # image: nginx:stable
- # hostname: nginx
- # restart: always
- # ports:
- # - "80:80"
- # - "443:443"
- # depends_on:
- # - kibana
- # links:
- # - kibana:kibana
- # volumes:
- # - ./nginx_conf:/etc/nginx/conf.d:ro
-
volumes:
ossec_api_configuration:
ossec_etc:
From ee26db692b27bd9ecde2f7f44d8f600bfed189b6 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 24 Sep 2020 11:32:51 +0200
Subject: [PATCH 49/50] Remove legacy code to run cmd on entrypoint
---
.../config/etc/cont-init.d/0-wazuh-init | 20 +------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init
index f3fbd1a4..1aa78f65 100644
--- a/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init
+++ b/wazuh-opendistro/config/etc/cont-init.d/0-wazuh-init
@@ -126,21 +126,6 @@ function ossec_shutdown(){
${WAZUH_INSTALL_PATH}/bin/ossec-control stop;
}
-##############################################################################
-# Interpret any passed arguments (via docker command to this entrypoint) as
-# paths or commands, and execute them.
-#
-# This can be useful for actions that need to be run before the services are
-# started, such as "/var/ossec/bin/ossec-control enable agentless".
-##############################################################################
-
-docker_custom_args() {
- for CUSTOM_COMMAND in "$@"
- do
- echo "Executing command \`${CUSTOM_COMMAND}\`"
- exec_cmd_stdout "${CUSTOM_COMMAND}"
- done
-}
##############################################################################
# Main function
@@ -169,10 +154,7 @@ main() {
mount_files
# Trap exit signals and do a proper shutdown
- trap "ossec_shutdown; exit" SIGINT SIGTERM
-
- # Execute custom args
- docker_custom_args
+ trap "ossec_shutdown; exit" SIGINT SIGTERM
# Delete temporary data folder
rm -rf ${WAZUH_INSTALL_PATH}/data_tmp
From 960105b776c31647799cac3d732b74d87d2ca8c4 Mon Sep 17 00:00:00 2001
From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com>
Date: Thu, 24 Sep 2020 12:55:46 +0200
Subject: [PATCH 50/50] Remove extra space
---
wazuh-opendistro/config/etc/cont-init.d/2-manager | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wazuh-opendistro/config/etc/cont-init.d/2-manager b/wazuh-opendistro/config/etc/cont-init.d/2-manager
index e548e8b1..6ce02ae2 100644
--- a/wazuh-opendistro/config/etc/cont-init.d/2-manager
+++ b/wazuh-opendistro/config/etc/cont-init.d/2-manager
@@ -1,3 +1,3 @@
#!/usr/bin/with-contenv bash
-/var/ossec/bin/ossec-control start
+/var/ossec/bin/ossec-control start