Skip to content
This repository has been archived by the owner on May 11, 2019. It is now read-only.

Commit

Permalink
Lots of changes. Added scripts and started tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkDavidson committed Aug 22, 2014
1 parent ad79cb4 commit 3a95601
Show file tree
Hide file tree
Showing 12 changed files with 1,687 additions and 34 deletions.
1 change: 1 addition & 0 deletions scripts/yeti_collection_information_client.bat
@@ -0,0 +1 @@
collection_information_client --host localhost --port 8080
1 change: 1 addition & 0 deletions scripts/yeti_discovery_client.bat
@@ -0,0 +1 @@
discovery_client --host localhost --port 8080
1 change: 1 addition & 0 deletions scripts/yeti_fulfillment_client.bat
@@ -0,0 +1 @@
fulfillment_client --host localhost --port 8080 %*
1 change: 1 addition & 0 deletions scripts/yeti_poll_client.bat
@@ -0,0 +1 @@
poll_client --host localhost --port 8080 --collection default
1,346 changes: 1,346 additions & 0 deletions yeti/StixXml111QueryHandler.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions yeti/__init__.py
Expand Up @@ -2,3 +2,6 @@
# For license information, see the LICENSE.txt file

__version__ = "1.1.0"

#import custom_handler
import StixXml111QueryHandler
36 changes: 36 additions & 0 deletions yeti/custom_handler.py
@@ -0,0 +1,36 @@
# Copyright (C) 2013 - The MITRE Corporation
# For license information, see the LICENSE.txt file

import taxii_services.taxii_handlers as th
import taxii_services.handlers as h
import libtaxii.messages_11 as tm11

class MyCustomHandler(th.MessageHandler):
"""
Does the same thing as the Built-in Discovery Request Handler,
plus prints a statement.
Just an example of how to extend MessageHandler
"""
supported_request_messages = [tm11.DiscoveryRequest]

@staticmethod
def handle_message(discovery_service, discovery_request, django_request):
print "MyCustomHandler is being called"
# Chain together all the enabled services that this discovery service advertises
advertised_services = list(chain(discovery_service.advertised_discovery_services.filter(enabled=True),
discovery_service.advertised_poll_services.filter(enabled=True),
discovery_service.advertised_inbox_services.filter(enabled=True),
discovery_service.advertised_collection_management_services.filter(enabled=True)))

# Create the stub DiscoveryResponse
discovery_response = tm11.DiscoveryResponse(tm11.generate_message_id(), discovery_request.message_id)

# Iterate over advertised services, creating a service instance for each
for service in advertised_services:
service_instances = taxiifiers.service_to_service_instances(service)
discovery_response.service_instances.extend(service_instances)

# Return the Discovery Response
return discovery_response

