Skip to content

Commit 891f359

Browse files
committed
Jira link in findings view and Jira Issue type in config
1 parent 68f9f3d commit 891f359

File tree

6 files changed

+55
-3
lines changed

6 files changed

+55
-3
lines changed

dojo/models.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class Finding(models.Model):
578578
last_reviewed = models.DateTimeField(null=True, editable=False)
579579
last_reviewed_by = models.ForeignKey(User, null=True, editable=False, related_name='last_reviewed_by')
580580
images = models.ManyToManyField('FindingImage', blank=True)
581-
581+
582582
SEVERITIES = {'Info': 4, 'Low': 3, 'Medium': 2,
583583
'High': 1, 'Critical': 0}
584584

@@ -634,6 +634,23 @@ def age(self):
634634

635635
return days if days > 0 else 0
636636

637+
def jira(self):
638+
try:
639+
jissue = JIRA_Issue.objects.get(finding=self)
640+
except:
641+
jissue = None
642+
pass
643+
return jissue
644+
645+
def jira_conf(self):
646+
try:
647+
jpkey = JIRA_PKey.objects.get(product=self.test.engagement.product)
648+
jconf = jpkey.conf
649+
except:
650+
jconf = None
651+
pass
652+
return jconf
653+
637654
def long_desc(self):
638655
long_desc = ''
639656
long_desc += '=== ' + self.title + ' ===\n\n'
@@ -913,6 +930,14 @@ class JIRA_Conf(models.Model):
913930
password = models.CharField(max_length=2000)
914931
# project_key = models.CharField(max_length=200,null=True, blank=True)
915932
# enabled = models.BooleanField(default=True)
933+
default_issue_type = models.CharField(max_length=9,
934+
choices=(
935+
('Task', 'Task'),
936+
('Story', 'Story'),
937+
('Epic', 'Epic'),
938+
('Spike', 'Spike'),
939+
('Bug', 'Bug')),
940+
default='Bug')
916941
epic_name_id = models.IntegerField()
917942
open_status_key = models.IntegerField()
918943
close_status_key = models.IntegerField()

dojo/templates/dojo/all_product_findings.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% extends "base.html" %}
22
{% load navigation_tags %}
3+
{% load get_config_setting %}
34
{% block content %}
45
<div class="row">
56
<div class="col-md-12">
@@ -34,6 +35,9 @@ <h3 class="has-filters">
3435
<th>Verified</th>
3536
<th>Active</th>
3637
<th>Age</th>
38+
{% if "ENABLE_JIRA"|get_config_setting %}
39+
<th>Jira</th>
40+
{% endif %}
3741
</tr>
3842
</thead>
3943
<tbody>
@@ -48,6 +52,11 @@ <h3 class="has-filters">
4852
<td>{{ finding.verified }}</td>
4953
<td>{{ finding.active }}</td>
5054
<td>{{ finding.age }}</td>
55+
{% if "ENABLE_JIRA"|get_config_setting %}
56+
<td>
57+
<a href="{{finding.jira_conf.url}}/browse/{{finding.jira.jira_key}}" target="_blank"> {{finding.jira.jira_key}} </a>
58+
</td>
59+
{% endif %}
5160
</tr>
5261
{% endfor %}
5362
</tbody>

