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


Python Address.object_from_dict方法代码示例

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


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

示例1: test_roundtrip2

# 需要导入模块: from cybox.objects.address_object import Address [as 别名]
# 或者: from cybox.objects.address_object.Address import object_from_dict [as 别名]
 def test_roundtrip2(self):
     addr_dict = {'address_value': "1.2.3.4",
                  'category': Address.CAT_IPV4,
                  'is_destination': True,
                  'is_source': False}
     addr_obj = Address.object_from_dict(addr_dict)
     addr_dict2 = Address.dict_from_object(addr_obj)
     self.assertEqual(addr_dict, addr_dict2)
开发者ID:2xyo,项目名称:python-cybox,代码行数:10,代码来源:address_test.py

示例2: object_from_dict

# 需要导入模块: from cybox.objects.address_object import Address [as 别名]
# 或者: from cybox.objects.address_object.Address import object_from_dict [as 别名]
 def object_from_dict(cls, network_connection_attributes):
     """Create the Network Connection Object object representation from an input dictionary"""
     network_connection_obj = network_connection_binding.NetworkConnectionType()
     for key, value in network_connection_attributes.items():
         if key == "tls_used" and utils.test_value(value):
             network_connection_obj.set_tls_used(value.get("value"))
         elif key == "layer3_protocol" and utils.test_value(value):
             network_connection_obj.set_Layer3_Protocol(
                 Base_Object_Attribute.object_from_dict(
                     common_types_binding.StringObjectAttributeType(datatype="String"), value
                 )
             )
         elif key == "layer4_protocol" and utils.test_value(value):
             network_connection_obj.set_Layer4_Protocol(
                 Base_Object_Attribute.object_from_dict(
                     common_types_binding.StringObjectAttributeType(datatype="String"), value
                 )
             )
         elif key == "layer7_protocol" and utils.test_value(value):
             network_connection_obj.set_Layer7_Protocol(
                 Base_Object_Attribute.object_from_dict(
                     common_types_binding.StringObjectAttributeType(datatype="String"), value
                 )
             )
         elif key == "local_ip_address":
             network_connection_obj.set_Local_IP_Address(Address.object_from_dict(value))
         elif key == "local_port":
             network_connection_obj.set_Local_Port(Port.object_from_dict(value))
         elif key == "remote_ip_address":
             network_connection_obj.set_Remote_IP_Address(Address.object_from_dict(value))
         elif key == "remote_port":
             network_connection_obj.set_Local_Port(Port.object_from_dict(value))
         elif key == "layer7_connections":
             layer7_conn_object = network_connection_binding.Layer7ConnectionsType()
             if value.get("http_session") is not None:
                 layer7_conn_object.set_HTTP_Session(HTTP_Session.object_from_dict(value.get("http_session")))
             if layer7_conn_object.hasContent_():
                 network_connection_obj.set_Layer7_Connections(layer7_conn_object)
     return network_connection_obj
开发者ID:2xyo,项目名称:python-cybox,代码行数:41,代码来源:network_connection_object.py

示例3: object_from_dict

