Skip to content

Latest commit

 

History

History
357 lines (253 loc) · 9.83 KB

messages_11.rst

File metadata and controls

357 lines (253 loc) · 9.83 KB

libtaxii.messages_11 Module

libtaxii.messages_11

Note

The examples on this page assume that you have run the equivalent of

import datetime
from dateutil.tz import tzutc
import libtaxii as t
import libtaxii.messages_11 as tm11
from libtaxii.constants import *

import datetime from dateutil.tz import tzutc import libtaxii as t import libtaxii.messages_11 as tm11 from libtaxii.constants import *

Status Message

StatusMessage

Example:

sm03 = tm11.StatusMessage(

message_id='SM03', in_response_to=tm11.generate_message_id(), status_type=ST_DESTINATION_COLLECTION_ERROR, status_detail={'ACCEPTABLE_DESTINATION': ['Collection1','Collection2']})

Discovery Request

DiscoveryRequest

Example:

headers={'ext_header1': 'value1', 'ext_header2': 'value2'} discovery_request = tm11.DiscoveryRequest( message_id=tm11.generate_message_id(), extended_headers=headers)

Discovery Response

DiscoveryResponse

ServiceInstance

Example:

discovery_response = tm11.DiscoveryResponse(

message_id=tm11.generate_message_id(), in_response_to=discovery_request.message_id)