dojo/templates/dojo/open_findings.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% extends "base.html" %}
22
{% load navigation_tags %}
3+
{% load get_config_setting %}
34
{% block content %}
45
<div class="row">
56
<div class="col-md-12">
@@ -28,6 +29,9 @@ <h3 class="has-filters">
2829
<th class="nowrap">{% dojo_sort request 'Reviewed' 'last_reviewed'%}</th>
2930
<th class="nowrap">{% dojo_sort request 'Severity' 'numerical_severity' 'asc' %}</th>
3031
<th class="nowrap">Age</th>
32+
{% if "ENABLE_JIRA"|get_config_setting %}
33+
<th class="nowrap">Jira</th>
34+
{% endif %}
3135
<th class="nowrap">{% dojo_sort request 'Product' 'test__engagement__product__name'%}</th>
3236
</tr>
3337
</thead>
@@ -43,6 +47,11 @@ <h3 class="has-filters">
4347
<p class="text-error">
4448
{% else %}<p>{% endif %}{{ finding.severity }}</p></td>
4549
<td>{{ finding.age }}</td>
50+
{% if "ENABLE_JIRA"|get_config_setting %}
51+
<td>
52+
<a href="{{finding.jira_conf.url}}/browse/{{finding.jira.jira_key}}" target="_blank"> {{finding.jira.jira_key}} </a>
53+
</td>
54+
{% endif %}
4655
<td><a
4756
href="{% url 'view_product' finding.test.engagement.product.id %}"
4857
title="{{ finding.test.engagement.product }}">{{ finding.test.engagement.product }}</a>

dojo/templates/dojo/view_finding.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ <h4>JIRA Link
188188
</h4>
189189
</div>
190190
<div id="jira_link" class="panel-body endpoint-panel table-responsive collapse in">
191-
<a href="{{jconf.url}}/browse/{{jissue.jira_key}}"> {{jconf.url}}/browse/{{jissue.jira_key}} </a>
191+
<a href="{{jconf.url}}/browse/{{jissue.jira_key}}" target="_blank"> {{jconf.url}}/browse/{{jissue.jira_key}} </a>
192192
</div>
193193
</div>
194194
</div>

dojo/templates/dojo/view_test.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% extends "base.html" %}
22
{% load display_tags %}
3+
{% load get_config_setting %}
34
{% load static from staticfiles %}
45
{% block add_styles %}
56
ul#select_by_severity a:hover, ul#bulk_edit a:hover {
@@ -219,6 +220,9 @@ <h4 class="pull-left"> Findings &nbsp;&nbsp;</h4>
219220
<th>Verified</th>
220221
<th>Active</th>
221222
<th>Duplicate</th>
223+
{% if "ENABLE_JIRA"|get_config_setting %}
224+
<th>Jira</th>
225+
{% endif %}
222226
<th>Actions</th>
223227
</tr>
224228
</thead>
@@ -240,6 +244,11 @@ <h4 class="pull-left"> Findings &nbsp;&nbsp;</h4>
240244
<td>{{ finding.verified }}</td>
241245
<td>{{ finding.active }}</td>
242246
<td>{{ finding.duplicate }}</td>
247+
{% if "ENABLE_JIRA"|get_config_setting %}
248+
<td>
249+
<a href="{{finding.jira_conf.url}}/browse/{{finding.jira.jira_key}}" target="_blank"> {{finding.jira.jira_key}} </a>
250+
</td>
251+
{% endif %}
243252
<td>
244253
<div class="btn-group">
245254
<a class="btn btn-sm btn-primary"

dojo/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def add_issue(find, push_to_jira):
752752
if push_to_jira:
753753
if 'Active' in find.status() and 'Verified' in find.status():
754754
jira = JIRA(server=jira_conf.url, basic_auth=(jira_conf.username, jira_conf.password))
755-
new_issue = jira.create_issue(project=jpkey.project_key, summary=find.title, description=jira_long_description(find.long_desc(), find.id), issuetype={'name': 'Bug'}, priority={'name': jira_conf.get_priority(find.severity)})
755+
new_issue = jira.create_issue(project=jpkey.project_key, summary=find.title, description=jira_long_description(find.long_desc(), find.id), issuetype={'name': jira_conf.default_issue_type}, priority={'name': jira_conf.get_priority(find.severity)})
756756
j_issue = JIRA_Issue(jira_id=new_issue.id, jira_key=new_issue, finding = find)
757757
j_issue.save()
758758
issue = jira.issue(new_issue.id)

0 commit comments

Comments
 (0)