End of changes

master
Desai, Kartikey H 2019-09-11 10:44:14 -04:00
parent 5b6592e2dc
commit d828e41c78
4 changed files with 17 additions and 40 deletions

View File

@ -393,12 +393,12 @@ class _Observable(_STIXBase):
if streamlined_obj_vals:
data = canonicalize(streamlined_obj_vals, utf8=False)
# print (str(type(data)))
# try/except here to enable python 2 compatibility
try:
return required_prefix + six.text_type(uuid.uuid5(namespace, data))
except UnicodeDecodeError:
return required_prefix + six.text_type(uuid.uuid5(namespace, six.binary_type(data)))
# return required_prefix + six.text_type(uuid.uuid5(namespace, data))
# We return None if there are no values specified for any of the id-contributing-properties
return None

View File

@ -24,6 +24,8 @@
import re
import six
from stix2.canonicalization.NumberToJson import convert2Es6Format
try:
@ -395,7 +397,8 @@ def _make_iterencode(
else:
items = dct.items()
for key, value in items:
if isinstance(key, str):
# Replaced isinstance(key, str) with below to enable simultaneous python 2 & 3 compatibility
if isinstance(key, six.string_types) or isinstance(key, six.binary_type):
pass
# JavaScript is weakly typed for these, so it makes sense to
# also allow them. Many encoders seem to do something like this.
@ -454,7 +457,8 @@ def _make_iterencode(
del markers[markerid]
def _iterencode(o, _current_indent_level):
if isinstance(o, str):
# Replaced isinstance(o, str) with below to enable simultaneous python 2 & 3 compatibility
if isinstance(o, six.string_types) or isinstance(o, six.binary_type):
yield _encoder(o)
elif o is None:
yield 'null'

View File

@ -90,23 +90,6 @@ class Filter(collections.namedtuple('Filter', ['property', 'op', 'value'])):
filter_value = self.value
if self.op == "=":
boolA = stix_obj_property == filter_value
if boolA is False:
print ('$$$$$')
print (stix_obj_property)
print ('\n')
print (filter_value)
print ('\n')
print ('$$$$$')
pass
else:
# print ('222222222')
# print (stix_obj_property)
# print ('\n')
# print (filter_value)
# print ('\n')
# print ('222222222')
pass
return stix_obj_property == filter_value
elif self.op == "!=":
return stix_obj_property != filter_value
@ -114,23 +97,6 @@ class Filter(collections.namedtuple('Filter', ['property', 'op', 'value'])):
return stix_obj_property in filter_value
elif self.op == "contains":
if isinstance(filter_value, dict):
boolB = filter_value in stix_obj_property.values()
if boolB is False:
print ('@@@@@@')
print (filter_value)
print ('\n')
print (stix_obj_property.values())
print ('\n')
print ('@@@@@@@')
pass
else:
# print ('55555555555')
# print (filter_value)
# print ('\n')
# print (stix_obj_property.values())
# print ('\n')
# print ('55555555555')
pass
return filter_value in stix_obj_property.values()
else:
return filter_value in stix_obj_property

View File

@ -89,6 +89,7 @@ stix_objs = [
"spec_version": "2.1",
"id": "file--42a7175a-42cc-508f-8fa7-23b330aff876",
"name": "HAL 9000.exe",
"defanged": False,
},
},
@ -111,8 +112,14 @@ filters = [
Filter("object_marking_refs", "=", "marking-definition--613f2e26-0000-4000-8000-b8e91df99dc9"),
Filter("granular_markings.selectors", "in", "description"),
Filter("external_references.source_name", "=", "CVE"),
Filter("objects", "=", {"0": {"type": "file", "id": "file--42a7175a-42cc-508f-8fa7-23b330aff876", "name": "HAL 9000.exe", "spec_version": "2.1"}}),
Filter("objects", "contains", {"type": "file", "id": "file--42a7175a-42cc-508f-8fa7-23b330aff876", "name": "HAL 9000.exe", "spec_version": "2.1"}),
Filter(
"objects", "=",
{"0": {"type": "file", "id": "file--42a7175a-42cc-508f-8fa7-23b330aff876", "name": "HAL 9000.exe", "spec_version": "2.1", "defanged": False}},
),
Filter(
"objects", "contains",
{"type": "file", "id": "file--42a7175a-42cc-508f-8fa7-23b330aff876", "name": "HAL 9000.exe", "spec_version": "2.1", "defanged": False},
),
Filter("labels", "contains", "heartbleed"),
]