Skip to content

Commit 2df8556

Browse files
authored
Merge branch 'master' into master
2 parents bf55012 + 27f0008 commit 2df8556

File tree

33 files changed

+723
-328
lines changed

33 files changed

+723
-328
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: python
33
install: true
44

55
env:
6+
- TEST=smoke-test
67
- TEST=integration-test
78
- TEST=unit-test
89
- TEST=sourceclear
@@ -29,6 +30,11 @@ script:
2930
- |
3031
echo "Running test=$TEST"
3132
case "$TEST" in
33+
smoke-test)
34+
travis_fold start "smoke-test"
35+
bash ./scripts/travis-smoke-test.sh || exit 1
36+
travis_fold end "smoke-test"
37+
;;
3238
unit-test)
3339
travis_fold start "unit-test"
3440
bash ./scripts/travis-unit-test.sh || exit 1

ansible/legacy/roles/webserver/tasks/app.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@
4444
sudo_user: '{{ dd_user }}'
4545

4646
- name: Install Pillow
47-
pip: name=Pillow version=2.3.0 virtualenv={{ venv_dir }}
48-
sudo: yes
49-
sudo_user: '{{ dd_user }}'
50-
51-
- name: Install django-secure
52-
pip: name=django-secure virtualenv={{ venv_dir }}
47+
pip: name=Pillow version=5.0.0 virtualenv={{ venv_dir }}
5348
sudo: yes
5449
sudo_user: '{{ dd_user }}'
5550

@@ -153,11 +148,6 @@
153148
sudo: yes
154149
sudo_user: '{{ dd_user }}'
155150

156-
- name: Install sqlalchemy
157-
pip: name=sqlalchemy virtualenv={{ venv_dir }}
158-
sudo: yes
159-
sudo_user: '{{ dd_user }}'
160-
161151
- name: install pdfkit
162152
pip: name=pdfkit virtualenv={{ venv_dir }}
163153
sudo: yes

ansible/prod-install/files/requirements/production.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
Django==1.11.2
2-
Pillow==4.1.1
3-
django-secure>1.0
2+
Pillow==5.0.0
43
django-tastypie>=0.12.2
54
django-tastypie-swagger
65
gunicorn>=19.1.1
@@ -17,8 +16,6 @@ vobject
1716
html2text
1817
django-watson==1.3.1
1918
celery==3.1.24
20-
kombu==3.0.37
21-
sqlalchemy
2219
django-polymorphic==1.2
2320
pdfkit==0.5.0
2421
django-overextends

