Skip to content

Commit bc19dd3

Browse files
authored
Merge pull request #315 from devGregA/master
Adds leads to tests
2 parents 9d63dab + 881ab6d commit bc19dd3

File tree

10 files changed

+226
-6
lines changed

10 files changed

+226
-6
lines changed

docs/dojo-production.rst

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
Running in Production
2+
=====================
3+
4+
This guide will walk you through how to setup DefectDojo for running in production using Ubuntu 16.04, nginx, and uwsgi.
5+
6+
*Install, Setup, and Activate Virtualenv*
7+
8+
.. code-block:: console
9+
10+
pip install virtualenv
11+
12+
virtualenv dojo
13+
14+
source my_project/bin/activate
15+
16+
**Install Dojo**
17+
18+
.. code-block:: console
19+
20+
cd django-DefectDojo
21+
22+
./install.bash
23+
24+
**Install Uwsgi**
25+
26+
.. code-block:: console
27+
28+
pip install uwsgi
29+
30+
**Install WKHTML**
31+
32+
from inside the django-DefectDojo/ directory execute:
33+
34+
.. code-block:: console
35+
36+
./reports.sh
37+
38+
**Disable Debugging**
39+
40+
Using the text-editor of your choice, change ``DEBUG`` in django-DefectDojo/dojo/settings.py to:
41+
42+
.. code-block:: console
43+
44+
`DEBUG = False`
45+
46+
**Start Celery and Beats**
47+
48+
From inside the django-DefectDojo/ directory execute:
49+
50+
.. code-block:: console
51+
52+
celery -A dojo worker -l info --concurrency 3
53+
54+
celery beat -A dojo -l info
55+
56+
It is recommended that you daemonized both these processes with the sample configurations found `here`_ and `here.`_
57+
58+
.. _here: https://github.com/celery/celery/blob/3.1/extra/supervisord/celeryd.conf
59+
.. _here.: https://github.com/celery/celery/blob/3.1/extra/supervisord/celerybeat.conf
60+
61+
However, for a quick setup you can use the following to run both in the background
62+
63+
.. code-block:: console
64+
65+
celery -A dojo worker -l info --concurrency 3 &
66+
67+
celery beat -A dojo -l info &
68+
69+
*Start Uwsgi*
70+
71+
From inside the django-DefectDojo/ directory execute:
72+
73+
.. code-block:: console
74+
75+
uwsgi --socket :8001 --wsgi-file wsgi.py --workers 7
76+
77+
It is recommended that you use an Upstart job or a @restart cron job to launch uwsgi on reboot. However, if you’re in a hurry you can use the following to run it in the background:
78+
79+
.. code-block:: console
80+
81+
uwsgi --socket :8001 --wsgi-file wsgi.py --workers 7 &
82+
83+
*NGINX Configuration*
84+
85+
Everyone feels a little differently about nginx settings, so here are the barebones to add your to your nginx configuration to proxy uwsgi:
86+
87+
.. code-block:: json
88+
89+
upstream django {
90+
91+
server 127.0.0.1:8001;
92+
}
93+
94+
location /dojo/static/ {
95+
alias /data/prod_dojo/django-DefectDojo/static/;
96+
}
97+
98+
location /dojo/media/ {
99+
alias /data/prod_dojo/django-DefectDojo/media/;
100+
}
101+
102+
103+
location /dojo {
104+
uwsgi_pass django;
105+
include /data/prod_dojo/django-DefectDojo/wsgi_params;
106+
}
107+
108+
*That's it!*

