Skip to content

Commit d411791

Browse files
authored
Merge pull request #1834 from ptrovatelli/v1.5.4rc6
V1.5.4rc6
2 parents 6a63533 + 8ca1cd1 commit d411791

File tree

275 files changed

+64286
-1521
lines changed

Some content is hidden

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

275 files changed

+64286
-1521
lines changed

.dependabot/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ update_configs:
1414
directory: "/"
1515
target_branch: "dev"
1616
update_schedule: "weekly"
17-

.github/release-drafter.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1+
name-template: 'v$NEXT_PATCH_VERSION 🌈'
2+
tag-template: 'v$NEXT_PATCH_VERSION'
3+
categories:
4+
- title: '🚀 New scanners'
5+
labels:
6+
- 'Import Scans'
7+
- title: '🚀 Features and enhancements'
8+
labels:
9+
- 'feature'
10+
- 'enhancement'
11+
- title: '🐛 Bug Fixes'
12+
labels:
13+
- 'fix'
14+
- 'bugfix'
15+
- 'bug'
16+
- title: '🧰 Maintenance'
17+
labels:
18+
- 'dependencies'
19+
- 'maintenance'
20+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
121
template: |
2-
## What's Changed
22+
## Changes
323
424
$CHANGES
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
# branches to consider in the event; optional, defaults to all
6+
branches:
7+
- master
8+
9+
jobs:
10+
update_release_draft:
11+
runs-on: ubuntu-latest
12+
steps:
13+
# Drafts your next Release notes as Pull Requests are merged into "master"
14+
- uses: release-drafter/[email protected]
15+
# with:
16+
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
17+
# config-name: my-config.yml
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,8 @@ quick.bash
107107

108108
#visual studio code
109109
*.code-workspace
110+
111+
# pipenv
112+
Pipfile
113+
Pipfile*
114+

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
- TEST=flake8
1717
- TEST=snyk
1818
- TEST=docker
19+
- TEST=integration_tests
1920
matrix:
2021
allow_failures:
2122
- env: TEST=snyk

DOCKER.md

Lines changed: 100 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# Run with Docker Compose
1+
# Running with Docker Compose
22

33
Docker compose is not intended for production use.
44
If you want to deploy a containerized DefectDojo to a production environment,
55
use the [Default installation](setup/README.md) approach.
66

7-
## Prerequisites
7+
# Prerequisites
88
* Docker version
99
* Installing with docker-compose requires at least docker 18.09.4 and docker-compose 1.24.0. See "Checking Docker versions" below for version errors during running docker-compose.
1010
* Proxies
1111
* If you're behind a corporate proxy check https://docs.docker.com/network/proxy/ .
1212

1313

14-
## Setup via Docker Compose - introduction
14+
# Setup via Docker Compose - introduction
1515

1616
DefectDojo needs several docker images to run. Two of them depend on DefectDojo code:
1717

@@ -28,8 +28,8 @@ When running the application without building images, the application will run b
2828
* https://hub.docker.com/r/defectdojo/defectdojo-nginx
2929

3030

31-
## Setup via Docker Compose - building and running the application
32-
### Building images
31+
# Setup via Docker Compose - building and running the application
32+
## Building images
3333

3434
To build images and put them in your local docker cache, run:
3535

@@ -40,7 +40,7 @@ docker-compose build
4040
To build a single image, run:
4141

4242
```zsh
43-
docker-compose build django
43+
docker-compose build uwsgi
4444
```
4545
or
4646

@@ -49,7 +49,7 @@ docker-compose build nginx
4949
```
5050

5151

52-
### Run with Docker compose in release mode
52+
## Run with Docker compose in release mode
5353
To run the application based on previously built image (or based on dockerhub images if none was locally built), run:
5454

5555
```zsh
@@ -62,7 +62,7 @@ This will run the application based on docker-compose.yml only.
6262
In this setup, you need to rebuild django and/or nginx images after each code change and restart the containers.
6363