service_instance = tm11.ServiceInstance(

service_type=SVC_POLL, services_version=VID_TAXII_SERVICES_11, protocol_binding=VID_TAXII_HTTP_10, service_address='http://example.com/poll/', message_bindings=[VID_TAXII_XML_11], available=True, message='This is a message.', #supported_query=[tdq1], )

discovery_response.service_instances.append(service_instance)

# Alternatively, you could define the service instance(s) first and use the # following:

service_instance_list = [service_instance] discovery_response = tm11.DiscoveryResponse( message_id=tm11.generate_message_id(), in_response_to=discovery_request.message_id, service_instances=service_instance_list)

Collection Information Request

CollectionInformationRequest

Example:

ext_headers = {'name1': 'val1', 'name2': 'val2'} collection_information_request = tm11.CollectionInformationRequest( message_id='CIReq01', extended_headers=ext_headers)

Collection Information Response

CollectionInformationResponse

CollectionInformation

PushMethod

PollingServiceInstance

SubscriptionMethod

ReceivingInboxService

Example:

push_method1 = tm11.PushMethod(

push_protocol=VID_TAXII_HTTP_10, push_message_bindings=[VID_TAXII_XML_11])

poll_service1 = tm11.PollingServiceInstance(

poll_protocol=VID_TAXII_HTTPS_10, poll_address='https://example.com/PollService1', poll_message_bindings=[VID_TAXII_XML_11])

poll_service2 = tm11.PollingServiceInstance(

poll_protocol=VID_TAXII_HTTPS_10, poll_address='https://example.com/PollService2', poll_message_bindings=[VID_TAXII_XML_11])

subs_method1 = tm11.SubscriptionMethod(

subscription_protocol=VID_TAXII_HTTPS_10, subscription_address='https://example.com/SubscriptionService', subscription_message_bindings=[VID_TAXII_XML_11])

inbox_service1 = tm11.ReceivingInboxService(

inbox_protocol=VID_TAXII_HTTPS_10, inbox_address='https://example.com/InboxService', inbox_message_bindings=[VID_TAXII_XML_11], supported_contents=None)

collection1 = tm11.CollectionInformation(

collection_name='collection1', collection_description='This is a collection', supported_contents=[tm11.ContentBinding(CB_STIX_XML_101)], available=False, push_methods=[push_method1], polling_service_instances=[poll_service1, poll_service2], subscription_methods=[subs_method1], collection_volume=4, collection_type=CT_DATA_FEED, receiving_inbox_services=[inbox_service1])

collection_response1 = tm11.CollectionInformationResponse(

message_id='CIR01', in_response_to='0', collection_informations=[collection1])

Manage Collection Subscription Request

ManageCollectionSubscriptionRequest

Example:

subscription_parameters1 = tm11.SubscriptionParameters() push_parameters1 = tm11.PushParameters("", "", "")

subs_req1 = tm11.ManageCollectionSubscriptionRequest(

message_id='SubsReq01', action=ACT_SUBSCRIBE, collection_name='collection1', subscription_parameters=subscription_parameters1, push_parameters=push_parameters1)

Manage Collection Subscription Response

ManageCollectionSubscriptionResponse

SubscriptionInstance

PollInstance

Example:

subscription_parameters1 = tm11.SubscriptionParameters() push_parameters1 = tm11.PushParameters("", "", "")

poll_instance1 = tm11.PollInstance(

poll_protocol=VID_TAXII_HTTPS_10, poll_address='https://example.com/poll1/', poll_message_bindings=[VID_TAXII_XML_11])

subs1 = tm11.SubscriptionInstance(

subscription_id='Subs001', status=SS_ACTIVE, subscription_parameters=subscription_parameters1, push_parameters=push_parameters1, poll_instances=[poll_instance1])

subs_resp1 = tm11.ManageCollectionSubscriptionResponse(

message_id='SubsResp01', in_response_to='xyz', collection_name='abc123', message='Hullo!', subscription_instances=[subs1])

Poll Request

PollRequest

PollParameters

Example:

delivery_parameters1 = tm11.DeliveryParameters(

inbox_protocol=VID_TAXII_HTTPS_10, inbox_address='https://example.com/inboxAddress/', delivery_message_binding=VID_TAXII_XML_11)

poll_params1 = tm11.PollParameters(

allow_asynch=False, response_type=RT_COUNT_ONLY, content_bindings=[tm11.ContentBinding(binding_id=CB_STIX_XML_11)], #query=query1, delivery_parameters=delivery_parameters1)

poll_req3 = tm11.PollRequest(

message_id='PollReq03', collection_name='collection100', exclusive_begin_timestamp_label=datetime.datetime.now(tzutc()), inclusive_end_timestamp_label=datetime.datetime.now(tzutc()), poll_parameters=poll_params1)

Poll Response

PollResponse

Example:

cb1 = tm11.ContentBlock(CB_STIX_XML_11, "") cb2 = tm11.ContentBlock(CB_STIX_XML_11, "")

count = tm11.RecordCount(record_count=22, partial_count=False)

poll_resp1 = tm11.PollResponse(

message_id='PollResp1', in_response_to='tmp', collection_name='blah', exclusive_begin_timestamp_label=datetime.datetime.now(tzutc()), inclusive_end_timestamp_label=datetime.datetime.now(tzutc()), subscription_id='24', message='This is a test message', content_blocks=[cb1, cb2], more=True, result_id='123', result_part_number=1, record_count=count)

Inbox Message

InboxMessage

SubscriptionInformation

Example:

cb1 = tm11.ContentBlock(CB_STIX_XML_11, "") cb2 = tm11.ContentBlock(CB_STIX_XML_11, "")

subs_info1 = tm11.SubscriptionInformation(

collection_name='SomeCollectionName', subscription_id='SubsId021', exclusive_begin_timestamp_label=datetime.datetime.now(tzutc()), inclusive_end_timestamp_label=datetime.datetime.now(tzutc()))

inbox1 = tm11.InboxMessage(

message_id='Inbox1', result_id='123', destination_collection_names=['collection1','collection2'], message='Hello!', subscription_information=subs_info1, record_count=tm11.RecordCount(22, partial_count=True), content_blocks=[cb1, cb2])

Poll Fulfillment Request

PollFulfillmentRequest

Example:

pf1 = tm11.PollFulfillmentRequest(

message_id='pf1', collection_name='1-800-collection', result_id='123', result_part_number=1)

Other Classes

TAXIIMessage

ContentBinding

ContentBlock

Example:

cb001 = tm11.ContentBlock(

content_binding=tm11.ContentBinding(CB_STIX_XML_11), content='<stix:STIX_Package xmlns:stix="http://stix.mitre.org/stix-1"/>', timestamp_label=datetime.datetime.now(tzutc()), message='Hullo!', padding='The quick brown fox jumped over the lazy dogs.')

DeliveryParameters

PushParameters

RecordCount

SubscriptionParameters

Functions

generate_message_id

validate_xml

get_message_from_xml

get_message_from_dict

get_message_from_json