Skip to content

Commit f6519a5

Browse files
authored
Merge pull request #540 from aaronweaver/master
Updating slack notifications.
2 parents 582349d + 9f9a154 commit f6519a5

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

dojo/templatetags/display_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def asvs_calc_level(benchmark_score):
109109
@register.filter(name='asvs_level')
110110
def asvs_level(benchmark_score):
111111
benchmark_score.desired_level, level, total_pass, total = asvs_calc_level(benchmark_score)
112-
return "ASVS " + benchmark_score.desired_level + " (" + str(level) + ") Total Pass: " + str(total_pass) + " Total: " + str(total)
112+
return "ASVS " + benchmark_score.desired_level + " (" + level + ") Pass: " + total_pass + " Total: " + total
113113

114114
@register.filter(name='version_num')
115115
def version_num(value):

dojo/utils.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from jira.exceptions import JIRAError
2424
from dojo.models import Finding, Scan, Test, Engagement, Stub_Finding, Finding_Template, \
2525
Report, Product, JIRA_PKey, JIRA_Issue, Dojo_User, User, Notes, \
26-
FindingImage, Alerts, System_Settings, Notifications
26+
FindingImage, Alerts, System_Settings, Notifications, UserContactInfo
2727
from django_slack import slack_message
2828
from asteval import Interpreter
2929

@@ -1043,8 +1043,9 @@ def get_slack_user_id(user_email):
10431043
for member in users["members"]:
10441044
if "email" in member["profile"]:
10451045
if user_email == member["profile"]["email"]:
1046-
user_id = member["id"]
1047-
break
1046+
if "id" in member:
1047+
user_id = member["id"]
1048+
break
10481049

10491050
return user_id
10501051

@@ -1061,15 +1062,15 @@ def create_notification_message(event, notification_type):
10611062
return notification
10621063

10631064
def send_slack_notification(channel):
1064-
try:
1065-
res = requests.request(method='POST', url='https://slack.com/api/chat.postMessage',
1066-
data={'token':get_system_setting('slack_token'),
1067-
'channel':channel,
1068-
'username':get_system_setting('slack_username'),
1069-
'text':create_notification_message(event, 'slack')})
1070-
except Exception as e:
1071-
log_alert(e)
1072-
pass
1065+
#try:
1066+
res = requests.request(method='POST', url='https://slack.com/api/chat.postMessage',
1067+
data={'token':get_system_setting('slack_token'),
1068+
'channel':channel,
1069+
'username':get_system_setting('slack_username'),
1070+
'text':create_notification_message(event, 'slack')})
1071+
#except Exception as e:
1072+
# log_alert(e)
1073+
# pass
10731074

10741075
def send_hipchat_notification(channel):
10751076
try:
@@ -1150,6 +1151,9 @@ def log_alert(e):
11501151
if user.usercontactinfo.slack_user_id is None:
11511152
#Lookup the slack userid
11521153
slack_user_id = get_slack_user_id(user.usercontactinfo.slack_username)
1154+
slack_user_save = UserContactInfo.objects.get(user_id=user.id)
1155+
slack_user_save.slack_user_id = slack_user_id
1156+
slack_user_save.save()
11531157

11541158
send_slack_notification('@%s' % slack_user_id)
11551159

0 commit comments

Comments
 (0)