import sys import re from rt2jira import jira, config, pp, logger, JIRAError, syslog, resolve rt2jira_regex = re.compile('From: rt2jira\n') action_regex = re.compile('Action: (.*)\n') tid_regex = re.compile('Ticket ID: (.*?)(\r|)\n') # Get the set of tickets that have been inactive for a set amount of time. jira_results = jira.search_issues('project = ' + config.get('jira', 'project') + ' AND component = "' + config.get('jira', 'component') + '" AND status in ("Open") AND createdDate <= startOfDay(-' + config.get('jira', 'auto_resolve_after_days') + 'd) ORDER BY created ASC', maxResults=False) try: for jira_issue in jira_results: logger.info('Processing Ticket (' + jira_issue.key + ')') syslog.syslog(syslog.LOG_INFO, 'Processing Ticket (' + jira_issue.key + ')') # Next, obtain all current comments on the JIRA ticket. jira_comments = jira.comments(jira_issue) ticket_acted_upon = False for existing_comment in jira_comments: action_match = action_regex.search(existing_comment.body) tid_match = tid_regex.search(existing_comment.body) ticket_id = None if tid_match and (len(tid_match.groups()) >= 1): ticket_id = tid_match.group(1) if jira_issue.fields.assignee: ticket_acted_upon = True
return output # Requestor regex format. from_regex = re.compile('From: (.*?\@FireEye\.com)(\r|)\n') # KB Notified regex format. kb_notified_regex = re.compile('KB Notified: (.*?\@FireEye\.com)(?:\r|)(?:\n|)') # Get the set of tickets that require an auto reply. jira_results = jira.search_issues('project = ' + config.get('jira', 'project') + ' AND component = "' + config.get('jira', 'component') + '" AND labels in ("' + config.get('jira', 'new_issue_label') + '", "' + config.get('jira', 'new_comment_label') + '") ORDER BY created ASC', maxResults=False) try: for jira_issue in jira_results: logger.info('Processing JIRA Ticket (' + jira_issue.key + ')') syslog.syslog(syslog.LOG_INFO, 'Processing JIRA Ticket (' + jira_issue.key + ')') # Get the original RT ticket ID. ticket_id = None fields_dict = config_get_dict(config, 'jira', 'create_fields') if fields_dict != {}: for k,v in fields_dict.iteritems(): try: if 'ticket_id' in v: ticket_id = eval('jira_issue.fields.' + k) except: continue if not ticket_id: logger.warn('Unable to find equivalent RT ticket ID in JIRA: ' + jira_issue.key) syslog.syslog(syslog.LOG_WARNING, 'Unable to find equivalent RT ticket ID in JIRA: ' + jira_issue.key)
# KB Notified regex format. kb_notified_regex = re.compile( 'KB Notified: (.*?\@FireEye\.com)(?:\r|)(?:\n|)') # Get the set of tickets that require an auto reply. jira_results = jira.search_issues( 'project = ' + config.get('jira', 'project') + ' AND component = "' + config.get('jira', 'component') + '" AND labels in ("' + config.get('jira', 'new_issue_label') + '", "' + config.get('jira', 'new_comment_label') + '") ORDER BY created ASC', maxResults=False) try: for jira_issue in jira_results: logger.info('Processing JIRA Ticket (' + jira_issue.key + ')') syslog.syslog(syslog.LOG_INFO, 'Processing JIRA Ticket (' + jira_issue.key + ')') # Get the original RT ticket ID. ticket_id = None fields_dict = config_get_dict(config, 'jira', 'create_fields') if fields_dict != {}: for k, v in fields_dict.iteritems(): try: if 'ticket_id' in v: ticket_id = eval('jira_issue.fields.' + k) except: continue if not ticket_id: logger.warn('Unable to find equivalent RT ticket ID in JIRA: ' + jira_issue.key)
rt2jira_regex = re.compile('From: rt2jira\n') action_regex = re.compile('Action: (.*)\n') tid_regex = re.compile('Ticket ID: (.*?)(\r|)\n') # Get the set of tickets that have been inactive for a set amount of time. jira_results = jira.search_issues( 'project = ' + config.get('jira', 'project') + ' AND component = "' + config.get('jira', 'component') + '" AND status in ("Open") AND createdDate <= startOfDay(-' + config.get('jira', 'auto_resolve_after_days') + 'd) ORDER BY created ASC', maxResults=False) try: for jira_issue in jira_results: logger.info('Processing Ticket (' + jira_issue.key + ')') syslog.syslog(syslog.LOG_INFO, 'Processing Ticket (' + jira_issue.key + ')') # Next, obtain all current comments on the JIRA ticket. jira_comments = jira.comments(jira_issue) ticket_acted_upon = False for existing_comment in jira_comments: action_match = action_regex.search(existing_comment.body) tid_match = tid_regex.search(existing_comment.body) ticket_id = None if tid_match and (len(tid_match.groups()) >= 1): ticket_id = tid_match.group(1) if jira_issue.fields.assignee: ticket_acted_upon = True