End of changes
parent
5b6592e2dc
commit
d828e41c78
|
@ -393,12 +393,12 @@ class _Observable(_STIXBase):
|
||||||
|
|
||||||
if streamlined_obj_vals:
|
if streamlined_obj_vals:
|
||||||
data = canonicalize(streamlined_obj_vals, utf8=False)
|
data = canonicalize(streamlined_obj_vals, utf8=False)
|
||||||
# print (str(type(data)))
|
|
||||||
|
# try/except here to enable python 2 compatibility
|
||||||
try:
|
try:
|
||||||
return required_prefix + six.text_type(uuid.uuid5(namespace, data))
|
return required_prefix + six.text_type(uuid.uuid5(namespace, data))
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return required_prefix + six.text_type(uuid.uuid5(namespace, six.binary_type(data)))
|
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
|
# We return None if there are no values specified for any of the id-contributing-properties
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from stix2.canonicalization.NumberToJson import convert2Es6Format
|
from stix2.canonicalization.NumberToJson import convert2Es6Format
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -395,7 +397,8 @@ def _make_iterencode(
|
||||||
else:
|
else:
|
||||||
items = dct.items()
|
items = dct.items()
|
||||||
for key, value in 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
|
pass
|
||||||
# JavaScript is weakly typed for these, so it makes sense to
|
# JavaScript is weakly typed for these, so it makes sense to
|
||||||
# also allow them. Many encoders seem to do something like this.
|
# also allow them. Many encoders seem to do something like this.
|
||||||
|
@ -454,7 +457,8 @@ def _make_iterencode(
|
||||||
del markers[markerid]
|
del markers[markerid]
|
||||||
|
|
||||||
def _iterencode(o, _current_indent_level):
|
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)
|
yield _encoder(o)
|
||||||
elif o is None:
|
elif o is None:
|
||||||
yield 'null'
|
yield 'null'
|
||||||
|
|
|
@ -90,23 +90,6 @@ class Filter(collections.namedtuple('Filter', ['property', 'op', 'value'])):
|
||||||
filter_value = self.value
|
filter_value = self.value
|
||||||
|
|
||||||
if self.op == "=":
|
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
|
return stix_obj_property == filter_value
|
||||||
elif self.op == "!=":
|
elif self.op == "!=":
|
||||||
return stix_obj_property != filter_value
|
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
|
return stix_obj_property in filter_value
|
||||||
elif self.op == "contains":
|
elif self.op == "contains":
|
||||||
if isinstance(filter_value, dict):
|
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()
|
return filter_value in stix_obj_property.values()
|
||||||
else:
|
else:
|
||||||
return filter_value in stix_obj_property
|
return filter_value in stix_obj_property
|
||||||
|
|
|
@ -89,6 +89,7 @@ stix_objs = [
|
||||||
"spec_version": "2.1",
|
"spec_version": "2.1",
|
||||||
"id": "file--42a7175a-42cc-508f-8fa7-23b330aff876",
|
"id": "file--42a7175a-42cc-508f-8fa7-23b330aff876",
|
||||||
"name": "HAL 9000.exe",
|
"name": "HAL 9000.exe",
|
||||||
|
"defanged": False,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -111,8 +112,14 @@ filters = [
|
||||||
Filter("object_marking_refs", "=", "marking-definition--613f2e26-0000-4000-8000-b8e91df99dc9"),
|
Filter("object_marking_refs", "=", "marking-definition--613f2e26-0000-4000-8000-b8e91df99dc9"),
|
||||||
Filter("granular_markings.selectors", "in", "description"),
|
Filter("granular_markings.selectors", "in", "description"),
|
||||||
Filter("external_references.source_name", "=", "CVE"),
|
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(
|
||||||
Filter("objects", "contains", {"type": "file", "id": "file--42a7175a-42cc-508f-8fa7-23b330aff876", "name": "HAL 9000.exe", "spec_version": "2.1"}),
|
"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"),
|
Filter("labels", "contains", "heartbleed"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue