Skip to content

Commit

Permalink
Fix compatibility issues with latest python version
Browse files Browse the repository at this point in the history
Update generate.sh script to use env variables
  • Loading branch information
QU3B1M committed Dec 10, 2024
1 parent 25d16d3 commit ba80cb5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
20 changes: 10 additions & 10 deletions docker/ecs/images/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM python:latest
FROM python:3.10

RUN apt-get update && \
apt-get upgrade && \
apt-get install \
git \
jq && \
apt-get clean \ && \
apt-get upgrade -y && \
apt-get install -y git jq && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
git clone https://github.com/elastic/ecs.git && \
pip install -r ecs/scripts/requirements.txt && \
mkdir /wazuh-indexer
mkdir -p /source/ecs

# Change this to a volume
ADD docker/ecs/images/generate.sh ecs/generate.sh
ADD docker/ecs/images/generate.sh /ecs/generate.sh
#ADD docker/ecs/images/entrypoint.sh entrypoint.sh
ADD ecs/ /wazuh-indexer/ecs

WORKDIR ecs/
RUN chmod +x /ecs/generate.sh

ENTRYPOINT ["generate.sh"]
WORKDIR /ecs

ENTRYPOINT ["/bin/bash", "/ecs/generate.sh"]
31 changes: 14 additions & 17 deletions docker/ecs/images/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,25 @@ set -euo pipefail
# compatible open source license.

# Default values
DEFAULT_ECS_VERSION="v8.11.0"
DEFAULT_INDEXER_PATH="/wazuh-indexer"
ECS_VERSION="${ECS_VERSION:-v8.11.0}"
INDEXER_PATH="${INDEXER_PATH:-/source}"

# Function to display usage information
show_usage() {
echo "Usage: $0 <ECS_MODULE> [<INDEXER_PATH>] [<ECS_VERSION>]"
echo " * ECS_MODULE: Module to generate mappings for"
echo " * INDEXER_PATH: Path to the Wazuh indexer repository (default: /wazuh-indexer)"
echo " * ECS_VERSION: ECS version to generate mappings for (default: v8.11.0)"
echo "Example: $0 vulnerability-detector ~/wazuh-indexer v8.11.0"
echo "Usage: $0"
echo "Environment Variables:"
echo " * ECS_MODULE: Module to generate mappings for"
echo " * INDEXER_PATH: (Optional) Path to the Wazuh indexer repository (default: /source)"
echo " * ECS_VERSION: (Optional) ECS version to generate mappings for (default: v8.11.0)"
echo "Example: docker run -e ECS_MODULE=vulnerability-detector -e INDEXER_PATH=/source -e ECS_VERSION=v8.11.0 ecs-generator"
}

# Ensure ECS_MODULE is provided
if [ -z "${ECS_MODULE:-}" ]; then
show_usage
exit 1
fi

# Function to remove multi-fields from the generated index template
remove_multi_fields() {
local in_file="$1"
Expand Down Expand Up @@ -86,15 +93,5 @@ generate_mappings() {
echo "Mappings saved to $out_dir"
}

# Parse command line arguments
if [ -z "${1:-}" ]; then
show_usage
exit 1
fi

ECS_MODULE="$1"
INDEXER_PATH="${2:-$DEFAULT_INDEXER_PATH}"
ECS_VERSION="${3:-$DEFAULT_ECS_VERSION}"

# Generate mappings
generate_mappings "$ECS_MODULE" "$INDEXER_PATH" "$ECS_VERSION"

0 comments on commit ba80cb5

Please sign in to comment.