Skip to content

Commit

Permalink
Merge pull request #270 from STIXProject/issue252
Browse files Browse the repository at this point in the history
Issue252
  • Loading branch information
Bryan Worrell committed Jul 7, 2015
2 parents c352142 + 736a163 commit 2e601d6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions stix/incident/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def __init__(self, id_=None, idref=None, timestamp=None, title=None, description
self.coa_taken = None
self.coa_requested = None
self.history = History()
self._contacts = None
self._url = None


@property
Expand Down Expand Up @@ -454,6 +456,27 @@ def related_packages(self, value):
def add_related_package(self, value):
self.related_packages.append(value)

@property
def contacts(self):
return self._contacts

@contacts.setter
def contacts(self, contacts_list):
self._contacts = _InformationSources(contacts_list)

def add_contact(self, contact):
if self._contacts is None:
self._contacts = _InformationSources()
self._contacts.append(contact)

@property
def url(self):
return self._url

@url.setter
def url(self, value):
self._url = value

def to_obj(self, return_obj=None, ns_info=None):
if not return_obj:
return_obj = self._binding_class()
Expand Down Expand Up @@ -506,6 +529,10 @@ def to_obj(self, return_obj=None, ns_info=None):
return_obj.History = self.history.to_obj(ns_info=ns_info)
if self.related_packages:
return_obj.Related_Packages = self.related_packages.to_obj(ns_info=ns_info)
if self.contacts:
return_obj.Contact = self.contacts.to_obj(ns_info=ns_info)
if self.url:
return_obj.URL = self.url

return return_obj

Expand Down Expand Up @@ -543,6 +570,8 @@ def from_obj(cls, obj, return_obj=None):
return_obj.impact_assessment = ImpactAssessment.from_obj(obj.Impact_Assessment)
return_obj.security_compromise = VocabString.from_obj(obj.Security_Compromise)
return_obj.related_packages = RelatedPackageRefs.from_obj(obj.Related_Packages)
return_obj.contacts = _InformationSources.from_obj(obj.Contact)
return_obj.url = obj.URL

return return_obj

Expand Down Expand Up @@ -583,6 +612,8 @@ def from_dict(cls, dict_repr, return_obj=None):
return_obj.status = VocabString.from_dict(get('status'))
return_obj.history = History.from_dict(get('history'))
return_obj.related_packages = RelatedPackageRefs.from_dict(get('related_packages'))
return_obj.contacts = _InformationSources.from_dict(get('contacts'))
return_obj.url = get('url')

return return_obj

Expand Down
2 changes: 2 additions & 0 deletions stix/test/incident_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ class IncidentTest(EntityTestCase, unittest.TestCase):
'discovery_methods': DiscoveryMethodsTests._full_dict,
'confidence': confidence_test.ConfidenceTests._full_dict,
'related_packages': related_test.RelatedPackageRefsTests._full_dict,
'contacts': InformationSourcesTest._full_dict,
'url': 'http://www.example.com/'
}

def test_parse_category(self):
Expand Down

0 comments on commit 2e601d6

Please sign in to comment.