当前位置: 首页>>代码示例>>Python>>正文


Python Observable.observable_composition方法代码示例

本文整理汇总了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))
开发者ID:dandye,项目名称:openioc-to-stix,代码行数:27,代码来源:utils_tests.py

示例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
开发者ID:DKBlack,项目名称:python-stix,代码行数:13,代码来源:indicator.py

示例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
开发者ID:STIXProject,项目名称:python-stix,代码行数:13,代码来源:indicator.py

示例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
开发者ID:AmesianX,项目名称:MISP,代码行数:13,代码来源:misp2cybox.py

示例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
开发者ID:cnbird1999,项目名称:MISP,代码行数:22,代码来源:misp2cybox.py

示例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
开发者ID:dandye,项目名称:openioc-to-stix,代码行数:40,代码来源:translate.py


注:本文中的cybox.core.Observable.observable_composition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。