6464

65-
### Run with Docker compose in development mode with hot-reloading
65+
## Run with Docker compose in development mode with hot-reloading
6666

6767
For development, use:
6868

@@ -82,7 +82,7 @@ This will run the application based on merged configurations from docker-compose
8282
* Hot-reloading for the **celeryworker** container is not yet implemented. When working on deduplication for example, restart the celeryworker container with:
8383

8484
```
85-
docker restart django-defectdojo_celeryworker_1
85+
docker-compose restart celeryworker
8686
```
8787

8888
* The mysql port is forwarded to the host so that you can access your database from outside the container.
@@ -100,32 +100,66 @@ To update changes in static resources, served by nginx, just refresh the browser
100100
id -u
101101
```
102102

103-
### Access the application
104-
Navigate to <http://localhost:8080> where you can log in with username admin.
105-
To find out the admin password, check the very beginning of the console
106-
output of the initializer container, typically name 'django-defectdojo_initializer_1', or run the following:
103+
## Run with Docker compose in development mode with ptvsd (remote debug)
104+
105+
If you want to be able to step in your code, you can activate ptvsd.Server.
106+
107+
You can launch your local dev instance of DefectDojo as
107108

108109
```zsh
109-
container_id=(`docker ps -a \
110-
--filter "name=django-defectdojo_initializer_1" \
111-
| awk 'FNR == 2 {print $1}'`) && \
112-
docker logs $container_id 2>&1 | grep "Admin password:"
110+
cp dojo/settings/settings.dist.py dojo/settings/settings.py
111+
docker/setEnv.sh ptvsd
112+
docker-compose up
113113
```
114114

115-
or:
115+
This will run the application based on merged configurations from docker-compose.yml and docker-compose.override.ptvsd.yml.
116+
117+
The default configuration assumes port 3000 by default for ptvsd, and you should access the DefectDojo UI on port 8000 instead of port 8080, as the uwsgi container will serve directly.
118+
119+
### VS code
120+
Add the following python debug configuration (You would have to install the `ms-python.python`. Other setup may work.)
121+
122+
```
123+
{
124+
"name": "Remote DefectDojo",
125+
"type": "python",
126+
"request": "attach",
127+
"pathMappings": [
128+
{
129+
"localRoot": "${workspaceFolder}",
130+
"remoteRoot": "/app"
131+
}
132+
],
133+
"port": 3000,
134+
"host": "localhost"
135+
}
136+
```
137+
138+
You can now launch the remote debug from VS Code, place your breakpoints and step through the code.
139+
140+
> At present, 2 caveats:
141+
> - Static will not be present. You would have to `docker cp` them over from the nginx container
142+
> - For some reason, the page loading may hang. You can stop the loading and reload, the page will ultimately appear.
143+
144+
145+
## Access the application
146+
Navigate to <http://localhost:8080> where you can log in with username admin.
147+
To find out the admin password, check the very beginning of the console
148+
output of the initializer container by running:
116149

117150
```zsh
118-
docker logs django-defectdojo_initializer_1
151+
docker-compose logs initializer | grep "Admin password:"
119152
```
120153

121154
Make sure you write down the first password generated as you'll need it when re-starting the application.
122155

123-
### Disable the database initialization
156+
# Exploitation, versioning
157+
## Disable the database initialization
124158
The initializer container can be disabled by exporting: `export DD_INITIALIZE=false`.
125159

126160
This will ensure that the database remains unchanged when re-running the application, keeping your previous settings and admin password.
127161

128-
### Versioning
162+
## Versioning
129163
In order to use a specific version when building the images and running the containers, set the environment with
130164
* For the nginx image: `NGINX_VERSION=x.y.z`
131165
* For the django image: `DJANGO_VERSION=x.y.z`
@@ -149,9 +183,7 @@ aedc404d6dee defectdojo/defectdojo-nginx:1.0.0 "/entrypoint-nginx.sh"
149183
```
150184

