Пример #1
0
def load_method_simple_cfg_cost(engagement, project, cmsix):
    result = {}
    result['meta'] = {}
    try:
        app = load_engagement_app(engagement, project)
        cfg = app.get_method(int(cmsix)).get_cfg()
        methodcost = app.get_costmodel().get_method_cost(int(cmsix))

        (nodes, dotgraph) = cfg.as_dot(methodcost=methodcost, simplecost=True)
        svggraph = UG.get_svg(app.path, dotgraph)

        loop_levels = cfg.get_loop_level_counts()
        UG.append_pcs(svggraph, nodes)
        UG.append_loop_levels(svggraph, loop_levels)
        svg = ET.tostring(svggraph.getroot(),
                          encoding='unicode',
                          method='html')
    except Exception as e:
        result['meta']['status'] = 'fail'
        result['meta']['reason'] = print(e)
        traceback.print_exc()
    else:
        result['meta']['status'] = 'ok'
        result['content'] = {}
        result['content']['svg'] = svg
    return jsonify(result)
Пример #2
0
def loadtaintgraph(engagement, project, index):
    result = {}
    result['meta'] = {}
    loops = False
    sink = None
    try:
        title = engagement + ":" + project + ":" + index
        app = load_engagement_app(engagement, project)
        name = str(app.jd.ttd.get_taint_origin(int(index)))
        app = UA.analyze_taint_propagation(project, index)

        if request.method == 'POST':
            req = request.form
            loops = True if 'loops' in req else False
            sink = req['sinkid'] if 'sinkid' in req else None

        taintgraph = TaintGraph(app, project, index, loops=loops, sink=sink)
        dotgraph = taintgraph.as_dot(index)
        svggraph = UG.get_svg(app.path, dotgraph)
        svg = ET.tostring(svggraph.getroot(),
                          encoding='unicode',
                          method='html')

        if request.method == 'GET':
            template = render_template('taint.html',
                                       title=title,
                                       body=Markup(svg),
                                       name=name,
                                       eng=engagement,
                                       proj=project,
                                       index=index)
    except Exception as e:
        result['meta']['status'] = 'fail'
        result['meta']['reason'] = print(e)
        traceback.print_exc()
        return result
    else:
        if request.method == 'GET':
            return template
        if request.method == 'POST':
            result['meta']['status'] = 'ok'
            result['content'] = {}
            result['content']['svg'] = Markup(svg)
            return result
Пример #3
0
def load_method_rev_cg(engagement, project, cmsix):
    result = {}
    result['meta'] = {}
    try:
        app = load_engagement_app(engagement, project)
        revcg = app.get_callgraph()

        dotgraph = revcg.as_rev_dot(int(cmsix))
        svggraph = UG.get_svg(app.path, dotgraph)

        svg = ET.tostring(svggraph.getroot(),
                          encoding='unicode',
                          method='html')
    except Exception as e:
        result['meta']['status'] = 'fail'
        result['meta']['reason'] = print(e)
        traceback.print_exc()
    else:
        result['meta']['status'] = 'ok'
        result['content'] = {}
        result['content']['svg'] = svg
    return jsonify(result)