docs/labels.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Issue Labels
2+
============================
3+
4+
This section covers our issue labels and what they mean.
5+
6+
'1.2 release' - These issues are targeted for the 1.2 release of DefectDojo which is scheduled for AppSec USA on September 19th
7+
8+
'believe to be fixed' - Issues that have been investigated / verified where code has been merged to resolve the issue. We do not close verified issues until the person who submitted the issue confirm the fix is working. If the submitter is unresponsive we will go ahead and close a 'believe to be fixed' issue, provided that the author of the code has tested the resolution.
9+
10+
'bug' - Issues that have been investigated and are confirmed.
11+
12+
'code sprint' - DefectDojo is participating in the OWASP 2017 Code Sprint where students assist with OWASP projects. Although this issues are earmarked for the Code Sprint, anyone is welcome to work on a Code Sprint issue, provided that is hasn't been assigned. These are great introductory issues for first time contributors.
13+
14+
'docker' - Issues that are specific to the Docker deployment that are not present in the regular install.
15+
16+
'documentation' - Issues that are related to documentation and do not have any impact related to code or application performance.
17+
18+
'enhancement' - Ideas that are not bugs that may or may not be implemented in the future.
19+
20+
‘high priority’ - Issues that the maintainers consider to be highly impacting and will receive priority.
21+
22+
‘in progress’ - Issues that code is actively being developed for.
23+
24+
‘invalid’ - Issues that invalid possibly from using an old code base or outdated library.
25+
26+
‘investigating’ - Issues that are actively being investigated but haven’t been confirmed as a bug.
27+
28+
‘out of scope’ - Issues that related to third party libraries or code we don’t have control over.
29+
30+
‘question’ - These are questions from the community on, docs, deployment, code, or contributing.
31+
32+
‘swag reward’ - when a ‘swag reward’ issue is fixed, the contributor receives swag (such as shirt, stickers, etc).
33+
34+
‘top priority’ - Issues with this label out-rank ‘high priority’ and receive priority on completion from a maintainer.
35+
36+
‘unable to reproduce’ - The issues has been investigated and the maintainer is not able to reproduce the issue.
37+
38+
‘$100 reward’ - The contributor will receive $100 USD for successfully fixing the issue.
39+
40+

