Skip to content

Commit

Permalink
Accept lists and tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Worrell committed Feb 28, 2015
1 parent 7fab509 commit 851c69b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions stix/core/stix_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# external
from dateutil.tz import tzutc
from cybox.core import Observables

# internal
import stix
Expand All @@ -21,14 +22,11 @@
from stix.threat_actor import ThreatActor
from stix.common.related import RelatedPackages
from .ttps import TTPs
from cybox.core import Observables

import stix.bindings.stix_common as stix_common_binding
import stix.bindings.stix_core as stix_core_binding




class STIXPackage(stix.Entity):
_binding = stix_core_binding
_binding_class = _binding.STIXType
Expand Down Expand Up @@ -112,7 +110,7 @@ def indicators(self, value):

if not value:
return
elif isinstance(value, list):
elif isinstance(value, (list, tuple)):
for v in value:
self.add_indicator(v)
else:
Expand Down Expand Up @@ -140,7 +138,7 @@ def campaigns(self, value):

if not value:
return
elif isinstance(value, list):
elif isinstance(value, (list, tuple)):
for v in value:
self.add_campaign(v)
else:
Expand Down Expand Up @@ -185,7 +183,7 @@ def incidents(self, value):

if not value:
return
elif isinstance(value, list):
elif isinstance(value, (list, tuple)):
for v in value:
self.add_incident(v)
else:
Expand Down Expand Up @@ -213,7 +211,7 @@ def threat_actors(self, value):

if not value:
return
elif isinstance(value, list):
elif isinstance(value, (list, tuple)):
for v in value:
self.add_threat_actor(v)
else:
Expand Down Expand Up @@ -241,7 +239,7 @@ def courses_of_action(self, value):

if not value:
return
elif isinstance(value, list):
elif isinstance(value, (list, tuple)):
for v in value:
self.add_course_of_action(v)
else:
Expand Down Expand Up @@ -269,7 +267,7 @@ def exploit_targets(self, value):

if not value:
return
elif isinstance(value, list):
elif isinstance(value, (list, tuple)):
for v in value:
self.add_exploit_target(v)
else:
Expand All @@ -295,7 +293,7 @@ def ttps(self, value):

if not value:
self._ttps = TTPs()
elif isinstance(value, list):
elif isinstance(value, (list, tuple)):
for v in value:
self.add_ttp(v)
else:
Expand Down Expand Up @@ -323,7 +321,7 @@ def to_obj(self, return_obj=None, ns_info=None):

if self.stix_header:
return_obj.STIX_Header = self.stix_header.to_obj(ns_info=ns_info)

if self.campaigns:
return_obj.Campaigns = self.campaigns.to_obj(ns_info=ns_info)

Expand Down Expand Up @@ -355,6 +353,7 @@ def to_obj(self, return_obj=None, ns_info=None):

def to_dict(self):
d = {}

if self.id_:
d['id'] = self.id_
if self.idref:
Expand Down

0 comments on commit 851c69b

Please sign in to comment.