コード例 #1
0
ファイル: sow.py プロジェクト: owasp-sbot/OSBot-Browser
def get_issue_data(jira_id):
    jira_data = Lambda('osbot_jira.lambdas.gw.gw_jira').invoke(
        {"issue_id": jira_id})
    if jira_data is None:
        return {}

    enhancement_id = jira_data.get('EnhancementId')
    title = jira_data.get('Summary')
    description = jira_data.get('Description')
    setup = jira_data.get('Setup')
    verification_method = jira_data.get('Verification Method')
    execution_steps = jira_data.get('Execution Steps')
    expected_result = jira_data.get('Expected Results')
    status = jira_data.get('Status')
    issue_links = jira_data.get('Issue Links')
    results = jira_data.get('Actual results')

    issue_data = {
        "requirement_number": enhancement_id,
        "requirement_language": title,
        "verification_method": verification_method,
        "setup": setup,
        "execution_steps": execution_steps,
        "expected_result": expected_result,
        "compliance": f'{status}',
        "results": results,
        "issue_links": f'{issue_links}',
        "jira_id": jira_id
    }
    return issue_data
コード例 #2
0
    def handle_dialog_submission(self, data):
        callback_id = data['callback_id']
        channel     = data['channel']['id']
        user_id     = data['user']['id']

        if callback_id =='jira-graph-chooser':
            graph_name = data['submission'].get('graph_name')
            Lambda('pbx_gs_python_utils.lambdas.gs.elastic_jira').invoke_async({"params": ["graph", graph_name], "user": user_id, "channel": channel})

        elif callback_id == 'jira-view-issue-links':
            self.handle_callback_jira_view_issue_links(data)

        elif callback_id == 'jira-view-issue-dialogue':
            slack_message('jira-view-issue-dialogue: {0}'.format(data),[], channel)
            key     = data.get('submission').get('key')
            result  = Lambda('pbx_gs_python_utils.lambdas.gs.elastic_jira').invoke({"params": ["issue", key], "user": user_id, "channel": channel})
            slack_message(result.get('text'), result.get('attachments'), channel)

        # elif callback_id == 'issue-search-dialog':
        #     self.(data)

        else:
            error_message = ":red_circle: Dialog callback_id not supported: {0}".format(callback_id)
            slack_message(error_message, [], channel)
            #self.api_slack.send_message(error_message, channel=channel)

        return None
コード例 #3
0
 def process_slash_command(self, data):
     try:
         log_to_elk('process_slash_command', data)
         command = data.get('command')
         attachments = []
         #if command =='/cst':
         #    (text, attachments) = Slash_Cst().process_command(data)
         if command == '/jira':
             result = Lambda('gs.jira_dialog').invoke({
                 'type': 'jira_slash_command',
                 'data': data
             })
             if (result                    is not None and \
                 type(result)              is not str  and \
                 result.get('text')        is not None and \
                 result.get('attachments') is not None     ):
                 text = result.get('text')
                 attachments = result.get('attachments')
             else:
                 text = result
         else:
             text = ':point_right: unrecongnised Slash Command: {0}'.format(
                 command)
         return {'text': text, 'attachments': attachments}
     except Exception as error:
         error_message = 'Error in API_Slack_Integration.process slash command: {0}'.format(
             error)
         log_to_elk(error_message, level='error')
         return {'text': error_message, 'attachments': []}
コード例 #4
0
 def test___cmd_search_graph__send_results_to_Lambda(self):
     slack_cmd = 'links RISK-1534,RISK-1496,RISK-1498,RISK-1494,RISK-1592,RISK-1495 down 1'
     params = slack_cmd.split(' ')
     user_id = None
     channel = 'DDKUZTK6X'
     result = Lambda('osbot_jira.lambdas.jira').invoke({
         "params": params,
         "user": user_id,
         "channel": channel
     })
     ##Dev.pprint(result)
     slack_message(result.get('text'), result.get('attachments'), channel)
コード例 #5
0
        def send_message(team_id, channel):

            text = 'direct slack message to team_id: {0}'.format(team_id)
            attachments = []

            payload = {
                'text': text,
                'attachments': attachments,
                'channel': channel,
                'team_id': team_id
            }

            result = Lambda('pbx_gs_python_utils.lambdas.utils.slack_message'
                            ).invoke(payload)
            assert result.get('ok') == True
            assert result.get('channel') == channel
コード例 #6
0
    def create_dashboard_for_graph(self, graph_name, root_node):
        from osbot_browser.view_helpers.Vis_Js import Vis_Js
        self.graph_name = graph_name
        self.jira_key = root_node

        payload = {"graph_name": graph_name, 'destination_node': root_node}
        graph_paths = Lambda('gs.graph_paths').invoke(payload)

        self.create_dashboard_with_R1_R2()

        graph_data = Vis_Js().get_graph_data(graph_name)

        nodes = graph_data.get('nodes')

        colors_scores = {}
        for key, node in nodes.items():
            if node:
                if 'R2' in node.get('Labels'):
                    summary = node.get('Summary')
                    cell_key = (
                        "r" + summary.split('-')[0].replace('.', '_')).strip()
                    #Dev.pprint(graph_paths.get(key))

                    if graph_paths.get(key):
                        score = len(graph_paths.get(key))
                        colors_scores[cell_key] = score
                    #Dev.pprint(score)
                    #Dev.pprint(key + '   ' + cell_key + '   ' + str(score) + '   ' + summary)

        #return colors_scores
        #Dev.pprint(colors_scores)

        js_codes = []
        for i in range(1, 7):
            for j in range(1, 7):
                r2_id = "r{0}_{1}".format(i, j)
                color = colors_scores.get(r2_id)
                self.js_apply_css_color(js_codes, r2_id, color)

        self.js_eval(js_codes)

        return self
コード例 #7
0
    def mindmap_issue(team_id=None, channel=None, params=None):
        def log_message(message):
            slack_message(':point_right: {0}'.format(message),[],channel,team_id)

        def log_error(message):
            slack_message(':red_circle: {0}'.format(message),[],channel,team_id)

        (start, direction, depth, view) = (params.pop(0), 'all', 1, '')

        log_message('Step 1: Generating graph for issue {0} using direction `all` and depth `{1}`'.format(direction, depth))

        payload     = {"params": ['links', start, direction, depth, view]}
        result      = Lambda('gs.elastic_jira').invoke(payload)
        graph       = json.loads(result.get('text'))
        graph_name  = graph.get('graph_name')
        sleep(0.5)
        log_message('Step 2: Filtering graph {0} with filter `group_by_field` on field `Issue links`'.format(graph_name))
        payload = {"params": ["filter", "group_by_field", graph_name, "Issue Links"]}
        graph_filtered_name = Lambda('lambdas.gsbot.gsbot_graph').invoke(payload)
        if graph_name:
            log_message('Step 3: Creating  mindmap for filtered graph `{0}`'.format(graph_filtered_name))
            return Go_Js_Views.mindmap(team_id, channel, params=[graph_filtered_name], root_node_text=start)
        log_error('Error in step 2) No graph was created')
コード例 #8
0
def show_graph(graph, height=200):
    puml = graph.render_puml().puml
    result = Lambda('utils.puml_to_png').invoke({"puml": puml})
    png_data = result.get('png_base64')
    show_png(png_data, height)