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


Python Address.istypeof方法代码示例

本文整理汇总了Python中cybox.objects.address_object.Address.istypeof方法的典型用法代码示例。如果您正苦于以下问题:Python Address.istypeof方法的具体用法?Python Address.istypeof怎么用?Python Address.istypeof使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cybox.objects.address_object.Address的用法示例。


在下文中一共展示了Address.istypeof方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_istypeof

# 需要导入模块: from cybox.objects.address_object import Address [as 别名]
# 或者: from cybox.objects.address_object.Address import istypeof [as 别名]
    def test_istypeof(self):
        a = "[email protected]"

        addr1 = EmailAddress(a)
        self.assertTrue(Address.istypeof(addr1))
        self.assertTrue(EmailAddress.istypeof(addr1))

        # Address with no category set
        addr2 = Address(a)
        self.assertTrue(Address.istypeof(addr2))
        self.assertFalse(EmailAddress.istypeof(addr2))

        # Even though the isinstance check fails, the istypeof check should
        # succeed
        addr2.category = Address.CAT_EMAIL
        self.assertTrue(Address.istypeof(addr2))
        self.assertTrue(EmailAddress.istypeof(addr2))
        self.assertFalse(isinstance(addr2, EmailAddress))

        # Address with category set to something other than CAT_EMAIL
        addr2.category = Address.CAT_IPV4
        self.assertTrue(Address.istypeof(addr2))
        self.assertFalse(EmailAddress.istypeof(addr2))
开发者ID:pallav17,项目名称:python-cybox,代码行数:25,代码来源:address_test.py

示例2: load_rule_obj

# 需要导入模块: from cybox.objects.address_object import Address [as 别名]
# 或者: from cybox.objects.address_object.Address import istypeof [as 别名]
def load_rule_obj(stix_object):
    """
    Load stix object as data to load rule object
    :param stix_object:
    :return:
    """
    rulelist = []
    if stix_object.observables:
        if stix_object.observables.observables:
            for observ in stix_object.observables.observables:
                if hasattr(observ.object_, 'properties'):
                    if Address.istypeof(observ.object_.properties):
                        if observ.object_.properties.category == 'ipv4-addr':
                            rule_ = rulegen.Rule()
                            rule_.load_address_obj(observ.object_.properties, observable_id_=observ.object_.id_)
                            rulelist.append(rule_)
                            # pass through properties if it's an address
    return rulelist
开发者ID:ryanbreed,项目名称:adapter-snort,代码行数:20,代码来源:rulelist.py

示例3: load_ruleobs_obs

# 需要导入模块: from cybox.objects.address_object import Address [as 别名]
# 或者: from cybox.objects.address_object.Address import istypeof [as 别名]
def load_ruleobs_obs(ruleobs):
    """
    Load RuleDataObs object into stix2snort rule gen.
    :param ruleobs:
    :return:
    """
    observ = ruleobs.observable
    indicator_id = ruleobs.indicator_id
    rulelist = []
    if hasattr(observ.object_, 'properties'):
        if Address.istypeof(observ.object_.properties):
            if observ.object_.properties.category == 'ipv4-addr':
                rule_ = rulegen.Rule()
                rule_.load_address_obj(observ.object_.properties, observable_id_=observ.id_, indicator_id_=indicator_id)
                rule_._sid = next(_sid_counter)
                rulelist.append(rule_)
    if len(rulelist) > 0:
        return rulelist
    else:
        return None
开发者ID:ryanbreed,项目名称:adapter-snort,代码行数:22,代码来源:rulelist.py


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