Skip to content

Commit

Permalink
Merge pull request #318 from emmanvg/master
Browse files Browse the repository at this point in the history
Replace __hash__ definition for __hash__ as class variable.
  • Loading branch information
gtback committed May 2, 2017
2 parents f03e921 + b76e7b3 commit fe77f42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 5 additions & 6 deletions stix/common/kill_chains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

from mixbox import fields
from mixbox import typedlist
from mixbox import entities

# internal
import stix
import stix.bindings.stix_common as common_binding

from mixbox.vendor.six import string_types


class KillChain(stix.Entity):
__hash__ = entities.Entity.__hash__

_binding = common_binding
_namespace = 'http://stix.mitre.org/common-1'
_binding_class = _binding.KillChainType
Expand Down Expand Up @@ -61,6 +62,8 @@ def _dict_as_list(cls):


class KillChainPhase(stix.Entity):
__hash__ = entities.Entity.__hash__

_binding = common_binding
_namespace = 'http://stix.mitre.org/common-1'
_binding_class = _binding.KillChainPhaseType
Expand Down Expand Up @@ -88,10 +91,6 @@ def __eq__(self, other):
def __ne__(self, other):
return not self.__eq__(other)

def __hash__(self):
# TODO (bworrell): Is all the tuple(sorted(...))) needed?
return hash(tuple(sorted(self.to_dict().items())))


class KillChainPhaseReference(KillChainPhase):
_binding = common_binding
Expand Down
3 changes: 3 additions & 0 deletions stix/common/vocabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def validate_value(instance, value):
error = error.format(**locals())
raise ValueError(error)


class VocabList(typedlist.TypedList):
"""VocabString fields can be any type of VocabString, though there is often
a preferred/default VocabString type.
Expand Down Expand Up @@ -80,6 +81,8 @@ def entity_class(cls, key):


class VocabString(stix.Entity):
__hash__ = entities.Entity.__hash__

_binding = stix_common_binding
_binding_class = stix_common_binding.ControlledVocabularyStringType
_namespace = 'http://stix.mitre.org/common-1'
Expand Down

0 comments on commit fe77f42

Please sign in to comment.