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


Python STIXPackage.to_dict方法代码示例

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


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

示例1: main

# 需要导入模块: from stix.core import STIXPackage [as 别名]
# 或者: from stix.core.STIXPackage import to_dict [as 别名]
def main():
    stix_package = STIXPackage()
    stix_header = STIXHeader()

    # Add tool information
    stix_header.information_source = InformationSource()
    stix_header.information_source.tools = ToolInformationList()
    stix_header.information_source.tools.append(ToolInformation("python-stix ex_04.py", "The MITRE Corporation"))

    stix_header.description = "Example "
    stix_package.stix_header = stix_header

    print(stix_package.to_xml())
    print(stix_package.to_dict())
开发者ID:DavidWatersHub,项目名称:python-stix,代码行数:16,代码来源:creation_tool_metadata.py

示例2: main

# 需要导入模块: from stix.core import STIXPackage [as 别名]
# 或者: from stix.core.STIXPackage import to_dict [as 别名]
def main():
    # Create a new STIXPackage
    stix_package = STIXPackage()

    # Create a new STIXHeader
    stix_header = STIXHeader()

    # Add Information Source. This is where we will add the tool information.
    stix_header.information_source = InformationSource()

    # Create a ToolInformation object. Use the initialization parameters
    # to set the tool and vendor names.
    #
    # Note: This is an instance of cybox.common.ToolInformation and NOT
    # stix.common.ToolInformation.
    tool = ToolInformation(
        tool_name="python-stix",
        tool_vendor="The MITRE Corporation"
    )

    # Set the Information Source "tools" section to a
    # cybox.common.ToolInformationList which contains our tool that we
    # created above.
    stix_header.information_source.tools = ToolInformationList(tool)

    # Set the header description
    stix_header.description = "Example"

    # Set the STIXPackage header
    stix_package.stix_header = stix_header

    # Print the XML!
    print(stix_package.to_xml())

    # Print the dictionary!
    pprint(stix_package.to_dict())
开发者ID:ExodusIntelligence,项目名称:python-stix,代码行数:38,代码来源:creation_tool_metadata.py

示例3: main

# 需要导入模块: from stix.core import STIXPackage [as 别名]
# 或者: from stix.core.STIXPackage import to_dict [as 别名]
def main():
    # Create a CybOX File Object with a contained hash
    f = File()
    f.add_hash("4EC0027BEF4D7E1786A04D021FA8A67F")

    # Create an Indicator with the File Hash Object created above.
    indicator = Indicator()
    indicator.title = "File Hash Example"
    indicator.description = (
        "An indicator containing a File observable with an associated hash"
    )
    indicator.set_producer_identity("The MITRE Corporation")
    indicator.set_produced_time(utils.dates.now())

    # Add The File Object to the Indicator. This will promote the CybOX Object
    # to a CybOX Observable internally.
    indicator.add_object(f)

    # Build our STIX CIQ Identity object
    party_name = stix_ciq.PartyName(
        name_lines=("Foo", "Bar"),
        person_names=("John Smith", "Jill Smith"),
        organisation_names=("Foo Inc.", "Bar Corp.")
    )
    ident_spec = stix_ciq.STIXCIQIdentity3_0(party_name=party_name)
    ident_spec.add_electronic_address_identifier("[email protected]")
    ident_spec.add_free_text_line("Demonstrating Free Text!")
    ident_spec.add_contact_number("555-555-5555")
    ident_spec.add_contact_number("555-555-5556")

    # Build and add a CIQ Address
    addr = stix_ciq.Address(
        free_text_address='1234 Example Lane.',
        country='USA',
        administrative_area='An Admin Area'
    )
    ident_spec.add_address(addr)

    # Build and add a nationality
    nationality = stix_ciq.Country("Norway")
    ident_spec.add_nationality(nationality)

    identity = stix_ciq.CIQIdentity3_0Instance(specification=ident_spec)

    # Set the Indicator producer identity to our CIQ Identity
    indicator.set_producer_identity(identity)

    # Build our STIX Package
    stix_package = STIXPackage()

    # Build a STIX Header and add a description
    stix_header = STIXHeader()
    stix_header.description = "STIX CIQ Identity Extension Example"

    # Set the STIX Header on our STIX Package
    stix_package.stix_header = stix_header

    # Add our Indicator object. The add() method will inspect the input and
    # append it to the `stix_package.indicators` collection.
    stix_package.add(indicator)
    
    # Print the XML!
    print(stix_package.to_xml())

    # Print a dictionary!
    pprint(stix_package.to_dict())
开发者ID:ExodusIntelligence,项目名称:python-stix,代码行数:68,代码来源:ciq_identity.py


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