@@ -231,7 +231,7 @@ def get_punchcard_data(findings, weeks_between, start_date):
231
231
days [day_offset [finding .date .weekday ()]] += 1
232
232
if days [day_offset [finding .date .weekday ()]] > highest_count :
233
233
highest_count = days [day_offset [finding .date .weekday ()]]
234
- except :
234
+ except :
235
235
if new_date < finding .date <= end_date :
236
236
# [0,0,(20*.02)]
237
237
# [week, day, weight]
@@ -387,7 +387,7 @@ def get_period_counts(active_findings, findings, findings_closed, accepted_findi
387
387
elif finding .severity == 'Low' :
388
388
low_count += 1
389
389
pass
390
-
390
+
391
391
total = crit_count + high_count + med_count + low_count
392
392
opened_in_period .append (
393
393
[(tcalendar .timegm (new_date .timetuple ()) * 1000 ), new_date , crit_count , high_count , med_count , low_count ,
@@ -420,7 +420,7 @@ def get_period_counts(active_findings, findings, findings_closed, accepted_findi
420
420
med_count += 1
421
421
elif finding .severity == 'Low' :
422
422
low_count += 1
423
- except :
423
+ except :
424
424
if finding .date <= end_date :
425
425
if finding .severity == 'Critical' :
426
426
crit_count += 1
@@ -430,12 +430,12 @@ def get_period_counts(active_findings, findings, findings_closed, accepted_findi
430
430
med_count += 1
431
431
elif finding .severity == 'Low' :
432
432
low_count += 1
433
- pass
433
+ pass
434
434
total = crit_count + high_count + med_count + low_count
435
435
active_in_period .append (
436
436
[(tcalendar .timegm (new_date .timetuple ()) * 1000 ), new_date , crit_count , high_count , med_count , low_count ,
437
437
total ])
438
-
438
+
439
439
return {'opened_per_period' : opened_in_period ,
440
440
'accepted_per_period' : accepted_in_period ,
441
441
'active_per_period' : active_in_period }
@@ -733,6 +733,17 @@ def handle_uploaded_threat(f, eng):
733
733
eng .tmodel_path = settings .MEDIA_ROOT + '/threat/%s%s' % (eng .id , extension )
734
734
eng .save ()
735
735
736
+ def add_labels (find , issue ):
737
+ #Update Label with Security
738
+ issue .fields .labels .append (u'security' )
739
+ #Update the label with the product name (underscore)
740
+ prod_name = find .test .engagement .product .name .replace (" " , "_" )
741
+ issue .fields .labels .append (prod_name )
742
+ issue .update (fields = {"labels" : issue .fields .labels })
743
+
744
+ def jira_long_description (find_description , find_id ):
745
+ return find_description + "\n \n *Dojo ID:* " + str (find_id )
746
+
736
747
def add_issue (find , push_to_jira ):
737
748
eng = Engagement .objects .get (test = find .test )
738
749
prod = Product .objects .get (engagement = eng )
@@ -741,13 +752,17 @@ def add_issue(find, push_to_jira):
741
752
if push_to_jira :
742
753
if 'Active' in find .status () and 'Verified' in find .status ():
743
754
jira = JIRA (server = jira_conf .url , basic_auth = (jira_conf .username , jira_conf .password ))
744
- new_issue = jira .create_issue (project = jpkey .project_key , summary = find .title , description = find .long_desc (), 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' : 'Bug' }, priority = {'name' : jira_conf .get_priority (find .severity )})
745
756
j_issue = JIRA_Issue (jira_id = new_issue .id , jira_key = new_issue , finding = find )
746
757
j_issue .save ()
747
- if jpkey .enable_engagement_epic_mapping :
748
- epic = JIRA_Issue .objects .get (engagement = eng )
749
- issue_list = [j_issue .jira_id ,]
750
- jira .add_issues_to_epic (epic_id = epic .jira_id , issue_keys = [str (j_issue .jira_id )], ignore_epics = True )
758
+ issue = jira .issue (new_issue .id )
759
+ #Add labels (security & product)
760
+ add_labels (find , new_issue )
761
+
762
+ #if jpkey.enable_engagement_epic_mapping:
763
+ # epic = JIRA_Issue.objects.get(engagement=eng)
764
+ # issue_list = [j_issue.jira_id,]
765
+ # jira.add_issues_to_epic(epic_id=epic.jira_id, issue_keys=[str(j_issue.jira_id)], ignore_epics=True)
751
766
752
767
def update_issue ( find , old_status , push_to_jira ):
753
768
prod = Product .objects .get (engagement = Engagement .objects .get (test = find .test ))
@@ -757,16 +772,20 @@ def update_issue( find, old_status, push_to_jira):
757
772
j_issue = JIRA_Issue .objects .get (finding = find )
758
773
jira = JIRA (server = jira_conf .url , basic_auth = (jira_conf .username , jira_conf .password ))
759
774
issue = jira .issue (j_issue .jira_id )
760
- issue .update (summary = find .title , description = find .long_desc (), priority = {'name' : jira_conf .get_priority (find .severity )})
775
+ issue .update (summary = find .title , description = jira_long_description (find .long_desc (), find .id ), priority = {'name' : jira_conf .get_priority (find .severity )})
776
+
777
+ #Add labels(security & product)
778
+ add_labels (find , issue )
779
+
761
780
req_url = jira_conf .url + '/rest/api/latest/issue/' + j_issue .jira_id + '/transitions'
762
781
if 'Inactive' in find .status () or 'Mitigated' in find .status () or 'False Positive' in find .status () or 'Out of Scope' in find .status () or 'Duplicate' in find .status ():
763
782
if 'Active' in old_status :
764
783
json_data = {'transition' :{'id' :jira_conf .close_status_key }}
765
784
r = requests .post (url = req_url , auth = HTTPBasicAuth (jira_conf .username , jira_conf .password ), json = json_data )
766
785
elif 'Active' in find .status () and 'Verified' in find .status ():
767
786
if 'Inactive' in old_status :
768
- json_data = {'transition' :{'id' :jira_conf .open_status_key }}
769
- r = requests .post (url = req_url , auth = HTTPBasicAuth (jira_conf .username , jira_conf .password ), json = json_data )
787
+ json_data = {'transition' :{'id' :jira_conf .open_status_key }}
788
+ r = requests .post (url = req_url , auth = HTTPBasicAuth (jira_conf .username , jira_conf .password ), json = json_data )
770
789
771
790
def close_epic (eng , push_to_jira ):
772
791
engagement = eng
@@ -835,5 +854,3 @@ def send_review_email(request, user, finding, users, new_note):
835
854
recipients ,
836
855
fail_silently = False )
837
856
pass
838
-
839
-
0 commit comments