Example #1
0
  def StoreResults(self, responses):
    if not responses.success:
      raise flow.FlowError(responses.status)

    self.state.files_found = len(responses)
    with data_store.DB.GetMutationPool() as pool:
      for response in responses:
        if response.uploaded_file:
          self._CreateAFF4ObjectForUploadedFile(response.uploaded_file)
          # TODO(user): Make the export support UploadedFile directly.
          # This fixes the export which expects the stat_entry in
          # response.stat_entry only.
          response.stat_entry = response.uploaded_file.stat_entry
        elif response.stat_entry:
          filesystem.CreateAFF4Object(
              response.stat_entry, self.client_id, pool, token=self.token)
        self.SendReply(response)

        # Publish the new file event to cause the file to be added to the
        # filestore. This is not time critical so do it when we have spare
        # capacity.
        self.Publish(
            "FileStore.AddFileToStore",
            response.stat_entry.pathspec.AFF4Path(self.client_id),
            priority=rdf_flows.GrrMessage.Priority.LOW_PRIORITY)
Example #2
0
    def ProcessCollectedRegistryStatEntry(self, responses):
        """Create AFF4 objects for registry statentries.

    We need to do this explicitly because we call StatFile client action
    directly for performance reasons rather than using one of the flows that do
    this step automatically.

    Args:
      responses: Response objects from the artifact source.
    """
        if not responses.success:
            self.CallStateInline(next_state="ProcessCollected",
                                 responses=responses)
            return

        with data_store.DB.GetMutationPool() as pool:
            new_responses = []
            for response in responses:
                # Create the aff4object and add the aff4path to the response object.
                filesystem.CreateAFF4Object(response,
                                            self.client_id,
                                            pool,
                                            token=self.token)
                new_responses.append(response)

        self.CallStateInline(next_state="ProcessCollected",
                             request_data=responses.request_data,
                             messages=new_responses)
Example #3
0
    def ProcessListDirectory(self, responses):
        """Processes the results of the ListDirectory client action.

    Args:
      responses: a flow Responses object.
    """
        if not responses.success:
            raise flow.FlowError("Unable to list directory.")

        with data_store.DB.GetMutationPool(token=self.token) as pool:
            for response in responses:
                stat_entry = rdf_client.StatEntry(response)
                filesystem.CreateAFF4Object(stat_entry,
                                            self.client_id,
                                            pool,
                                            token=self.token)
                self.SendReply(stat_entry)
Example #4
0
    def ProcessListDirectory(self, responses):
        """Processes the results of the ListDirectory client action.

    Args:
      responses: a flow Responses object.
    """
        if not responses.success:
            raise flow.FlowError("Unable to list directory.")

        for response in responses:
            stat_entry = rdf_client.StatEntry(response)
            filesystem.CreateAFF4Object(stat_entry,
                                        self.client_id,
                                        self.token,
                                        sync=False)
            self.SendReply(stat_entry)

            aff4.FACTORY.Flush()
Example #5
0
 def _CreateAff4Stat(self, response, mutation_pool=None):
     filesystem.CreateAFF4Object(response.stat_entry,
                                 self.client_id,
                                 token=self.token,
                                 mutation_pool=mutation_pool)