mirror of
https://github.com/certat/intelmq-docker.git
synced 2025-12-06 09:12:49 +01:00
docker for dev ready
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
FROM certat/intelmq-full:1.0
|
||||
FROM certat/intelmq-full:latest
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
MAINTAINER Einar <elanfranco@cert.unlp.edu.ar>
|
||||
MAINTAINER Jeremias <jpretto@cert.unlp.edu.ar>
|
||||
LABEL maintainer="Einar <elanfranco@csirtamericas.org>"
|
||||
LABEL maintainer="Jeremias <jpretto@cert.unlp.edu.ar>"
|
||||
LABEL maintainer="Mateo <mdurante@cert.unlp.edu.ar>"
|
||||
|
||||
ADD entrypoint_dev.sh /opt/dev/entrypoint_dev.sh
|
||||
ADD update.sh /opt/dev/update.sh
|
||||
ADD merge_BOTS.py /opt/dev/merge_BOTS.py
|
||||
WORKDIR /opt
|
||||
ADD entrypoint-dev.sh /opt/entrypoint-dev.sh
|
||||
ADD install_reqs_and_deploy_bots /opt/install_reqs_and_deploy_bots.sh
|
||||
RUN sudo chmod +x /opt/entrypoint-dev.sh \
|
||||
&& sudo chown intelmq:intelmq /opt/entrypoint-dev.sh
|
||||
RUN sudo chmod +x /opt/install_reqs_and_deploy_bots.sh \
|
||||
&& sudo chown intelmq:intelmq /opt/install_reqs_and_deploy_bots.sh
|
||||
|
||||
# Merge bots for merge_BOTS.py
|
||||
RUN sudo python3 -m pip install jsonmerge
|
||||
|
||||
|
||||
# Permission denied when installing new bots
|
||||
RUN sudo chown -R intelmq:intelmq /opt/intelmq/intelmq.egg-info
|
||||
|
||||
ENV PATH="/opt/intelmq/.local/bin:${PATH}"
|
||||
|
||||
ENTRYPOINT ["/opt/dev/entrypoint_dev.sh"]
|
||||
USER intelmq:intelmq
|
||||
|
||||
ENTRYPOINT [ "/opt/entrypoint-dev.sh" ]
|
||||
|
||||
29
.docker/intelmq-full-dev/entrypoint-dev.sh
Normal file
29
.docker/intelmq-full-dev/entrypoint-dev.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
export INTELMQ_IS_DOCKER=1
|
||||
|
||||
if [[ ${IS_DEV} == "true" ]]
|
||||
then
|
||||
cd /etc/intelmq
|
||||
sudo pip3 install hug url-normalize geolib imbox jinja2 pyasn textx tld time-machine
|
||||
sudo pip3 install --force pymisp[fileobjects,openioc,virustotal]
|
||||
/opt/install_reqs_and_deploy_bots.sh
|
||||
fi
|
||||
|
||||
sudo chown -R intelmq:intelmq /etc/intelmq
|
||||
sudo chown -R intelmq:intelmq /opt/intelmq
|
||||
|
||||
intelmqctl upgrade-config
|
||||
intelmqctl check
|
||||
|
||||
intelmq_user="${INTELMQ_API_USER:=intelmq}"
|
||||
intelmq_pass="${INTELMQ_API_PASS:=intelmq}"
|
||||
|
||||
intelmq-api-adduser --user "$intelmq_user" --password "$intelmq_pass"
|
||||
|
||||
if [[ $1 == "selftest" ]]
|
||||
then
|
||||
export INTELMQ_TEST_EXOTIC=1
|
||||
nosetests3 /etc/intelmq/intelmq/tests
|
||||
else
|
||||
cd /etc/intelmq-api && hug -m intelmq_api.serve -p8080
|
||||
fi
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
/opt/dev/update.sh
|
||||
|
||||
if [ "${ENABLE_BOTNET_AT_BOOT}" = "true" ]; then
|
||||
intelmqctl start
|
||||
fi
|
||||
|
||||
|
||||
/opt/entrypoint.sh
|
||||
10
.docker/intelmq-full-dev/install_reqs_and_deploy_bots
Executable file
10
.docker/intelmq-full-dev/install_reqs_and_deploy_bots
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
for file in $(find /etc/intelmq/intelmq/bots -name "*REQUIREMENTS.txt"); do
|
||||
cat file >> /tmp/fullrequirements.txt
|
||||
done
|
||||
cat /tmp/fullrequirements.txt | sort | uniq > /tmp/orderfullrequirements.txt
|
||||
sudo pip3 install -r /tmp/orderfullrequirements.txt;
|
||||
cd /etc/intelmq
|
||||
sudo pip3 install --no-cache-dir -e .
|
||||
|
||||
intelmqsetup
|
||||
@@ -1,38 +0,0 @@
|
||||
import json
|
||||
from jsonmerge import merge
|
||||
import argparse
|
||||
from collections import OrderedDict
|
||||
|
||||
parser = argparse.ArgumentParser(description='Merge two json.')
|
||||
parser.add_argument('input_file_1', type=str, help='input_file_1')
|
||||
parser.add_argument('input_file_2', type=str, help='input_file_2')
|
||||
parser.add_argument('output_file', type=str, help='output_file')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.input_file_1, 'r') as f:
|
||||
j1 = json.load(f)
|
||||
with open(args.input_file_2, 'r') as f:
|
||||
j2 = json.load(f)
|
||||
|
||||
def sortOD(od):
|
||||
res = OrderedDict()
|
||||
for k, v in sorted(od.items()):
|
||||
if isinstance(v, dict):
|
||||
res[k] = sortOD(v)
|
||||
else:
|
||||
res[k] = v
|
||||
return res
|
||||
|
||||
|
||||
merged = sortOD(merge(j1,j2))
|
||||
|
||||
desired_order_list = ['Collector', 'Parser', 'Expert', 'Output']
|
||||
reordered_dict = {k: merged[k] for k in desired_order_list}
|
||||
|
||||
# add other keys
|
||||
reordered_dict.update({k: merged[k] for k in merged.keys() - desired_order_list})
|
||||
|
||||
with open(args.output_file, 'w') as f:
|
||||
json.dump(reordered_dict, f, indent=4)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Installing requirements for bots in dev repository"
|
||||
for file in $(find /opt/dev/mybots -name "*REQUIREMENTS.txt"); do pip3 install -r $file; done
|
||||
|
||||
if [ test -f /opt/intelmq/intelmq/bots/BOTS ]; then
|
||||
if [ "${AUTO_MIX_BOTS}" = "true" ]; then
|
||||
# Backup Original BOTS
|
||||
cp /opt/intelmq/intelmq/bots/BOTS /opt/intelmq/intelmq/bots/BOTS.bk
|
||||
echo "Merge your BOTS file with BOTS"
|
||||
python3 /opt/dev/merge_BOTS.py "/opt/dev/mybots/BOTS" "/opt/intelmq/intelmq/bots/BOTS" "/opt/intelmq/intelmq/bots/BOTS"
|
||||
cp /opt/intelmq/intelmq/bots/BOTS /opt/intelmq/etc/BOTS
|
||||
echo "Copying BOTS"
|
||||
cp -a /opt/dev/mybots/bots/* /opt/intelmq/intelmq/bots/
|
||||
# Restore original BOTS
|
||||
mv /opt/intelmq/intelmq/bots/BOTS.bk /opt/intelmq/intelmq/bots/BOTS
|
||||
else
|
||||
cp /opt/intelmq/etc/BOTS /opt/intelmq/intelmq/bots/BOTS
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Installing new BOTS"
|
||||
cd /opt/intelmq && pip3 install -e . --user && python3 setup.py install --user
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user