Example #1
0
    def CreateFileWithTimeline(client_id, path, path_type, token):
        """Add a file with timeline."""

        # Add a version of the file at gui_test_lib.TIME_0. Since we write all MAC
        # times, this will result in three timeline items.
        stat_entry = rdf_client_fs.StatEntry()
        stat_entry.pathspec.path = path
        stat_entry.pathspec.pathtype = path_type
        stat_entry.st_atime = gui_test_lib.TIME_0.AsSecondsSinceEpoch() + 1000
        stat_entry.st_mtime = gui_test_lib.TIME_0.AsSecondsSinceEpoch()
        stat_entry.st_ctime = gui_test_lib.TIME_0.AsSecondsSinceEpoch() - 1000

        with test_lib.FakeTime(gui_test_lib.TIME_0):
            filesystem.WriteStatEntries([stat_entry],
                                        client_id.Basename(),
                                        mutation_pool=None,
                                        token=token)

        # Add a version with a stat entry, but without timestamps.
        stat_entry = rdf_client_fs.StatEntry()
        stat_entry.pathspec.path = path
        stat_entry.pathspec.pathtype = path_type
        stat_entry.st_ino = 99

        with test_lib.FakeTime(gui_test_lib.TIME_1):
            filesystem.WriteStatEntries([stat_entry],
                                        client_id.Basename(),
                                        mutation_pool=None,
                                        token=token)
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:
      stat_entries = list(map(rdf_client.StatEntry, responses))
      filesystem.WriteStatEntries(
          stat_entries,
          client_id=self.client_id,
          mutation_pool=pool,
          token=self.token)

    self.CallStateInline(
        next_state="ProcessCollected",
        request_data=responses.request_data,
        messages=stat_entries)
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_base.FlowError("Unable to list directory.")

        filesystem.WriteStatEntries(
            [rdf_client_fs.StatEntry(response) for response in responses],
            client_id=self.client_id)

        for response in responses:
            self.SendReply(response)
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.")

    with data_store.DB.GetMutationPool() as pool:
      filesystem.WriteStatEntries(
          [rdf_client_fs.StatEntry(response) for response in responses],
          client_id=self.client_id,
          mutation_pool=pool,
          token=self.token)

    for response in responses:
      self.SendReply(response)
Example #5
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=compatibility.GetName(self.ProcessCollected),
          responses=responses)
      return

    stat_entries = list(map(rdf_client_fs.StatEntry, responses))
    filesystem.WriteStatEntries(stat_entries, client_id=self.client_id)

    self.CallStateInline(
        next_state=compatibility.GetName(self.ProcessCollected),
        request_data=responses.request_data,
        messages=stat_entries)
Example #6
0
 def _WriteStatEntries(self, stat_entries):
     filesystem.WriteStatEntries(stat_entries, client_id=self.client_id)
Example #7
0
 def _CreateAff4Stat(self, response, mutation_pool=None):
     filesystem.WriteStatEntries([response.stat_entry],
                                 client_id=self.client_id,
                                 token=self.token,
                                 mutation_pool=mutation_pool)
Example #8
0
 def _WriteStatEntries(self, stat_entries, mutation_pool=None):
     filesystem.WriteStatEntries(stat_entries,
                                 client_id=self.client_id,
                                 token=self.token,
                                 mutation_pool=mutation_pool)