本文整理汇总了Python中cybox.core.Observable.observable_composition方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.observable_composition方法的具体用法?Python Observable.observable_composition怎么用?Python Observable.observable_composition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cybox.core.Observable
的用法示例。
在下文中一共展示了Observable.observable_composition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_is_empty_observable
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import observable_composition [as 别名]
def test_is_empty_observable(self):
# Check to see if the cybox.core.Observable object is empty by calling `is_empty_observable`
# Empty Observable
test = Observable()
self.assertTrue(utils.is_empty_observable(test))
# Observable is None
test = None
self.assertTrue(utils.is_empty_observable(test))
# Non empty Observable with Object
test = Observable(MockObject())
self.assertFalse(utils.is_empty_observable(test))
# Non empty Observable with Event
test = Observable(Event())
self.assertFalse(utils.is_empty_observable(test))
# Checks non empty observable_composition and observable_composition.observables
test = Observable()
obs = ObservableComposition()
test.observable_composition = obs
test.observable_composition.observables = obs
self.assertFalse(utils.is_empty_observable(test))
示例2: _merge_observables
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import observable_composition [as 别名]
def _merge_observables(self, observables, operator='AND'):
observable_composition = ObservableComposition()
observable_composition.operator = operator
for observable_ in observables:
observable_composition.add(observable_)
root_observable = Observable()
root_observable.observable_composition = observable_composition
return root_observable
示例3: _merge_observables
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import observable_composition [as 别名]
def _merge_observables(self, observables):
observable_composition = ObservableComposition()
observable_composition.operator = self.observable_composition_operator
for observable in observables:
observable_composition.add(observable)
root_observable = Observable()
root_observable.observable_composition = observable_composition
return root_observable
示例4: returnAttachmentComposition
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import observable_composition [as 别名]
def returnAttachmentComposition(attribute):
file_object = File()
file_object.file_name = attribute["value"]
observable = Observable()
if "data" in attribute:
artifact = Artifact(data = attribute["data"])
composition = ObservableComposition(observables = [artifact, file_object])
observable.observable_composition = composition
else:
observable = Observable(file_object)
return observable
示例5: returnAttachmentComposition
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import observable_composition [as 别名]
def returnAttachmentComposition(attribute):
file_object = File()
file_object.file_name = attribute["value"]
file_object.parent.id_ = cybox.utils.idgen.__generator.namespace.prefix + ":file-" + attribute["uuid"]
observable = Observable()
if "data" in attribute:
artifact = Artifact(data = attribute["data"])
artifact.parent.id_ = cybox.utils.idgen.__generator.namespace.prefix + ":artifact-" + attribute["uuid"]
observable_artifact = Observable(artifact)
observable_artifact.id_ = cybox.utils.idgen.__generator.namespace.prefix + ":observable-artifact-" + attribute["uuid"]
observable_file = Observable(file_object)
observable_file.id_ = cybox.utils.idgen.__generator.namespace.prefix + ":observable-file-" + attribute["uuid"]
composition = ObservableComposition(observables = [observable_artifact, observable_file])
observable.observable_composition = composition
else:
observable = Observable(file_object)
observable.id_ = cybox.utils.idgen.__generator.namespace.prefix + ":observable-" + attribute["uuid"]
if attribute["comment"] != "":
observable.description = attribute["comment"]
return observable
示例6: _indicator_to_observable
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import observable_composition [as 别名]
def _indicator_to_observable(indicator):
"""Process indicator item(s), that can be nested, and create a composite object with observables.
Args:
indicator: Indicator(s) that will be translated
Returns:
A cybox.core.Observable object if `indicator` can be translated.
None is returned if `indicator` contains invalid or untranslatable items.
"""
items = openioc.get_items(indicator)
nested = openioc.get_indicators(indicator)
if not (nested or items):
return None
# If the openioc indicator has only one IndicatorItem, return an Observable
# object which has a single CybOX Object child.
if not nested and len(items) == 1:
return _translate_item(items[0])
# The openioc Indicator had more than one item or nested indicators, so
# we need to create an Observable Composition.
# Initialize the parent Observable
id_ = _translate_id(indicator.attrib.get("id"))
root = Observable(id_=id_)
operator = indicator.attrib.get("operator", "AND")
composite = ObservableComposition(operator=operator)
root.observable_composition = composite
# Translate all the IndicatorItem and nested Indicator children
observables = _translate_items(items) + _translate_indicators(nested)
# Add the translated Observable objects to the composite
composite.observables.extend(observables)
return root