예제 #1
0
파일: views.py 프로젝트: ykoji8681/stip-rs
def publish(request):
    # ajax parameter取得
    stix_id = request.GET['stix_id']
    taxii_id = request.GET['taxii_id']
    # Publish (Push) する StixFile object
    stix = StixFiles.objects.get(id=stix_id)
    # Publish (Push) の時に使用する TaxiiClients object
    client = Client(taxii_id=taxii_id)
    # publish する
    try:
        client.push(stix)
        resp = {'status': 'OK', 'message': 'Success'}
    except Exception as e:
        # traceback.print_exc()
        resp = {'status': 'NG', 'message': str(e)}
    return JsonResponse(resp)
예제 #2
0
def publish(request):
    stix_id = request.GET['stix_id']
    taxii_id = request.GET['taxii_id']
    protocol_version = request.GET['protocol_version']
    stix = StixFiles.objects.get(id=stix_id)
    if protocol_version.startswith('1.'):
        taxii_client = TaxiiClients.objects.get(id=taxii_id)
        client = Client(taxii_client=taxii_client)
    else:
        taxii_client = Taxii2Clients.objects.get(id=taxii_id)
        client = Client(taxii2_client=taxii_client)
    if not client._can_write:
        resp = {'status': 'NG',
                'message': 'This collection is not for publishing.'}
        return JsonResponse(resp)
    try:
        msg = client.push(stix)
        resp = {'status': 'OK',
                'message': msg}
    except Exception as e:
        resp = {'status': 'NG',
                'message': str(e)}
    return JsonResponse(resp)