Beispiel #1
0
def start(request, id_):
    if not request.user.is_active:
        return error_page_inactive(request)
    if not request.user.is_admin:
        return error_page_no_view_permission(request)
    protocol_version = get_protocol_version(request)
    start = get_datetime_from_string(get_start_start(request))
    end = get_datetime_from_string(get_start_end(request))
    try:
        replace_dict = get_common_replace_dict(request)
        if protocol_version.startswith('1.'):
            taxii_client = TaxiiClients.objects.get(id=id_)
            replace_dict['taxii'] = taxii_client
            cl = Client(taxii_client=taxii_client)
        elif protocol_version.startswith('2.'):
            taxii2_client = Taxii2Clients.objects.get(id=id_)
            replace_dict['taxii'] = taxii2_client
            cl = Client(taxii2_client=taxii2_client)
        else:
            raise Exception('Invalid taxii protocol version.')

        if cl._can_read:
            cl.set_start_time(start)
            cl.set_end_time(end)
            count = cl.poll()
            replace_dict[
                'info_msg'] = 'Poll end successfully!! (Get %d stix files.)' % (
                    count)
        else:
            replace_dict['error_msg'] = 'This collection is not for polling'
        return render(request, 'poll_detail.html', replace_dict)
    except Exception:
        return error_page(request)
Beispiel #2
0
def start(request, id_):
    # activeユーザー以外はエラー
    if not request.user.is_active:
        return error_page_inactive(request)
    start = get_datetime_from_string(get_start_start(request))
    end = get_datetime_from_string(get_start_end(request))
    try:
        cl = Client(taxii_id=id_)
        cl.set_start_time(start)
        cl.set_end_time(end)
        count = cl.poll()
        replace_dict = get_common_replace_dict(request)
        replace_dict['taxii'] = TaxiiClients.objects.get(id=id_)
        replace_dict[
            'info_msg'] = 'Poll end successfully!! (Get %d stix files.)' % (
                count)
        # レンダリング
        return render(request, 'poll_detail.html', replace_dict)
    except Exception:
        # エラーページ
        return error_page(request)