Skip to content

Commit 6954b92

Browse files
authored
Merge pull request DefectDojo#958 from DefectDojo/dev
1.5.4rc1
2 parents 4b40421 + 52fc174 commit 6954b92

File tree

228 files changed

+50681
-1840
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+50681
-1840
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git
2+
.gitignore
3+
*.md
4+
.env*

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ ignore =
2323
E402
2424
E126
2525
E128
26+
# line break after binary operator
27+
W504
2628

2729
exclude =
2830
# No need to traverse our git directory

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Docker container persistent data
2+
docker/data/
3+
docker/static/
4+
5+
# VS Code
6+
.vscode/
7+
18
# Byte-compiled / optimized / DLL files
29
__pycache__/
310
*.py[cod]
@@ -70,6 +77,7 @@ dojo/uploads/threat/*
7077
*.sqlite
7178
*.db
7279
celerybeat.pid
80+
*.env*
7381

7482
weekly.txt
7583
Monthly.txt
@@ -91,3 +99,5 @@ dojo/media
9199
.venv/
92100
venv/
93101
ENV/
102+
quick.bash
103+
*.tgz

.travis.yml

Lines changed: 19 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,22 @@
1+
dist: xenial
2+
language: minimal
13
sudo: required
2-
language: python
3-
install: true
4-
5-
env:
6-
- TEST=smoke-test
7-
- TEST=integration-test
8-
- TEST=unit-test
9-
- TEST=bandit
10-
- TEST=docker-bench-security
11-
- TEST=ansible
12-
- TEST=flake8-complete
13-
- TEST=flake8
14-
15-
matrix:
16-
allow_failures:
17-
- env: TEST=smoke-test
18-
- env: TEST=bandit
19-
- env: TEST=sourceclear
20-
- env: TEST=flake8-complete
21-
224
services:
235
- docker
24-
25-
before_script:
26-
- export -f travis_fold
27-
- export REPO=appsecpipeline/django-defectdojo
28-
- export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi`
29-
30-
script:
31-
- |
32-
echo "Running test=$TEST"
33-
case "$TEST" in
34-
smoke-test)
35-
travis_fold start "smoke-test"
36-
bash entrypoint_scripts/test/travis-smoke-test.sh || exit 1
37-
travis_fold end "smoke-test"
38-
;;
39-
unit-test)
40-
travis_fold start "unit-test"
41-
bash entrypoint_scripts/test/travis-unit-test.sh || exit 1
42-
travis_fold end "unit-test"
43-
;;
44-
integration-test)
45-
travis_fold start "integration-test"
46-
bash entrypoint_scripts/test/travis-integration-test.sh || exit 1
47-
travis_fold end "integration-test"
48-
;;
49-
sourceclear)
50-
## Run the SRC:CLR Scan
51-
curl -sSL https://download.sourceclear.com/ci.sh | bash
52-
;;
53-
bandit)
54-
# install bandit
55-
pip install bandit
56-
57-
## Run Bandit python static code
58-
bandit -r * -x venv,tests,ansible
59-
;;
60-
docker-bench-security)
61-
## Run Docker Bench for Security
62-
git clone https://github.com/docker/docker-bench-security.git
63-
cd docker-bench-security
64-
sh docker-bench-security.sh
65-
;;
66-
ansible)
67-
true
68-
;;
69-
pep8)
70-
pip install flake8
71-
flake8 .
72-
;;
73-
flake8)
74-
echo "$TRAVIS_BRANCH"
75-
if [ "$TRAVIS_BRANCH" == "dev" ]
76-
then
77-
echo "Running Flake8 tests on dev branch aka pull requests"
78-
# We need to checkout dev for flake8-diff to work properly
79-
git checkout dev
80-
pip install pep8 flake8 flake8-diff
81-
flake8-diff
82-
else
83-
echo "true"
84-
fi
85-
esac
86-
87-
after_success:
88-
#Push to docker repo
89-
- |
90-
if [ "$TRAVIS_TAG" != "" ] && [ "$DOCKER_USER" != "" ] && [ "$DOCKER_PASS" != "" ]; then
91-
docker tag $REPO $REPO:$TRAVIS_TAG
92-
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS";
93-
docker push $REPO ;
94-
fi
95-
96-
notifications:
97-
slack:
98-
rooms:
99-
secure: nPXwHnPcf37yGkCkLimx5UmY9LTtOHL0lw88cAQeXCNNjeZuhS2jS5xGUOwwp3SrsYE4tZhD0WuVEHGDcyIhmBZh9Qqk3NHKz+tQDD/e0GE/8uTTfR1Eh+pq1YOIcLYzzKA2khmJSeHqqDriVZZoWpn67oHtrui9FYesapZ8AX0=
100-
on_success: never
101-
on_failure: never
102-
on_start: never
103-
addons:
104-
firefox: "45.0"
105-
chrome: stable
6+
env:
7+
global:
8+
- K8S_VERSION=v1.13.4
9+
- MINIKUBE_VERSION=v0.35.0
10+
- HELM_VERSION=v2.13.0
11+
- CHANGE_MINIKUBE_NONE_USER=true
12+
matrix:
13+
- BROKER=rabbitmq DATABASE=mysql
14+
- BROKER=rabbitmq DATABASE=postgresql
15+
- BROKER=redis DATABASE=mysql
16+
- BROKER=redis DATABASE=postgresql
17+
- TEST=flake8
18+
- TEST=docker
19+
before_install: ['./travis/before-install.sh']
20+
before_script: ['./travis/before-script.sh']
21+
script: ['./travis/script.sh']
22+
after_success: ['./travis/after-success-script.sh']

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Here are a few things to keep in mind when making changes to DefectDojo.
1414

1515
## Modifying DefectDojo and Testing
1616

17-
Please use [these test scripts](./tests) to test your changes. These are the exact scripts we run in our [Travis Build](https://travis-ci.org/OWASP/django-DefectDojo)
17+
Please use [these test scripts](./tests) to test your changes. These are the exact scripts we run in our [Travis Build](https://travis-ci.org/OWASP/django-DefectDojo).
1818

19-
For changes that require additional settings. settings.dist.py is the file you want to change. settings.py is populated by setup.bash from settings.dist.py
19+
For changes that require additional settings, settings.dist.py is the file you want to change. Settings.py is created by setup.bash from settings.dist.py
2020

2121
## Submitting Pull Requests
2222

DOCKER.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Run with Docker Compose
2+
3+
Docker compose is not intended for production use.
4+
If you want to deploy a containerized DefectDojo to a production environment,
5+
use the [Helm and Kubernetes](KUBERNETES.md) approach.
6+
7+
## Setup via Docker Compose
8+
9+
If you start your DefectDojo instance on Docker Compose for the first time, just
10+
run `docker-compose up`.
11+
12+
Navigate to <http://localhost:8080> where you can log in with username admin.
13+
To find out the admin user’s password, check the very beginning of the console
14+
output of the initializer container, typically name 'django-defectdojo_initializer_1', or run the following:
15+
16+
```zsh
17+
container_id=(`docker ps -a \
18+
--filter "name=django-defectdojo_initializer_1" \
19+
| awk 'FNR == 2 {print $1}'`) && \
20+
docker logs $container_id 2>&1 | grep "Admin password:"
21+
```
22+
23+
If you ran DefectDojo with compose before and you want to prevent the
24+
initializer container from running again, define an environment variable
25+
DD_INITIALIZE=false to prevent re-initialization.
26+
27+
### Build Images Locally
28+
29+
Build the docker containers locally for testing purposes.
30+
31+
```zsh
32+
# Build images
33+
docker build -t defectdojo/defectdojo-django -f Dockerfile.django .
34+
docker build -t defectdojo/defectdojo-nginx -f Dockerfile.nginx .
35+
```
36+
37+
### Clean up Docker Compose
38+
39+
```zsh
40+
docker-compose down --volumes
41+
```

DefectDojoMaintainers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Greg Anderson, Aaron Weaver and Matt Tesauro.
1+
Greg Anderson, Aaron Weaver and Matt Tesauro.

Dockerfile

Lines changed: 0 additions & 53 deletions
This file was deleted.

Dockerfile.django

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# code: language=Dockerfile
2+
FROM python:2
3+
WORKDIR /app
4+
RUN \
5+
apt-get -y update && \
6+
apt-get -y install \
7+
dnsutils \
8+
mysql-client \
9+
postgresql-client \
10+
&& \
11+
apt-get clean && \
12+
rm -rf /var/lib/apt/lists && \
13+
true
14+
COPY requirements.txt ./
15+
RUN pip install -r ./requirements.txt
16+
COPY \
17+
docker/entrypoint-celery-beat.sh \
18+
docker/entrypoint-celery-worker.sh \
19+
docker/entrypoint-initializer.sh \
20+
docker/entrypoint-uwsgi.sh \
21+
docker/entrypoint-unit-tests.sh \
22+
docker/wait-for-it.sh \
23+
/
24+
COPY wsgi.py manage.py tests/unit-tests.sh ./
25+
COPY dojo/ ./dojo/
26+
# Legacy installs need the modified settings.py, do not remove!
27+
RUN \
28+
cp dojo/settings/settings.dist.py dojo/settings/settings.py
29+
COPY tests/ ./tests/
30+
RUN \
31+
mkdir dojo/migrations && \
32+
chmod g=u dojo/migrations && \
33+
chmod g=u /var/run && \
34+
true
35+
USER 1001
36+
ENV \
37+
DD_ADMIN_USER=admin \
38+
39+
DD_ADMIN_PASSWORD= \
40+
DD_ADMIN_FIRST_NAME=Administrator \
41+
DD_ADMIN_LAST_NAME=User \
42+
DD_ALLOWED_HOSTS="*" \
43+
DD_CELERY_BEAT_SCHEDULE_FILENAME="/run/celery-beat-schedule" \
44+
DD_CELERY_BROKER_SCHEME="amqp" \
45+
DD_CELERY_BROKER_USER="defectdojo" \
46+
DD_CELERY_BROKER_PASSWORD="defectdojo" \
47+
DD_CELERY_BROKER_HOST="rabbitmq" \
48+
DD_CELERY_BROKER_PORT="5672" \
49+
DD_CELERY_BROKER_PATH="//" \
50+
DD_CELERY_LOG_LEVEL="INFO" \
51+
DD_DATABASE_ENGINE="django.db.backends.mysql" \
52+
DD_DATABASE_HOST="mysql" \
53+
DD_DATABASE_NAME="defectdojo" \
54+
DD_DATABASE_PASSWORD="defectdojo" \
55+
DD_DATABASE_PORT="3306" \
56+
DD_DATABASE_USER="defectdojo" \
57+
DD_SECRET_KEY="hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq" \
58+
DD_CREDENTIAL_AES_256_KEY="&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw" \
59+
DD_INITIALIZE=true \
60+
DD_UWSGI_MODE="socket" \
61+
DD_UWSGI_ENDPOINT="0.0.0.0:3031"
62+
ENTRYPOINT ["/entrypoint-uwsgi.sh"]

Dockerfile.nginx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# code: language=Dockerfile
2+
FROM defectdojo/defectdojo-django:latest AS build
3+
4+
USER root
5+
RUN \
6+
apt-get -y update && \
7+
apt-get -y install apt-transport-https ca-certificates && \
8+
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
9+
echo "deb https://deb.nodesource.com/node_11.x stretch main" | tee /etc/apt/sources.list.d/nodesource.list && \
10+
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
11+
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
12+
apt-get -y update && \
13+
apt-get -y install nodejs && \
14+
apt-get -y install --no-install-recommends yarn && \
15+
apt-get clean && \
16+
rm -rf /var/lib/apt/lists && \
17+
true
18+
COPY components/ ./components/
19+
RUN \
20+
cd components && \
21+
yarn && \
22+
cd .. && \
23+
python manage.py collectstatic && \
24+
true
25+
26+
FROM nginx
27+
COPY --from=build /app/static/ /usr/share/nginx/html/static/
28+
COPY wsgi_params nginx/nginx.conf /etc/nginx/
29+
COPY docker/entrypoint-nginx.sh /
30+
RUN \
31+
chmod -R g=u /var/cache/nginx && \
32+
chmod -R g=u /var/run && \
33+
true
34+
ENV \
35+
DD_UWSGI_PASS="uwsgi_server" \
36+
DD_UWSGI_HOST="uwsgi" \
37+
DD_UWSGI_PORT="3031"
38+
USER 1001
39+
ENTRYPOINT ["/entrypoint-nginx.sh"]

0 commit comments

Comments
 (0)