results = self.RunFlow(client_id) self.assertEquals(len(results), 1) self.assertEquals( results[0].found_pathspec, rdf_paths.PathSpec(path="C:\\Windows\\bar.exe", pathtype="OS")) self.assertFalse(results[0].HasField("downloaded_file")) def testIncludesDownloadedFilesIntoReplyIfFetchSucceeds(self): client_id = self.SetupClient(0) self.collector_replies = [ self.MakeRegistryStatEntry(u"HKEY_LOCAL_MACHINE\\SOFTWARE\\foo", u"C:\\Windows\\bar.exe") ] self.received_files = [self.MakeFileStatEntry("C:\\Windows\\bar.exe")] results = self.RunFlow(client_id) self.assertEquals(len(results), 1) self.assertEquals(results[0].downloaded_file, self.received_files[0]) def main(argv): # Run the full test suite test_lib.main(argv) if __name__ == "__main__": flags.StartMain(main)
def AdminUI(): from grr_response_server.gui import admin_ui SetConfigOptions() flags.StartMain(admin_ui.main)
from grr_response_core.lib import flags from grr_response_server.gui import gui_test_lib from grr.test_lib import test_lib class JavascriptErrorTest(gui_test_lib.GRRSeleniumTest): """Tests that Javascript errors are caught in Selenium tests.""" def testJavascriptErrorTriggersPythonExcpetion(self): self.Open("/") # Erase global Angular object. # Things are guaranteed to stop working correctly after this. self.GetJavaScriptValue("window.angular = undefined;") self.Click("client_query_submit") with self.assertRaisesRegexp(self.failureException, "Javascript error encountered"): self.WaitUntil(self.IsElementPresent, "css=grr-clients-list") # The page has some tickers running that also use Angular so there # is a race that they can cause more js errors after the test has # already finished. By navigating to the main page, we make sure # the Angular object is valid again which means no more errors and # also clear the list of recorded errors in case there have been # any in the meantime. self.Open("/") if __name__ == "__main__": flags.StartMain(test_lib.main)
def Worker(): from grr_response_server.bin import worker SetConfigOptions() flags.StartMain(worker.main)
def GRRFuse(): from grr_response_server.bin import fuse_mount SetConfigOptions() flags.StartMain(fuse_mount.main)
def GrrServer(): from grr_response_server.bin import grr_server SetConfigOptions() flags.StartMain(grr_server.main)
def GrrFrontend(): from grr_response_server.bin import frontend SetConfigOptions() flags.StartMain(frontend.main)
def ApiShellRawAccess(): from grr_response_server.bin import api_shell_raw_access SetConfigOptions() flags.StartMain(api_shell_raw_access.main)
def ConfigUpdater(): from grr_response_server.bin import config_updater SetConfigOptions() flags.StartMain(config_updater.main)
def DistEntry(): """The main entry point for packages.""" flags.StartMain(main)
def Console(): from grr_response_server.bin import console SetConfigOptions() flags.StartMain(console.main)
def PoolClient(): from grr_response_client import poolclient SetConfigOptions() flags.StartMain(poolclient.main)
def FleetspeakClient(): from grr_response_client import grr_fs_client SetConfigOptions() flags.StartMain(grr_fs_client.main)
def Client(): from grr_response_client import client SetConfigOptions() flags.StartMain(client.main)
def ClientBuild(): from grr_response_client import client_build SetConfigOptions() flags.StartMain(client_build.main)
installer.RunInstaller() errors = config.CONFIG.Validate(["Client", "CA", "Logging"]) if errors and list(iterkeys(errors)) != ["Client.private_key"]: raise config_lib.ConfigFormatError(errors) if config.CONFIG["Client.fleetspeak_enabled"]: raise ValueError( "This is not a Fleetspeak client, yet 'Client.fleetspeak_enabled' is " "set to 'True'.") enrollment_necessary = not config.CONFIG.Get("Client.private_key") # Instantiating the client will create a private_key so we need to use a flag. client = comms.GRRHTTPClient(ca_cert=config.CONFIG["CA.certificate"], private_key=config.CONFIG.Get( "Client.private_key", default=None)) if enrollment_necessary: logging.info("No private key found, starting enrollment.") client.InitiateEnrolment() if flags.FLAGS.break_on_start: pdb.set_trace() else: client.Run() if __name__ == "__main__": flags.StartMain(main, requires_root=True)