def test_inbox_message2(self): inbox_message2 = tm10.InboxMessage( message_id=tm10.generate_message_id(), # Required message='This is a message.', # Optional subscription_information=self.subscription_information1, # Optional content_blocks=[string_content_block1]) # Optional round_trip_message(inbox_message2)
def test_13(self): """ Send a TAXII 1.0 Inbox Message to /services/test_inbox_3/ """ inbox = tm10.InboxMessage(generate_message_id()) msg = make_request('/services/test_inbox_3/', inbox.to_xml(), get_headers(VID_TAXII_SERVICES_10, False), MSG_STATUS_MESSAGE, st=ST_SUCCESS)
def test_11(self): """ Send a TAXII 1.0 Inbox Message to /services/test_inbox_1/. Will always fail because /services/test_inbox_1/ requires a DCN and TAXII 1.0 cannot specify that. """ inbox = tm10.InboxMessage(generate_message_id()) msg = make_request('/services/test_inbox_1/', inbox.to_xml(), get_headers(VID_TAXII_SERVICES_10, False), MSG_STATUS_MESSAGE, st=ST_FAILURE)
def make_inbox_message(version, blocks=None, dest_collection=None): if version == 10: inbox_message = tm10.InboxMessage(message_id=MESSAGE_ID, content_blocks=blocks) elif version == 11: inbox_message = tm11.InboxMessage(message_id=MESSAGE_ID, content_blocks=blocks) if dest_collection: inbox_message.destination_collection_names.append(dest_collection) else: raise ValueError('Unknown TAXII message version: %s' % version) return inbox_message
def create_request_message(self, args): if args.content_file is self.stix_watchlist: data = self.stix_watchlist else: with open(args.content_file, 'r') as f: data = f.read() cb = tm10.ContentBlock(args.content_binding, data) if args.subtype is not None: cb.content_binding.subtype_ids.append(args.subtype) inbox_message = tm10.InboxMessage(message_id=generate_message_id(), content_blocks=[cb]) return inbox_message
def test_inbox_message_deprecated(self): # Test nested-class form: # InboxMessage.SubscriptionInformation sub_info = tm10.InboxMessage.SubscriptionInformation( feed_name='SomeFeedName', subscription_id='SubsId021', inclusive_begin_timestamp_label=datetime.datetime.now(tzutc()), inclusive_end_timestamp_label=datetime.datetime.now(tzutc())) inbox_msg = tm10.InboxMessage(message_id=tm10.generate_message_id(), subscription_information=sub_info, content_blocks=[xml_content_block1]) round_trip_message(inbox_msg)
def push(self, content, content_binding, uri=None, timestamp=None): """Push content into Inbox Service. if ``uri`` is not provided, client will try to discover services and find Inbox Service among them. Content Binding subtypes and Destionation collections are not supported in TAXII Specification v1.0. :param str content: content to push :param content_binding: content binding for a content :type content_binding: string or :py:class:`cabby.entities.ContentBinding` :param datetime timestamp: timestamp label of the content block (current UTC time by default) :param str uri: URI path to a specific Inbox Service :raises ValueError: if URI provided is invalid or schema is not supported :raises `cabby.exceptions.HTTPError`: if HTTP error happened :raises `cabby.exceptions.UnsuccessfulStatusError`: if Status Message received and status_type is not `SUCCESS` :raises `cabby.exceptions.ServiceNotFoundError`: if no service found :raises `cabby.exceptions.AmbiguousServicesError`: more than one service with type specified :raises `cabby.exceptions.NoURIProvidedError`: no URI provided and client can't discover services """ content_block = tm10.ContentBlock( content=content, content_binding=pack_content_binding(content_binding, version=10), timestamp_label=timestamp or get_utc_now(), ) inbox_message = tm10.InboxMessage(message_id=self._generate_id(), content_blocks=[content_block]) self._execute_request(inbox_message, uri=uri, service_type=const.SVC_INBOX) self.log.debug("Content block successfully pushed")