Compare commits

...

8 Commits

Author SHA1 Message Date
AlfonsoRBJ
ebd1381fbf Update to 3.12.3 (#348)
Former-commit-id: d584062230
2020-05-25 18:18:05 +02:00
AlfonsoRBJ
27a354a3ad queue/fim/db/fim.db removed when updating (#343)
Former-commit-id: 2f76c70480
2020-05-19 10:24:45 +02:00
AlfonsoRBJ
1d777bb22f Adapt wazuh to 3.12.2_7.6.1 (#342)
Former-commit-id: b48e5f819a
2020-05-13 16:23:59 +02:00
Jesus Linares
3aed4a12bf Merge branch 'cloud-0.21' into cloud-0.22
Former-commit-id: 749c66a037
2020-04-28 11:49:52 +02:00
Robin
5f7f2b696c Update wazuh app (#337)
Former-commit-id: 5fd1c85a67
2020-04-27 10:54:07 +02:00
Jesus Linares
a29dd86339 Merge branch 'cloud-0.21' into cloud-0.22
Former-commit-id: ebeec2cbd3
2020-04-24 17:14:24 +02:00
AlfonsoRBJ
6d527b9869 Custom app (#336)
Former-commit-id: 4d808d74c4
2020-04-23 18:22:51 +02:00
Mayte Ariza
c9e2dac443 Improve Wazuh image: overwriting and removing files (#335)
Former-commit-id: 5a6c086f6b
2020-04-23 10:39:31 +02:00
4 changed files with 76 additions and 22 deletions

View File

@@ -2,19 +2,16 @@
FROM phusion/baseimage:latest
# Arguments
ARG FILEBEAT_VERSION=7.4.2
ARG WAZUH_VERSION=3.11.5-1
ARG FILEBEAT_VERSION=7.6.1
ARG WAZUH_VERSION=3.12.3-1
# Environment variables
ENV API_USER="foo" \
API_PASS="bar"
ARG TEMPLATE_VERSION="v3.11.5"
ARG TEMPLATE_VERSION="v3.12.3"
ENV FILEBEAT_DESTINATION="elasticsearch"
COPY config/wazuh-manager_3.11.5-1_amd64.deb /wazuh-manager_3.11.5-1_amd64.deb
COPY config/wazuh-api_3.11.5-1_amd64.deb /wazuh-api_3.11.5-1_amd64.deb
# Install packages
RUN set -x && \
echo "deb https://packages.wazuh.com/3.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list && \
@@ -29,14 +26,8 @@ RUN set -x && \
apt-get upgrade -y -o Dpkg::Options::="--force-confold" && \
apt-get --no-install-recommends --no-install-suggests -y install openssl apt-transport-https vim expect python-boto python-pip python-cryptography && \
apt-get --no-install-recommends --no-install-suggests -y install postfix bsd-mailx mailutils libsasl2-2 ca-certificates libsasl2-modules && \
# apt-get --no-install-recommends --no-install-suggests -y install wazuh-manager=${WAZUH_VERSION} && \
dpkg -i /wazuh-manager_3.11.5-1_amd64.deb && apt-get install -f && \
# apt-get --no-install-recommends --no-install-suggests -y install nodejs wazuh-api=${WAZUH_VERSION} && \
apt-get --no-install-recommends --no-install-suggests -y install nodejs && \
dpkg -i /wazuh-api_3.11.5-1_amd64.deb && apt-get install -f && \
# Disable updates to this package
echo "wazuh-manager hold" | dpkg --set-selections && \
echo "wazuh-api hold" | dpkg --set-selections && \
apt-get --no-install-recommends --no-install-suggests -y install wazuh-manager=${WAZUH_VERSION} && \
apt-get --no-install-recommends --no-install-suggests -y install nodejs wazuh-api=${WAZUH_VERSION} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
rm -f /var/ossec/logs/alerts/*/*/* && \
@@ -46,7 +37,6 @@ RUN set -x && \
rm -f /var/ossec/logs/cluster/*/*/* && \
rm -f /var/ossec/logs/ossec/*/*/* && \
rm /var/ossec/var/run/* && \
rm /wazuh-manager_3.11.5-1_amd64.deb && \
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-${FILEBEAT_VERSION}-amd64.deb && \
dpkg -i filebeat-${FILEBEAT_VERSION}-amd64.deb && rm -f filebeat-${FILEBEAT_VERSION}-amd64.deb
@@ -110,6 +100,7 @@ COPY config/03-config_filebeat.sh /entrypoint-scripts/03-config_filebeat.sh
COPY config/20-ossec-configuration.sh /entrypoint-scripts/20-ossec-configuration.sh
COPY config/25-backups.sh /entrypoint-scripts/25-backups.sh
COPY config/35-remove_credentials_file.sh /entrypoint-scripts/35-remove_credentials_file.sh
COPY config/85-save_wazuh_version.sh /entrypoint-scripts/85-save_wazuh_version.sh
RUN chmod 755 /entrypoint.sh && \
chmod 755 /entrypoint-scripts/00-decrypt_credentials.sh && \
chmod 755 /entrypoint-scripts/01-wazuh.sh && \
@@ -117,7 +108,8 @@ RUN chmod 755 /entrypoint.sh && \
chmod 755 /entrypoint-scripts/03-config_filebeat.sh && \
chmod 755 /entrypoint-scripts/20-ossec-configuration.sh && \
chmod 755 /entrypoint-scripts/25-backups.sh && \
chmod 755 /entrypoint-scripts/35-remove_credentials_file.sh
chmod 755 /entrypoint-scripts/35-remove_credentials_file.sh && \
chmod 755 /entrypoint-scripts/85-save_wazuh_version.sh
# Workaround.
# Issues: Wazuh-api
@@ -131,4 +123,4 @@ ADD https://raw.githubusercontent.com/wazuh/wazuh/$TEMPLATE_VERSION/extensions/e
RUN chmod go-w /etc/filebeat/wazuh-template.json
# Run all services
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -32,6 +32,42 @@ exec_cmd_stdout() {
}
##############################################################################
# Check_update
# This function considers the following cases:
# - If /var/ossec/etc/ossec-init.conf does not exist -> Action Nothing. There is no data in the EBS. First time deploying Wazuh
# - If /var/ossec/etc/VERSION does not exist -> Action: Update. The previous version was prior to 3.11.5.
# - If both files exist: different Wazuh version -> Action: Update. The previous version is older than the current one.
# - If both files exist: the same Wazuh version -> Acton: Nothing. Same Wazuh version.
##############################################################################
check_update() {
if [ -e /var/ossec/etc/ossec-init.conf ]
then
if [ -e /var/ossec/etc/VERSION ]
then
previous_version=$(cat /var/ossec/etc/VERSION | grep -i version | cut -d'"' -f2)
echo "Previous version: $previous_version"
current_version=$(cat ${WAZUH_INSTALL_PATH}/data_tmp/permanent/var/ossec/etc/ossec-init.conf | grep -i version | cut -d'"' -f2)
echo "Current version: $current_version"
if [ $previous_version == $current_version ]
then
echo "Same Wazuh version in the EBS and image"
return 0
else
echo "Different Wazuh version: Update"
return 1
fi
else
echo "Previous version prior to 3.11.5: Update"
return 1
fi
else
echo "First time mounting EBS"
return 0
fi
}
##############################################################################
# Edit configuration
##############################################################################
@@ -90,7 +126,7 @@ apply_exclusion_data() {
remove_data_files() {
for del_file in "${PERMANENT_DATA_DEL[@]}"; do
if [ -e ${del_file} ]
if [ $(ls ${del_file} 2> /dev/null | wc -l) -ne 0 ]
then
print "Removing ${del_file}"
exec_cmd "rm ${del_file}"
@@ -202,14 +238,25 @@ change_api_user_credentials() {
##############################################################################
main() {
# Check Wazuh version in the image and EBS (It returns 1 when updating the environment)
check_update
update=$?
# 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
# When updating the environment, remove some files in permanent_data (i.e. .template.db)
if [ $update == 1 ]
then
echo "Removing databases"
remove_data_files
else
echo "Keeping databases"
fi
# Generate ossec-authd certs if AUTO_ENROLLMENT_ENABLED is true and does not exist
if [ $AUTO_ENROLLMENT_ENABLED == true ]

View File

@@ -0,0 +1,6 @@
#!/bin/bash
# Wazuh Docker Copyright (C) 2020 Wazuh Inc. (License GPLv2)
# Copy /var/ossec/etc/ossec-init.conf contents in /var/ossec/etc/VERSION to be able to check the previous Wazuh version in pod.
echo "Adding Wazuh version to /var/ossec/etc/VERSION"
cat /var/ossec/etc/ossec-init.conf > /var/ossec/etc/VERSION

View File

@@ -53,9 +53,18 @@ PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/cve-ubuntu-xenial-
PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-debian-8-ds.xml"
PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-ubuntu-1404-ds.xml"
PERMANENT_DATA_EXCP[((i++))]="/var/ossec/wodles/oscap/content/ssg-ubuntu-1604-ds.xml"
PERMANENT_DATA_EXCP[((i++))]="/var/ossec/queue/vulnerabilities/dictionaries/cpe_helper.json"
PERMANENT_DATA_EXCP[((i++))]="/var/ossec/queue/vulnerabilities/dictionaries/msu.json.gz"
export PERMANENT_DATA_EXCP
# Files mounted in a volume that should be deleted
# Files mounted in a volume that should be deleted when updating
i=0
PERMANENT_DATA_DEL[((i++))]="/var/ossec/queue/db/.template.db"
export PERMANENT_DATA_DEL
PERMANENT_DATA_DEL[((i++))]="/var/ossec/var/db/global.db*"
PERMANENT_DATA_DEL[((i++))]="/var/ossec/var/db/.profile.db*"
PERMANENT_DATA_DEL[((i++))]="/var/ossec/var/db/.template.db*"
PERMANENT_DATA_DEL[((i++))]="/var/ossec/var/db/agents/*"
PERMANENT_DATA_DEL[((i++))]="/var/ossec/wodles/cve.db"
PERMANENT_DATA_DEL[((i++))]="/var/ossec/queue/vulnerabilities/cve.db"
PERMANENT_DATA_DEL[((i++))]="/var/ossec/queue/fim/db/fim.db"
export PERMANENT_DATA_DEL