partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
CreateClientPool
Create n clients to run in a pool.
grr/client/grr_response_client/poolclient.py
def CreateClientPool(n): """Create n clients to run in a pool.""" clients = [] # Load previously stored clients. try: certificates = [] with open(flags.FLAGS.cert_file, "rb") as fd: # Certificates are base64-encoded, so that we can use new-lines as # separators. for l in fd: c...
def CreateClientPool(n): """Create n clients to run in a pool.""" clients = [] # Load previously stored clients. try: certificates = [] with open(flags.FLAGS.cert_file, "rb") as fd: # Certificates are base64-encoded, so that we can use new-lines as # separators. for l in fd: c...
[ "Create", "n", "clients", "to", "run", "in", "a", "pool", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/poolclient.py#L90-L176
[ "def", "CreateClientPool", "(", "n", ")", ":", "clients", "=", "[", "]", "# Load previously stored clients.", "try", ":", "certificates", "=", "[", "]", "with", "open", "(", "flags", ".", "FLAGS", ".", "cert_file", ",", "\"rb\"", ")", "as", "fd", ":", "#...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CheckLocation
Checks that the poolclient is not accidentally ran against production.
grr/client/grr_response_client/poolclient.py
def CheckLocation(): """Checks that the poolclient is not accidentally ran against production.""" for url in (config.CONFIG["Client.server_urls"] + config.CONFIG["Client.control_urls"]): if "staging" in url or "localhost" in url: # This is ok. return logging.error("Poolclient should ...
def CheckLocation(): """Checks that the poolclient is not accidentally ran against production.""" for url in (config.CONFIG["Client.server_urls"] + config.CONFIG["Client.control_urls"]): if "staging" in url or "localhost" in url: # This is ok. return logging.error("Poolclient should ...
[ "Checks", "that", "the", "poolclient", "is", "not", "accidentally", "ran", "against", "production", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/poolclient.py#L179-L187
[ "def", "CheckLocation", "(", ")", ":", "for", "url", "in", "(", "config", ".", "CONFIG", "[", "\"Client.server_urls\"", "]", "+", "config", ".", "CONFIG", "[", "\"Client.control_urls\"", "]", ")", ":", "if", "\"staging\"", "in", "url", "or", "\"localhost\"",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRWorker.Run
Event loop.
grr/server/grr_response_server/worker_lib.py
def Run(self): """Event loop.""" if data_store.RelationalDBEnabled(): data_store.REL_DB.RegisterMessageHandler( self._ProcessMessageHandlerRequests, self.well_known_flow_lease_time, limit=100) data_store.REL_DB.RegisterFlowProcessingHandler(self.ProcessFlow) try: ...
def Run(self): """Event loop.""" if data_store.RelationalDBEnabled(): data_store.REL_DB.RegisterMessageHandler( self._ProcessMessageHandlerRequests, self.well_known_flow_lease_time, limit=100) data_store.REL_DB.RegisterFlowProcessingHandler(self.ProcessFlow) try: ...
[ "Event", "loop", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/worker_lib.py#L111-L134
[ "def", "Run", "(", "self", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "data_store", ".", "REL_DB", ".", "RegisterMessageHandler", "(", "self", ".", "_ProcessMessageHandlerRequests", ",", "self", ".", "well_known_flow_lease_time", ",",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRWorker._ProcessMessageHandlerRequests
Processes message handler requests.
grr/server/grr_response_server/worker_lib.py
def _ProcessMessageHandlerRequests(self, requests): """Processes message handler requests.""" logging.debug("Leased message handler request ids: %s", ",".join(str(r.request_id) for r in requests)) grouped_requests = collection.Group(requests, lambda r: r.handler_name) for handler_name,...
def _ProcessMessageHandlerRequests(self, requests): """Processes message handler requests.""" logging.debug("Leased message handler request ids: %s", ",".join(str(r.request_id) for r in requests)) grouped_requests = collection.Group(requests, lambda r: r.handler_name) for handler_name,...
[ "Processes", "message", "handler", "requests", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/worker_lib.py#L136-L160
[ "def", "_ProcessMessageHandlerRequests", "(", "self", ",", "requests", ")", ":", "logging", ".", "debug", "(", "\"Leased message handler request ids: %s\"", ",", "\",\"", ".", "join", "(", "str", "(", "r", ".", "request_id", ")", "for", "r", "in", "requests", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRWorker.RunOnce
Processes one set of messages from Task Scheduler. The worker processes new jobs from the task master. For each job we retrieve the session from the Task Scheduler. Returns: Total number of messages processed by this call.
grr/server/grr_response_server/worker_lib.py
def RunOnce(self): """Processes one set of messages from Task Scheduler. The worker processes new jobs from the task master. For each job we retrieve the session from the Task Scheduler. Returns: Total number of messages processed by this call. """ start_time = time.time() processe...
def RunOnce(self): """Processes one set of messages from Task Scheduler. The worker processes new jobs from the task master. For each job we retrieve the session from the Task Scheduler. Returns: Total number of messages processed by this call. """ start_time = time.time() processe...
[ "Processes", "one", "set", "of", "messages", "from", "Task", "Scheduler", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/worker_lib.py#L162-L227
[ "def", "RunOnce", "(", "self", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "processed", "=", "0", "queue_manager", "=", "queue_manager_lib", ".", "QueueManager", "(", "token", "=", "self", ".", "token", ")", "for", "queue", "in", "self", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRWorker.ProcessMessages
Processes all the flows in the messages. Precondition: All tasks come from the same queue. Note that the server actually completes the requests in the flow when receiving the messages from the client. We do not really look at the messages here at all any more - we just work from the completed mess...
grr/server/grr_response_server/worker_lib.py
def ProcessMessages(self, active_notifications, queue_manager, time_limit=0): """Processes all the flows in the messages. Precondition: All tasks come from the same queue. Note that the server actually completes the requests in the flow when receiving the messages from the client. We do not really ...
def ProcessMessages(self, active_notifications, queue_manager, time_limit=0): """Processes all the flows in the messages. Precondition: All tasks come from the same queue. Note that the server actually completes the requests in the flow when receiving the messages from the client. We do not really ...
[ "Processes", "all", "the", "flows", "in", "the", "messages", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/worker_lib.py#L247-L280
[ "def", "ProcessMessages", "(", "self", ",", "active_notifications", ",", "queue_manager", ",", "time_limit", "=", "0", ")", ":", "now", "=", "time", ".", "time", "(", ")", "processed", "=", "0", "for", "notification", "in", "active_notifications", ":", "if",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRWorker._ProcessRegularFlowMessages
Processes messages for a given flow.
grr/server/grr_response_server/worker_lib.py
def _ProcessRegularFlowMessages(self, flow_obj, notification): """Processes messages for a given flow.""" session_id = notification.session_id if not isinstance(flow_obj, flow.FlowBase): logging.warning("%s is not a proper flow object (got %s)", session_id, type(flow_obj)) ...
def _ProcessRegularFlowMessages(self, flow_obj, notification): """Processes messages for a given flow.""" session_id = notification.session_id if not isinstance(flow_obj, flow.FlowBase): logging.warning("%s is not a proper flow object (got %s)", session_id, type(flow_obj)) ...
[ "Processes", "messages", "for", "a", "given", "flow", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/worker_lib.py#L282-L301
[ "def", "_ProcessRegularFlowMessages", "(", "self", ",", "flow_obj", ",", "notification", ")", ":", "session_id", "=", "notification", ".", "session_id", "if", "not", "isinstance", "(", "flow_obj", ",", "flow", ".", "FlowBase", ")", ":", "logging", ".", "warnin...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRWorker._ProcessMessages
Does the real work with a single flow.
grr/server/grr_response_server/worker_lib.py
def _ProcessMessages(self, notification, queue_manager): """Does the real work with a single flow.""" flow_obj = None session_id = notification.session_id try: # Take a lease on the flow: flow_name = session_id.FlowName() if flow_name in self.well_known_flows: # Well known flo...
def _ProcessMessages(self, notification, queue_manager): """Does the real work with a single flow.""" flow_obj = None session_id = notification.session_id try: # Take a lease on the flow: flow_name = session_id.FlowName() if flow_name in self.well_known_flows: # Well known flo...
[ "Does", "the", "real", "work", "with", "a", "single", "flow", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/worker_lib.py#L303-L383
[ "def", "_ProcessMessages", "(", "self", ",", "notification", ",", "queue_manager", ")", ":", "flow_obj", "=", "None", "session_id", "=", "notification", ".", "session_id", "try", ":", "# Take a lease on the flow:", "flow_name", "=", "session_id", ".", "FlowName", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRWorker.ProcessFlow
The callback for the flow processing queue.
grr/server/grr_response_server/worker_lib.py
def ProcessFlow(self, flow_processing_request): """The callback for the flow processing queue.""" client_id = flow_processing_request.client_id flow_id = flow_processing_request.flow_id data_store.REL_DB.AckFlowProcessingRequests([flow_processing_request]) try: rdf_flow = data_store.REL_DB....
def ProcessFlow(self, flow_processing_request): """The callback for the flow processing queue.""" client_id = flow_processing_request.client_id flow_id = flow_processing_request.flow_id data_store.REL_DB.AckFlowProcessingRequests([flow_processing_request]) try: rdf_flow = data_store.REL_DB....
[ "The", "callback", "for", "the", "flow", "processing", "queue", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/worker_lib.py#L396-L434
[ "def", "ProcessFlow", "(", "self", ",", "flow_processing_request", ")", ":", "client_id", "=", "flow_processing_request", ".", "client_id", "flow_id", "=", "flow_processing_request", ".", "flow_id", "data_store", ".", "REL_DB", ".", "AckFlowProcessingRequests", "(", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FileOperation.WaitUntilDone
Wait until the operation is done. Args: timeout: timeout in seconds. None means default timeout (1 hour). 0 means no timeout (wait forever). Returns: Operation object with refreshed target_file. Raises: PollTimeoutError: if timeout is reached.
api_client/python/grr_api_client/vfs.py
def WaitUntilDone(self, timeout=None): """Wait until the operation is done. Args: timeout: timeout in seconds. None means default timeout (1 hour). 0 means no timeout (wait forever). Returns: Operation object with refreshed target_file. Raises: PollTimeoutError: if time...
def WaitUntilDone(self, timeout=None): """Wait until the operation is done. Args: timeout: timeout in seconds. None means default timeout (1 hour). 0 means no timeout (wait forever). Returns: Operation object with refreshed target_file. Raises: PollTimeoutError: if time...
[ "Wait", "until", "the", "operation", "is", "done", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/vfs.py#L45-L62
[ "def", "WaitUntilDone", "(", "self", ",", "timeout", "=", "None", ")", ":", "utils", ".", "Poll", "(", "generator", "=", "self", ".", "GetState", ",", "condition", "=", "lambda", "s", ":", "s", "!=", "self", ".", "__class__", ".", "STATE_RUNNING", ",",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FileBase.Get
Fetch file's data and return proper File object.
api_client/python/grr_api_client/vfs.py
def Get(self): """Fetch file's data and return proper File object.""" args = vfs_pb2.ApiGetFileDetailsArgs( client_id=self.client_id, file_path=self.path) data = self._context.SendRequest("GetFileDetails", args).file return File(client_id=self.client_id, data=data, context=self._context)
def Get(self): """Fetch file's data and return proper File object.""" args = vfs_pb2.ApiGetFileDetailsArgs( client_id=self.client_id, file_path=self.path) data = self._context.SendRequest("GetFileDetails", args).file return File(client_id=self.client_id, data=data, context=self._context)
[ "Fetch", "file", "s", "data", "and", "return", "proper", "File", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/vfs.py#L165-L171
[ "def", "Get", "(", "self", ")", ":", "args", "=", "vfs_pb2", ".", "ApiGetFileDetailsArgs", "(", "client_id", "=", "self", ".", "client_id", ",", "file_path", "=", "self", ".", "path", ")", "data", "=", "self", ".", "_context", ".", "SendRequest", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetOutputPluginIndex
Gets an output plugin index for a plugin with a given id. Historically output plugins descriptors were stored in dicts-like structures with unique identifiers as keys. In REL_DB-based implementation, however, both plugin descriptors and their states are stored in flat lists (see Flow definition in flows.proto)...
grr/server/grr_response_server/gui/api_plugins/flow.py
def GetOutputPluginIndex( plugin_descriptors, plugin_id): """Gets an output plugin index for a plugin with a given id. Historically output plugins descriptors were stored in dicts-like structures with unique identifiers as keys. In REL_DB-based implementation, however, both plugin descriptors and their...
def GetOutputPluginIndex( plugin_descriptors, plugin_id): """Gets an output plugin index for a plugin with a given id. Historically output plugins descriptors were stored in dicts-like structures with unique identifiers as keys. In REL_DB-based implementation, however, both plugin descriptors and their...
[ "Gets", "an", "output", "plugin", "index", "for", "a", "plugin", "with", "a", "given", "id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/flow.py#L936-L975
[ "def", "GetOutputPluginIndex", "(", "plugin_descriptors", ",", "plugin_id", ")", ":", "used_names", "=", "collections", ".", "Counter", "(", ")", "for", "(", "index", ",", "desc", ")", "in", "enumerate", "(", "plugin_descriptors", ")", ":", "cur_plugin_id", "=...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiFlowId.ResolveCronJobFlowURN
Resolve a URN of a flow with this id belonging to a given cron job.
grr/server/grr_response_server/gui/api_plugins/flow.py
def ResolveCronJobFlowURN(self, cron_job_id): """Resolve a URN of a flow with this id belonging to a given cron job.""" if not self._value: raise ValueError("Can't call ResolveCronJobFlowURN on an empty " "client id.") return cron_job_id.ToURN().Add(self._value)
def ResolveCronJobFlowURN(self, cron_job_id): """Resolve a URN of a flow with this id belonging to a given cron job.""" if not self._value: raise ValueError("Can't call ResolveCronJobFlowURN on an empty " "client id.") return cron_job_id.ToURN().Add(self._value)
[ "Resolve", "a", "URN", "of", "a", "flow", "with", "this", "id", "belonging", "to", "a", "given", "cron", "job", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/flow.py#L79-L85
[ "def", "ResolveCronJobFlowURN", "(", "self", ",", "cron_job_id", ")", ":", "if", "not", "self", ".", "_value", ":", "raise", "ValueError", "(", "\"Can't call ResolveCronJobFlowURN on an empty \"", "\"client id.\"", ")", "return", "cron_job_id", ".", "ToURN", "(", ")...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiFlowId.ResolveClientFlowURN
Resolve a URN of a flow with this id belonging to a given client. Note that this may need a roundtrip to the datastore. Resolving algorithm is the following: 1. If the flow id doesn't contain slashes (flow is not nested), we just append it to the <client id>/flows. 2. If the flow id has slash...
grr/server/grr_response_server/gui/api_plugins/flow.py
def ResolveClientFlowURN(self, client_id, token=None): """Resolve a URN of a flow with this id belonging to a given client. Note that this may need a roundtrip to the datastore. Resolving algorithm is the following: 1. If the flow id doesn't contain slashes (flow is not nested), we just append...
def ResolveClientFlowURN(self, client_id, token=None): """Resolve a URN of a flow with this id belonging to a given client. Note that this may need a roundtrip to the datastore. Resolving algorithm is the following: 1. If the flow id doesn't contain slashes (flow is not nested), we just append...
[ "Resolve", "a", "URN", "of", "a", "flow", "with", "this", "id", "belonging", "to", "a", "given", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/flow.py#L87-L128
[ "def", "ResolveClientFlowURN", "(", "self", ",", "client_id", ",", "token", "=", "None", ")", ":", "if", "not", "self", ".", "_value", ":", "raise", "ValueError", "(", "\"Can't call ResolveClientFlowURN on an empty client id.\"", ")", "components", "=", "self", "....
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiFlowDescriptor._GetArgsDescription
Get a simplified description of the args_type for a flow.
grr/server/grr_response_server/gui/api_plugins/flow.py
def _GetArgsDescription(self, args_type): """Get a simplified description of the args_type for a flow.""" args = {} if args_type: for type_descriptor in args_type.type_infos: if not type_descriptor.hidden: args[type_descriptor.name] = { "description": type_descriptor.de...
def _GetArgsDescription(self, args_type): """Get a simplified description of the args_type for a flow.""" args = {} if args_type: for type_descriptor in args_type.type_infos: if not type_descriptor.hidden: args[type_descriptor.name] = { "description": type_descriptor.de...
[ "Get", "a", "simplified", "description", "of", "the", "args_type", "for", "a", "flow", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/flow.py#L145-L158
[ "def", "_GetArgsDescription", "(", "self", ",", "args_type", ")", ":", "args", "=", "{", "}", "if", "args_type", ":", "for", "type_descriptor", "in", "args_type", ".", "type_infos", ":", "if", "not", "type_descriptor", ".", "hidden", ":", "args", "[", "typ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiFlowDescriptor._GetCallingPrototypeAsString
Get a description of the calling prototype for this flow class.
grr/server/grr_response_server/gui/api_plugins/flow.py
def _GetCallingPrototypeAsString(self, flow_cls): """Get a description of the calling prototype for this flow class.""" output = [] output.append("flow.StartAFF4Flow(client_id=client_id, ") output.append("flow_name=\"%s\", " % flow_cls.__name__) prototypes = [] if flow_cls.args_type: for t...
def _GetCallingPrototypeAsString(self, flow_cls): """Get a description of the calling prototype for this flow class.""" output = [] output.append("flow.StartAFF4Flow(client_id=client_id, ") output.append("flow_name=\"%s\", " % flow_cls.__name__) prototypes = [] if flow_cls.args_type: for t...
[ "Get", "a", "description", "of", "the", "calling", "prototype", "for", "this", "flow", "class", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/flow.py#L160-L173
[ "def", "_GetCallingPrototypeAsString", "(", "self", ",", "flow_cls", ")", ":", "output", "=", "[", "]", "output", ".", "append", "(", "\"flow.StartAFF4Flow(client_id=client_id, \"", ")", "output", ".", "append", "(", "\"flow_name=\\\"%s\\\", \"", "%", "flow_cls", "....
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiFlowDescriptor._GetFlowArgsHelpAsString
Get a string description of the calling prototype for this flow.
grr/server/grr_response_server/gui/api_plugins/flow.py
def _GetFlowArgsHelpAsString(self, flow_cls): """Get a string description of the calling prototype for this flow.""" output = [ " Call Spec:", " %s" % self._GetCallingPrototypeAsString(flow_cls), "" ] arg_list = sorted( iteritems(self._GetArgsDescription(flow_cls.args_type)),...
def _GetFlowArgsHelpAsString(self, flow_cls): """Get a string description of the calling prototype for this flow.""" output = [ " Call Spec:", " %s" % self._GetCallingPrototypeAsString(flow_cls), "" ] arg_list = sorted( iteritems(self._GetArgsDescription(flow_cls.args_type)),...
[ "Get", "a", "string", "description", "of", "the", "calling", "prototype", "for", "this", "flow", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/flow.py#L175-L194
[ "def", "_GetFlowArgsHelpAsString", "(", "self", ",", "flow_cls", ")", ":", "output", "=", "[", "\" Call Spec:\"", ",", "\" %s\"", "%", "self", ".", "_GetCallingPrototypeAsString", "(", "flow_cls", ")", ",", "\"\"", "]", "arg_list", "=", "sorted", "(", "ite...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiListFlowDescriptorsHandler.Handle
Renders list of descriptors for all the flows.
grr/server/grr_response_server/gui/api_plugins/flow.py
def Handle(self, args, token=None): """Renders list of descriptors for all the flows.""" if data_store.RelationalDBEnabled(): flow_iterator = iteritems(registry.FlowRegistry.FLOW_REGISTRY) else: flow_iterator = iteritems(registry.AFF4FlowRegistry.FLOW_REGISTRY) result = [] for name, cl...
def Handle(self, args, token=None): """Renders list of descriptors for all the flows.""" if data_store.RelationalDBEnabled(): flow_iterator = iteritems(registry.FlowRegistry.FLOW_REGISTRY) else: flow_iterator = iteritems(registry.AFF4FlowRegistry.FLOW_REGISTRY) result = [] for name, cl...
[ "Renders", "list", "of", "descriptors", "for", "all", "the", "flows", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/flow.py#L1366-L1390
[ "def", "Handle", "(", "self", ",", "args", ",", "token", "=", "None", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "flow_iterator", "=", "iteritems", "(", "registry", ".", "FlowRegistry", ".", "FLOW_REGISTRY", ")", "else", ":", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AuthorizationManager.AuthorizeUser
Allow given user access to a given subject.
grr/server/grr_response_server/authorization/auth_manager.py
def AuthorizeUser(self, user, subject): """Allow given user access to a given subject.""" user_set = self.authorized_users.setdefault(subject, set()) user_set.add(user)
def AuthorizeUser(self, user, subject): """Allow given user access to a given subject.""" user_set = self.authorized_users.setdefault(subject, set()) user_set.add(user)
[ "Allow", "given", "user", "access", "to", "a", "given", "subject", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/authorization/auth_manager.py#L88-L92
[ "def", "AuthorizeUser", "(", "self", ",", "user", ",", "subject", ")", ":", "user_set", "=", "self", ".", "authorized_users", ".", "setdefault", "(", "subject", ",", "set", "(", ")", ")", "user_set", ".", "add", "(", "user", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AuthorizationManager.AuthorizeGroup
Allow given group access to a given subject.
grr/server/grr_response_server/authorization/auth_manager.py
def AuthorizeGroup(self, group, subject): """Allow given group access to a given subject.""" # Add the subject to the dict if is isn't present, so it will get checked in # CheckPermissions self.authorized_users.setdefault(subject, set()) self.group_access_manager.AuthorizeGroup(group, subject)
def AuthorizeGroup(self, group, subject): """Allow given group access to a given subject.""" # Add the subject to the dict if is isn't present, so it will get checked in # CheckPermissions self.authorized_users.setdefault(subject, set()) self.group_access_manager.AuthorizeGroup(group, subject)
[ "Allow", "given", "group", "access", "to", "a", "given", "subject", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/authorization/auth_manager.py#L94-L100
[ "def", "AuthorizeGroup", "(", "self", ",", "group", ",", "subject", ")", ":", "# Add the subject to the dict if is isn't present, so it will get checked in", "# CheckPermissions", "self", ".", "authorized_users", ".", "setdefault", "(", "subject", ",", "set", "(", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AuthorizationManager.CheckPermissions
Checks if a given user has access to a given subject.
grr/server/grr_response_server/authorization/auth_manager.py
def CheckPermissions(self, username, subject): """Checks if a given user has access to a given subject.""" if subject in self.authorized_users: return ((username in self.authorized_users[subject]) or self.group_access_manager.MemberOfAuthorizedGroup( username, subject)) ...
def CheckPermissions(self, username, subject): """Checks if a given user has access to a given subject.""" if subject in self.authorized_users: return ((username in self.authorized_users[subject]) or self.group_access_manager.MemberOfAuthorizedGroup( username, subject)) ...
[ "Checks", "if", "a", "given", "user", "has", "access", "to", "a", "given", "subject", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/authorization/auth_manager.py#L107-L118
[ "def", "CheckPermissions", "(", "self", ",", "username", ",", "subject", ")", ":", "if", "subject", "in", "self", ".", "authorized_users", ":", "return", "(", "(", "username", "in", "self", ".", "authorized_users", "[", "subject", "]", ")", "or", "self", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WindowsPersistenceMechanismsParser._GetFilePaths
Guess windows filenames from a commandline string.
grr/core/grr_response_core/lib/parsers/windows_persistence.py
def _GetFilePaths(self, path, pathtype, kb): """Guess windows filenames from a commandline string.""" environ_vars = artifact_utils.GetWindowsEnvironmentVariablesMap(kb) path_guesses = path_detection_windows.DetectExecutablePaths([path], envir...
def _GetFilePaths(self, path, pathtype, kb): """Guess windows filenames from a commandline string.""" environ_vars = artifact_utils.GetWindowsEnvironmentVariablesMap(kb) path_guesses = path_detection_windows.DetectExecutablePaths([path], envir...
[ "Guess", "windows", "filenames", "from", "a", "commandline", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/windows_persistence.py#L24-L38
[ "def", "_GetFilePaths", "(", "self", ",", "path", ",", "pathtype", ",", "kb", ")", ":", "environ_vars", "=", "artifact_utils", ".", "GetWindowsEnvironmentVariablesMap", "(", "kb", ")", "path_guesses", "=", "path_detection_windows", ".", "DetectExecutablePaths", "(",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WindowsPersistenceMechanismsParser.Parse
Convert persistence collector output to downloadable rdfvalues.
grr/core/grr_response_core/lib/parsers/windows_persistence.py
def Parse(self, persistence, knowledge_base, download_pathtype): """Convert persistence collector output to downloadable rdfvalues.""" pathspecs = [] if isinstance(persistence, rdf_client.WindowsServiceInformation): if persistence.HasField("binary"): pathspecs.append(persistence.binary.pathsp...
def Parse(self, persistence, knowledge_base, download_pathtype): """Convert persistence collector output to downloadable rdfvalues.""" pathspecs = [] if isinstance(persistence, rdf_client.WindowsServiceInformation): if persistence.HasField("binary"): pathspecs.append(persistence.binary.pathsp...
[ "Convert", "persistence", "collector", "output", "to", "downloadable", "rdfvalues", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/windows_persistence.py#L40-L58
[ "def", "Parse", "(", "self", ",", "persistence", ",", "knowledge_base", ",", "download_pathtype", ")", ":", "pathspecs", "=", "[", "]", "if", "isinstance", "(", "persistence", ",", "rdf_client", ".", "WindowsServiceInformation", ")", ":", "if", "persistence", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
File.FileHacks
Hacks to make the filesystem look normal.
grr/client/grr_response_client/vfs_handlers/files.py
def FileHacks(self): """Hacks to make the filesystem look normal.""" if sys.platform == "win32": import win32api # pylint: disable=g-import-not-at-top # Make the filesystem look like the topmost level are the drive letters. if self.path == "/": self.files = win32api.GetLogicalDriveSt...
def FileHacks(self): """Hacks to make the filesystem look normal.""" if sys.platform == "win32": import win32api # pylint: disable=g-import-not-at-top # Make the filesystem look like the topmost level are the drive letters. if self.path == "/": self.files = win32api.GetLogicalDriveSt...
[ "Hacks", "to", "make", "the", "filesystem", "look", "normal", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/files.py#L163-L197
[ "def", "FileHacks", "(", "self", ")", ":", "if", "sys", ".", "platform", "==", "\"win32\"", ":", "import", "win32api", "# pylint: disable=g-import-not-at-top", "# Make the filesystem look like the topmost level are the drive letters.", "if", "self", ".", "path", "==", "\"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
File.Read
Read from the file.
grr/client/grr_response_client/vfs_handlers/files.py
def Read(self, length=None): """Read from the file.""" if self.progress_callback: self.progress_callback() available_to_read = max(0, (self.size or 0) - self.offset) if length is None: to_read = available_to_read else: to_read = min(length, available_to_read) with FileHandle...
def Read(self, length=None): """Read from the file.""" if self.progress_callback: self.progress_callback() available_to_read = max(0, (self.size or 0) - self.offset) if length is None: to_read = available_to_read else: to_read = min(length, available_to_read) with FileHandle...
[ "Read", "from", "the", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/files.py#L214-L238
[ "def", "Read", "(", "self", ",", "length", "=", "None", ")", ":", "if", "self", ".", "progress_callback", ":", "self", ".", "progress_callback", "(", ")", "available_to_read", "=", "max", "(", "0", ",", "(", "self", ".", "size", "or", "0", ")", "-", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
File._Stat
Returns stat information of a specific path. Args: path: A unicode string containing the path. ext_attrs: Whether the call should also collect extended attributes. Returns: a StatResponse proto Raises: IOError when call to os.stat() fails
grr/client/grr_response_client/vfs_handlers/files.py
def _Stat(self, path, ext_attrs=False): """Returns stat information of a specific path. Args: path: A unicode string containing the path. ext_attrs: Whether the call should also collect extended attributes. Returns: a StatResponse proto Raises: IOError when call to os.stat() f...
def _Stat(self, path, ext_attrs=False): """Returns stat information of a specific path. Args: path: A unicode string containing the path. ext_attrs: Whether the call should also collect extended attributes. Returns: a StatResponse proto Raises: IOError when call to os.stat() f...
[ "Returns", "stat", "information", "of", "a", "specific", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/files.py#L243-L267
[ "def", "_Stat", "(", "self", ",", "path", ",", "ext_attrs", "=", "False", ")", ":", "# Note that the encoding of local path is system specific", "local_path", "=", "client_utils", ".", "CanonicalPathToLocalPath", "(", "path", ")", "result", "=", "client_utils", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
File.ListFiles
List all files in the dir.
grr/client/grr_response_client/vfs_handlers/files.py
def ListFiles(self, ext_attrs=False): """List all files in the dir.""" if not self.IsDirectory(): raise IOError("%s is not a directory." % self.path) for path in self.files: try: filepath = utils.JoinPath(self.path, path) response = self._Stat(filepath, ext_attrs=ext_attrs) ...
def ListFiles(self, ext_attrs=False): """List all files in the dir.""" if not self.IsDirectory(): raise IOError("%s is not a directory." % self.path) for path in self.files: try: filepath = utils.JoinPath(self.path, path) response = self._Stat(filepath, ext_attrs=ext_attrs) ...
[ "List", "all", "files", "in", "the", "dir", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/files.py#L269-L284
[ "def", "ListFiles", "(", "self", ",", "ext_attrs", "=", "False", ")", ":", "if", "not", "self", ".", "IsDirectory", "(", ")", ":", "raise", "IOError", "(", "\"%s is not a directory.\"", "%", "self", ".", "path", ")", "for", "path", "in", "self", ".", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
File.StatFS
Call os.statvfs for a given list of rdf_paths. OS X and Linux only. Note that a statvfs call for a network filesystem (e.g. NFS) that is unavailable, e.g. due to no network, will result in the call blocking. Args: path: a Unicode string containing the path or None. If path is None the v...
grr/client/grr_response_client/vfs_handlers/files.py
def StatFS(self, path=None): """Call os.statvfs for a given list of rdf_paths. OS X and Linux only. Note that a statvfs call for a network filesystem (e.g. NFS) that is unavailable, e.g. due to no network, will result in the call blocking. Args: path: a Unicode string containing the path or...
def StatFS(self, path=None): """Call os.statvfs for a given list of rdf_paths. OS X and Linux only. Note that a statvfs call for a network filesystem (e.g. NFS) that is unavailable, e.g. due to no network, will result in the call blocking. Args: path: a Unicode string containing the path or...
[ "Call", "os", ".", "statvfs", "for", "a", "given", "list", "of", "rdf_paths", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/files.py#L289-L311
[ "def", "StatFS", "(", "self", ",", "path", "=", "None", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "\"Windows\"", ":", "raise", "RuntimeError", "(", "\"os.statvfs not available on Windows\"", ")", "local_path", "=", "client_utils", ".", "Canoni...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
File.GetMountPoint
Walk back from the path to find the mount point. Args: path: a Unicode string containing the path or None. If path is None the value in self.path is used. Returns: path string of the mount point
grr/client/grr_response_client/vfs_handlers/files.py
def GetMountPoint(self, path=None): """Walk back from the path to find the mount point. Args: path: a Unicode string containing the path or None. If path is None the value in self.path is used. Returns: path string of the mount point """ path = os.path.abspath( client_u...
def GetMountPoint(self, path=None): """Walk back from the path to find the mount point. Args: path: a Unicode string containing the path or None. If path is None the value in self.path is used. Returns: path string of the mount point """ path = os.path.abspath( client_u...
[ "Walk", "back", "from", "the", "path", "to", "find", "the", "mount", "point", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/files.py#L313-L329
[ "def", "GetMountPoint", "(", "self", ",", "path", "=", "None", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "client_utils", ".", "CanonicalPathToLocalPath", "(", "path", "or", "self", ".", "path", ")", ")", "while", "not", "os", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.WriteHuntObject
Writes a hunt object to the database.
grr/server/grr_response_server/databases/mysql_hunts.py
def WriteHuntObject(self, hunt_obj, cursor=None): """Writes a hunt object to the database.""" query = """ INSERT INTO hunts (hunt_id, creator, description, duration_micros, hunt_state, client_rate, client_limit, hunt) VALUES (%(hunt_id...
def WriteHuntObject(self, hunt_obj, cursor=None): """Writes a hunt object to the database.""" query = """ INSERT INTO hunts (hunt_id, creator, description, duration_micros, hunt_state, client_rate, client_limit, hunt) VALUES (%(hunt_id...
[ "Writes", "a", "hunt", "object", "to", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L49-L76
[ "def", "WriteHuntObject", "(", "self", ",", "hunt_obj", ",", "cursor", "=", "None", ")", ":", "query", "=", "\"\"\"\n INSERT INTO hunts (hunt_id, creator, description, duration_micros,\n hunt_state,\n client_rate, client_limit,\n ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.UpdateHuntObject
Updates the hunt object by applying the update function.
grr/server/grr_response_server/databases/mysql_hunts.py
def UpdateHuntObject(self, hunt_id, duration=None, client_rate=None, client_limit=None, hunt_state=None, hunt_state_comment=None, start_time=None, ...
def UpdateHuntObject(self, hunt_id, duration=None, client_rate=None, client_limit=None, hunt_state=None, hunt_state_comment=None, start_time=None, ...
[ "Updates", "the", "hunt", "object", "by", "applying", "the", "update", "function", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L79-L137
[ "def", "UpdateHuntObject", "(", "self", ",", "hunt_id", ",", "duration", "=", "None", ",", "client_rate", "=", "None", ",", "client_limit", "=", "None", ",", "hunt_state", "=", "None", ",", "hunt_state_comment", "=", "None", ",", "start_time", "=", "None", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.DeleteHuntObject
Deletes a given hunt object.
grr/server/grr_response_server/databases/mysql_hunts.py
def DeleteHuntObject(self, hunt_id, cursor=None): """Deletes a given hunt object.""" query = "DELETE FROM hunts WHERE hunt_id = %s" hunt_id_int = db_utils.HuntIDToInt(hunt_id) rows_deleted = cursor.execute(query, [hunt_id_int]) if rows_deleted == 0: raise db.UnknownHuntError(hunt_id) que...
def DeleteHuntObject(self, hunt_id, cursor=None): """Deletes a given hunt object.""" query = "DELETE FROM hunts WHERE hunt_id = %s" hunt_id_int = db_utils.HuntIDToInt(hunt_id) rows_deleted = cursor.execute(query, [hunt_id_int]) if rows_deleted == 0: raise db.UnknownHuntError(hunt_id) que...
[ "Deletes", "a", "given", "hunt", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L140-L150
[ "def", "DeleteHuntObject", "(", "self", ",", "hunt_id", ",", "cursor", "=", "None", ")", ":", "query", "=", "\"DELETE FROM hunts WHERE hunt_id = %s\"", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "hunt_id", ")", "rows_deleted", "=", "cursor", ".", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin._HuntObjectFromRow
Generates a flow object from a database row.
grr/server/grr_response_server/databases/mysql_hunts.py
def _HuntObjectFromRow(self, row): """Generates a flow object from a database row.""" ( create_time, last_update_time, creator, duration_micros, client_rate, client_limit, hunt_state, hunt_state_comment, init_start_time, last_start_...
def _HuntObjectFromRow(self, row): """Generates a flow object from a database row.""" ( create_time, last_update_time, creator, duration_micros, client_rate, client_limit, hunt_state, hunt_state_comment, init_start_time, last_start_...
[ "Generates", "a", "flow", "object", "from", "a", "database", "row", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L152-L206
[ "def", "_HuntObjectFromRow", "(", "self", ",", "row", ")", ":", "(", "create_time", ",", "last_update_time", ",", "creator", ",", "duration_micros", ",", "client_rate", ",", "client_limit", ",", "hunt_state", ",", "hunt_state_comment", ",", "init_start_time", ",",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntObject
Reads a hunt object from the database.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntObject(self, hunt_id, cursor=None): """Reads a hunt object from the database.""" query = ("SELECT {columns} " "FROM hunts WHERE hunt_id = %s".format( columns=_HUNT_COLUMNS_SELECT)) nr_results = cursor.execute(query, [db_utils.HuntIDToInt(hunt_id)]) if nr_result...
def ReadHuntObject(self, hunt_id, cursor=None): """Reads a hunt object from the database.""" query = ("SELECT {columns} " "FROM hunts WHERE hunt_id = %s".format( columns=_HUNT_COLUMNS_SELECT)) nr_results = cursor.execute(query, [db_utils.HuntIDToInt(hunt_id)]) if nr_result...
[ "Reads", "a", "hunt", "object", "from", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L209-L219
[ "def", "ReadHuntObject", "(", "self", ",", "hunt_id", ",", "cursor", "=", "None", ")", ":", "query", "=", "(", "\"SELECT {columns} \"", "\"FROM hunts WHERE hunt_id = %s\"", ".", "format", "(", "columns", "=", "_HUNT_COLUMNS_SELECT", ")", ")", "nr_results", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntObjects
Reads multiple hunt objects from the database.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntObjects(self, offset, count, with_creator=None, created_after=None, with_description_match=None, cursor=None): """Reads multiple hunt objects from the database.""" quer...
def ReadHuntObjects(self, offset, count, with_creator=None, created_after=None, with_description_match=None, cursor=None): """Reads multiple hunt objects from the database.""" quer...
[ "Reads", "multiple", "hunt", "objects", "from", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L222-L254
[ "def", "ReadHuntObjects", "(", "self", ",", "offset", ",", "count", ",", "with_creator", "=", "None", ",", "created_after", "=", "None", ",", "with_description_match", "=", "None", ",", "cursor", "=", "None", ")", ":", "query", "=", "\"SELECT {columns} FROM hu...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin._HuntOutputPluginStateFromRow
Builds OutputPluginState object from a DB row.
grr/server/grr_response_server/databases/mysql_hunts.py
def _HuntOutputPluginStateFromRow(self, row): """Builds OutputPluginState object from a DB row.""" plugin_name, plugin_args_bytes, plugin_state_bytes = row plugin_descriptor = rdf_output_plugin.OutputPluginDescriptor( plugin_name=plugin_name) if plugin_args_bytes is not None: plugin_args_...
def _HuntOutputPluginStateFromRow(self, row): """Builds OutputPluginState object from a DB row.""" plugin_name, plugin_args_bytes, plugin_state_bytes = row plugin_descriptor = rdf_output_plugin.OutputPluginDescriptor( plugin_name=plugin_name) if plugin_args_bytes is not None: plugin_args_...
[ "Builds", "OutputPluginState", "object", "from", "a", "DB", "row", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L256-L276
[ "def", "_HuntOutputPluginStateFromRow", "(", "self", ",", "row", ")", ":", "plugin_name", ",", "plugin_args_bytes", ",", "plugin_state_bytes", "=", "row", "plugin_descriptor", "=", "rdf_output_plugin", ".", "OutputPluginDescriptor", "(", "plugin_name", "=", "plugin_name...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntOutputPluginsStates
Reads all hunt output plugins states of a given hunt.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntOutputPluginsStates(self, hunt_id, cursor=None): """Reads all hunt output plugins states of a given hunt.""" columns = ", ".join(_HUNT_OUTPUT_PLUGINS_STATES_COLUMNS) query = ("SELECT {columns} FROM hunt_output_plugins_states " "WHERE hunt_id = %s".format(columns=columns)) rows...
def ReadHuntOutputPluginsStates(self, hunt_id, cursor=None): """Reads all hunt output plugins states of a given hunt.""" columns = ", ".join(_HUNT_OUTPUT_PLUGINS_STATES_COLUMNS) query = ("SELECT {columns} FROM hunt_output_plugins_states " "WHERE hunt_id = %s".format(columns=columns)) rows...
[ "Reads", "all", "hunt", "output", "plugins", "states", "of", "a", "given", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L279-L298
[ "def", "ReadHuntOutputPluginsStates", "(", "self", ",", "hunt_id", ",", "cursor", "=", "None", ")", ":", "columns", "=", "\", \"", ".", "join", "(", "_HUNT_OUTPUT_PLUGINS_STATES_COLUMNS", ")", "query", "=", "(", "\"SELECT {columns} FROM hunt_output_plugins_states \"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.WriteHuntOutputPluginsStates
Writes hunt output plugin states for a given hunt.
grr/server/grr_response_server/databases/mysql_hunts.py
def WriteHuntOutputPluginsStates(self, hunt_id, states, cursor=None): """Writes hunt output plugin states for a given hunt.""" columns = ", ".join(_HUNT_OUTPUT_PLUGINS_STATES_COLUMNS) placeholders = mysql_utils.Placeholders( 2 + len(_HUNT_OUTPUT_PLUGINS_STATES_COLUMNS)) hunt_id_int = db_utils.H...
def WriteHuntOutputPluginsStates(self, hunt_id, states, cursor=None): """Writes hunt output plugin states for a given hunt.""" columns = ", ".join(_HUNT_OUTPUT_PLUGINS_STATES_COLUMNS) placeholders = mysql_utils.Placeholders( 2 + len(_HUNT_OUTPUT_PLUGINS_STATES_COLUMNS)) hunt_id_int = db_utils.H...
[ "Writes", "hunt", "output", "plugin", "states", "for", "a", "given", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L301-L326
[ "def", "WriteHuntOutputPluginsStates", "(", "self", ",", "hunt_id", ",", "states", ",", "cursor", "=", "None", ")", ":", "columns", "=", "\", \"", ".", "join", "(", "_HUNT_OUTPUT_PLUGINS_STATES_COLUMNS", ")", "placeholders", "=", "mysql_utils", ".", "Placeholders"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.UpdateHuntOutputPluginState
Updates hunt output plugin state for a given output plugin.
grr/server/grr_response_server/databases/mysql_hunts.py
def UpdateHuntOutputPluginState(self, hunt_id, state_index, update_fn, cursor=None): """Updates hunt output plugin state for a given output plugin.""" hunt_id_int = db_utils.H...
def UpdateHuntOutputPluginState(self, hunt_id, state_index, update_fn, cursor=None): """Updates hunt output plugin state for a given output plugin.""" hunt_id_int = db_utils.H...
[ "Updates", "hunt", "output", "plugin", "state", "for", "a", "given", "output", "plugin", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L329-L358
[ "def", "UpdateHuntOutputPluginState", "(", "self", ",", "hunt_id", ",", "state_index", ",", "update_fn", ",", "cursor", "=", "None", ")", ":", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "hunt_id", ")", "query", "=", "\"SELECT hunt_id FROM hunts WHERE...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntLogEntries
Reads hunt log entries of a given hunt using given query options.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntLogEntries(self, hunt_id, offset, count, with_substring=None, cursor=None): """Reads hunt log entries of a given hunt using given query options.""" hunt_id_int = db_utils.Hunt...
def ReadHuntLogEntries(self, hunt_id, offset, count, with_substring=None, cursor=None): """Reads hunt log entries of a given hunt using given query options.""" hunt_id_int = db_utils.Hunt...
[ "Reads", "hunt", "log", "entries", "of", "a", "given", "hunt", "using", "given", "query", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L361-L398
[ "def", "ReadHuntLogEntries", "(", "self", ",", "hunt_id", ",", "offset", ",", "count", ",", "with_substring", "=", "None", ",", "cursor", "=", "None", ")", ":", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "hunt_id", ")", "query", "=", "(", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.CountHuntLogEntries
Returns number of hunt log entries of a given hunt.
grr/server/grr_response_server/databases/mysql_hunts.py
def CountHuntLogEntries(self, hunt_id, cursor=None): """Returns number of hunt log entries of a given hunt.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = ("SELECT COUNT(*) FROM flow_log_entries " "FORCE INDEX(flow_log_entries_by_hunt) " "WHERE hunt_id = %s AND flow_id = h...
def CountHuntLogEntries(self, hunt_id, cursor=None): """Returns number of hunt log entries of a given hunt.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = ("SELECT COUNT(*) FROM flow_log_entries " "FORCE INDEX(flow_log_entries_by_hunt) " "WHERE hunt_id = %s AND flow_id = h...
[ "Returns", "number", "of", "hunt", "log", "entries", "of", "a", "given", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L401-L409
[ "def", "CountHuntLogEntries", "(", "self", ",", "hunt_id", ",", "cursor", "=", "None", ")", ":", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "hunt_id", ")", "query", "=", "(", "\"SELECT COUNT(*) FROM flow_log_entries \"", "\"FORCE INDEX(flow_log_entries_b...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntResults
Reads hunt results of a given hunt using given query options.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntResults(self, hunt_id, offset, count, with_tag=None, with_type=None, with_substring=None, with_timestamp=None, cursor=None): """...
def ReadHuntResults(self, hunt_id, offset, count, with_tag=None, with_type=None, with_substring=None, with_timestamp=None, cursor=None): """...
[ "Reads", "hunt", "results", "of", "a", "given", "hunt", "using", "given", "query", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L412-L482
[ "def", "ReadHuntResults", "(", "self", ",", "hunt_id", ",", "offset", ",", "count", ",", "with_tag", "=", "None", ",", "with_type", "=", "None", ",", "with_substring", "=", "None", ",", "with_timestamp", "=", "None", ",", "cursor", "=", "None", ")", ":",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.CountHuntResults
Counts hunt results of a given hunt using given query options.
grr/server/grr_response_server/databases/mysql_hunts.py
def CountHuntResults(self, hunt_id, with_tag=None, with_type=None, cursor=None): """Counts hunt results of a given hunt using given query options.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = "SELECT COUNT...
def CountHuntResults(self, hunt_id, with_tag=None, with_type=None, cursor=None): """Counts hunt results of a given hunt using given query options.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = "SELECT COUNT...
[ "Counts", "hunt", "results", "of", "a", "given", "hunt", "using", "given", "query", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L485-L506
[ "def", "CountHuntResults", "(", "self", ",", "hunt_id", ",", "with_tag", "=", "None", ",", "with_type", "=", "None", ",", "cursor", "=", "None", ")", ":", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "hunt_id", ")", "query", "=", "\"SELECT COUN...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.CountHuntResultsByType
Counts number of hunts results per type.
grr/server/grr_response_server/databases/mysql_hunts.py
def CountHuntResultsByType(self, hunt_id, cursor=None): """Counts number of hunts results per type.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = ("SELECT type, COUNT(*) FROM flow_results " "WHERE hunt_id = %s GROUP BY type") cursor.execute(query, [hunt_id_int]) return dict(c...
def CountHuntResultsByType(self, hunt_id, cursor=None): """Counts number of hunts results per type.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = ("SELECT type, COUNT(*) FROM flow_results " "WHERE hunt_id = %s GROUP BY type") cursor.execute(query, [hunt_id_int]) return dict(c...
[ "Counts", "number", "of", "hunts", "results", "per", "type", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L509-L517
[ "def", "CountHuntResultsByType", "(", "self", ",", "hunt_id", ",", "cursor", "=", "None", ")", ":", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "hunt_id", ")", "query", "=", "(", "\"SELECT type, COUNT(*) FROM flow_results \"", "\"WHERE hunt_id = %s GROUP ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin._HuntFlowCondition
Builds an SQL condition matching db.HuntFlowsCondition.
grr/server/grr_response_server/databases/mysql_hunts.py
def _HuntFlowCondition(self, condition): """Builds an SQL condition matching db.HuntFlowsCondition.""" if condition == db.HuntFlowsCondition.UNSET: return "", [] elif condition == db.HuntFlowsCondition.FAILED_FLOWS_ONLY: return ("AND flow_state = %s ", [int(rdf_flow_objects.Flow.Fl...
def _HuntFlowCondition(self, condition): """Builds an SQL condition matching db.HuntFlowsCondition.""" if condition == db.HuntFlowsCondition.UNSET: return "", [] elif condition == db.HuntFlowsCondition.FAILED_FLOWS_ONLY: return ("AND flow_state = %s ", [int(rdf_flow_objects.Flow.Fl...
[ "Builds", "an", "SQL", "condition", "matching", "db", ".", "HuntFlowsCondition", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L519-L541
[ "def", "_HuntFlowCondition", "(", "self", ",", "condition", ")", ":", "if", "condition", "==", "db", ".", "HuntFlowsCondition", ".", "UNSET", ":", "return", "\"\"", ",", "[", "]", "elif", "condition", "==", "db", ".", "HuntFlowsCondition", ".", "FAILED_FLOWS...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntFlows
Reads hunt flows matching given conditins.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntFlows(self, hunt_id, offset, count, filter_condition=db.HuntFlowsCondition.UNSET, cursor=None): """Reads hunt flows matching given conditins.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query ...
def ReadHuntFlows(self, hunt_id, offset, count, filter_condition=db.HuntFlowsCondition.UNSET, cursor=None): """Reads hunt flows matching given conditins.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query ...
[ "Reads", "hunt", "flows", "matching", "given", "conditins", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L544-L566
[ "def", "ReadHuntFlows", "(", "self", ",", "hunt_id", ",", "offset", ",", "count", ",", "filter_condition", "=", "db", ".", "HuntFlowsCondition", ".", "UNSET", ",", "cursor", "=", "None", ")", ":", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "h...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.CountHuntFlows
Counts hunt flows matching given conditions.
grr/server/grr_response_server/databases/mysql_hunts.py
def CountHuntFlows(self, hunt_id, filter_condition=db.HuntFlowsCondition.UNSET, cursor=None): """Counts hunt flows matching given conditions.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = ("SELECT COUNT(*) FROM flows " "FO...
def CountHuntFlows(self, hunt_id, filter_condition=db.HuntFlowsCondition.UNSET, cursor=None): """Counts hunt flows matching given conditions.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = ("SELECT COUNT(*) FROM flows " "FO...
[ "Counts", "hunt", "flows", "matching", "given", "conditions", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L569-L585
[ "def", "CountHuntFlows", "(", "self", ",", "hunt_id", ",", "filter_condition", "=", "db", ".", "HuntFlowsCondition", ".", "UNSET", ",", "cursor", "=", "None", ")", ":", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "hunt_id", ")", "query", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntCounters
Reads hunt counters.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntCounters(self, hunt_id, cursor=None): """Reads hunt counters.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = ("SELECT flow_state, COUNT(*) " "FROM flows " "FORCE INDEX(flows_by_hunt) " "WHERE parent_hunt_id = %s AND parent_flow_id IS NULL " ...
def ReadHuntCounters(self, hunt_id, cursor=None): """Reads hunt counters.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = ("SELECT flow_state, COUNT(*) " "FROM flows " "FORCE INDEX(flows_by_hunt) " "WHERE parent_hunt_id = %s AND parent_flow_id IS NULL " ...
[ "Reads", "hunt", "counters", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L588-L644
[ "def", "ReadHuntCounters", "(", "self", ",", "hunt_id", ",", "cursor", "=", "None", ")", ":", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "hunt_id", ")", "query", "=", "(", "\"SELECT flow_state, COUNT(*) \"", "\"FROM flows \"", "\"FORCE INDEX(flows_by_h...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin._BinsToQuery
Builds an SQL query part to fetch counts corresponding to given bins.
grr/server/grr_response_server/databases/mysql_hunts.py
def _BinsToQuery(self, bins, column_name): """Builds an SQL query part to fetch counts corresponding to given bins.""" result = [] # With the current StatsHistogram implementation the last bin simply # takes all the values that are greater than range_max_value of # the one-before-the-last bin. range...
def _BinsToQuery(self, bins, column_name): """Builds an SQL query part to fetch counts corresponding to given bins.""" result = [] # With the current StatsHistogram implementation the last bin simply # takes all the values that are greater than range_max_value of # the one-before-the-last bin. range...
[ "Builds", "an", "SQL", "query", "part", "to", "fetch", "counts", "corresponding", "to", "given", "bins", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L646-L662
[ "def", "_BinsToQuery", "(", "self", ",", "bins", ",", "column_name", ")", ":", "result", "=", "[", "]", "# With the current StatsHistogram implementation the last bin simply", "# takes all the values that are greater than range_max_value of", "# the one-before-the-last bin. range_max...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntClientResourcesStats
Read/calculate hunt client resources stats.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntClientResourcesStats(self, hunt_id, cursor=None): """Read/calculate hunt client resources stats.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = """ SELECT COUNT(*), SUM(user_cpu_time_used_micros), SUM((user_cpu_time_used_micros) * (user_cpu_time_used_micros...
def ReadHuntClientResourcesStats(self, hunt_id, cursor=None): """Read/calculate hunt client resources stats.""" hunt_id_int = db_utils.HuntIDToInt(hunt_id) query = """ SELECT COUNT(*), SUM(user_cpu_time_used_micros), SUM((user_cpu_time_used_micros) * (user_cpu_time_used_micros...
[ "Read", "/", "calculate", "hunt", "client", "resources", "stats", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L665-L769
[ "def", "ReadHuntClientResourcesStats", "(", "self", ",", "hunt_id", ",", "cursor", "=", "None", ")", ":", "hunt_id_int", "=", "db_utils", ".", "HuntIDToInt", "(", "hunt_id", ")", "query", "=", "\"\"\"\n SELECT\n COUNT(*),\n SUM(user_cpu_time_used_micros...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntFlowsStatesAndTimestamps
Reads hunt flows states and timestamps.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntFlowsStatesAndTimestamps(self, hunt_id, cursor=None): """Reads hunt flows states and timestamps.""" query = """ SELECT flow_state, UNIX_TIMESTAMP(timestamp), UNIX_TIMESTAMP(last_update) FROM flows FORCE INDEX(flows_by_hunt) WHERE parent_hunt_id = %s AND parent_flow_i...
def ReadHuntFlowsStatesAndTimestamps(self, hunt_id, cursor=None): """Reads hunt flows states and timestamps.""" query = """ SELECT flow_state, UNIX_TIMESTAMP(timestamp), UNIX_TIMESTAMP(last_update) FROM flows FORCE INDEX(flows_by_hunt) WHERE parent_hunt_id = %s AND parent_flow_i...
[ "Reads", "hunt", "flows", "states", "and", "timestamps", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L772-L793
[ "def", "ReadHuntFlowsStatesAndTimestamps", "(", "self", ",", "hunt_id", ",", "cursor", "=", "None", ")", ":", "query", "=", "\"\"\"\n SELECT\n flow_state, UNIX_TIMESTAMP(timestamp), UNIX_TIMESTAMP(last_update)\n FROM flows\n FORCE INDEX(flows_by_hunt)\n WHERE p...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.ReadHuntOutputPluginLogEntries
Reads hunt output plugin log entries.
grr/server/grr_response_server/databases/mysql_hunts.py
def ReadHuntOutputPluginLogEntries(self, hunt_id, output_plugin_id, offset, count, with_type=None, ...
def ReadHuntOutputPluginLogEntries(self, hunt_id, output_plugin_id, offset, count, with_type=None, ...
[ "Reads", "hunt", "output", "plugin", "log", "entries", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L796-L837
[ "def", "ReadHuntOutputPluginLogEntries", "(", "self", ",", "hunt_id", ",", "output_plugin_id", ",", "offset", ",", "count", ",", "with_type", "=", "None", ",", "cursor", "=", "None", ")", ":", "query", "=", "(", "\"SELECT client_id, flow_id, log_entry_type, message,...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBHuntMixin.CountHuntOutputPluginLogEntries
Counts hunt output plugin log entries.
grr/server/grr_response_server/databases/mysql_hunts.py
def CountHuntOutputPluginLogEntries(self, hunt_id, output_plugin_id, with_type=None, cursor=None): """Counts hunt output plugin log entries.""" query = ("SELECT...
def CountHuntOutputPluginLogEntries(self, hunt_id, output_plugin_id, with_type=None, cursor=None): """Counts hunt output plugin log entries.""" query = ("SELECT...
[ "Counts", "hunt", "output", "plugin", "log", "entries", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_hunts.py#L840-L860
[ "def", "CountHuntOutputPluginLogEntries", "(", "self", ",", "hunt_id", ",", "output_plugin_id", ",", "with_type", "=", "None", ",", "cursor", "=", "None", ")", ":", "query", "=", "(", "\"SELECT COUNT(*) \"", "\"FROM flow_output_plugin_log_entries \"", "\"FORCE INDEX (fl...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Foreman._CheckIfHuntTaskWasAssigned
Will return True if hunt's task was assigned to this client before.
grr/server/grr_response_server/foreman.py
def _CheckIfHuntTaskWasAssigned(self, client_id, hunt_id): """Will return True if hunt's task was assigned to this client before.""" if data_store.RelationalDBEnabled(): flow_id = hunt_id if hunt.IsLegacyHunt(hunt_id): # Strip "H:" prefix. flow_id = flow_id[2:] try: da...
def _CheckIfHuntTaskWasAssigned(self, client_id, hunt_id): """Will return True if hunt's task was assigned to this client before.""" if data_store.RelationalDBEnabled(): flow_id = hunt_id if hunt.IsLegacyHunt(hunt_id): # Strip "H:" prefix. flow_id = flow_id[2:] try: da...
[ "Will", "return", "True", "if", "hunt", "s", "task", "was", "assigned", "to", "this", "client", "before", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/foreman.py#L39-L59
[ "def", "_CheckIfHuntTaskWasAssigned", "(", "self", ",", "client_id", ",", "hunt_id", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "flow_id", "=", "hunt_id", "if", "hunt", ".", "IsLegacyHunt", "(", "hunt_id", ")", ":", "# Strip \"H:\...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Foreman._RunAction
Run all the actions specified in the rule. Args: rule: Rule which actions are to be executed. client_id: Id of a client where rule's actions are to be executed. Returns: Number of actions started.
grr/server/grr_response_server/foreman.py
def _RunAction(self, rule, client_id): """Run all the actions specified in the rule. Args: rule: Rule which actions are to be executed. client_id: Id of a client where rule's actions are to be executed. Returns: Number of actions started. """ actions_count = 0 try: if ...
def _RunAction(self, rule, client_id): """Run all the actions specified in the rule. Args: rule: Rule which actions are to be executed. client_id: Id of a client where rule's actions are to be executed. Returns: Number of actions started. """ actions_count = 0 try: if ...
[ "Run", "all", "the", "actions", "specified", "in", "the", "rule", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/foreman.py#L61-L98
[ "def", "_RunAction", "(", "self", ",", "rule", ",", "client_id", ")", ":", "actions_count", "=", "0", "try", ":", "if", "self", ".", "_CheckIfHuntTaskWasAssigned", "(", "client_id", ",", "rule", ".", "hunt_id", ")", ":", "logging", ".", "info", "(", "\"F...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Foreman.AssignTasksToClient
Examines our rules and starts up flows based on the client. Args: client_id: Client id of the client for tasks to be assigned. Returns: Number of assigned tasks.
grr/server/grr_response_server/foreman.py
def AssignTasksToClient(self, client_id): """Examines our rules and starts up flows based on the client. Args: client_id: Client id of the client for tasks to be assigned. Returns: Number of assigned tasks. """ rules = data_store.REL_DB.ReadAllForemanRules() if not rules: ret...
def AssignTasksToClient(self, client_id): """Examines our rules and starts up flows based on the client. Args: client_id: Client id of the client for tasks to be assigned. Returns: Number of assigned tasks. """ rules = data_store.REL_DB.ReadAllForemanRules() if not rules: ret...
[ "Examines", "our", "rules", "and", "starts", "up", "flows", "based", "on", "the", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/foreman.py#L107-L157
[ "def", "AssignTasksToClient", "(", "self", ",", "client_id", ")", ":", "rules", "=", "data_store", ".", "REL_DB", ".", "ReadAllForemanRules", "(", ")", "if", "not", "rules", ":", "return", "0", "last_foreman_run", "=", "self", ".", "_GetLastForemanRunTime", "(...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_GetSignedBinaryMetadata
Fetches metadata for the given binary from the datastore. Args: binary_type: ApiGrrBinary.Type of the binary. relative_path: Relative path of the binary, relative to the canonical URN roots for signed binaries (see _GetSignedBlobsRoots()). Returns: An ApiGrrBinary RDFProtoStruct containing metad...
grr/server/grr_response_server/gui/api_plugins/config.py
def _GetSignedBinaryMetadata(binary_type, relative_path): """Fetches metadata for the given binary from the datastore. Args: binary_type: ApiGrrBinary.Type of the binary. relative_path: Relative path of the binary, relative to the canonical URN roots for signed binaries (see _GetSignedBlobsRoots()). ...
def _GetSignedBinaryMetadata(binary_type, relative_path): """Fetches metadata for the given binary from the datastore. Args: binary_type: ApiGrrBinary.Type of the binary. relative_path: Relative path of the binary, relative to the canonical URN roots for signed binaries (see _GetSignedBlobsRoots()). ...
[ "Fetches", "metadata", "for", "the", "given", "binary", "from", "the", "datastore", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/config.py#L173-L206
[ "def", "_GetSignedBinaryMetadata", "(", "binary_type", ",", "relative_path", ")", ":", "root_urn", "=", "_GetSignedBlobsRoots", "(", ")", "[", "binary_type", "]", "binary_urn", "=", "root_urn", ".", "Add", "(", "relative_path", ")", "blob_iterator", ",", "timestam...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiGetConfigHandler.Handle
Build the data structure representing the config.
grr/server/grr_response_server/gui/api_plugins/config.py
def Handle(self, unused_args, token=None): """Build the data structure representing the config.""" sections = {} for descriptor in config.CONFIG.type_infos: if descriptor.section in sections: continue section_data = {} for parameter in self._ListParametersInSection(descriptor.sec...
def Handle(self, unused_args, token=None): """Build the data structure representing the config.""" sections = {} for descriptor in config.CONFIG.type_infos: if descriptor.section in sections: continue section_data = {} for parameter in self._ListParametersInSection(descriptor.sec...
[ "Build", "the", "data", "structure", "representing", "the", "config", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/config.py#L102-L127
[ "def", "Handle", "(", "self", ",", "unused_args", ",", "token", "=", "None", ")", ":", "sections", "=", "{", "}", "for", "descriptor", "in", "config", ".", "CONFIG", ".", "type_infos", ":", "if", "descriptor", ".", "section", "in", "sections", ":", "co...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiGetConfigOptionHandler.Handle
Renders specified config option.
grr/server/grr_response_server/gui/api_plugins/config.py
def Handle(self, args, token=None): """Renders specified config option.""" if not args.name: raise ValueError("Name not specified.") return ApiConfigOption().InitFromConfigOption(args.name)
def Handle(self, args, token=None): """Renders specified config option.""" if not args.name: raise ValueError("Name not specified.") return ApiConfigOption().InitFromConfigOption(args.name)
[ "Renders", "specified", "config", "option", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/config.py#L140-L146
[ "def", "Handle", "(", "self", ",", "args", ",", "token", "=", "None", ")", ":", "if", "not", "args", ".", "name", ":", "raise", "ValueError", "(", "\"Name not specified.\"", ")", "return", "ApiConfigOption", "(", ")", ".", "InitFromConfigOption", "(", "arg...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Proxy
A helper to create a proxy method in a class.
grr/core/grr_response_core/lib/utils.py
def Proxy(f): """A helper to create a proxy method in a class.""" def Wrapped(self, *args): return getattr(self, f)(*args) return Wrapped
def Proxy(f): """A helper to create a proxy method in a class.""" def Wrapped(self, *args): return getattr(self, f)(*args) return Wrapped
[ "A", "helper", "to", "create", "a", "proxy", "method", "in", "a", "class", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L53-L59
[ "def", "Proxy", "(", "f", ")", ":", "def", "Wrapped", "(", "self", ",", "*", "args", ")", ":", "return", "getattr", "(", "self", ",", "f", ")", "(", "*", "args", ")", "return", "Wrapped" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Synchronized
Synchronization decorator.
grr/core/grr_response_core/lib/utils.py
def Synchronized(f): """Synchronization decorator.""" @functools.wraps(f) def NewFunction(self, *args, **kw): with self.lock: return f(self, *args, **kw) return NewFunction
def Synchronized(f): """Synchronization decorator.""" @functools.wraps(f) def NewFunction(self, *args, **kw): with self.lock: return f(self, *args, **kw) return NewFunction
[ "Synchronization", "decorator", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L79-L87
[ "def", "Synchronized", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "NewFunction", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "with", "self", ".", "lock", ":", "return", "f", "(", "self", ",", "*"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SmartUnicode
Returns a unicode object. This function will always return a unicode object. It should be used to guarantee that something is always a unicode object. Args: string: The string to convert. Returns: a unicode object.
grr/core/grr_response_core/lib/utils.py
def SmartUnicode(string): """Returns a unicode object. This function will always return a unicode object. It should be used to guarantee that something is always a unicode object. Args: string: The string to convert. Returns: a unicode object. """ if isinstance(string, Text): return string ...
def SmartUnicode(string): """Returns a unicode object. This function will always return a unicode object. It should be used to guarantee that something is always a unicode object. Args: string: The string to convert. Returns: a unicode object. """ if isinstance(string, Text): return string ...
[ "Returns", "a", "unicode", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L509-L532
[ "def", "SmartUnicode", "(", "string", ")", ":", "if", "isinstance", "(", "string", ",", "Text", ")", ":", "return", "string", "if", "isinstance", "(", "string", ",", "bytes", ")", ":", "return", "string", ".", "decode", "(", "\"utf-8\"", ",", "\"ignore\"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Xor
Returns a `bytes` object where each byte has been xored with key.
grr/core/grr_response_core/lib/utils.py
def Xor(bytestr, key): """Returns a `bytes` object where each byte has been xored with key.""" # TODO(hanuszczak): Remove this import when string migration is done. # pytype: disable=import-error from builtins import bytes # pylint: disable=redefined-builtin, g-import-not-at-top # pytype: enable=import-error...
def Xor(bytestr, key): """Returns a `bytes` object where each byte has been xored with key.""" # TODO(hanuszczak): Remove this import when string migration is done. # pytype: disable=import-error from builtins import bytes # pylint: disable=redefined-builtin, g-import-not-at-top # pytype: enable=import-error...
[ "Returns", "a", "bytes", "object", "where", "each", "byte", "has", "been", "xored", "with", "key", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L535-L551
[ "def", "Xor", "(", "bytestr", ",", "key", ")", ":", "# TODO(hanuszczak): Remove this import when string migration is done.", "# pytype: disable=import-error", "from", "builtins", "import", "bytes", "# pylint: disable=redefined-builtin, g-import-not-at-top", "# pytype: enable=import-err...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FormatAsHexString
Takes an int and returns the number formatted as a hex string.
grr/core/grr_response_core/lib/utils.py
def FormatAsHexString(num, width=None, prefix="0x"): """Takes an int and returns the number formatted as a hex string.""" # Strip "0x". hex_str = hex(num)[2:] # Strip "L" for long values. hex_str = hex_str.replace("L", "") if width: hex_str = hex_str.rjust(width, "0") return "%s%s" % (prefix, hex_str)
def FormatAsHexString(num, width=None, prefix="0x"): """Takes an int and returns the number formatted as a hex string.""" # Strip "0x". hex_str = hex(num)[2:] # Strip "L" for long values. hex_str = hex_str.replace("L", "") if width: hex_str = hex_str.rjust(width, "0") return "%s%s" % (prefix, hex_str)
[ "Takes", "an", "int", "and", "returns", "the", "number", "formatted", "as", "a", "hex", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L554-L562
[ "def", "FormatAsHexString", "(", "num", ",", "width", "=", "None", ",", "prefix", "=", "\"0x\"", ")", ":", "# Strip \"0x\".", "hex_str", "=", "hex", "(", "num", ")", "[", "2", ":", "]", "# Strip \"L\" for long values.", "hex_str", "=", "hex_str", ".", "rep...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
NormalizePath
A sane implementation of os.path.normpath. The standard implementation treats leading / and // as different leading to incorrect normal forms. NOTE: Its ok to use a relative path here (without leading /) but any /../ will still be removed anchoring the path at the top level (e.g. foo/../../../../bar => bar)...
grr/core/grr_response_core/lib/utils.py
def NormalizePath(path, sep="/"): """A sane implementation of os.path.normpath. The standard implementation treats leading / and // as different leading to incorrect normal forms. NOTE: Its ok to use a relative path here (without leading /) but any /../ will still be removed anchoring the path at the top le...
def NormalizePath(path, sep="/"): """A sane implementation of os.path.normpath. The standard implementation treats leading / and // as different leading to incorrect normal forms. NOTE: Its ok to use a relative path here (without leading /) but any /../ will still be removed anchoring the path at the top le...
[ "A", "sane", "implementation", "of", "os", ".", "path", ".", "normpath", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L572-L626
[ "def", "NormalizePath", "(", "path", ",", "sep", "=", "\"/\"", ")", ":", "if", "not", "path", ":", "return", "sep", "path", "=", "SmartUnicode", "(", "path", ")", "path_list", "=", "path", ".", "split", "(", "sep", ")", "# This is a relative path and the f...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
JoinPath
A sane version of os.path.join. The intention here is to append the stem to the path. The standard module removes the path if the stem begins with a /. Args: stem: The stem to join to. *parts: parts of the path to join. The first arg is always the root and directory traversal is not allowed. ...
grr/core/grr_response_core/lib/utils.py
def JoinPath(stem="", *parts): """A sane version of os.path.join. The intention here is to append the stem to the path. The standard module removes the path if the stem begins with a /. Args: stem: The stem to join to. *parts: parts of the path to join. The first arg is always the root and di...
def JoinPath(stem="", *parts): """A sane version of os.path.join. The intention here is to append the stem to the path. The standard module removes the path if the stem begins with a /. Args: stem: The stem to join to. *parts: parts of the path to join. The first arg is always the root and di...
[ "A", "sane", "version", "of", "os", ".", "path", ".", "join", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L629-L649
[ "def", "JoinPath", "(", "stem", "=", "\"\"", ",", "*", "parts", ")", ":", "# Ensure all path components are unicode", "parts", "=", "[", "SmartUnicode", "(", "path", ")", "for", "path", "in", "parts", "]", "result", "=", "(", "stem", "+", "NormalizePath", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GeneratePassphrase
Create a 20 char passphrase with easily typeable chars.
grr/core/grr_response_core/lib/utils.py
def GeneratePassphrase(length=20): """Create a 20 char passphrase with easily typeable chars.""" valid_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" valid_chars += "0123456789 ,-_&$#" return "".join(random.choice(valid_chars) for i in range(length))
def GeneratePassphrase(length=20): """Create a 20 char passphrase with easily typeable chars.""" valid_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" valid_chars += "0123456789 ,-_&$#" return "".join(random.choice(valid_chars) for i in range(length))
[ "Create", "a", "20", "char", "passphrase", "with", "easily", "typeable", "chars", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L691-L695
[ "def", "GeneratePassphrase", "(", "length", "=", "20", ")", ":", "valid_chars", "=", "\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"", "valid_chars", "+=", "\"0123456789 ,-_&$#\"", "return", "\"\"", ".", "join", "(", "random", ".", "choice", "(", "valid_chars"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PassphraseCallback
A utility function to read a passphrase from stdin.
grr/core/grr_response_core/lib/utils.py
def PassphraseCallback(verify=False, prompt1="Enter passphrase:", prompt2="Verify passphrase:"): """A utility function to read a passphrase from stdin.""" while 1: try: p1 = getpass.getpass(prompt1) if verify: p2 = getpass.getpass(prompt2) ...
def PassphraseCallback(verify=False, prompt1="Enter passphrase:", prompt2="Verify passphrase:"): """A utility function to read a passphrase from stdin.""" while 1: try: p1 = getpass.getpass(prompt1) if verify: p2 = getpass.getpass(prompt2) ...
[ "A", "utility", "function", "to", "read", "a", "passphrase", "from", "stdin", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L698-L713
[ "def", "PassphraseCallback", "(", "verify", "=", "False", ",", "prompt1", "=", "\"Enter passphrase:\"", ",", "prompt2", "=", "\"Verify passphrase:\"", ")", ":", "while", "1", ":", "try", ":", "p1", "=", "getpass", ".", "getpass", "(", "prompt1", ")", "if", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ResolveHostnameToIP
Resolves a hostname to an IP address.
grr/core/grr_response_core/lib/utils.py
def ResolveHostnameToIP(host, port): """Resolves a hostname to an IP address.""" ip_addrs = socket.getaddrinfo(host, port, socket.AF_UNSPEC, 0, socket.IPPROTO_TCP) # getaddrinfo returns tuples (family, socktype, proto, canonname, sockaddr). # We are interested in sockaddr which i...
def ResolveHostnameToIP(host, port): """Resolves a hostname to an IP address.""" ip_addrs = socket.getaddrinfo(host, port, socket.AF_UNSPEC, 0, socket.IPPROTO_TCP) # getaddrinfo returns tuples (family, socktype, proto, canonname, sockaddr). # We are interested in sockaddr which i...
[ "Resolves", "a", "hostname", "to", "an", "IP", "address", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L1257-L1271
[ "def", "ResolveHostnameToIP", "(", "host", ",", "port", ")", ":", "ip_addrs", "=", "socket", ".", "getaddrinfo", "(", "host", ",", "port", ",", "socket", ".", "AF_UNSPEC", ",", "0", ",", "socket", ".", "IPPROTO_TCP", ")", "# getaddrinfo returns tuples (family,...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FastStore.Expire
Expires old cache entries.
grr/core/grr_response_core/lib/utils.py
def Expire(self): """Expires old cache entries.""" while len(self._age) > self._limit: node = self._age.PopLeft() self._hash.pop(node.key, None) self.KillObject(node.data)
def Expire(self): """Expires old cache entries.""" while len(self._age) > self._limit: node = self._age.PopLeft() self._hash.pop(node.key, None) self.KillObject(node.data)
[ "Expires", "old", "cache", "entries", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L263-L268
[ "def", "Expire", "(", "self", ")", ":", "while", "len", "(", "self", ".", "_age", ")", ">", "self", ".", "_limit", ":", "node", "=", "self", ".", "_age", ".", "PopLeft", "(", ")", "self", ".", "_hash", ".", "pop", "(", "node", ".", "key", ",", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FastStore.Put
Add the object to the cache.
grr/core/grr_response_core/lib/utils.py
def Put(self, key, obj): """Add the object to the cache.""" # Remove the old entry if it is there. node = self._hash.pop(key, None) if node: self._age.Unlink(node) # Make a new node and insert it. node = Node(key=key, data=obj) self._hash[key] = node self._age.AppendNode(node) ...
def Put(self, key, obj): """Add the object to the cache.""" # Remove the old entry if it is there. node = self._hash.pop(key, None) if node: self._age.Unlink(node) # Make a new node and insert it. node = Node(key=key, data=obj) self._hash[key] = node self._age.AppendNode(node) ...
[ "Add", "the", "object", "to", "the", "cache", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L271-L285
[ "def", "Put", "(", "self", ",", "key", ",", "obj", ")", ":", "# Remove the old entry if it is there.", "node", "=", "self", ".", "_hash", ".", "pop", "(", "key", ",", "None", ")", "if", "node", ":", "self", ".", "_age", ".", "Unlink", "(", "node", ")...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FastStore.ExpireObject
Expire a specific object from cache.
grr/core/grr_response_core/lib/utils.py
def ExpireObject(self, key): """Expire a specific object from cache.""" node = self._hash.pop(key, None) if node: self._age.Unlink(node) self.KillObject(node.data) return node.data
def ExpireObject(self, key): """Expire a specific object from cache.""" node = self._hash.pop(key, None) if node: self._age.Unlink(node) self.KillObject(node.data) return node.data
[ "Expire", "a", "specific", "object", "from", "cache", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L288-L295
[ "def", "ExpireObject", "(", "self", ",", "key", ")", ":", "node", "=", "self", ".", "_hash", ".", "pop", "(", "key", ",", "None", ")", "if", "node", ":", "self", ".", "_age", ".", "Unlink", "(", "node", ")", "self", ".", "KillObject", "(", "node"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FastStore.ExpireRegEx
Expire all the objects with the key matching the regex.
grr/core/grr_response_core/lib/utils.py
def ExpireRegEx(self, regex): """Expire all the objects with the key matching the regex.""" reg = re.compile(regex) for key in list(self._hash): if reg.match(key): self.ExpireObject(key)
def ExpireRegEx(self, regex): """Expire all the objects with the key matching the regex.""" reg = re.compile(regex) for key in list(self._hash): if reg.match(key): self.ExpireObject(key)
[ "Expire", "all", "the", "objects", "with", "the", "key", "matching", "the", "regex", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L298-L303
[ "def", "ExpireRegEx", "(", "self", ",", "regex", ")", ":", "reg", "=", "re", ".", "compile", "(", "regex", ")", "for", "key", "in", "list", "(", "self", ".", "_hash", ")", ":", "if", "reg", ".", "match", "(", "key", ")", ":", "self", ".", "Expi...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FastStore.ExpirePrefix
Expire all the objects with the key having a given prefix.
grr/core/grr_response_core/lib/utils.py
def ExpirePrefix(self, prefix): """Expire all the objects with the key having a given prefix.""" for key in list(self._hash): if key.startswith(prefix): self.ExpireObject(key)
def ExpirePrefix(self, prefix): """Expire all the objects with the key having a given prefix.""" for key in list(self._hash): if key.startswith(prefix): self.ExpireObject(key)
[ "Expire", "all", "the", "objects", "with", "the", "key", "having", "a", "given", "prefix", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L306-L310
[ "def", "ExpirePrefix", "(", "self", ",", "prefix", ")", ":", "for", "key", "in", "list", "(", "self", ".", "_hash", ")", ":", "if", "key", ".", "startswith", "(", "prefix", ")", ":", "self", ".", "ExpireObject", "(", "key", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FastStore.Pop
Remove the object from the cache completely.
grr/core/grr_response_core/lib/utils.py
def Pop(self, key): """Remove the object from the cache completely.""" node = self._hash.get(key) if node: del self._hash[key] self._age.Unlink(node) return node.data
def Pop(self, key): """Remove the object from the cache completely.""" node = self._hash.get(key) if node: del self._hash[key] self._age.Unlink(node) return node.data
[ "Remove", "the", "object", "from", "the", "cache", "completely", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L313-L321
[ "def", "Pop", "(", "self", ",", "key", ")", ":", "node", "=", "self", ".", "_hash", ".", "get", "(", "key", ")", "if", "node", ":", "del", "self", ".", "_hash", "[", "key", "]", "self", ".", "_age", ".", "Unlink", "(", "node", ")", "return", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FastStore.Get
Fetch the object from cache. Objects may be flushed from cache at any time. Callers must always handle the possibility of KeyError raised here. Args: key: The key used to access the object. Returns: Cached object. Raises: KeyError: If the object is not present in the cache.
grr/core/grr_response_core/lib/utils.py
def Get(self, key): """Fetch the object from cache. Objects may be flushed from cache at any time. Callers must always handle the possibility of KeyError raised here. Args: key: The key used to access the object. Returns: Cached object. Raises: KeyError: If the object is no...
def Get(self, key): """Fetch the object from cache. Objects may be flushed from cache at any time. Callers must always handle the possibility of KeyError raised here. Args: key: The key used to access the object. Returns: Cached object. Raises: KeyError: If the object is no...
[ "Fetch", "the", "object", "from", "cache", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L324-L347
[ "def", "Get", "(", "self", ",", "key", ")", ":", "if", "key", "not", "in", "self", ".", "_hash", ":", "raise", "KeyError", "(", "key", ")", "node", "=", "self", ".", "_hash", "[", "key", "]", "self", ".", "_age", ".", "Unlink", "(", "node", ")"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FastStore.Flush
Flush all items from cache.
grr/core/grr_response_core/lib/utils.py
def Flush(self): """Flush all items from cache.""" while self._age: node = self._age.PopLeft() self.KillObject(node.data) self._hash = dict()
def Flush(self): """Flush all items from cache.""" while self._age: node = self._age.PopLeft() self.KillObject(node.data) self._hash = dict()
[ "Flush", "all", "items", "from", "cache", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L358-L364
[ "def", "Flush", "(", "self", ")", ":", "while", "self", ".", "_age", ":", "node", "=", "self", ".", "_age", ".", "PopLeft", "(", ")", "self", ".", "KillObject", "(", "node", ".", "data", ")", "self", ".", "_hash", "=", "dict", "(", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Struct.GetSize
Calculate the size of the struct.
grr/core/grr_response_core/lib/utils.py
def GetSize(cls): """Calculate the size of the struct.""" format_str = "".join([x[0] for x in cls._fields]) return struct.calcsize(format_str)
def GetSize(cls): """Calculate the size of the struct.""" format_str = "".join([x[0] for x in cls._fields]) return struct.calcsize(format_str)
[ "Calculate", "the", "size", "of", "the", "struct", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L485-L488
[ "def", "GetSize", "(", "cls", ")", ":", "format_str", "=", "\"\"", ".", "join", "(", "[", "x", "[", "0", "]", "for", "x", "in", "cls", ".", "_fields", "]", ")", "return", "struct", ".", "calcsize", "(", "format_str", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RollingMemoryStream.GetValueAndReset
Gets stream buffer since the last GetValueAndReset() call.
grr/core/grr_response_core/lib/utils.py
def GetValueAndReset(self): """Gets stream buffer since the last GetValueAndReset() call.""" if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to get a value from a closed stream.") value = self._stream.getvalue() self._stream.seek(0) self._stream.truncate() ret...
def GetValueAndReset(self): """Gets stream buffer since the last GetValueAndReset() call.""" if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to get a value from a closed stream.") value = self._stream.getvalue() self._stream.seek(0) self._stream.truncate() ret...
[ "Gets", "stream", "buffer", "since", "the", "last", "GetValueAndReset", "()", "call", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L782-L792
[ "def", "GetValueAndReset", "(", "self", ")", ":", "if", "not", "self", ".", "_stream", ":", "raise", "ArchiveAlreadyClosedError", "(", "\"Attempting to get a value from a closed stream.\"", ")", "value", "=", "self", ".", "_stream", ".", "getvalue", "(", ")", "sel...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingZipGenerator._GenerateZipInfo
Generate ZipInfo instance for the given name, compression and stat. Args: arcname: The name in the archive this should take. compress_type: Compression type (zipfile.ZIP_DEFLATED, or ZIP_STORED) st: An optional stat object to be used for setting headers. Returns: ZipInfo instance. ...
grr/core/grr_response_core/lib/utils.py
def _GenerateZipInfo(self, arcname=None, compress_type=None, st=None): """Generate ZipInfo instance for the given name, compression and stat. Args: arcname: The name in the archive this should take. compress_type: Compression type (zipfile.ZIP_DEFLATED, or ZIP_STORED) st: An optional stat obj...
def _GenerateZipInfo(self, arcname=None, compress_type=None, st=None): """Generate ZipInfo instance for the given name, compression and stat. Args: arcname: The name in the archive this should take. compress_type: Compression type (zipfile.ZIP_DEFLATED, or ZIP_STORED) st: An optional stat obj...
[ "Generate", "ZipInfo", "instance", "for", "the", "given", "name", "compression", "and", "stat", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L828-L877
[ "def", "_GenerateZipInfo", "(", "self", ",", "arcname", "=", "None", ",", "compress_type", "=", "None", ",", "st", "=", "None", ")", ":", "# Fake stat response.", "if", "st", "is", "None", ":", "# TODO(user):pytype: stat_result typing is not correct.", "# pytype: di...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingZipGenerator.WriteSymlink
Writes a symlink into the archive.
grr/core/grr_response_core/lib/utils.py
def WriteSymlink(self, src_arcname, dst_arcname): """Writes a symlink into the archive.""" # Inspired by: # http://www.mail-archive.com/python-list@python.org/msg34223.html if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to write to a ZIP archive that was already close...
def WriteSymlink(self, src_arcname, dst_arcname): """Writes a symlink into the archive.""" # Inspired by: # http://www.mail-archive.com/python-list@python.org/msg34223.html if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to write to a ZIP archive that was already close...
[ "Writes", "a", "symlink", "into", "the", "archive", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L879-L912
[ "def", "WriteSymlink", "(", "self", ",", "src_arcname", ",", "dst_arcname", ")", ":", "# Inspired by:", "# http://www.mail-archive.com/python-list@python.org/msg34223.html", "if", "not", "self", ".", "_stream", ":", "raise", "ArchiveAlreadyClosedError", "(", "\"Attempting t...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingZipGenerator.WriteFileHeader
Writes a file header.
grr/core/grr_response_core/lib/utils.py
def WriteFileHeader(self, arcname=None, compress_type=None, st=None): """Writes a file header.""" if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to write to a ZIP archive that was already closed.") self.cur_zinfo = self._GenerateZipInfo( arcname=arcname, compress...
def WriteFileHeader(self, arcname=None, compress_type=None, st=None): """Writes a file header.""" if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to write to a ZIP archive that was already closed.") self.cur_zinfo = self._GenerateZipInfo( arcname=arcname, compress...
[ "Writes", "a", "file", "header", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L914-L950
[ "def", "WriteFileHeader", "(", "self", ",", "arcname", "=", "None", ",", "compress_type", "=", "None", ",", "st", "=", "None", ")", ":", "if", "not", "self", ".", "_stream", ":", "raise", "ArchiveAlreadyClosedError", "(", "\"Attempting to write to a ZIP archive ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingZipGenerator.WriteFileChunk
Writes file chunk.
grr/core/grr_response_core/lib/utils.py
def WriteFileChunk(self, chunk): """Writes file chunk.""" precondition.AssertType(chunk, bytes) if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to write to a ZIP archive that was already closed.") self.cur_file_size += len(chunk) # TODO(user):pytype: crc32 is not ...
def WriteFileChunk(self, chunk): """Writes file chunk.""" precondition.AssertType(chunk, bytes) if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to write to a ZIP archive that was already closed.") self.cur_file_size += len(chunk) # TODO(user):pytype: crc32 is not ...
[ "Writes", "file", "chunk", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L952-L971
[ "def", "WriteFileChunk", "(", "self", ",", "chunk", ")", ":", "precondition", ".", "AssertType", "(", "chunk", ",", "bytes", ")", "if", "not", "self", ".", "_stream", ":", "raise", "ArchiveAlreadyClosedError", "(", "\"Attempting to write to a ZIP archive that was al...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingZipGenerator.WriteFileFooter
Writes the file footer (finished the file).
grr/core/grr_response_core/lib/utils.py
def WriteFileFooter(self): """Writes the file footer (finished the file).""" if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to write to a ZIP archive that was already closed.") if self.cur_cmpr: buf = self.cur_cmpr.flush() self.cur_compress_size += len(buf) ...
def WriteFileFooter(self): """Writes the file footer (finished the file).""" if not self._stream: raise ArchiveAlreadyClosedError( "Attempting to write to a ZIP archive that was already closed.") if self.cur_cmpr: buf = self.cur_cmpr.flush() self.cur_compress_size += len(buf) ...
[ "Writes", "the", "file", "footer", "(", "finished", "the", "file", ")", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L973-L1016
[ "def", "WriteFileFooter", "(", "self", ")", ":", "if", "not", "self", ".", "_stream", ":", "raise", "ArchiveAlreadyClosedError", "(", "\"Attempting to write to a ZIP archive that was already closed.\"", ")", "if", "self", ".", "cur_cmpr", ":", "buf", "=", "self", "....
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingZipGenerator.WriteFromFD
Write a zip member from a file like object. Args: src_fd: A file like object, must support seek(), tell(), read(). arcname: The name in the archive this should take. compress_type: Compression type (zipfile.ZIP_DEFLATED, or ZIP_STORED) st: An optional stat object to be used for setting head...
grr/core/grr_response_core/lib/utils.py
def WriteFromFD(self, src_fd, arcname=None, compress_type=None, st=None): """Write a zip member from a file like object. Args: src_fd: A file like object, must support seek(), tell(), read(). arcname: The name in the archive this should take. compress_type: Compression type (zipfile.ZIP_DEFLA...
def WriteFromFD(self, src_fd, arcname=None, compress_type=None, st=None): """Write a zip member from a file like object. Args: src_fd: A file like object, must support seek(), tell(), read(). arcname: The name in the archive this should take. compress_type: Compression type (zipfile.ZIP_DEFLA...
[ "Write", "a", "zip", "member", "from", "a", "file", "like", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L1022-L1046
[ "def", "WriteFromFD", "(", "self", ",", "src_fd", ",", "arcname", "=", "None", ",", "compress_type", "=", "None", ",", "st", "=", "None", ")", ":", "yield", "self", ".", "WriteFileHeader", "(", "arcname", "=", "arcname", ",", "compress_type", "=", "compr...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingTarGenerator.WriteSymlink
Writes a symlink into the archive.
grr/core/grr_response_core/lib/utils.py
def WriteSymlink(self, src_arcname, dst_arcname): """Writes a symlink into the archive.""" info = self._tar_fd.tarinfo() info.tarfile = self._tar_fd info.name = SmartStr(dst_arcname) info.size = 0 info.mtime = time.time() info.type = tarfile.SYMTYPE info.linkname = SmartStr(src_arcname)...
def WriteSymlink(self, src_arcname, dst_arcname): """Writes a symlink into the archive.""" info = self._tar_fd.tarinfo() info.tarfile = self._tar_fd info.name = SmartStr(dst_arcname) info.size = 0 info.mtime = time.time() info.type = tarfile.SYMTYPE info.linkname = SmartStr(src_arcname)...
[ "Writes", "a", "symlink", "into", "the", "archive", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L1099-L1111
[ "def", "WriteSymlink", "(", "self", ",", "src_arcname", ",", "dst_arcname", ")", ":", "info", "=", "self", ".", "_tar_fd", ".", "tarinfo", "(", ")", "info", ".", "tarfile", "=", "self", ".", "_tar_fd", "info", ".", "name", "=", "SmartStr", "(", "dst_ar...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingTarGenerator.WriteFileHeader
Writes file header.
grr/core/grr_response_core/lib/utils.py
def WriteFileHeader(self, arcname=None, st=None): """Writes file header.""" if st is None: raise ValueError("Stat object can't be None.") self.cur_file_size = 0 self.cur_info = self._tar_fd.tarinfo() self.cur_info.tarfile = self._tar_fd self.cur_info.type = tarfile.REGTYPE self.cur_...
def WriteFileHeader(self, arcname=None, st=None): """Writes file header.""" if st is None: raise ValueError("Stat object can't be None.") self.cur_file_size = 0 self.cur_info = self._tar_fd.tarinfo() self.cur_info.tarfile = self._tar_fd self.cur_info.type = tarfile.REGTYPE self.cur_...
[ "Writes", "file", "header", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L1113-L1131
[ "def", "WriteFileHeader", "(", "self", ",", "arcname", "=", "None", ",", "st", "=", "None", ")", ":", "if", "st", "is", "None", ":", "raise", "ValueError", "(", "\"Stat object can't be None.\"", ")", "self", ".", "cur_file_size", "=", "0", "self", ".", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingTarGenerator.WriteFileChunk
Writes file chunk.
grr/core/grr_response_core/lib/utils.py
def WriteFileChunk(self, chunk): """Writes file chunk.""" self._tar_fd.fileobj.write(chunk) self.cur_file_size += len(chunk) return self._stream.GetValueAndReset()
def WriteFileChunk(self, chunk): """Writes file chunk.""" self._tar_fd.fileobj.write(chunk) self.cur_file_size += len(chunk) return self._stream.GetValueAndReset()
[ "Writes", "file", "chunk", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L1133-L1138
[ "def", "WriteFileChunk", "(", "self", ",", "chunk", ")", ":", "self", ".", "_tar_fd", ".", "fileobj", ".", "write", "(", "chunk", ")", "self", ".", "cur_file_size", "+=", "len", "(", "chunk", ")", "return", "self", ".", "_stream", ".", "GetValueAndReset"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StreamingTarGenerator.WriteFileFooter
Writes file footer (finishes the file).
grr/core/grr_response_core/lib/utils.py
def WriteFileFooter(self): """Writes file footer (finishes the file).""" if self.cur_file_size != self.cur_info.size: raise IOError("Incorrect file size: st_size=%d, but written %d bytes." % (self.cur_info.size, self.cur_file_size)) # TODO(user):pytype: BLOCKSIZE/NUL constants ar...
def WriteFileFooter(self): """Writes file footer (finishes the file).""" if self.cur_file_size != self.cur_info.size: raise IOError("Incorrect file size: st_size=%d, but written %d bytes." % (self.cur_info.size, self.cur_file_size)) # TODO(user):pytype: BLOCKSIZE/NUL constants ar...
[ "Writes", "file", "footer", "(", "finishes", "the", "file", ")", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/utils.py#L1140-L1159
[ "def", "WriteFileFooter", "(", "self", ")", ":", "if", "self", ".", "cur_file_size", "!=", "self", ".", "cur_info", ".", "size", ":", "raise", "IOError", "(", "\"Incorrect file size: st_size=%d, but written %d bytes.\"", "%", "(", "self", ".", "cur_info", ".", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrUserBase.Get
Fetches user's data and returns it wrapped in a Grruser object.
api_client/python/grr_api_client/root.py
def Get(self): """Fetches user's data and returns it wrapped in a Grruser object.""" args = user_management_pb2.ApiGetGrrUserArgs(username=self.username) data = self._context.SendRequest("GetGrrUser", args) return GrrUser(data=data, context=self._context)
def Get(self): """Fetches user's data and returns it wrapped in a Grruser object.""" args = user_management_pb2.ApiGetGrrUserArgs(username=self.username) data = self._context.SendRequest("GetGrrUser", args) return GrrUser(data=data, context=self._context)
[ "Fetches", "user", "s", "data", "and", "returns", "it", "wrapped", "in", "a", "Grruser", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/root.py#L31-L36
[ "def", "Get", "(", "self", ")", ":", "args", "=", "user_management_pb2", ".", "ApiGetGrrUserArgs", "(", "username", "=", "self", ".", "username", ")", "data", "=", "self", ".", "_context", ".", "SendRequest", "(", "\"GetGrrUser\"", ",", "args", ")", "retur...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrUserBase.Delete
Deletes the user.
api_client/python/grr_api_client/root.py
def Delete(self): """Deletes the user.""" args = user_management_pb2.ApiDeleteGrrUserArgs(username=self.username) self._context.SendRequest("DeleteGrrUser", args)
def Delete(self): """Deletes the user.""" args = user_management_pb2.ApiDeleteGrrUserArgs(username=self.username) self._context.SendRequest("DeleteGrrUser", args)
[ "Deletes", "the", "user", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/root.py#L38-L42
[ "def", "Delete", "(", "self", ")", ":", "args", "=", "user_management_pb2", ".", "ApiDeleteGrrUserArgs", "(", "username", "=", "self", ".", "username", ")", "self", ".", "_context", ".", "SendRequest", "(", "\"DeleteGrrUser\"", ",", "args", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrUserBase.Modify
Modifies user's type and/or password.
api_client/python/grr_api_client/root.py
def Modify(self, user_type=None, password=None): """Modifies user's type and/or password.""" args = user_management_pb2.ApiModifyGrrUserArgs( username=self.username, user_type=user_type) if user_type is not None: args.user_type = user_type if password is not None: args.password = ...
def Modify(self, user_type=None, password=None): """Modifies user's type and/or password.""" args = user_management_pb2.ApiModifyGrrUserArgs( username=self.username, user_type=user_type) if user_type is not None: args.user_type = user_type if password is not None: args.password = ...
[ "Modifies", "user", "s", "type", "and", "/", "or", "password", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/root.py#L44-L57
[ "def", "Modify", "(", "self", ",", "user_type", "=", "None", ",", "password", "=", "None", ")", ":", "args", "=", "user_management_pb2", ".", "ApiModifyGrrUserArgs", "(", "username", "=", "self", ".", "username", ",", "user_type", "=", "user_type", ")", "i...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrBinaryRef.Upload
Uploads data from a given stream and signs them with a given key.
api_client/python/grr_api_client/root.py
def Upload(self, fd, sign_fn=None): """Uploads data from a given stream and signs them with a given key.""" if not sign_fn: raise ValueError("sign_fn can't be empty. " "See DefaultUploadSigner as a possible option.") args = binary_management_pb2.ApiUploadGrrBinaryArgs( ...
def Upload(self, fd, sign_fn=None): """Uploads data from a given stream and signs them with a given key.""" if not sign_fn: raise ValueError("sign_fn can't be empty. " "See DefaultUploadSigner as a possible option.") args = binary_management_pb2.ApiUploadGrrBinaryArgs( ...
[ "Uploads", "data", "from", "a", "given", "stream", "and", "signs", "them", "with", "a", "given", "key", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/root.py#L104-L129
[ "def", "Upload", "(", "self", ",", "fd", ",", "sign_fn", "=", "None", ")", ":", "if", "not", "sign_fn", ":", "raise", "ValueError", "(", "\"sign_fn can't be empty. \"", "\"See DefaultUploadSigner as a possible option.\"", ")", "args", "=", "binary_management_pb2", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RootGrrApi.CreateGrrUser
Creates a new GRR user of a given type with a given username/password.
api_client/python/grr_api_client/root.py
def CreateGrrUser(self, username=None, user_type=None, password=None): """Creates a new GRR user of a given type with a given username/password.""" if not username: raise ValueError("Username can't be empty.") args = user_management_pb2.ApiCreateGrrUserArgs(username=username) if user_type is no...
def CreateGrrUser(self, username=None, user_type=None, password=None): """Creates a new GRR user of a given type with a given username/password.""" if not username: raise ValueError("Username can't be empty.") args = user_management_pb2.ApiCreateGrrUserArgs(username=username) if user_type is no...
[ "Creates", "a", "new", "GRR", "user", "of", "a", "given", "type", "with", "a", "given", "username", "/", "password", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/root.py#L144-L159
[ "def", "CreateGrrUser", "(", "self", ",", "username", "=", "None", ",", "user_type", "=", "None", ",", "password", "=", "None", ")", ":", "if", "not", "username", ":", "raise", "ValueError", "(", "\"Username can't be empty.\"", ")", "args", "=", "user_manage...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RootGrrApi.ListGrrUsers
Lists all registered GRR users.
api_client/python/grr_api_client/root.py
def ListGrrUsers(self): """Lists all registered GRR users.""" args = user_management_pb2.ApiListGrrUsersArgs() items = self._context.SendIteratorRequest("ListGrrUsers", args) return utils.MapItemsIterator( lambda data: GrrUser(data=data, context=self._context), items)
def ListGrrUsers(self): """Lists all registered GRR users.""" args = user_management_pb2.ApiListGrrUsersArgs() items = self._context.SendIteratorRequest("ListGrrUsers", args) return utils.MapItemsIterator( lambda data: GrrUser(data=data, context=self._context), items)
[ "Lists", "all", "registered", "GRR", "users", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/root.py#L166-L173
[ "def", "ListGrrUsers", "(", "self", ")", ":", "args", "=", "user_management_pb2", ".", "ApiListGrrUsersArgs", "(", ")", "items", "=", "self", ".", "_context", ".", "SendIteratorRequest", "(", "\"ListGrrUsers\"", ",", "args", ")", "return", "utils", ".", "MapIt...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetAuditLogEntries
Return all audit log entries between now-offset and now. Args: offset: rdfvalue.Duration how far back to look in time now: rdfvalue.RDFDatetime for current time token: GRR access token Yields: AuditEvents created during the time range
grr/server/grr_response_server/gui/api_plugins/report_plugins/report_utils.py
def GetAuditLogEntries(offset, now, token): """Return all audit log entries between now-offset and now. Args: offset: rdfvalue.Duration how far back to look in time now: rdfvalue.RDFDatetime for current time token: GRR access token Yields: AuditEvents created during the time range """ start_t...
def GetAuditLogEntries(offset, now, token): """Return all audit log entries between now-offset and now. Args: offset: rdfvalue.Duration how far back to look in time now: rdfvalue.RDFDatetime for current time token: GRR access token Yields: AuditEvents created during the time range """ start_t...
[ "Return", "all", "audit", "log", "entries", "between", "now", "-", "offset", "and", "now", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/report_utils.py#L10-L25
[ "def", "GetAuditLogEntries", "(", "offset", ",", "now", ",", "token", ")", ":", "start_time", "=", "now", "-", "offset", "-", "audit", ".", "AUDIT_ROLLOVER_TIME", "for", "fd", "in", "audit", ".", "LegacyAuditLogsForTimespan", "(", "start_time", ",", "now", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_IterateAllClients
Fetches client data from the relational db. Args: recency_window: An rdfvalue.Duration specifying a window of last-ping timestamps to consider. Clients that haven't communicated with GRR servers longer than the given period will be skipped. If recency_window is None, all clients will be iterate...
grr/server/grr_response_server/flows/cron/system.py
def _IterateAllClients(recency_window=None): """Fetches client data from the relational db. Args: recency_window: An rdfvalue.Duration specifying a window of last-ping timestamps to consider. Clients that haven't communicated with GRR servers longer than the given period will be skipped. If recency...
def _IterateAllClients(recency_window=None): """Fetches client data from the relational db. Args: recency_window: An rdfvalue.Duration specifying a window of last-ping timestamps to consider. Clients that haven't communicated with GRR servers longer than the given period will be skipped. If recency...
[ "Fetches", "client", "data", "from", "the", "relational", "db", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/system.py#L112-L132
[ "def", "_IterateAllClients", "(", "recency_window", "=", "None", ")", ":", "if", "recency_window", "is", "None", ":", "min_last_ping", "=", "None", "else", ":", "min_last_ping", "=", "rdfvalue", ".", "RDFDatetime", ".", "Now", "(", ")", "-", "recency_window", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ActiveCounter.Add
Adds another instance of this category into the active_days counter. We automatically count the event towards all relevant active_days. For example, if the category "Windows" was seen 8 days ago it will be counted towards the 30 day active, 14 day active but not against the 7 and 1 day actives. Ar...
grr/server/grr_response_server/flows/cron/system.py
def Add(self, category, label, age): """Adds another instance of this category into the active_days counter. We automatically count the event towards all relevant active_days. For example, if the category "Windows" was seen 8 days ago it will be counted towards the 30 day active, 14 day active but not ...
def Add(self, category, label, age): """Adds another instance of this category into the active_days counter. We automatically count the event towards all relevant active_days. For example, if the category "Windows" was seen 8 days ago it will be counted towards the 30 day active, 14 day active but not ...
[ "Adds", "another", "instance", "of", "this", "category", "into", "the", "active_days", "counter", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/system.py#L70-L90
[ "def", "Add", "(", "self", ",", "category", ",", "label", ",", "age", ")", ":", "now", "=", "rdfvalue", ".", "RDFDatetime", ".", "Now", "(", ")", "category", "=", "utils", ".", "SmartUnicode", "(", "category", ")", "for", "active_time", "in", "self", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ActiveCounter.Save
Generate a histogram object and store in the specified attribute.
grr/server/grr_response_server/flows/cron/system.py
def Save(self, token=None): """Generate a histogram object and store in the specified attribute.""" graph_series_by_label = {} for active_time in self.active_days: for label in self.categories[active_time]: graphs_for_label = graph_series_by_label.setdefault( label, rdf_stats.Clien...
def Save(self, token=None): """Generate a histogram object and store in the specified attribute.""" graph_series_by_label = {} for active_time in self.active_days: for label in self.categories[active_time]: graphs_for_label = graph_series_by_label.setdefault( label, rdf_stats.Clien...
[ "Generate", "a", "histogram", "object", "and", "store", "in", "the", "specified", "attribute", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/system.py#L92-L106
[ "def", "Save", "(", "self", ",", "token", "=", "None", ")", ":", "graph_series_by_label", "=", "{", "}", "for", "active_time", "in", "self", ".", "active_days", ":", "for", "label", "in", "self", ".", "categories", "[", "active_time", "]", ":", "graphs_f...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AbstractClientStatsCronJob.Run
Retrieve all the clients for the AbstractClientStatsCollectors.
grr/server/grr_response_server/flows/cron/system.py
def Run(self): """Retrieve all the clients for the AbstractClientStatsCollectors.""" try: self.stats = {} self.BeginProcessing() processed_count = 0 for client_info_batch in _IterateAllClients( recency_window=self.recency_window): for client_info in client_info_batc...
def Run(self): """Retrieve all the clients for the AbstractClientStatsCollectors.""" try: self.stats = {} self.BeginProcessing() processed_count = 0 for client_info_batch in _IterateAllClients( recency_window=self.recency_window): for client_info in client_info_batc...
[ "Retrieve", "all", "the", "clients", "for", "the", "AbstractClientStatsCollectors", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/system.py#L167-L193
[ "def", "Run", "(", "self", ")", ":", "try", ":", "self", ".", "stats", "=", "{", "}", "self", ".", "BeginProcessing", "(", ")", "processed_count", "=", "0", "for", "client_info_batch", "in", "_IterateAllClients", "(", "recency_window", "=", "self", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74