예제 #1
0
파일: file.py 프로젝트: avmi/grr
  def FileFetchFailed(self,
                      pathspec: rdf_paths.PathSpec,
                      request_data: Any = None,
                      status: Optional[rdf_flow_objects.FlowStatus] = None):
    """See MultiGetFileLogic."""
    original_result = request_data["original_result"]

    if (self.client_os == "Windows" and
        pathspec.pathtype == rdf_paths.PathSpec.PathType.OS):
      # Retry with raw filesystem access on Windows,
      # the file might be locked for reads.
      raw_pathspec = rdf_paths.PathSpec(
          path=self.args.path,
          pathtype=config.CONFIG["Server.raw_filesystem_access_pathtype"])
      self.StartFileFetch(raw_pathspec)

      self.state.progress.num_raw_fs_access_retries += 1
    else:
      if status is not None and status.error_message:
        error_description = "{} when fetching {} with {}".format(
            status.error_message, pathspec.path, pathspec.pathtype)
      else:
        error_description = (
            "File {} could not be fetched with {} due to an unknown error. "
            "Check the flow logs.".format(pathspec.path, pathspec.pathtype))

      result = rdf_file_finder.CollectMultipleFilesResult(
          stat=original_result.stat_entry,
          error=error_description,
          status=rdf_file_finder.CollectMultipleFilesResult.Status.FAILED,
      )
      self.SendReply(result)

      self.state.progress.num_in_progress = max(
          0, self.state.progress.num_in_progress - 1)
예제 #2
0
  def _ReceiveFiles(self, responses):
    result = rdf_file_finder.CollectMultipleFilesResult()

    for response in responses:
      result.files.Append(
          rdf_file_finder.CollectedFile(
              stat=response.stat_entry, hash=response.hash_entry))

    self.SendReply(result)

    if not responses.success:
      raise flow_base.FlowError(responses.status.error_message)
예제 #3
0
파일: file.py 프로젝트: khanhgithead/grr
    def ReceiveFetchedFile(self,
                           stat_entry,
                           hash_obj,
                           request_data=None,
                           is_duplicate=False):
        """See MultiGetFileLogic."""
        del request_data, is_duplicate  # Unused.

        result = rdf_file_finder.CollectMultipleFilesResult(
            stat=stat_entry,
            hash=hash_obj,
            status=rdf_file_finder.CollectMultipleFilesResult.Status.COLLECTED)
        self.SendReply(result)

        self.state.progress.num_in_progress = max(
            0, self.state.progress.num_in_progress - 1)
        self.state.progress.num_collected += 1