#h.register_message_handler(MyCustomHandler, name="MySuperHandler")
50 changes: 23 additions & 27 deletions yeti/fixtures/initial_data.json

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions yeti/fixtures/initial_data.json.20140806
@@ -0,0 +1,28 @@
[
{"pk": 1, "model": "taxii_services.contentbinding", "fields": {"name": "STIX v1.1.1 XML Content", "date_updated": "2014-07-31T16:49:23.110Z", "validator": null, "binding_id": "urn:stix.mitre.org:xml:1.1.1", "date_created": "2014-07-31T16:48:47.624Z", "description": ""}},
{"pk": 2, "model": "taxii_services.contentbinding", "fields": {"name": "STIX v1.1 XML Content", "date_updated": "2014-07-31T16:49:15.097Z", "validator": null, "binding_id": "urn:stix.mitre.org:xml:1.1", "date_created": "2014-07-31T16:49:15.097Z", "description": ""}},
{"pk": 3, "model": "taxii_services.contentbinding", "fields": {"name": "STIX v1.0 XML Content", "date_updated": "2014-07-31T16:49:43.590Z", "validator": null, "binding_id": "urn:stix.mitre.org:xml:1.0", "date_created": "2014-07-31T16:49:43.590Z", "description": ""}},
{"pk": 4, "model": "taxii_services.contentbinding", "fields": {"name": "STIX v1.0.1 XML Content", "date_updated": "2014-07-31T16:50:07.644Z", "validator": null, "binding_id": "urn:stix.mitre.org:xml:1.0.1", "date_created": "2014-07-31T16:50:07.644Z", "description": ""}},
{"pk": 1, "model": "taxii_services.contentbindingsubtype", "fields": {"name": "Indicator Profile", "parent": 1, "date_updated": "2014-07-31T16:48:47.626Z", "validator": null, "subtype_id": "urn:stix.mitre.org:xml:1.1.1:indicator_profile", "date_created": "2014-07-31T16:48:47.626Z", "description": "A profile of indicators"}},
{"pk": 1, "model": "taxii_services.contentbindingandsubtype", "fields": {"date_updated": "2014-07-31T16:48:47.625Z", "subtype": null, "content_binding": 1, "date_created": "2014-07-31T16:48:47.625Z"}},
{"pk": 3, "model": "taxii_services.contentbindingandsubtype", "fields": {"date_updated": "2014-07-31T16:49:15.098Z", "subtype": null, "content_binding": 2, "date_created": "2014-07-31T16:49:15.098Z"}},
{"pk": 4, "model": "taxii_services.contentbindingandsubtype", "fields": {"date_updated": "2014-07-31T16:49:43.592Z", "subtype": null, "content_binding": 3, "date_created": "2014-07-31T16:49:43.592Z"}},
{"pk": 5, "model": "taxii_services.contentbindingandsubtype", "fields": {"date_updated": "2014-07-31T16:50:07.645Z", "subtype": null, "content_binding": 4, "date_created": "2014-07-31T16:50:07.645Z"}},
{"pk": 1, "model": "taxii_services.messagebinding", "fields": {"date_updated": "2014-07-31T16:51:07.466Z", "date_created": "2014-07-31T16:50:49.638Z", "binding_id": "urn:taxii.mitre.org:message:xml:1.1", "name": "TAXII XML v1.1", "description": ""}},
{"pk": 1, "model": "taxii_services.protocolbinding", "fields": {"date_updated": "2014-07-31T16:51:20.501Z", "date_created": "2014-07-31T16:51:20.501Z", "binding_id": "urn:taxii.mitre.org:protocol:http:1.0", "name": "TAXII HTTP v1.0", "description": ""}},
{"pk": 1, "model": "taxii_services.datacollection", "fields": {"accept_all_content": true, "name": "default", "date_updated": "2014-07-31T16:50:27.768Z", "supported_content": [], "enabled": true, "content_blocks": [], "date_created": "2014-07-31T16:50:27.768Z", "type": "DATA_FEED", "description": ""}},
{"pk": 1, "model": "taxii_services.messagehandler", "fields": {"class_hash": "4779807", "supported_messages": "[<class 'libtaxii.messages_11.DiscoveryRequest'>]", "name": "Discovery Handler", "class_name": "DiscoveryRequestHandler", "date_updated": "2014-07-31T16:51:59.262Z", "handler": "taxii_services.taxii_handlers.DiscoveryRequestHandler", "date_created": "2014-07-31T16:51:59.262Z", "module_name": "taxii_services.taxii_handlers", "description": "Built-in Discovery Request Handler."}},
{"pk": 2, "model": "taxii_services.messagehandler", "fields": {"class_hash": "4779136", "supported_messages": "[<class 'libtaxii.messages_11.PollRequest'>]", "name": "Poll Request Handler", "class_name": "PollRequestHandler", "date_updated": "2014-07-31T16:52:16.294Z", "handler": "taxii_services.taxii_handlers.PollRequestHandler", "date_created": "2014-07-31T16:52:16.294Z", "module_name": "taxii_services.taxii_handlers", "description": "Built-in Poll Request Handler"}},
{"pk": 3, "model": "taxii_services.messagehandler", "fields": {"class_hash": "-2142704665", "supported_messages": "[<class 'libtaxii.messages_11.PollFulfillmentRequest'>]", "name": "Poll Fulfillment Handler", "class_name": "PollFulfillmentRequestHandler", "date_updated": "2014-07-31T16:52:44.507Z", "handler": "taxii_services.taxii_handlers.PollFulfillmentRequestHandler", "date_created": "2014-07-31T16:52:44.507Z", "module_name": "taxii_services.taxii_handlers", "description": "Built-in Poll Fulfillment Request Handler."}},
{"pk": 4, "model": "taxii_services.messagehandler", "fields": {"class_hash": "-2142704726", "supported_messages": "[<class 'libtaxii.messages_11.CollectionInformationRequest'>]", "name": "Collection Information Handler", "class_name": "CollectionInformationRequestHandler", "date_updated": "2014-07-31T16:53:00.645Z", "handler": "taxii_services.taxii_handlers.CollectionInformationRequestHandler", "date_created": "2014-07-31T16:53:00.645Z", "module_name": "taxii_services.taxii_handlers", "description": "Built-in Collection Information Request Handler."}},
{"pk": 6, "model": "taxii_services.messagehandler", "fields": {"class_hash": "-2143668267", "supported_messages": "[<class 'libtaxii.messages_11.ManageCollectionSubscriptionRequest'>]", "name": "Manage Collection Subscription Request Handler", "class_name": "ManageCollectionSubscriptionRequestHandler", "date_updated": "2014-07-31T16:56:36.548Z", "handler": "taxii_services.taxii_handlers.ManageCollectionSubscriptionRequestHandler", "date_created": "2014-07-31T16:56:36.548Z", "module_name": "taxii_services.taxii_handlers", "description": "Built-in Management Collection Subscription Request Handler."}},
{"pk": 7, "model": "taxii_services.messagehandler", "fields": {"class_hash": "3701704", "supported_messages": "[<class 'libtaxii.messages_11.InboxMessage'>]", "name": "Inbox Message Handler", "class_name": "InboxMessageHandler", "date_updated": "2014-07-31T17:01:34.703Z", "handler": "taxii_services.taxii_handlers.InboxMessageHandler", "date_created": "2014-07-31T17:01:08.556Z", "module_name": "taxii_services.taxii_handlers", "description": "Built-in Inbox Message Handler."}},
{"pk": 1, "model": "taxii_services._taxiiservice", "fields": {"supported_message_bindings": [1], "name": "Poll Service", "date_updated": "2014-07-31T16:59:53.009Z", "supported_protocol_bindings": [1], "enabled": true, "date_created": "2014-07-31T16:59:53.009Z", "path": "/services/poll/", "description": "The default Poll Service"}},
{"pk": 2, "model": "taxii_services._taxiiservice", "fields": {"supported_message_bindings": [1], "name": "Inbox Service", "date_updated": "2014-07-31T17:02:03.951Z", "supported_protocol_bindings": [1], "enabled": true, "date_created": "2014-07-31T17:02:03.951Z", "path": "/services/inbox/", "description": "The default Inbox Service"}},
{"pk": 3, "model": "taxii_services._taxiiservice", "fields": {"supported_message_bindings": [1], "name": "Discovery Service", "date_updated": "2014-07-31T17:03:02.168Z", "supported_protocol_bindings": [1], "enabled": true, "date_created": "2014-07-31T17:02:30.123Z", "path": "/services/discovery/", "description": "The default Discovery Service"}},
{"pk": 4, "model": "taxii_services._taxiiservice", "fields": {"supported_message_bindings": [1], "name": "Collection Management Service", "date_updated": "2014-07-31T17:02:50.184Z", "supported_protocol_bindings": [1], "enabled": true, "date_created": "2014-07-31T17:02:50.184Z", "path": "/services/collection-management/", "description": ""}},
{"pk": 2, "model": "taxii_services.inboxservice", "fields": {"inbox_message_handler": 7, "accept_all_content": true, "supported_content": [], "supported_message_bindings": [1], "supported_protocol_bindings": [1], "destination_collection_status": "OPTIONAL", "destination_collections": [1]}},
{"pk": 1, "model": "taxii_services.pollservice", "fields": {"supported_message_bindings": [1], "data_collections": [1], "supported_queries": [], "supported_protocol_bindings": [1], "poll_request_handler": 2, "poll_fulfillment_handler": 3}},
{"pk": 4, "model": "taxii_services.collectionmanagementservice", "fields": {"collection_information_handler": 4, "advertised_collections": [1], "supported_queries": [], "supported_message_bindings": [1], "supported_protocol_bindings": [1], "subscription_management_handler": 6}},
{"pk": 3, "model": "taxii_services.discoveryservice", "fields": {"advertised_collection_management_services": [4], "supported_message_bindings": [1], "supported_protocol_bindings": [1], "advertised_inbox_services": [2], "discovery_handler": 1, "advertised_discovery_services": [], "advertised_poll_services": [1]}}
]
Empty file added yeti/models.py
Empty file.
8 changes: 1 addition & 7 deletions yeti/settings.py
Expand Up @@ -120,6 +120,7 @@
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'taxii_services.middleware.StatusMessageExceptionMiddleware'
#'taxii_services.middleware.ProcessExceptionMiddleware',#TODO: What goes on with this?
#'django.contrib.auth.middleware.RemoteUserMiddleware',
# Uncomment the next line for simple clickjacking protection:
Expand Down Expand Up @@ -157,7 +158,6 @@
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
#'taxiiweb',
'taxii_services',
'yeti',
)
Expand Down Expand Up @@ -221,10 +221,4 @@
}


try:
from yeti.settings_local import * # overwrite with local settings if settings_local.py exists
except ImportError:
pass



0 comments on commit 3a95601

Please sign in to comment.