def testCopyingFlowWithRawBytesWithNonAsciiCharsInArgumentsWorks(self): args = rdf_file_finder.FileFinderArgs( paths=["a/b/*"], upload_token=rdf_client.UploadToken( # Encrypted policy is defined simply as "bytes" in its proto # definition. We make sure to assign ascii-incompatible value # to it here. encrypted_policy="\xde\xad\xbe\xef")) flow.GRRFlow.StartFlow(flow_name=flows_file_finder.FileFinder.__name__, args=args, client_id=self.client_id, token=self.token) # Navigate to client and select newly created flow. self.Open("/#/clients/C.0000000000000001/flows") self.Click("css=td:contains('FileFinder')") # Open wizard and launch the copy flow. self.Click("css=button[name=copy_flow]") self.Click("css=button:contains('Launch')") # Check that flows list got updated and that the new flow is selected. self.WaitUntil( self.IsElementPresent, "css=grr-client-flows-list tr:contains('FileFinder'):nth(1)") self.WaitUntil( self.IsElementPresent, "css=grr-client-flows-list " "tr:contains('FileFinder'):nth(0).row-selected")
def Start(self): for pathspec in self.args.pathspecs: # The AFF4 path under the client's namespace where we store the file. filename = pathspec.AFF4Path(self.client_id).RelativeName( self.client_id) policy = rdf_client.UploadPolicy( client_id=self.client_id, expires=rdfvalue.RDFDatetime.Now() + rdfvalue.Duration("7d")) upload_token = rdf_client.UploadToken() upload_token.SetPolicy(policy) upload_token.GenerateHMAC() self.CallClient(server_stubs.UploadFile, pathspec=pathspec, upload_token=upload_token, next_state="ProcessFileUpload", request_data=dict(path=filename))
def Start(self): """Issue the find request.""" super(ClientFileFinder, self).Start() if self.args.pathtype != "OS": raise ValueError("Only supported pathtype is OS.") action = self.args.action if action.action_type == "DOWNLOAD": policy = rdf_client.UploadPolicy( client_id=self.client_id, expires=rdfvalue.RDFDatetime.Now() + rdfvalue.Duration("7d")) upload_token = rdf_client.UploadToken() upload_token.SetPolicy(policy) upload_token.GenerateHMAC() self.args.upload_token = upload_token self.CallClient( server_stubs.FileFinderOS, request=self.args, next_state="StoreResults")