components/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"@yarn_components/mocha": "mochajs/mocha#~1.17.1",
2929
"@yarn_components/moment": "moment/moment#^2.9.0",
3030
"@yarn_components/morrisjs": "morrisjs/morris.js#~0.5.1",
31-
"@yarn_components/raphael": "DmitryBaranovskiy/raphael#~2.1.4",
3231
"@yarn_components/startbootstrap-sb-admin-2": "BlackrockDigital/startbootstrap-sb-admin-2#*"
3332
},
3433
"engines": {

docs/features.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,6 @@ you can run: ::
586586

587587
pip install celery
588588

589-
You will also need to install `sqlalchemy`: ::
590-
591-
pip install sqlalchemy
592-
593589
If you are using virtual environments make sure your environment is activated. You can also follow the `installation
594590
instructions`_ from the Celery documentation.
595591

docs/getting-started.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ And the `python` packages are (listed in `setup.py` as well):
8484

8585
* 'Django==1.8',
8686
* 'MySQL-python==1.2.3',
87-
* 'Pillow==2.3.0',
88-
* 'django-secure==1.0',
87+
* 'Pillow==5.0.0',
8988
* 'django-tastypie==0.12.1',
9089
* 'django-tastypie-swagger',
9190
* 'gunicorn==19.1.1',

docs/running-in-production.rst

Lines changed: 118 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,27 @@ Running in Production
33

44
This guide will walk you through how to setup DefectDojo for running in production using Ubuntu 16.04, nginx, and uwsgi.
55

6-
*Install, Setup, and Activate Virtualenv*
6+
**Install, Setup, and Activate Virtualenv**
7+
8+
Assumes running as root or using sudo command for the below.
79

810
.. code-block:: console
911
1012
pip install virtualenv
1113
14+
cd /opt
15+
1216
virtualenv dojo
17+
18+
cd /opt/dojo
19+
20+
git clone https://github.com/DefectDojo/django-DefectDojo.git
21+
22+
useradd -m dojo
23+
24+
chown -R dojo /opt/dojo
1325
14-
source dojo/bin/activate
26+
source ./bin/activate
1527
1628
**Install Dojo**
1729

@@ -66,7 +78,7 @@ However, for a quick setup you can use the following to run both in the backgrou
6678
6779
celery beat -A dojo -l info &
6880
69-
*Start Uwsgi*
81+
**Start Uwsgi**
7082

7183
From inside the django-DefectDojo/ directory execute:
7284

@@ -80,6 +92,45 @@ It is recommended that you use an Upstart job or a @restart cron job to launch u
8092
8193
uwsgi --socket :8001 --wsgi-file wsgi.py --workers 7 &
8294
95+
**Making Defect Dojo start on boot**
96+
97+
Below we configure service files for systemd. The commands follow, the config files are below the Nginx in the next section.
98+
99+
.. code-block:: console
100+
101+
cd /etc/systemd/system/
102+
103+
vi dojo.service
104+
[contents below]
105+
106+
systemctl enable dojo
107+
108+
systemctl start dojo
109+
110+
systemctl status dojo
111+
[ensure it launched OK]
112+
113+
vi celery-worker.service
114+
[contents below]
115+
116+
systemctl enable celery-worker
117+
118+
systemctl start celery-worker
119+
120+
systemctl status celery-worker
121+
[ensure it launched OK]
122+
123+
vi celery-beat.service
124+
[contents below]
125+
126+
systemctl enable celery-beat
127+
128+
systemctl start celery-beat
129+
130+
systemctl status celery-beat
131+
[ensure it launched OK]
132+
133+
83134
*NGINX Configuration*
84135

85136
Everyone feels a little differently about nginx settings, so here are the barebones to add your to your nginx configuration to proxy uwsgi. Make sure to modify the filesystem paths if needed:
@@ -122,4 +173,68 @@ Everyone feels a little differently about nginx settings, so here are the barebo
122173
}
123174
}
124175
176+
*Systemd Configuration Files*
177+
178+
dojo.service
179+
180+
.. code-block:: console
181+
182+
[Unit]
183+
Description=uWSGI instance to serve DefectDojo
184+
Requires=nginx.service mysql.service
185+
Before=nginx.service
186+
After=mysql.service
187+
188+
[Service]
189+
ExecStart=/bin/bash -c 'su - dojo -c "cd /opt/dojo/django-DefectDojo && source ../bin/activate && uwsgi --socket :8001 --wsgi-file wsgi.py --workers 7"'
190+
Restart=always
191+
RestartSec=3
192+
#StandardOutput=syslog
193+
#StandardError=syslog
194+
SyslogIdentifier=dojo
195+
196+
[Install]
197+
WantedBy=multi-user.target
198+
199+
celery-worker.service
200+
201+
.. code-block:: console
202+
203+
[Unit]
204+
Description=celery workers for DefectDojo
205+
Requires=dojo.service
206+
After=dojo.service
207+
208+
[Service]
209+
ExecStart=/bin/bash -c 'su - dojo -c "cd /opt/dojo/django-DefectDojo && source ../bin/activate && celery -A dojo worker -l info --concurrency 3"'
210+
Restart=always
211+
RestartSec=3
212+
#StandardOutput=syslog
213+
#StandardError=syslog
214+
SyslogIdentifier=celeryworker
215+
216+
[Install]
217+
WantedBy=multi-user.target
218+
219+
celery-beat.service
220+
221+
.. code-block:: console
222+
223+
[Unit]
224+
Description=celery beat for DefectDojo
225+
Requires=dojo.service
226+
After=dojo.service
227+
228+
[Service]
229+
ExecStart=/bin/bash -c 'su - dojo -c "cd /opt/dojo/django-DefectDojo && source ../bin/activate && celery beat -A dojo -l info"'
230+
Restart=always
231+
RestartSec=3
232+
#StandardOutput=syslog
233+
#StandardError=syslog
234+
SyslogIdentifier=celerybeat
235+
236+
[Install]
237+
WantedBy=multi-user.target
238+
239+
125240
*That's it!*