# 需要导入模块: from cybox.objects.address_object import Address [as 别名]
# 或者: from cybox.objects.address_object.Address import object_from_dict [as 别名]
 def object_from_dict(cls, process_dict, process_obj = None):
     if process_obj == None:
         process_obj = process_binding.ProcessObjectType()
         process_obj.set_anyAttributes_({'xsi:type' : 'ProcessObj:ProcessObjectType'})
     
     for key, value in process_dict.items():
         if key == 'is_hidden' and utils.test_value(value):
             process_obj.set_is_hidden(value.get('value'))
         elif key == 'name' and utils.test_value(value):
             process_obj.set_Name(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'),value))
         elif key == 'image_info':
             image_info = process_binding.ImageInfoType()
             for image_info_key, image_info_value in value.items():
                 if image_info_key == 'file_name' and utils.test_value(image_info_value):
                     image_info.set_File_Name(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'),image_info_value))
                 elif image_info_key == 'command_line' and utils.test_value(image_info_value):
                     image_info.set_Command_Line(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'),image_info_value))
                 elif image_info_key == 'current_directory' and utils.test_value(image_info_value):
                     image_info.set_Current_Directory(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'),image_info_value))
                 elif image_info_key == 'path' and utils.test_value(image_info_value):
                     image_info.set_Command_Line(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'),image_info_value))
             if image_info.hasContent_() : process_obj.set_Image_Info(image_info)
         elif key == 'pid' and utils.test_value(value):
             process_obj.set_PID(Base_Object_Attribute.object_from_dict(common_types_binding.UnsignedIntegerObjectAttributeType(datatype='UnsignedInt'),value))
         elif key == 'parent_pid' and utils.test_value(value):
             process_obj.set_Parent_PID(Base_Object_Attribute.object_from_dict(common_types_binding.UnsignedIntegerObjectAttributeType(datatype='UnsignedInt'),value))
         elif key == 'child_pid_list':
             child_list = process_binding.ChildPIDListType()
             for id in value:
                 child_list.add_Child_PID(Base_Object_Attribute.object_from_dict(common_types_binding.UnsignedIntegerObjectAttributeType(datatype='UnsignedInt'), id))
             if child_list.hasContent_() : process_obj.set_Child_PID_List(child_list)
         elif key == 'argument_list':
             arg_list = []
             for arg in value:
                 arg_list.append(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'),arg))
             argument_list = process_binding.ArgumentListType()
             argument_list.set_Argument(arg_list)
             process_obj.set_Argument_List(argument_list)
         elif key == 'environment_variable_list':
             env_variable_list = Environment_Variable_List.object_from_dict(value)
             if env_variable_list.hasContent_(): process_obj.set_Environment_Variable_List(env_list)
         elif key == 'port_list':
             port_list = process_binding.PortListType()
             for port_dict in value:
                 port_obj = port.object_from_dict(port_dict)
                 port_list.add_Port(port_obj)
             process_obj.set_Post_List(port_list)
         elif key == 'network_connection_list':
             conn_list = process_binding.NetworkConnectionListType()
             for conn_dict in value:
                 connobj = process_binding.NetworkConnectionType()
                 for conn_key, conn_value in conn_dict.items():
                     if conn_key == 'creation_time' and utils.test_value(conn_value):
                         connobj.set_Creation_Time(Base_Object_Attribute.object_from_dict(common_types_binding.DateTimeObjectAttributeType(datatype='DateTime'),conn_value))
                     elif conn_key == 'destination_ip_Address' and utils.test_value(conn_value):
                         connobj.set_Destination_Address(Address.object_from_dict(conn_value))
                     elif conn_key == 'destination_port' and utils.test_value(conn_value):
                         connobj.set_Source_Port(port.object_from_dict(conn_value))
                     elif conn_key == 'source_ip_Address' and utils.test_value(conn_value):
                         connobj.set_Source_Address(Address.object_from_dict(conn_value))
                     elif conn_key == 'source_port' and utils.test_value(conn_value):
                         connobj.set_Source_Port(port.object_from_dict(conn_value))
                     elif conn_key == 'tcp_state' and utils.test_value(conn_value):
                         connobj.set_TCP_State(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'), value))
                 if connobj.hasContent_() : conn_list.add_Network_Connection(connobj)
         elif key == 'string_list':
             string_list = Extracted_String_List.object_from_list(value)
             if string_list.hasContent_() : process_obj.set_String_List(string_list)
         elif key == 'username' and utils.test_value(value):
             process_obj.set_Username(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'),value))
         elif key == 'creation_time' and utils.test_value(value):
             process_obj.set_Creation_Time(Base_Object_Attribute.object_from_dict(common_types_binding.DateTimeObjectAttributeType(datatype='DateTime'),value))
         elif key == 'start_time' and utils.test_value(value):
             process_obj.set_Start_Time(Base_Object_Attribute.object_from_dict(common_types_binding.DateTimeObjectAttributeType(datatype='DateTime'),value))
         elif key == 'kernel_time' and utils.test_value(value):
             process_obj.set_Kernel_Time(Base_Object_Attribute.object_from_dict(common_types_binding.DurationObjectAttributeType(datatype='Duration'),value))            
         elif key == 'user_time' and utils.test_value(value):
             process_obj.set_User_Time(Base_Object_Attribute.object_from_dict(common_types_binding.DurationObjectAttributeType(datatype='Duration'),value))            
             
     return process_obj
开发者ID:2xyo,项目名称:python-cybox,代码行数:82,代码来源:process_object.py


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