コード例 #1
0
ファイル: messages_10_test.py プロジェクト: nadavc/libtaxii
    def test_feed_information_response1(self):
        push_method1 = tm10.PushMethod(
            push_protocol=t.VID_TAXII_HTTP_10,  # Required
            push_message_bindings=[t.VID_TAXII_XML_10])  # Required

        polling_service1 = tm10.PollingServiceInstance(
            poll_protocol=t.VID_TAXII_HTTP_10,  # Required
            poll_address='http://example.com/PollService/',  # Required
            poll_message_bindings=[t.VID_TAXII_XML_10])  # Required

        subscription_service1 = tm10.SubscriptionMethod(
            subscription_protocol=t.VID_TAXII_HTTP_10,  # Required
            subscription_address='http://example.com/SubsService/',  # Required
            subscription_message_bindings=[t.VID_TAXII_XML_10])  # Required

        feed1 = tm10.FeedInformation(
            feed_name='Feed1',  # Required
            feed_description='Description of a feed',  # Required
            supported_contents=[t.CB_STIX_XML_10],  # Required. List of supported content binding IDs
            available=True,  # Optional. Defaults to None (aka Unknown)
            push_methods=[push_method1],  # Required if there are no polling_services. Optional otherwise
            polling_service_instances=[polling_service1],  # Required if there are no push_methods. Optional otherwise.
            subscription_methods=[subscription_service1])  # Optional

        feed_information_response1 = tm10.FeedInformationResponse(
            message_id=tm10.generate_message_id(),  # Required
            in_response_to=tm10.generate_message_id(),  # Required. This should be the ID of the corresponding request
            feed_informations=[feed1])  # Optional

        round_trip_message(feed_information_response1)
コード例 #2
0
ファイル: converters.py プロジェクト: zach-threatq/OpenTAXII
def collection_to_feedcollection_information(service, collection, version):

    polling_instances = []
    for poll in service.get_polling_services(collection):
        polling_instances.extend(
            poll_service_to_polling_service_instance(poll, version=version))

    push_methods = service.get_push_methods(collection)

    subscription_methods = []
    for s in service.get_subscription_services(collection):
        subscription_methods.extend(
            subscription_service_to_subscription_method(s, version=version))

    if collection.accept_all_content:
        supported_content = []
    else:
        supported_content = content_binding_entities_to_content_bindings(
            collection.supported_content, version=version)

    if version == 11:
        inbox_instances = []
        for inbox in service.get_receiving_inbox_services(collection):
            inbox_instances.extend(inbox_to_receiving_inbox_instance(inbox))

        return tm11.CollectionInformation(
            collection_name=collection.name,
            collection_description=collection.description,
            supported_contents=supported_content,
            available=collection.available,
            push_methods=push_methods,
            polling_service_instances=polling_instances,
            subscription_methods=subscription_methods,
            collection_volume=collection.volume,
            collection_type=collection.type,
            receiving_inbox_services=inbox_instances)

    if version == 10:
        return tm10.FeedInformation(
            feed_name=collection.name,
            feed_description=collection.description,
            supported_contents=supported_content,
            available=collection.available,
            push_methods=push_methods,
            polling_service_instances=polling_instances,
            subscription_methods=subscription_methods
            # collection_volume, collection_type, and
            # receiving_inbox_services are not supported in TAXII 1.0
        )

    raise ValueError('invalid version')