예제 #1
0
파일: mem_paths.py 프로젝트: vismid86/grr
    def MultiWritePathHistory(self, client_path_histories):
        """Writes a collection of hash and stat entries observed for given paths."""
        for client_path, client_path_history in iteritems(
                client_path_histories):
            if client_path.client_id not in self.metadatas:
                raise db.UnknownClientError(client_path.client_id)

            path_info = rdf_objects.PathInfo(path_type=client_path.path_type,
                                             components=client_path.components)

            for timestamp, stat_entry in iteritems(
                    client_path_history.stat_entries):
                path_record = self._GetPathRecord(client_path.client_id,
                                                  path_info,
                                                  set_default=False)
                if path_record is None:
                    # TODO(hanuszczak): Provide more details about paths that caused that.
                    raise db.AtLeastOneUnknownPathError([])

                path_record.AddStatEntry(stat_entry, timestamp)

            for timestamp, hash_entry in iteritems(
                    client_path_history.hash_entries):
                path_record = self._GetPathRecord(client_path.client_id,
                                                  path_info,
                                                  set_default=False)
                if path_record is None:
                    # TODO(hanuszczak): Provide more details about paths that caused that.
                    raise db.AtLeastOneUnknownPathError([])

                path_record.AddHashEntry(hash_entry, timestamp)
예제 #2
0
파일: mem_blobs.py 프로젝트: hfakar/grr
    def WriteClientPathBlobReferences(self, references_by_client_path_id):
        """Writes blob references for given client path ids."""
        all_path_ids = self._AllPathIDs()

        for client_path_id, blob_refs in references_by_client_path_id.items():
            path_idx = (client_path_id.client_id, client_path_id.path_type,
                        client_path_id.path_id)

            if path_idx not in all_path_ids:
                raise db.AtLeastOneUnknownPathError(
                    itervalues(references_by_client_path_id))

            blob_record = self.blob_records.setdefault(path_idx, _BlobRecord())

            for blob_ref in blob_refs:
                blob_record.AddBlobReference(blob_ref)