def main(): discovery_response = tm11.DiscoveryResponse(message_id=generate_message_id(), in_response_to='1') # Create a targeting expression info # indicating STIX XML 1.1.1 and that only # Hash Value targets are allowed my_tei = tdq.TargetingExpressionInfo(CB_STIX_XML_111, preferred_scope=['**/Simple_Hash_Value'], allowed_scope=None) my_supported_query = tdq.DefaultQueryInfo([my_tei], [CM_CORE]) si = tm11.ServiceInstance(service_type=SVC_POLL, services_version=VID_TAXII_SERVICES_11, protocol_binding=VID_TAXII_HTTP_10, service_address='http://example.com/poll-service/', message_bindings=[VID_TAXII_XML_11], available=True, message='This is a File Hash Reputation Poll Service', supported_query=[my_supported_query]) discovery_response.service_instances.append(si) print discovery_response.to_xml(pretty_print=True)
def handle_discovery_request(s, msg): # Create poll response. resp = tm11.DiscoveryResponse(message_id=tm11.generate_message_id(), in_response_to=msg.message_id) # Send response s.respond(resp.to_xml())
def handle_message(cls, service, request): response = tm11.DiscoveryResponse(cls.generate_id(), request.message_id) for service in service.advertised_services: service_instances = service.to_service_instances(version=11) response.service_instances.extend(service_instances) return response