dojo/engagement/views.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,11 @@ def add_tests(request, eid):
309309
if form.is_valid():
310310
new_test = form.save(commit=False)
311311
new_test.engagement = eng
312-
# new_test.lead = User.objects.get(id=form['lead'].value())
312+
try:
313+
new_test.lead = User.objects.get(id=form['lead'].value())
314+
except:
315+
new_test.lead = None
316+
pass
313317
new_test.save()
314318
tags = request.POST.getlist('tags')
315319
t = ", ".join(tags)
@@ -338,6 +342,8 @@ def add_tests(request, eid):
338342
return HttpResponseRedirect(reverse('view_engagement', args=(eng.id,)))
339343
else:
340344
form = TestForm()
345+
form.initial['target_start'] = eng.target_start
346+
form.initial['target_end'] = eng.target_end
341347
add_breadcrumb(parent=eng, title="Add Tests", top_level=False, request=request)
342348
return render(request, 'dojo/add_tests.html',
343349
{'form': form,

dojo/forms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def __init__(self, *args, **kwargs):
183183

184184
class Meta:
185185
model = Product
186-
fields = ['name', 'description', 'tags', 'product_manager', 'technical_contact', 'team_manager', 'prod_type',
186+
fields = ['name', 'description', 'tags', 'prod_manager', 'tech_contact', 'manager', 'prod_type',
187187
'authorized_users']
188188

189189

@@ -555,6 +555,9 @@ class TestForm(forms.ModelForm):
555555
required=False,
556556
help_text="Add tags that help describe this test. "
557557
"Choose from the list or add new tags. Press TAB key to add.")
558+
lead = forms.ModelChoiceField(
559+
queryset=User.objects.exclude(is_staff=False),
560+
required=False, label="Testing Lead")
558561

559562

560563
def __init__(self, *args, **kwargs):

dojo/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ def get_breadcrumbs(self):
531531

532532
class Test(models.Model):
533533
engagement = models.ForeignKey(Engagement, editable=False)
534+
lead = models.ForeignKey(User, editable=True, null=True)
534535
test_type = models.ForeignKey(Test_Type)
535536
target_start = models.DateTimeField()
536537
target_end = models.DateTimeField()

dojo/templates/dojo/engagement.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,19 @@ <h3 class="has-filters">
6060
<td>
6161
{% for e in p.engagement_set.all %}
6262
{% if e.active %}
63-
<a class="eng_link" href="{% url 'view_engagement' e.id %}">
63+
<div class="lineContainer">
64+
<a style="display: inline" class="eng_link" href="{% url 'view_engagement' e.id %}">
6465
{% if e.name %}{{ e.name }} {% endif %}{{ e.target_start }}</a>
66+
| Lead: {{ e.lead.first_name }}
67+
|
68+
{% for test in e.test_set.all %}
69+
{% if test.lead %}
70+
<a href="{% url 'view_test' test.id %}"> {{ test.test_type }}: {{ test.lead.first_name }} </a> |
71+
{% else %}
72+
<a href="{% url 'view_test' test.id %}"> {{ test.test_type }} </a> |
73+
{% endif %}
74+
{% endfor %}
75+
</div>
6576
<sup>
6677
{% for tag in e.tags %}
6778
<a title="Search {{ tag }}" class="btn btn-tag btn-primary" href="{% url 'simple_search' %}?query={{ tag }}">{{ tag }}</a>

dojo/templates/dojo/view_eng.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ <h4 class="pull-left">
337337
<th>Type</th>
338338
<th>Start Date</th>
339339
<th>End Date</th>
340+
<th>Lead</th>
340341
<th>Findings</th>
341342
<th>Notes</th>
342343
<th>Actions</th>
@@ -356,6 +357,7 @@ <h4 class="pull-left">
356357
</td>
357358
<td>{{ test.target_start.date }}</td>
358359
<td>{{ test.target_end.date }}</td>
360+
<td>{{ test.lead }}</td>
359361
<td>{{ test.finding_set.all|length }}</td>
360362
<td>{{ test.notes.all|length }}</td>
361363
<td>

dojo/templates/dojo/view_product.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,9 @@ <h4>Details</h4>
354354
</tr>
355355
<tr>
356356
<td>{{ prod.prod_type }}</td>
357-
<td>{{ prod.team_manager | default:"Unknown" }}</td>
358-
<td>{{ prod.product_manager | default:"Unknown" }}</td>
359-
<td>{{ prod.technical_contact | default:"Unknown" }}</td>
357+
<td>{{ prod.manager | default:"Unknown" }}</td>
358+
<td>{{ prod.prod_manager | default:"Unknown" }}</td>
359+
<td>{{ prod.tech_contact | default:"Unknown" }}</td>
360360
<td>
361361
{% if prod.authorized_users.all %}
362362
<ul class="no-bullets">

wsgi.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
WSGI config for dojo project.
3+
4+
This module contains the WSGI application used by Django's development server
5+
and any production WSGI deployments. It should expose a module-level variable
6+
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
7+
this application via the ``WSGI_APPLICATION`` setting.
8+
9+
Usually you will have the standard Django WSGI application here, but it also
10+
might make sense to replace the whole Django WSGI application with a custom one
11+
that later delegates to the Django one. For example, you could introduce WSGI
12+
middleware here, or combine a Django application with an application of another
13+
framework.
14+
15+
"""
16+
import os
17+
18+
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
19+
# if running multiple sites in the same mod_wsgi process. To fix this, use
20+
# mod_wsgi daemon mode with each site in its own daemon process, or use
21+
# os.environ["DJANGO_SETTINGS_MODULE"] = "dojo.settings"
22+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dojo.settings")
23+
24+
# This application object is used by any WSGI server configured to use this
25+
# file. This includes Django's development server, if the WSGI_APPLICATION
26+
# setting points here.
27+
from django.core.wsgi import get_wsgi_application
28+
29+
application = get_wsgi_application()
30+
31+
# Apply WSGI middleware here.
32+
# from helloworld.wsgi import HelloWorldApplication
33+
# application = HelloWorldApplication(application)

wsgi_params

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
uwsgi_param QUERY_STRING $query_string;
2+
uwsgi_param REQUEST_METHOD $request_method;
3+
uwsgi_param CONTENT_TYPE $content_type;
4+
uwsgi_param CONTENT_LENGTH $content_length;
5+
6+
uwsgi_param REQUEST_URI $request_uri;
7+
uwsgi_param PATH_INFO $document_uri;
8+
uwsgi_param DOCUMENT_ROOT $document_root;
9+
uwsgi_param SERVER_PROTOCOL $server_protocol;
10+
uwsgi_param REQUEST_SCHEME $scheme;
11+
uwsgi_param HTTPS $https if_not_empty;
12+
13+
uwsgi_param REMOTE_ADDR $remote_addr;
14+
uwsgi_param REMOTE_PORT $remote_port;
15+
uwsgi_param SERVER_PORT $server_port;
16+
uwsgi_param SERVER_NAME $server_name;

0 commit comments

Comments
 (0)