151185

152-
153-
154-
### Clean up Docker Compose
186+
## Clean up Docker Compose
155187

156188
Removes all containers
157189

@@ -165,13 +197,52 @@ Removes all containers, networks and the database volume
165197
docker-compose down --volumes
166198
```
167199

168-
### Run the unit-tests with docker
169-
#### Introduction
200+
# Run with docker using https
201+
To secure the application by https, follow those steps
202+
* Generate a private key without password
203+
* Generate a CSR (Certificate Signing Request)
204+
* Have the CSR signed by a certificate authority
205+
* Place the private key and the certificate under the nginx folder
206+
* Replace nginx/nginx.conf by nginx/nginx_TLS.conf
207+
* In nginx.conf, update that part:
208+
```
209+
server_name your.servername.com;
210+
ssl_certificate /yourCertificate.cer;
211+
ssl_certificate_key /yourPrivateKey.key;
212+
```
213+
* Protect your private key from other users:
214+
```
215+
chmod 400 nginx/*.key
216+
```
217+
* Rebuild the nginx image in order to place the private key and the certificate where nginx will find them (under / in the nginx container):
218+
219+
```docker build -t defectdojo/defectdojo-nginx -f Dockerfile.nginx .```
220+
221+
222+
* Run defectDojo with:
223+
```
224+
rm -f docker-compose.override.yml
225+
ln -s docker-compose.override.https.yml docker-compose.override.yml
226+
docker-compose up
227+
```
228+
229+
The default https port is 8083.
230+
231+
To change the port:
232+
- update `nginx.conf`
233+
- update `docker-compose.override.https.yml` or set DD_PORT in the environment)
234+
- restart the application
235+
236+
NB: some third party software may require to change the exposed port in Dockerfile.nginx as they use docker-compose declarations to discover which ports to map when publishing the application.
237+
238+
239+
# Run the unit-tests with docker
240+
## Introduction
170241
The unit-tests are under `dojo/unittests`
171242

172243

173244

174-
#### Running the unit-tests
245+
## Running the unit-tests
175246
This will run all the tests and leave the uwsgi container up:
176247

177248
```
@@ -182,7 +253,7 @@ docker-compose up
182253
Enter the container to run more tests:
183254

184255
```
185-
docker exec -it django-defectdojo_uwsgi_1 bash
256+
docker-compose exec uwsgi bash
186257
```
187258
Rerun all the tests:
188259

@@ -202,7 +273,7 @@ Run a single test. Example:
202273
python manage.py test dojo.unittests.test_dependency_check_parser.TestDependencyCheckParser.test_parse_without_file_has_no_findings --keepdb
203274
```
204275

205-
## Checking Docker versions
276+
# Checking Docker versions
206277

207278
Run the following to determine the versions for docker and docker-compose:
208279

Dockerfile.busybox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
FROM busybox:1.31.0-musl
1+
FROM busybox:1.31.1-musl
22
ENTRYPOINT ["/bin/echo", "hello world"]

Dockerfile.django

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# The code for the build image should be idendical with the code in
55
# Dockerfile.nginx to use the caching mechanism of Docker.
66

7-
# Using 3.5.7 to avoid compatibility issues that may be introduced by python 3.5.6 and 3.5.7.
7+
# Using 3.5.7 to avoid compatibility issues that may be introduced by python 3.6 and 3.7.
88
# Please upgrade before end-of-life in september 2020!
99
# Ref: https://devguide.python.org/#branchstatus
10-
FROM python:3.5.7-buster@sha256:4598d4365bb7a8628ba840f87406323e699c4da01ae6f926ff33787c63230779 as build
10+
FROM python:3.5.9-buster@sha256:1baef6be00b82fbd77f1b60ab227a1dbede6f23825ce1b7f1e9c6f7d1469a45c as build
1111
WORKDIR /app
1212
RUN \
1313
apt-get -y update && \
@@ -24,7 +24,7 @@ RUN \
2424
COPY requirements.txt ./
2525
RUN pip3 wheel --wheel-dir=/tmp/wheels -r ./requirements.txt
2626

27-
FROM python:3.5.7-slim-buster@sha256:127fee645393d311c7fbc5e8c2e5034f10a4e66b47c9273d4dbe5da2926fc3f2
27+
FROM python:3.5.9-slim-buster@sha256:dfb042910e4ef352b5c6aa223031ce768f53f4f1aacf95936152e5508162bcb0
2828
WORKDIR /app
2929
RUN \
3030
apt-get -y update && \
@@ -60,6 +60,7 @@ COPY \
6060
docker/entrypoint-initializer.sh \
6161
docker/entrypoint-uwsgi.sh \
6262
docker/entrypoint-uwsgi-dev.sh \
63+
docker/entrypoint-uwsgi-ptvsd.sh \
6364
docker/entrypoint-unit-tests.sh \
6465
docker/entrypoint-unit-tests-devDocker.sh \
6566
docker/wait-for-it.sh \
@@ -76,7 +77,7 @@ RUN \
7677
chmod g=u /var/run && \
7778
true
7879
USER root
79-
RUN chmod 0777 /app
80+
RUN chmod -R 0777 /app
8081
USER 1001
8182
ENV \
8283
DD_ADMIN_USER=admin \
@@ -99,11 +100,9 @@ ENV \
99100
DD_DATABASE_PASSWORD="defectdojo" \
100101
DD_DATABASE_PORT="3306" \
101102
DD_DATABASE_USER="defectdojo" \
102-
DD_SECRET_KEY="hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq" \
103-
DD_CREDENTIAL_AES_256_KEY="&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw" \
104103
DD_INITIALIZE=true \
105104
DD_UWSGI_MODE="socket" \
106105
DD_UWSGI_ENDPOINT="0.0.0.0:3031" \
107-
DD_DJANGO_ADMIN_ENABLED="on" \
108-
DD_TRACK_MIGRATIONS="on"
106+
DD_DJANGO_ADMIN_ENABLED="True" \
107+
DD_TRACK_MIGRATIONS="True"
109108
ENTRYPOINT ["/entrypoint-uwsgi.sh"]

Dockerfile.nginx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# The code for the build image should be idendical with the code in
44
# Dockerfile.django to use the caching mechanism of Docker.
55

6-
FROM python:3.5.7-buster@sha256:4598d4365bb7a8628ba840f87406323e699c4da01ae6f926ff33787c63230779 as build
6+
FROM python:3.5.9-buster@sha256:1baef6be00b82fbd77f1b60ab227a1dbede6f23825ce1b7f1e9c6f7d1469a45c as build
77
WORKDIR /app
88
RUN \
99
apt-get -y update && \
@@ -55,13 +55,14 @@ RUN \
5555
python3 manage.py collectstatic --noinput && \
5656
true
5757

58-
FROM nginx:1.17.2@sha256:eb3320e2f9ca409b7c0aa71aea3cf7ce7d018f03a372564dbdb023646958770b
58+
FROM nginx:1.17.7@sha256:89a42c3ba15f09a3fbe39856bddacdf9e94cd03df7403cad4fc105088e268fc9
5959
COPY --from=collectstatic /app/static/ /usr/share/nginx/html/static/
6060
COPY wsgi_params nginx/nginx.conf /etc/nginx/
61-
COPY docker/entrypoint-nginx.sh /
61+
COPY docker/entrypoint-nginx.sh nginx/*.cer nginx/*.key /
6262
RUN \
6363
chmod -R g=u /var/cache/nginx && \
6464
chmod -R g=u /var/run && \
65+
if [ -f /*.key -o -f /*.cer ]; then chown 1001 /*.key /*.cer; fi && \
6566
true
6667
ENV \
6768
DD_UWSGI_PASS="uwsgi_server" \

0 commit comments

Comments
 (0)