Exemplo n.º 1
0
 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