Merge pull request #1432 from mozilla/create_scripts_directory

Create scripts directory
This commit is contained in:
Brandon Myers 2019-09-05 12:16:50 -05:00 коммит произвёл GitHub
Родитель e5f455429d dd6dac9c34
Коммит 4ab891acad
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
22 изменённых файлов: 33 добавлений и 12 удалений

Просмотреть файл

@ -49,7 +49,7 @@ services:
max-size: "10m"
env_file:
- cloudy_mozdef.env
command: bash -c 'python initial_setup.py http://elasticsearch:9200 cron/defaultMappingTemplate.json cron/mozdefStateDefaultMappingTemplate.json cron/backup.conf http://kibana:5601'
command: bash -c 'python initial_setup.py http://elasticsearch:9200 http://kibana:5601'
depends_on:
- base
networks:

Просмотреть файл

@ -130,7 +130,7 @@ services:
cache_from:
- mozdef/mozdef_bootstrap
- mozdef_bootstrap:latest
command: bash -c 'while ! timeout 1 bash -c "echo > /dev/tcp/elasticsearch/9200";do sleep 1;done && python initial_setup.py http://elasticsearch:9200 cron/defaultMappingTemplate.json cron/mozdefStateDefaultMappingTemplate.json cron/backup.conf http://kibana:5601'
command: bash -c 'while ! timeout 1 bash -c "echo > /dev/tcp/elasticsearch/9200";do sleep 1;done && python initial_setup.py http://elasticsearch:9200 http://kibana:5601'
depends_on:
- base
- elasticsearch

Просмотреть файл

@ -2,7 +2,7 @@ FROM centos:7
LABEL maintainer="mozdef@mozilla.com"
# When changing the kibana version, we'll need to update https://github.com/mozilla/MozDef/blob/master/docker/compose/mozdef_bootstrap/files/initial_setup.py accordingly
# When changing the kibana version, we'll need to update https://github.com/mozilla/MozDef/blob/master/scripts/setup/initial_setup.py accordingly
ENV KIBANA_VERSION 6.8.0
RUN \

Просмотреть файл

@ -7,10 +7,9 @@ RUN install --owner mozdef --group mozdef --directory /opt/mozdef/envs/mozdef/do
COPY --chown=mozdef:mozdef cron/mozdefStateDefaultMappingTemplate.json /opt/mozdef/envs/mozdef/cron/mozdefStateDefaultMappingTemplate.json
COPY --chown=mozdef:mozdef cron/defaultMappingTemplate.json /opt/mozdef/envs/mozdef/cron/defaultMappingTemplate.json
COPY --chown=mozdef:mozdef docker/compose/mozdef_cron/files/backup.conf /opt/mozdef/envs/mozdef/cron/backup.conf
COPY --chown=mozdef:mozdef docker/compose/mozdef_bootstrap/files/initial_setup.py /opt/mozdef/envs/mozdef/initial_setup.py
COPY --chown=mozdef:mozdef docker/compose/mozdef_bootstrap/files/index_mappings /opt/mozdef/envs/mozdef/index_mappings
COPY --chown=mozdef:mozdef docker/compose/mozdef_bootstrap/files/resources /opt/mozdef/envs/mozdef/resources
WORKDIR /opt/mozdef/envs/mozdef
COPY --chown=mozdef:mozdef scripts/setup /opt/mozdef/envs/mozdef/scripts/setup
WORKDIR /opt/mozdef/envs/mozdef/scripts/setup
USER mozdef

Просмотреть файл

@ -11,7 +11,6 @@ from datetime import datetime, timedelta
from time import sleep
from configlib import getConfig
import json
import time
import os
import sys
@ -20,12 +19,35 @@ import requests
from mozdef_util.elasticsearch_client import ElasticsearchClient
cron_dir_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../cron')
parser = argparse.ArgumentParser(description='Create the correct indexes and aliases in elasticsearch')
parser.add_argument('esserver', help='Elasticsearch server (ex: http://elasticsearch:9200)')
parser.add_argument('default_mapping_file', help='The relative path to default mapping json file (ex: cron/defaultMappingTemplate.json)')
parser.add_argument('state_mapping_file', help='The relative path to state mapping json file (ex: cron/mozdefStateDefaultMappingTemplate.json)')
parser.add_argument('backup_conf_file', help='The relative path to backup.conf file (ex: cron/backup.conf)')
default_file = os.path.realpath(cron_dir_path + '/defaultMappingTemplate.json')
parser.add_argument(
'default_mapping_file',
help='The relative path to default mapping json file (default: {0})'.format(default_file),
default=default_file,
nargs='?'
)
default_file = os.path.realpath(cron_dir_path + '/mozdefStateDefaultMappingTemplate.json')
parser.add_argument(
'state_mapping_file',
help='The relative path to state mapping json file (default: {0})'.format(default_file),
default=default_file,
nargs='?'
)
default_file = os.path.realpath(cron_dir_path + '/backup.json')
parser.add_argument(
'backup_conf_file',
help='The relative path to backup.conf file (default: {0})'.format(default_file),
default=default_file,
nargs='?'
)
parser.add_argument('kibana_url', help='The URL of the kibana endpoint (ex: http://kibana:5601)')
args = parser.parse_args()
@ -189,7 +211,7 @@ if kibana_index_name in client.get_indices():
sys.exit(0)
# Create visualizations/dashboards
dashboards_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources')
dashboards_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'example_resources')
listing = os.listdir(dashboards_path)
for infile in listing:
json_file_path = os.path.join(dashboards_path, infile)