dojo/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ def obj_create(self, bundle, **kwargs):
13211321
item.last_reviewed_by = bundle.request.user
13221322
item.active = bundle.data['active']
13231323
item.verified = bundle.data['verified']
1324-
item.save()
1324+
item.save(dedupe_option=False)
13251325

13261326
if hasattr(item, 'unsaved_req_resp') and len(item.unsaved_req_resp) > 0:
13271327
for req_resp in item.unsaved_req_resp:
@@ -1349,6 +1349,7 @@ def obj_create(self, bundle, **kwargs):
13491349
product=t.engagement.product)
13501350

13511351
item.endpoints.add(ep)
1352+
item.save()
13521353

13531354
if item.unsaved_tags is not None:
13541355
item.tags = item.unsaved_tags

dojo/endpoint/views.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def vulnerable_endpoints(request):
5858

5959
def all_endpoints(request):
6060
endpoints = Endpoint.objects.all()
61+
show_uri = get_system_setting('display_endpoint_uri')
6162
# are they authorized
6263
if request.user.is_staff:
6364
pass
@@ -75,14 +76,18 @@ def all_endpoints(request):
7576
product = get_object_or_404(Product, id=p[0])
7677

7778
ids = get_endpoint_ids(EndpointFilter(request.GET, queryset=endpoints, user=request.user).qs)
78-
endpoints = EndpointFilter(request.GET, queryset=endpoints.filter(id__in=ids), user=request.user)
79-
paged_endpoints = get_page_items(request, endpoints.qs, 25)
79+
if show_uri:
80+
paged_endpoints = get_page_items(request, endpoints, 25)
81+
else:
82+
endpoints = EndpointFilter(request.GET, queryset=endpoints.filter(id__in=ids), user=request.user)
83+
paged_endpoints = get_page_items(request, endpoints.qs, 25)
8084
add_breadcrumb(title="All Endpoints", top_level=not len(request.GET), request=request)
8185
return render(request,
8286
'dojo/endpoints.html',
8387
{"endpoints": paged_endpoints,
8488
"filtered": endpoints,
8589
"name": "All Endpoints",
90+
"show_uri": show_uri
8691
})
8792

8893

@@ -148,6 +153,11 @@ def view_endpoint(request, eid):
148153

149154
paged_findings = get_page_items(request, active_findings, 25)
150155

156+
vulnerable = False
157+
158+
if active_findings.count() != 0:
159+
vulnerable = True
160+
151161
add_breadcrumb(parent=endpoint, top_level=False, request=request)
152162
return render(request,
153163
"dojo/view_endpoint.html",
@@ -157,6 +167,7 @@ def view_endpoint(request, eid):
157167
'all_findings': all_findings,
158168
'opened_per_month': monthly_counts['opened_per_period'],
159169
'endpoint_metadata': endpoint_metadata,
170+
'vulnerable': vulnerable,
160171
})
161172

162173

dojo/engagement/views.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,16 @@ def delete_engagement(request, eid):
194194
})
195195

196196

197-
@user_passes_test(lambda u: u.is_staff)
198197
def view_engagement(request, eid):
199198
eng = Engagement.objects.get(id=eid)
200199
tests = Test.objects.filter(engagement=eng)
200+
prod = eng.product
201+
auth = request.user.is_staff or request.user in prod.authorized_users.all()
201202
risks_accepted = eng.risk_acceptance.all()
203+
if not auth:
204+
# will render 403
205+
raise PermissionDenied
206+
202207
try:
203208
jissue = JIRA_Issue.objects.get(engagement=eng)
204209
except:
@@ -220,7 +225,7 @@ def view_engagement(request, eid):
220225
check = None
221226
pass
222227
form = DoneForm()
223-
if request.method == 'POST':
228+
if request.method == 'POST' and request.user.is_staff:
224229
eng.progress = 'check_list'
225230
eng.save()
226231

0 commit comments

Comments
 (0)