Ejemplo n.º 1
0
 def testDownloadHuntResultCollection(self):
     """Check we can download files references in HuntResultCollection."""
     # Create a collection with URNs to some files.
     fd = results.HuntResultCollection(self.collection_urn,
                                       token=self.token)
     with data_store.DB.GetMutationPool(token=self.token) as pool:
         fd.AddAsMessage(rdfvalue.RDFURN(self.out.Add("testfile1")),
                         self.client_id,
                         mutation_pool=pool)
         fd.AddAsMessage(rdf_client.StatEntry(
             pathspec=rdf_paths.PathSpec(path="testfile2", pathtype="OS")),
                         self.client_id,
                         mutation_pool=pool)
         fd.AddAsMessage(rdf_file_finder.FileFinderResult(
             stat_entry=rdf_client.StatEntry(pathspec=rdf_paths.PathSpec(
                 path="testfile5", pathtype="OS"))),
                         self.client_id,
                         mutation_pool=pool)
         fd.AddAsMessage(collectors.ArtifactFilesDownloaderResult(
             downloaded_file=rdf_client.StatEntry(
                 pathspec=rdf_paths.PathSpec(path="testfile6",
                                             pathtype="OS"))),
                         self.client_id,
                         mutation_pool=pool)
     self._VerifyDownload()
Ejemplo n.º 2
0
 def _AddTestData(self, fd):
     with data_store.DB.GetMutationPool(token=self.token) as pool:
         fd.Add(rdfvalue.RDFURN(self.out.Add("testfile1")),
                mutation_pool=pool)
         fd.Add(rdf_client.StatEntry(
             pathspec=rdf_paths.PathSpec(path="testfile2", pathtype="OS")),
                mutation_pool=pool)
         fd.Add(rdf_file_finder.FileFinderResult(
             stat_entry=rdf_client.StatEntry(pathspec=rdf_paths.PathSpec(
                 path="testfile5", pathtype="OS"))),
                mutation_pool=pool)
         fd.Add(collectors.ArtifactFilesDownloaderResult(
             downloaded_file=rdf_client.StatEntry(
                 pathspec=rdf_paths.PathSpec(path="testfile6",
                                             pathtype="OS"))),
                mutation_pool=pool)
Ejemplo n.º 3
0
    def testDownloadCollectionIgnoresArtifactResultsWithoutFiles(self):
        # Create a collection with URNs to some files.
        fd = sequential_collection.GeneralIndexedCollection(
            self.collection_urn, token=self.token)
        with data_store.DB.GetMutationPool(token=self.token) as pool:
            fd.Add(collectors.ArtifactFilesDownloaderResult(),
                   mutation_pool=pool)

        with utils.TempDirectory() as tmpdir:
            export_utils.DownloadCollection(self.collection_urn,
                                            tmpdir,
                                            overwrite=True,
                                            dump_client_info=True,
                                            token=self.token,
                                            max_threads=2)
            expected_outdir = os.path.join(tmpdir, self.out.Path()[1:])
            self.assertFalse(os.path.exists(expected_outdir))
Ejemplo n.º 4
0
    def testShowsGenerateArchiveButtonForArtifactDownloaderHunt(self):
        stat_entry = rdf_client.StatEntry(pathspec=rdf_paths.PathSpec(
            path="/foo/bar", pathtype=rdf_paths.PathSpec.PathType.OS))
        values = [
            collectors.ArtifactFilesDownloaderResult(
                downloaded_file=stat_entry)
        ]

        self.CreateGenericHuntWithCollection(values=values)

        self.Open("/")
        self.Click("css=a[grrtarget=hunts]")
        self.Click("css=td:contains('GenericHunt')")
        self.Click("css=li[heading=Results]")

        self.WaitUntil(
            self.IsTextPresent,
            "Files referenced in this collection can be downloaded")
Ejemplo n.º 5
0
    def testShowsPerFileDownloadButtonForArtifactDownloaderHunt(self):
        stat_entry = rdf_client.StatEntry(pathspec=rdf_paths.PathSpec(
            path="/foo/bar", pathtype=rdf_paths.PathSpec.PathType.OS))
        values = [
            collectors.ArtifactFilesDownloaderResult(
                downloaded_file=stat_entry)
        ]

        self.CreateGenericHuntWithCollection(values=values)

        self.Open("/")
        self.Click("css=a[grrtarget=hunts]")
        self.Click("css=td:contains('GenericHunt')")
        self.Click("css=li[heading=Results]")

        self.WaitUntil(
            self.IsElementPresent,
            "css=grr-results-collection button:has(span.glyphicon-download)")