Exemplo n.º 1
0
def count_vulnerabilities(workspace=None):
    validate_workspace(workspace)
    get_logger(__name__).debug("Request parameters: {!r}"\
        .format(request.args))

    field = request.args.get('group_by')
    search = request.args.get('search')
    vuln_filter = filter_request_args('search', 'group_by')

    vuln_dao = VulnerabilityDAO(workspace)
    result = vuln_dao.count(group_by=field,
                            search=search,
                            vuln_filter=vuln_filter)
    if result is None:
        abort(400)

    return jsonify(result)
Exemplo n.º 2
0
def workspace_summary(workspace=None):
    validate_workspace(workspace)

    services_count = ServiceDAO(workspace).count()
    vuln_count = VulnerabilityDAO(workspace).count(vuln_filter=flask.request.args)
    host_count = HostDAO(workspace).count()
    iface_count = InterfaceDAO(workspace).count()
    note_count = NoteDAO(workspace).count()

    response = {
        'stats': {
            'services':    services_count.get('total_count', 0),
            'total_vulns': vuln_count.get('total_count', 0),
            'web_vulns':   vuln_count.get('web_vuln_count', 0),
            'std_vulns':   vuln_count.get('vuln_count', 0),
            'hosts':       host_count.get('total_count', 0),
            'interfaces':  iface_count.get('total_count', 0),
            'notes':       note_count.get('total_count', 0),
        }
    }

    return flask.jsonify(response)
Exemplo n.º 3
0
def get_vulnerabilities(workspace=None):
    validate_workspace(workspace)
    get_logger(__name__).debug("Request parameters: {!r}"\
        .format(request.args))

    page = get_integer_parameter('page', default=0)
    page_size = get_integer_parameter('page_size', default=0)
    search = request.args.get('search')
    order_by = request.args.get('sort')
    order_dir = request.args.get('sort_dir')

    vuln_filter = filter_request_args('page', 'page_size', 'search', 'sort',
                                      'sort_dir')

    vuln_dao = VulnerabilityDAO(workspace)

    result = vuln_dao.list(search=search,
                           page=page,
                           page_size=page_size,
                           order_by=order_by,
                           order_dir=order_dir,
                           vuln_filter=vuln_filter)

    return jsonify(result)