-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
046b2f0
commit cb2e49e
Showing
8 changed files
with
140 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Wazuh App Copyright (C) 2019 Wazuh Inc. (License GPLv2) | ||
FROM docker.elastic.co/elasticsearch/elasticsearch:6.5.4 | ||
|
||
ENV ALERTS_SHARDS="1" \ | ||
ALERTS_REPLICAS="0" | ||
|
||
ENV API_USER="foo" \ | ||
API_PASS="bar" | ||
|
||
ENV TEMPLATE_VERSION=v3.8.2 | ||
|
||
ADD https://raw.githubusercontent.com/wazuh/wazuh/$TEMPLATE_VERSION/extensions/elasticsearch/wazuh-elastic6-template-alerts.json /usr/share/elasticsearch/config | ||
|
||
COPY config/entrypoint.sh /entrypoint.sh | ||
|
||
RUN chmod 755 /entrypoint.sh | ||
|
||
COPY --chown=elasticsearch:elasticsearch ./config/load_settings.sh ./ | ||
|
||
RUN chmod +x ./load_settings.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["elasticsearch"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
# Wazuh App Copyright (C) 2019 Wazuh Inc. (License GPLv2) | ||
|
||
# For more information https://github.com/elastic/elasticsearch-docker/blob/6.5.4/build/elasticsearch/bin/docker-entrypoint.sh | ||
|
||
set -e | ||
|
||
# Files created by Elasticsearch should always be group writable too | ||
umask 0002 | ||
|
||
run_as_other_user_if_needed() { | ||
if [[ "$(id -u)" == "0" ]]; then | ||
# If running as root, drop to specified UID and run command | ||
exec chroot --userspec=1000 / "${@}" | ||
else | ||
# Either we are running in Openshift with random uid and are a member of the root group | ||
# or with a custom --user | ||
exec "${@}" | ||
fi | ||
} | ||
|
||
# Run load settings script. | ||
|
||
./load_settings.sh & | ||
|
||
# Execute elasticsearch | ||
|
||
run_as_other_user_if_needed /usr/share/elasticsearch/bin/elasticsearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
# Wazuh App Copyright (C) 2019 Wazuh Inc. (License GPLv2) | ||
|
||
set -e | ||
|
||
if [ "x${ELASTICSEARCH_URL}" = "x" ]; then | ||
el_url="http://elasticsearch:9200" | ||
else | ||
el_url="${ELASTICSEARCH_URL}" | ||
fi | ||
|
||
until curl -XGET $el_url; do | ||
>&2 echo "Elastic is unavailable - sleeping" | ||
sleep 5 | ||
done | ||
|
||
>&2 echo "Elastic is up - executing command" | ||
|
||
#Insert default templates | ||
|
||
sed -i 's| "index.refresh_interval": "5s"| "index.refresh_interval": "5s", "number_of_shards" : '"${ALERTS_SHARDS}"', "number_of_replicas" : '"${ALERTS_REPLICAS}"'|' /usr/share/elasticsearch/config/wazuh-elastic6-template-alerts.json | ||
|
||
cat /usr/share/elasticsearch/config/wazuh-elastic6-template-alerts.json | curl -XPUT "$el_url/_template/wazuh" -H 'Content-Type: application/json' -d @- | ||
sleep 5 | ||
|
||
|
||
API_PASS_Q=`echo "$API_PASS" | tr -d '"'` | ||
API_USER_Q=`echo "$API_USER" | tr -d '"'` | ||
API_PASSWORD=`echo -n $API_PASS_Q | base64` | ||
|
||
echo "Setting API credentials into Wazuh APP" | ||
CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/wazuh-configuration/1513629884013) | ||
if [ "x$CONFIG_CODE" = "x404" ]; then | ||
curl -s -XPOST $el_url/.wazuh/wazuh-configuration/1513629884013 -H 'Content-Type: application/json' -d' | ||
{ | ||
"api_user": "'"$API_USER_Q"'", | ||
"api_password": "'"$API_PASSWORD"'", | ||
"url": "https://wazuh", | ||
"api_port": "55000", | ||
"insecure": "true", | ||
"component": "API", | ||
"cluster_info": { | ||
"manager": "wazuh-manager", | ||
"cluster": "Disabled", | ||
"status": "disabled" | ||
}, | ||
"extensions": { | ||
"oscap": true, | ||
"audit": true, | ||
"pci": true, | ||
"aws": true, | ||
"virustotal": true, | ||
"gdpr": true, | ||
"ciscat": true | ||
} | ||
} | ||
' > /dev/null | ||
else | ||
echo "Wazuh APP already configured" | ||
fi | ||
sleep 5 | ||
|
||
curl -XPUT "$el_url/_cluster/settings" -H 'Content-Type: application/json' -d' | ||
{ | ||
"persistent": { | ||
"xpack.monitoring.collection.enabled": true | ||
} | ||
} | ||
' | ||
|
||
echo "Elasticsearch is ready." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters