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
StartHunt
This class method creates new hunts.
grr/server/grr_response_server/hunts/implementation.py
def StartHunt(args=None, runner_args=None, token=None, **kwargs): """This class method creates new hunts.""" # If no token is specified, raise. if not token: raise access_control.UnauthorizedAccess("A token must be specified.") # Build the runner args from the keywords. if runner_args is None: runne...
def StartHunt(args=None, runner_args=None, token=None, **kwargs): """This class method creates new hunts.""" # If no token is specified, raise. if not token: raise access_control.UnauthorizedAccess("A token must be specified.") # Build the runner args from the keywords. if runner_args is None: runne...
[ "This", "class", "method", "creates", "new", "hunts", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L52-L112
[ "def", "StartHunt", "(", "args", "=", "None", ",", "runner_args", "=", "None", ",", "token", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# If no token is specified, raise.", "if", "not", "token", ":", "raise", "access_control", ".", "UnauthorizedAccess", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.ProcessCompletedRequests
Go through the list of requests and process the completed ones. We take a snapshot in time of all requests and responses for this hunt. We then process as many completed requests as possible. If responses are not quite here we leave it for next time. Args: notification: The notification object t...
grr/server/grr_response_server/hunts/implementation.py
def ProcessCompletedRequests(self, notification, thread_pool): """Go through the list of requests and process the completed ones. We take a snapshot in time of all requests and responses for this hunt. We then process as many completed requests as possible. If responses are not quite here we leave it f...
def ProcessCompletedRequests(self, notification, thread_pool): """Go through the list of requests and process the completed ones. We take a snapshot in time of all requests and responses for this hunt. We then process as many completed requests as possible. If responses are not quite here we leave it f...
[ "Go", "through", "the", "list", "of", "requests", "and", "process", "the", "completed", "ones", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L187-L261
[ "def", "ProcessCompletedRequests", "(", "self", ",", "notification", ",", "thread_pool", ")", ":", "# First ensure that client messages are all removed. NOTE: We make a new", "# queue manager here because we want only the client messages to be removed", "# ASAP. This must happen before we ac...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.RunStateMethod
Completes the request by calling the state method. Args: method_name: The name of the state method to call. request: A RequestState protobuf. responses: A list of GrrMessages responding to the request. event: A threading.Event() instance to signal completion of this request. direct_re...
grr/server/grr_response_server/hunts/implementation.py
def RunStateMethod(self, method_name, request=None, responses=None, event=None, direct_response=None): """Completes the request by calling the state method. Args: method_name: The name of the state me...
def RunStateMethod(self, method_name, request=None, responses=None, event=None, direct_response=None): """Completes the request by calling the state method. Args: method_name: The name of the state me...
[ "Completes", "the", "request", "by", "calling", "the", "state", "method", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L263-L331
[ "def", "RunStateMethod", "(", "self", ",", "method_name", ",", "request", "=", "None", ",", "responses", "=", "None", ",", "event", "=", "None", ",", "direct_response", "=", "None", ")", ":", "client_id", "=", "None", "try", ":", "self", ".", "context", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.Publish
Sends the message to event listeners.
grr/server/grr_response_server/hunts/implementation.py
def Publish(self, event_name, msg, delay=0): """Sends the message to event listeners.""" events_lib.Events.PublishEvent(event_name, msg, delay=delay)
def Publish(self, event_name, msg, delay=0): """Sends the message to event listeners.""" events_lib.Events.PublishEvent(event_name, msg, delay=delay)
[ "Sends", "the", "message", "to", "event", "listeners", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L339-L341
[ "def", "Publish", "(", "self", ",", "event_name", ",", "msg", ",", "delay", "=", "0", ")", ":", "events_lib", ".", "Events", ".", "PublishEvent", "(", "event_name", ",", "msg", ",", "delay", "=", "delay", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner._GetSubFlowCPULimit
Get current CPU limit for subflows.
grr/server/grr_response_server/hunts/implementation.py
def _GetSubFlowCPULimit(self): """Get current CPU limit for subflows.""" subflow_cpu_limit = None if self.runner_args.per_client_cpu_limit: subflow_cpu_limit = self.runner_args.per_client_cpu_limit if self.runner_args.cpu_limit: cpu_usage_data = self.context.client_resources.cpu_usage ...
def _GetSubFlowCPULimit(self): """Get current CPU limit for subflows.""" subflow_cpu_limit = None if self.runner_args.per_client_cpu_limit: subflow_cpu_limit = self.runner_args.per_client_cpu_limit if self.runner_args.cpu_limit: cpu_usage_data = self.context.client_resources.cpu_usage ...
[ "Get", "current", "CPU", "limit", "for", "subflows", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L343-L364
[ "def", "_GetSubFlowCPULimit", "(", "self", ")", ":", "subflow_cpu_limit", "=", "None", "if", "self", ".", "runner_args", ".", "per_client_cpu_limit", ":", "subflow_cpu_limit", "=", "self", ".", "runner_args", ".", "per_client_cpu_limit", "if", "self", ".", "runner...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner._GetSubFlowNetworkLimit
Get current network limit for subflows.
grr/server/grr_response_server/hunts/implementation.py
def _GetSubFlowNetworkLimit(self): """Get current network limit for subflows.""" subflow_network_limit = None if self.runner_args.per_client_network_limit_bytes: subflow_network_limit = self.runner_args.per_client_network_limit_bytes if self.runner_args.network_bytes_limit: remaining_netw...
def _GetSubFlowNetworkLimit(self): """Get current network limit for subflows.""" subflow_network_limit = None if self.runner_args.per_client_network_limit_bytes: subflow_network_limit = self.runner_args.per_client_network_limit_bytes if self.runner_args.network_bytes_limit: remaining_netw...
[ "Get", "current", "network", "limit", "for", "subflows", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L366-L384
[ "def", "_GetSubFlowNetworkLimit", "(", "self", ")", ":", "subflow_network_limit", "=", "None", "if", "self", ".", "runner_args", ".", "per_client_network_limit_bytes", ":", "subflow_network_limit", "=", "self", ".", "runner_args", ".", "per_client_network_limit_bytes", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner._CallFlowLegacy
Creates a new flow and send its responses to a state. This creates a new flow. The flow may send back many responses which will be queued by the framework until the flow terminates. The final status message will cause the entire transaction to be committed to the specified state. Args: flow_nam...
grr/server/grr_response_server/hunts/implementation.py
def _CallFlowLegacy(self, flow_name=None, next_state=None, request_data=None, client_id=None, base_session_id=None, **kwargs): """Creates a new flow and send its responses to a state. ...
def _CallFlowLegacy(self, flow_name=None, next_state=None, request_data=None, client_id=None, base_session_id=None, **kwargs): """Creates a new flow and send its responses to a state. ...
[ "Creates", "a", "new", "flow", "and", "send", "its", "responses", "to", "a", "state", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L386-L463
[ "def", "_CallFlowLegacy", "(", "self", ",", "flow_name", "=", "None", ",", "next_state", "=", "None", ",", "request_data", "=", "None", ",", "client_id", "=", "None", ",", "base_session_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "client_id", "=...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner._CallFlowRelational
Creates a new flow and send its responses to a state. This creates a new flow. The flow may send back many responses which will be queued by the framework until the flow terminates. The final status message will cause the entire transaction to be committed to the specified state. Args: flow_nam...
grr/server/grr_response_server/hunts/implementation.py
def _CallFlowRelational(self, flow_name=None, args=None, runner_args=None, client_id=None, **kwargs): """Creates a new flow and send its responses to a state. This creates a new flo...
def _CallFlowRelational(self, flow_name=None, args=None, runner_args=None, client_id=None, **kwargs): """Creates a new flow and send its responses to a state. This creates a new flo...
[ "Creates", "a", "new", "flow", "and", "send", "its", "responses", "to", "a", "state", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L465-L508
[ "def", "_CallFlowRelational", "(", "self", ",", "flow_name", "=", "None", ",", "args", "=", "None", ",", "runner_args", "=", "None", ",", "client_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "client_id", ",", "rdfvalue", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.CallFlow
Creates a new flow and send its responses to a state. This creates a new flow. The flow may send back many responses which will be queued by the framework until the flow terminates. The final status message will cause the entire transaction to be committed to the specified state. Args: flow_nam...
grr/server/grr_response_server/hunts/implementation.py
def CallFlow(self, flow_name=None, next_state=None, request_data=None, client_id=None, base_session_id=None, **kwargs): """Creates a new flow and send its responses to a state. This creates a new flow. The flow may send b...
def CallFlow(self, flow_name=None, next_state=None, request_data=None, client_id=None, base_session_id=None, **kwargs): """Creates a new flow and send its responses to a state. This creates a new flow. The flow may send b...
[ "Creates", "a", "new", "flow", "and", "send", "its", "responses", "to", "a", "state", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L510-L556
[ "def", "CallFlow", "(", "self", ",", "flow_name", "=", "None", ",", "next_state", "=", "None", ",", "request_data", "=", "None", ",", "client_id", "=", "None", ",", "base_session_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "data_store", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner._Process
Hunts process all responses concurrently in a threadpool.
grr/server/grr_response_server/hunts/implementation.py
def _Process(self, request, responses, thread_pool=None, events=None): """Hunts process all responses concurrently in a threadpool.""" # This function is called and runs within the main processing thread. We do # not need to lock the hunt object while running in this method. if request.next_state == "Ad...
def _Process(self, request, responses, thread_pool=None, events=None): """Hunts process all responses concurrently in a threadpool.""" # This function is called and runs within the main processing thread. We do # not need to lock the hunt object while running in this method. if request.next_state == "Ad...
[ "Hunts", "process", "all", "responses", "concurrently", "in", "a", "threadpool", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L672-L729
[ "def", "_Process", "(", "self", ",", "request", ",", "responses", ",", "thread_pool", "=", "None", ",", "events", "=", "None", ")", ":", "# This function is called and runs within the main processing thread. We do", "# not need to lock the hunt object while running in this meth...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.Log
Logs the message using the hunt's standard logging. Args: format_str: Format string *args: arguments to the format string Raises: RuntimeError: on parent missing logs_collection
grr/server/grr_response_server/hunts/implementation.py
def Log(self, format_str, *args): """Logs the message using the hunt's standard logging. Args: format_str: Format string *args: arguments to the format string Raises: RuntimeError: on parent missing logs_collection """ format_str = utils.SmartUnicode(format_str) status = for...
def Log(self, format_str, *args): """Logs the message using the hunt's standard logging. Args: format_str: Format string *args: arguments to the format string Raises: RuntimeError: on parent missing logs_collection """ format_str = utils.SmartUnicode(format_str) status = for...
[ "Logs", "the", "message", "using", "the", "hunt", "s", "standard", "logging", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L731-L765
[ "def", "Log", "(", "self", ",", "format_str", ",", "*", "args", ")", ":", "format_str", "=", "utils", ".", "SmartUnicode", "(", "format_str", ")", "status", "=", "format_str", "if", "args", ":", "try", ":", "# The status message is always in unicode", "status"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.Error
Logs an error for a client but does not terminate the hunt.
grr/server/grr_response_server/hunts/implementation.py
def Error(self, backtrace, client_id=None): """Logs an error for a client but does not terminate the hunt.""" logging.error("Hunt Error: %s", backtrace) self.hunt_obj.LogClientError(client_id, backtrace=backtrace)
def Error(self, backtrace, client_id=None): """Logs an error for a client but does not terminate the hunt.""" logging.error("Hunt Error: %s", backtrace) self.hunt_obj.LogClientError(client_id, backtrace=backtrace)
[ "Logs", "an", "error", "for", "a", "client", "but", "does", "not", "terminate", "the", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L767-L770
[ "def", "Error", "(", "self", ",", "backtrace", ",", "client_id", "=", "None", ")", ":", "logging", ".", "error", "(", "\"Hunt Error: %s\"", ",", "backtrace", ")", "self", ".", "hunt_obj", ".", "LogClientError", "(", "client_id", ",", "backtrace", "=", "bac...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.SaveResourceUsage
Update the resource usage of the hunt.
grr/server/grr_response_server/hunts/implementation.py
def SaveResourceUsage(self, client_id, status): """Update the resource usage of the hunt.""" # Per client stats. self.hunt_obj.ProcessClientResourcesStats(client_id, status) # Overall hunt resource usage. self.UpdateProtoResources(status)
def SaveResourceUsage(self, client_id, status): """Update the resource usage of the hunt.""" # Per client stats. self.hunt_obj.ProcessClientResourcesStats(client_id, status) # Overall hunt resource usage. self.UpdateProtoResources(status)
[ "Update", "the", "resource", "usage", "of", "the", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L772-L777
[ "def", "SaveResourceUsage", "(", "self", ",", "client_id", ",", "status", ")", ":", "# Per client stats.", "self", ".", "hunt_obj", ".", "ProcessClientResourcesStats", "(", "client_id", ",", "status", ")", "# Overall hunt resource usage.", "self", ".", "UpdateProtoRes...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.InitializeContext
Initializes the context of this hunt.
grr/server/grr_response_server/hunts/implementation.py
def InitializeContext(self, args): """Initializes the context of this hunt.""" if args is None: args = rdf_hunts.HuntRunnerArgs() context = rdf_hunts.HuntContext( create_time=rdfvalue.RDFDatetime.Now(), creator=self.token.username, duration=args.expiry_time, start_time...
def InitializeContext(self, args): """Initializes the context of this hunt.""" if args is None: args = rdf_hunts.HuntRunnerArgs() context = rdf_hunts.HuntContext( create_time=rdfvalue.RDFDatetime.Now(), creator=self.token.username, duration=args.expiry_time, start_time...
[ "Initializes", "the", "context", "of", "this", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L779-L791
[ "def", "InitializeContext", "(", "self", ",", "args", ")", ":", "if", "args", "is", "None", ":", "args", "=", "rdf_hunts", ".", "HuntRunnerArgs", "(", ")", "context", "=", "rdf_hunts", ".", "HuntContext", "(", "create_time", "=", "rdfvalue", ".", "RDFDatet...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.GetNewSessionID
Returns a random integer session ID for this hunt. All hunts are created under the aff4:/hunts namespace. Returns: a formatted session id string.
grr/server/grr_response_server/hunts/implementation.py
def GetNewSessionID(self, **_): """Returns a random integer session ID for this hunt. All hunts are created under the aff4:/hunts namespace. Returns: a formatted session id string. """ return rdfvalue.SessionID(base="aff4:/hunts", queue=self.runner_args.queue)
def GetNewSessionID(self, **_): """Returns a random integer session ID for this hunt. All hunts are created under the aff4:/hunts namespace. Returns: a formatted session id string. """ return rdfvalue.SessionID(base="aff4:/hunts", queue=self.runner_args.queue)
[ "Returns", "a", "random", "integer", "session", "ID", "for", "this", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L793-L801
[ "def", "GetNewSessionID", "(", "self", ",", "*", "*", "_", ")", ":", "return", "rdfvalue", ".", "SessionID", "(", "base", "=", "\"aff4:/hunts\"", ",", "queue", "=", "self", ".", "runner_args", ".", "queue", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.Start
This uploads the rules to the foreman and, thus, starts the hunt.
grr/server/grr_response_server/hunts/implementation.py
def Start(self): """This uploads the rules to the foreman and, thus, starts the hunt.""" # We are already running. if self.hunt_obj.Get(self.hunt_obj.Schema.STATE) == "STARTED": return # Determine when this hunt will expire. self.context.duration = self.runner_args.expiry_time # When the...
def Start(self): """This uploads the rules to the foreman and, thus, starts the hunt.""" # We are already running. if self.hunt_obj.Get(self.hunt_obj.Schema.STATE) == "STARTED": return # Determine when this hunt will expire. self.context.duration = self.runner_args.expiry_time # When the...
[ "This", "uploads", "the", "rules", "to", "the", "foreman", "and", "thus", "starts", "the", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L811-L831
[ "def", "Start", "(", "self", ")", ":", "# We are already running.", "if", "self", ".", "hunt_obj", ".", "Get", "(", "self", ".", "hunt_obj", ".", "Schema", ".", "STATE", ")", "==", "\"STARTED\"", ":", "return", "# Determine when this hunt will expire.", "self", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner._AddForemanRule
Adds a foreman rule for this hunt.
grr/server/grr_response_server/hunts/implementation.py
def _AddForemanRule(self): """Adds a foreman rule for this hunt.""" if data_store.RelationalDBEnabled(): # Relational DB uses ForemanCondition objects. foreman_condition = foreman_rules.ForemanCondition( creation_time=rdfvalue.RDFDatetime.Now(), expiration_time=self.context.init_...
def _AddForemanRule(self): """Adds a foreman rule for this hunt.""" if data_store.RelationalDBEnabled(): # Relational DB uses ForemanCondition objects. foreman_condition = foreman_rules.ForemanCondition( creation_time=rdfvalue.RDFDatetime.Now(), expiration_time=self.context.init_...
[ "Adds", "a", "foreman", "rule", "for", "this", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L833-L876
[ "def", "_AddForemanRule", "(", "self", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "# Relational DB uses ForemanCondition objects.", "foreman_condition", "=", "foreman_rules", ".", "ForemanCondition", "(", "creation_time", "=", "rdfvalue", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner._RemoveForemanRule
Removes the foreman rule corresponding to this hunt.
grr/server/grr_response_server/hunts/implementation.py
def _RemoveForemanRule(self): """Removes the foreman rule corresponding to this hunt.""" if data_store.RelationalDBEnabled(): data_store.REL_DB.RemoveForemanRule(hunt_id=self.session_id.Basename()) return with aff4.FACTORY.Open( "aff4:/foreman", mode="rw", token=self.token) as foreman: ...
def _RemoveForemanRule(self): """Removes the foreman rule corresponding to this hunt.""" if data_store.RelationalDBEnabled(): data_store.REL_DB.RemoveForemanRule(hunt_id=self.session_id.Basename()) return with aff4.FACTORY.Open( "aff4:/foreman", mode="rw", token=self.token) as foreman: ...
[ "Removes", "the", "foreman", "rule", "corresponding", "to", "this", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L878-L890
[ "def", "_RemoveForemanRule", "(", "self", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "data_store", ".", "REL_DB", ".", "RemoveForemanRule", "(", "hunt_id", "=", "self", ".", "session_id", ".", "Basename", "(", ")", ")", "return"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner._Complete
Marks the hunt as completed.
grr/server/grr_response_server/hunts/implementation.py
def _Complete(self): """Marks the hunt as completed.""" self._RemoveForemanRule() if "w" in self.hunt_obj.mode: self.hunt_obj.Set(self.hunt_obj.Schema.STATE("COMPLETED")) self.hunt_obj.Flush()
def _Complete(self): """Marks the hunt as completed.""" self._RemoveForemanRule() if "w" in self.hunt_obj.mode: self.hunt_obj.Set(self.hunt_obj.Schema.STATE("COMPLETED")) self.hunt_obj.Flush()
[ "Marks", "the", "hunt", "as", "completed", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L892-L897
[ "def", "_Complete", "(", "self", ")", ":", "self", ".", "_RemoveForemanRule", "(", ")", "if", "\"w\"", "in", "self", ".", "hunt_obj", ".", "mode", ":", "self", ".", "hunt_obj", ".", "Set", "(", "self", ".", "hunt_obj", ".", "Schema", ".", "STATE", "(...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.Pause
Pauses the hunt (removes Foreman rules, does not touch expiry time).
grr/server/grr_response_server/hunts/implementation.py
def Pause(self): """Pauses the hunt (removes Foreman rules, does not touch expiry time).""" if not self.IsHuntStarted(): return self._RemoveForemanRule() self.hunt_obj.Set(self.hunt_obj.Schema.STATE("PAUSED")) self.hunt_obj.Flush() self._CreateAuditEvent("HUNT_PAUSED")
def Pause(self): """Pauses the hunt (removes Foreman rules, does not touch expiry time).""" if not self.IsHuntStarted(): return self._RemoveForemanRule() self.hunt_obj.Set(self.hunt_obj.Schema.STATE("PAUSED")) self.hunt_obj.Flush() self._CreateAuditEvent("HUNT_PAUSED")
[ "Pauses", "the", "hunt", "(", "removes", "Foreman", "rules", "does", "not", "touch", "expiry", "time", ")", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L899-L909
[ "def", "Pause", "(", "self", ")", ":", "if", "not", "self", ".", "IsHuntStarted", "(", ")", ":", "return", "self", ".", "_RemoveForemanRule", "(", ")", "self", ".", "hunt_obj", ".", "Set", "(", "self", ".", "hunt_obj", ".", "Schema", ".", "STATE", "(...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.Stop
Cancels the hunt (removes Foreman rules, resets expiry time to 0).
grr/server/grr_response_server/hunts/implementation.py
def Stop(self, reason=None): """Cancels the hunt (removes Foreman rules, resets expiry time to 0).""" self._RemoveForemanRule() self.hunt_obj.Set(self.hunt_obj.Schema.STATE("STOPPED")) self.hunt_obj.Flush() self._CreateAuditEvent("HUNT_STOPPED") if reason: notification_lib.Notify( ...
def Stop(self, reason=None): """Cancels the hunt (removes Foreman rules, resets expiry time to 0).""" self._RemoveForemanRule() self.hunt_obj.Set(self.hunt_obj.Schema.STATE("STOPPED")) self.hunt_obj.Flush() self._CreateAuditEvent("HUNT_STOPPED") if reason: notification_lib.Notify( ...
[ "Cancels", "the", "hunt", "(", "removes", "Foreman", "rules", "resets", "expiry", "time", "to", "0", ")", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L911-L926
[ "def", "Stop", "(", "self", ",", "reason", "=", "None", ")", ":", "self", ".", "_RemoveForemanRule", "(", ")", "self", ".", "hunt_obj", ".", "Set", "(", "self", ".", "hunt_obj", ".", "Schema", ".", "STATE", "(", "\"STOPPED\"", ")", ")", "self", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.IsHuntStarted
Is this hunt considered started? This method is used to check if new clients should be processed by this hunt. Note that child flow responses are always processed but new clients are not allowed to be scheduled unless the hunt is started. Returns: If a new client is allowed to be scheduled o...
grr/server/grr_response_server/hunts/implementation.py
def IsHuntStarted(self): """Is this hunt considered started? This method is used to check if new clients should be processed by this hunt. Note that child flow responses are always processed but new clients are not allowed to be scheduled unless the hunt is started. Returns: If a new cli...
def IsHuntStarted(self): """Is this hunt considered started? This method is used to check if new clients should be processed by this hunt. Note that child flow responses are always processed but new clients are not allowed to be scheduled unless the hunt is started. Returns: If a new cli...
[ "Is", "this", "hunt", "considered", "started?" ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L937-L957
[ "def", "IsHuntStarted", "(", "self", ")", ":", "state", "=", "self", ".", "hunt_obj", ".", "Get", "(", "self", ".", "hunt_obj", ".", "Schema", ".", "STATE", ")", "if", "state", "!=", "\"STARTED\"", ":", "return", "False", "# Stop the hunt due to expiry.", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntRunner.CallState
This method is used to asynchronously schedule a new hunt state. The state will be invoked in a later time and receive all the messages we send. Args: messages: A list of rdfvalues to send. If the last one is not a GrrStatus, we append an OK Status. next_state: The state in this hunt t...
grr/server/grr_response_server/hunts/implementation.py
def CallState(self, messages=None, next_state="", client_id=None, request_data=None, start_time=None): """This method is used to asynchronously schedule a new hunt state. The state will be invoked in a later time and receive all th...
def CallState(self, messages=None, next_state="", client_id=None, request_data=None, start_time=None): """This method is used to asynchronously schedule a new hunt state. The state will be invoked in a later time and receive all th...
[ "This", "method", "is", "used", "to", "asynchronously", "schedule", "a", "new", "hunt", "state", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L965-L1036
[ "def", "CallState", "(", "self", ",", "messages", "=", "None", ",", "next_state", "=", "\"\"", ",", "client_id", "=", "None", ",", "request_data", "=", "None", ",", "start_time", "=", "None", ")", ":", "if", "messages", "is", "None", ":", "messages", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHunt.CreateRunner
Make a new runner.
grr/server/grr_response_server/hunts/implementation.py
def CreateRunner(self, **kw): """Make a new runner.""" self.runner = HuntRunner(self, token=self.token, **kw) return self.runner
def CreateRunner(self, **kw): """Make a new runner.""" self.runner = HuntRunner(self, token=self.token, **kw) return self.runner
[ "Make", "a", "new", "runner", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L1120-L1123
[ "def", "CreateRunner", "(", "self", ",", "*", "*", "kw", ")", ":", "self", ".", "runner", "=", "HuntRunner", "(", "self", ",", "token", "=", "self", ".", "token", ",", "*", "*", "kw", ")", "return", "self", ".", "runner" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHunt.StartClients
This method is called by the foreman for each client it discovers. Note that this function is performance sensitive since it is called by the foreman for every client which needs to be scheduled. Args: hunt_id: The hunt to schedule. client_ids: List of clients that should be added to the hunt....
grr/server/grr_response_server/hunts/implementation.py
def StartClients(cls, hunt_id, client_ids, token=None): """This method is called by the foreman for each client it discovers. Note that this function is performance sensitive since it is called by the foreman for every client which needs to be scheduled. Args: hunt_id: The hunt to schedule. ...
def StartClients(cls, hunt_id, client_ids, token=None): """This method is called by the foreman for each client it discovers. Note that this function is performance sensitive since it is called by the foreman for every client which needs to be scheduled. Args: hunt_id: The hunt to schedule. ...
[ "This", "method", "is", "called", "by", "the", "foreman", "for", "each", "client", "it", "discovers", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L1331-L1370
[ "def", "StartClients", "(", "cls", ",", "hunt_id", ",", "client_ids", ",", "token", "=", "None", ")", ":", "token", "=", "token", "or", "access_control", ".", "ACLToken", "(", "username", "=", "\"Hunt\"", ",", "reason", "=", "\"hunting\"", ")", "with", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHunt.CallFlow
Create a new child flow from a hunt.
grr/server/grr_response_server/hunts/implementation.py
def CallFlow(self, flow_name=None, next_state=None, request_data=None, client_id=None, **kwargs): """Create a new child flow from a hunt.""" base_session_id = None if client_id: # The flow is stored in the hunt namespace, ...
def CallFlow(self, flow_name=None, next_state=None, request_data=None, client_id=None, **kwargs): """Create a new child flow from a hunt.""" base_session_id = None if client_id: # The flow is stored in the hunt namespace, ...
[ "Create", "a", "new", "child", "flow", "from", "a", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L1468-L1500
[ "def", "CallFlow", "(", "self", ",", "flow_name", "=", "None", ",", "next_state", "=", "None", ",", "request_data", "=", "None", ",", "client_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "base_session_id", "=", "None", "if", "client_id", ":", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHunt.Start
Initializes this hunt from arguments.
grr/server/grr_response_server/hunts/implementation.py
def Start(self): """Initializes this hunt from arguments.""" with data_store.DB.GetMutationPool() as mutation_pool: self.CreateCollections(mutation_pool) if not self.runner_args.description: self.SetDescription()
def Start(self): """Initializes this hunt from arguments.""" with data_store.DB.GetMutationPool() as mutation_pool: self.CreateCollections(mutation_pool) if not self.runner_args.description: self.SetDescription()
[ "Initializes", "this", "hunt", "from", "arguments", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L1517-L1523
[ "def", "Start", "(", "self", ")", ":", "with", "data_store", ".", "DB", ".", "GetMutationPool", "(", ")", "as", "mutation_pool", ":", "self", ".", "CreateCollections", "(", "mutation_pool", ")", "if", "not", "self", ".", "runner_args", ".", "description", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHunt.LogClientError
Logs an error for a client.
grr/server/grr_response_server/hunts/implementation.py
def LogClientError(self, client_id, log_message=None, backtrace=None): """Logs an error for a client.""" self.RegisterClientError( client_id, log_message=log_message, backtrace=backtrace)
def LogClientError(self, client_id, log_message=None, backtrace=None): """Logs an error for a client.""" self.RegisterClientError( client_id, log_message=log_message, backtrace=backtrace)
[ "Logs", "an", "error", "for", "a", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L1565-L1568
[ "def", "LogClientError", "(", "self", ",", "client_id", ",", "log_message", "=", "None", ",", "backtrace", "=", "None", ")", ":", "self", ".", "RegisterClientError", "(", "client_id", ",", "log_message", "=", "log_message", ",", "backtrace", "=", "backtrace", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHunt.ProcessClientResourcesStats
Process status message from a client and update the stats. Args: client_id: Client id. status: The status object returned from the client.
grr/server/grr_response_server/hunts/implementation.py
def ProcessClientResourcesStats(self, client_id, status): """Process status message from a client and update the stats. Args: client_id: Client id. status: The status object returned from the client. """ if hasattr(status, "child_session_id"): flow_path = status.child_session_id e...
def ProcessClientResourcesStats(self, client_id, status): """Process status message from a client and update the stats. Args: client_id: Client id. status: The status object returned from the client. """ if hasattr(status, "child_session_id"): flow_path = status.child_session_id e...
[ "Process", "status", "message", "from", "a", "client", "and", "update", "the", "stats", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L1570-L1588
[ "def", "ProcessClientResourcesStats", "(", "self", ",", "client_id", ",", "status", ")", ":", "if", "hasattr", "(", "status", ",", "\"child_session_id\"", ")", ":", "flow_path", "=", "status", ".", "child_session_id", "else", ":", "flow_path", "=", "\"aff4:/%s/f...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHunt.GetClientsByStatus
Get all the clients in a dict of {status: [client_list]}.
grr/server/grr_response_server/hunts/implementation.py
def GetClientsByStatus(self): """Get all the clients in a dict of {status: [client_list]}.""" started = self.GetClients() completed = self.GetCompletedClients() outstanding = started - completed return { "STARTED": started, "COMPLETED": completed, "OUTSTANDING": outstanding ...
def GetClientsByStatus(self): """Get all the clients in a dict of {status: [client_list]}.""" started = self.GetClients() completed = self.GetCompletedClients() outstanding = started - completed return { "STARTED": started, "COMPLETED": completed, "OUTSTANDING": outstanding ...
[ "Get", "all", "the", "clients", "in", "a", "dict", "of", "{", "status", ":", "[", "client_list", "]", "}", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L1631-L1641
[ "def", "GetClientsByStatus", "(", "self", ")", ":", "started", "=", "self", ".", "GetClients", "(", ")", "completed", "=", "self", ".", "GetCompletedClients", "(", ")", "outstanding", "=", "started", "-", "completed", "return", "{", "\"STARTED\"", ":", "star...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHunt.GetClientStates
Take in a client list and return dicts with their age and hostname.
grr/server/grr_response_server/hunts/implementation.py
def GetClientStates(self, client_list, client_chunk=50): """Take in a client list and return dicts with their age and hostname.""" for client_group in collection.Batch(client_list, client_chunk): for fd in aff4.FACTORY.MultiOpen( client_group, mode="r", aff4_type=aff4_grr.VFS...
def GetClientStates(self, client_list, client_chunk=50): """Take in a client list and return dicts with their age and hostname.""" for client_group in collection.Batch(client_list, client_chunk): for fd in aff4.FACTORY.MultiOpen( client_group, mode="r", aff4_type=aff4_grr.VFS...
[ "Take", "in", "a", "client", "list", "and", "return", "dicts", "with", "their", "age", "and", "hostname", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L1643-L1654
[ "def", "GetClientStates", "(", "self", ",", "client_list", ",", "client_chunk", "=", "50", ")", ":", "for", "client_group", "in", "collection", ".", "Batch", "(", "client_list", ",", "client_chunk", ")", ":", "for", "fd", "in", "aff4", ".", "FACTORY", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SearchClients
List clients conforming to a givent query.
api_client/python/grr_api_client/client.py
def SearchClients(query=None, context=None): """List clients conforming to a givent query.""" args = client_pb2.ApiSearchClientsArgs(query=query) items = context.SendIteratorRequest("SearchClients", args) return utils.MapItemsIterator(lambda data: Client(data=data, context=context), ...
def SearchClients(query=None, context=None): """List clients conforming to a givent query.""" args = client_pb2.ApiSearchClientsArgs(query=query) items = context.SendIteratorRequest("SearchClients", args) return utils.MapItemsIterator(lambda data: Client(data=data, context=context), ...
[ "List", "clients", "conforming", "to", "a", "givent", "query", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L264-L271
[ "def", "SearchClients", "(", "query", "=", "None", ",", "context", "=", "None", ")", ":", "args", "=", "client_pb2", ".", "ApiSearchClientsArgs", "(", "query", "=", "query", ")", "items", "=", "context", ".", "SendIteratorRequest", "(", "\"SearchClients\"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientApprovalBase.Get
Fetch and return a proper ClientApproval object.
api_client/python/grr_api_client/client.py
def Get(self): """Fetch and return a proper ClientApproval object.""" args = user_pb2.ApiGetClientApprovalArgs( client_id=self.client_id, approval_id=self.approval_id, username=self.username) result = self._context.SendRequest("GetClientApproval", args) return ClientApproval( ...
def Get(self): """Fetch and return a proper ClientApproval object.""" args = user_pb2.ApiGetClientApprovalArgs( client_id=self.client_id, approval_id=self.approval_id, username=self.username) result = self._context.SendRequest("GetClientApproval", args) return ClientApproval( ...
[ "Fetch", "and", "return", "a", "proper", "ClientApproval", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L49-L58
[ "def", "Get", "(", "self", ")", ":", "args", "=", "user_pb2", ".", "ApiGetClientApprovalArgs", "(", "client_id", "=", "self", ".", "client_id", ",", "approval_id", "=", "self", ".", "approval_id", ",", "username", "=", "self", ".", "username", ")", "result...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBase.File
Returns a reference to a file with a given path on client's VFS.
api_client/python/grr_api_client/client.py
def File(self, path): """Returns a reference to a file with a given path on client's VFS.""" return vfs.FileRef( client_id=self.client_id, path=path, context=self._context)
def File(self, path): """Returns a reference to a file with a given path on client's VFS.""" return vfs.FileRef( client_id=self.client_id, path=path, context=self._context)
[ "Returns", "a", "reference", "to", "a", "file", "with", "a", "given", "path", "on", "client", "s", "VFS", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L130-L134
[ "def", "File", "(", "self", ",", "path", ")", ":", "return", "vfs", ".", "FileRef", "(", "client_id", "=", "self", ".", "client_id", ",", "path", "=", "path", ",", "context", "=", "self", ".", "_context", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBase.Flow
Return a reference to a flow with a given id on this client.
api_client/python/grr_api_client/client.py
def Flow(self, flow_id): """Return a reference to a flow with a given id on this client.""" return flow.FlowRef( client_id=self.client_id, flow_id=flow_id, context=self._context)
def Flow(self, flow_id): """Return a reference to a flow with a given id on this client.""" return flow.FlowRef( client_id=self.client_id, flow_id=flow_id, context=self._context)
[ "Return", "a", "reference", "to", "a", "flow", "with", "a", "given", "id", "on", "this", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L136-L140
[ "def", "Flow", "(", "self", ",", "flow_id", ")", ":", "return", "flow", ".", "FlowRef", "(", "client_id", "=", "self", ".", "client_id", ",", "flow_id", "=", "flow_id", ",", "context", "=", "self", ".", "_context", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBase.CreateFlow
Create new flow on this client.
api_client/python/grr_api_client/client.py
def CreateFlow(self, name=None, args=None, runner_args=None): """Create new flow on this client.""" if not name: raise ValueError("name can't be empty") request = flow_pb2.ApiCreateFlowArgs(client_id=self.client_id) request.flow.name = name if runner_args: request.flow.runner_args.Cop...
def CreateFlow(self, name=None, args=None, runner_args=None): """Create new flow on this client.""" if not name: raise ValueError("name can't be empty") request = flow_pb2.ApiCreateFlowArgs(client_id=self.client_id) request.flow.name = name if runner_args: request.flow.runner_args.Cop...
[ "Create", "new", "flow", "on", "this", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L142-L159
[ "def", "CreateFlow", "(", "self", ",", "name", "=", "None", ",", "args", "=", "None", ",", "runner_args", "=", "None", ")", ":", "if", "not", "name", ":", "raise", "ValueError", "(", "\"name can't be empty\"", ")", "request", "=", "flow_pb2", ".", "ApiCr...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBase.ListFlows
List flows that ran on this client.
api_client/python/grr_api_client/client.py
def ListFlows(self): """List flows that ran on this client.""" args = flow_pb2.ApiListFlowsArgs(client_id=self.client_id) items = self._context.SendIteratorRequest("ListFlows", args) return utils.MapItemsIterator( lambda data: flow.Flow(data=data, context=self._context), items)
def ListFlows(self): """List flows that ran on this client.""" args = flow_pb2.ApiListFlowsArgs(client_id=self.client_id) items = self._context.SendIteratorRequest("ListFlows", args) return utils.MapItemsIterator( lambda data: flow.Flow(data=data, context=self._context), items)
[ "List", "flows", "that", "ran", "on", "this", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L161-L168
[ "def", "ListFlows", "(", "self", ")", ":", "args", "=", "flow_pb2", ".", "ApiListFlowsArgs", "(", "client_id", "=", "self", ".", "client_id", ")", "items", "=", "self", ".", "_context", ".", "SendIteratorRequest", "(", "\"ListFlows\"", ",", "args", ")", "r...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBase.Approval
Returns a reference to an approval.
api_client/python/grr_api_client/client.py
def Approval(self, username, approval_id): """Returns a reference to an approval.""" return ClientApprovalRef( client_id=self.client_id, username=username, approval_id=approval_id, context=self._context)
def Approval(self, username, approval_id): """Returns a reference to an approval.""" return ClientApprovalRef( client_id=self.client_id, username=username, approval_id=approval_id, context=self._context)
[ "Returns", "a", "reference", "to", "an", "approval", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L170-L177
[ "def", "Approval", "(", "self", ",", "username", ",", "approval_id", ")", ":", "return", "ClientApprovalRef", "(", "client_id", "=", "self", ".", "client_id", ",", "username", "=", "username", ",", "approval_id", "=", "approval_id", ",", "context", "=", "sel...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBase.CreateApproval
Create a new approval for the current user to access this client.
api_client/python/grr_api_client/client.py
def CreateApproval(self, reason=None, notified_users=None, email_cc_addresses=None, keep_client_alive=False): """Create a new approval for the current user to access this client.""" if not reason: raise ValueError("reason...
def CreateApproval(self, reason=None, notified_users=None, email_cc_addresses=None, keep_client_alive=False): """Create a new approval for the current user to access this client.""" if not reason: raise ValueError("reason...
[ "Create", "a", "new", "approval", "for", "the", "current", "user", "to", "access", "this", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L179-L203
[ "def", "CreateApproval", "(", "self", ",", "reason", "=", "None", ",", "notified_users", "=", "None", ",", "email_cc_addresses", "=", "None", ",", "keep_client_alive", "=", "False", ")", ":", "if", "not", "reason", ":", "raise", "ValueError", "(", "\"reason ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientRef.Get
Fetch client's data and return a proper Client object.
api_client/python/grr_api_client/client.py
def Get(self): """Fetch client's data and return a proper Client object.""" args = client_pb2.ApiGetClientArgs(client_id=self.client_id) result = self._context.SendRequest("GetClient", args) return Client(data=result, context=self._context)
def Get(self): """Fetch client's data and return a proper Client object.""" args = client_pb2.ApiGetClientArgs(client_id=self.client_id) result = self._context.SendRequest("GetClient", args) return Client(data=result, context=self._context)
[ "Fetch", "client", "s", "data", "and", "return", "a", "proper", "Client", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/client.py#L242-L247
[ "def", "Get", "(", "self", ")", ":", "args", "=", "client_pb2", ".", "ApiGetClientArgs", "(", "client_id", "=", "self", ".", "client_id", ")", "result", "=", "self", ".", "_context", ".", "SendRequest", "(", "\"GetClient\"", ",", "args", ")", "return", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetMetricMetadata
Returns a list of MetricMetadata for communicator-related metrics.
grr/core/grr_response_core/lib/communicator.py
def GetMetricMetadata(): """Returns a list of MetricMetadata for communicator-related metrics.""" return [ stats_utils.CreateCounterMetadata("grr_client_unknown"), stats_utils.CreateCounterMetadata("grr_decoding_error"), stats_utils.CreateCounterMetadata("grr_decryption_error"), stats_utils....
def GetMetricMetadata(): """Returns a list of MetricMetadata for communicator-related metrics.""" return [ stats_utils.CreateCounterMetadata("grr_client_unknown"), stats_utils.CreateCounterMetadata("grr_decoding_error"), stats_utils.CreateCounterMetadata("grr_decryption_error"), stats_utils....
[ "Returns", "a", "list", "of", "MetricMetadata", "for", "communicator", "-", "related", "metrics", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L27-L38
[ "def", "GetMetricMetadata", "(", ")", ":", "return", "[", "stats_utils", ".", "CreateCounterMetadata", "(", "\"grr_client_unknown\"", ")", ",", "stats_utils", ".", "CreateCounterMetadata", "(", "\"grr_decoding_error\"", ")", ",", "stats_utils", ".", "CreateCounterMetada...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Cipher.Encrypt
Symmetrically encrypt the data using the optional iv.
grr/core/grr_response_core/lib/communicator.py
def Encrypt(self, data, iv=None): """Symmetrically encrypt the data using the optional iv.""" if iv is None: iv = rdf_crypto.EncryptionKey.GenerateKey(length=128) cipher = rdf_crypto.AES128CBCCipher(self.cipher.key, iv) return iv, cipher.Encrypt(data)
def Encrypt(self, data, iv=None): """Symmetrically encrypt the data using the optional iv.""" if iv is None: iv = rdf_crypto.EncryptionKey.GenerateKey(length=128) cipher = rdf_crypto.AES128CBCCipher(self.cipher.key, iv) return iv, cipher.Encrypt(data)
[ "Symmetrically", "encrypt", "the", "data", "using", "the", "optional", "iv", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L102-L107
[ "def", "Encrypt", "(", "self", ",", "data", ",", "iv", "=", "None", ")", ":", "if", "iv", "is", "None", ":", "iv", "=", "rdf_crypto", ".", "EncryptionKey", ".", "GenerateKey", "(", "length", "=", "128", ")", "cipher", "=", "rdf_crypto", ".", "AES128C...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Cipher.Decrypt
Symmetrically decrypt the data.
grr/core/grr_response_core/lib/communicator.py
def Decrypt(self, data, iv): """Symmetrically decrypt the data.""" key = rdf_crypto.EncryptionKey(self.cipher.key) iv = rdf_crypto.EncryptionKey(iv) return rdf_crypto.AES128CBCCipher(key, iv).Decrypt(data)
def Decrypt(self, data, iv): """Symmetrically decrypt the data.""" key = rdf_crypto.EncryptionKey(self.cipher.key) iv = rdf_crypto.EncryptionKey(iv) return rdf_crypto.AES128CBCCipher(key, iv).Decrypt(data)
[ "Symmetrically", "decrypt", "the", "data", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L109-L113
[ "def", "Decrypt", "(", "self", ",", "data", ",", "iv", ")", ":", "key", "=", "rdf_crypto", ".", "EncryptionKey", "(", "self", ".", "cipher", ".", "key", ")", "iv", "=", "rdf_crypto", ".", "EncryptionKey", "(", "iv", ")", "return", "rdf_crypto", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ReceivedCipher._VerifyHMAC
Verifies the HMAC. This method raises a DecryptionError if the received HMAC does not verify. If the HMAC verifies correctly, True is returned. Args: comms: The comms RdfValue to verify. Raises: DecryptionError: The HMAC did not verify. Returns: True
grr/core/grr_response_core/lib/communicator.py
def _VerifyHMAC(self, comms=None): """Verifies the HMAC. This method raises a DecryptionError if the received HMAC does not verify. If the HMAC verifies correctly, True is returned. Args: comms: The comms RdfValue to verify. Raises: DecryptionError: The HMAC did not verify. Retur...
def _VerifyHMAC(self, comms=None): """Verifies the HMAC. This method raises a DecryptionError if the received HMAC does not verify. If the HMAC verifies correctly, True is returned. Args: comms: The comms RdfValue to verify. Raises: DecryptionError: The HMAC did not verify. Retur...
[ "Verifies", "the", "HMAC", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L204-L240
[ "def", "_VerifyHMAC", "(", "self", ",", "comms", "=", "None", ")", ":", "# Check the encrypted message integrity using HMAC.", "if", "self", ".", "hmac_type", "==", "\"SIMPLE_HMAC\"", ":", "msg", "=", "comms", ".", "encrypted", "digest", "=", "comms", ".", "hmac...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ReceivedCipher.VerifyCipherSignature
Verifies the signature on the encrypted cipher block. This method returns True if the signature verifies correctly with the key given. Args: remote_public_key: The remote public key. Returns: None Raises: rdf_crypto.VerificationError: A signature and a key were both given but ...
grr/core/grr_response_core/lib/communicator.py
def VerifyCipherSignature(self, remote_public_key): """Verifies the signature on the encrypted cipher block. This method returns True if the signature verifies correctly with the key given. Args: remote_public_key: The remote public key. Returns: None Raises: rdf_crypto.Veri...
def VerifyCipherSignature(self, remote_public_key): """Verifies the signature on the encrypted cipher block. This method returns True if the signature verifies correctly with the key given. Args: remote_public_key: The remote public key. Returns: None Raises: rdf_crypto.Veri...
[ "Verifies", "the", "signature", "on", "the", "encrypted", "cipher", "block", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L242-L263
[ "def", "VerifyCipherSignature", "(", "self", ",", "remote_public_key", ")", ":", "if", "self", ".", "cipher_metadata", ".", "signature", "and", "remote_public_key", ":", "stats_collector_instance", ".", "Get", "(", ")", ".", "IncrementCounter", "(", "\"grr_rsa_opera...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Communicator.EncodeMessageList
Encode the MessageList into the packed_message_list rdfvalue.
grr/core/grr_response_core/lib/communicator.py
def EncodeMessageList(cls, message_list, packed_message_list): """Encode the MessageList into the packed_message_list rdfvalue.""" # By default uncompress uncompressed_data = message_list.SerializeToString() packed_message_list.message_list = uncompressed_data compressed_data = zlib.compress(uncomp...
def EncodeMessageList(cls, message_list, packed_message_list): """Encode the MessageList into the packed_message_list rdfvalue.""" # By default uncompress uncompressed_data = message_list.SerializeToString() packed_message_list.message_list = uncompressed_data compressed_data = zlib.compress(uncomp...
[ "Encode", "the", "MessageList", "into", "the", "packed_message_list", "rdfvalue", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L290-L302
[ "def", "EncodeMessageList", "(", "cls", ",", "message_list", ",", "packed_message_list", ")", ":", "# By default uncompress", "uncompressed_data", "=", "message_list", ".", "SerializeToString", "(", ")", "packed_message_list", ".", "message_list", "=", "uncompressed_data"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Communicator._GetServerCipher
Returns the cipher for self.server_name.
grr/core/grr_response_core/lib/communicator.py
def _GetServerCipher(self): """Returns the cipher for self.server_name.""" if self.server_cipher is not None: expiry = self.server_cipher_age + rdfvalue.Duration("1d") if expiry > rdfvalue.RDFDatetime.Now(): return self.server_cipher remote_public_key = self._GetRemotePublicKey(self.se...
def _GetServerCipher(self): """Returns the cipher for self.server_name.""" if self.server_cipher is not None: expiry = self.server_cipher_age + rdfvalue.Duration("1d") if expiry > rdfvalue.RDFDatetime.Now(): return self.server_cipher remote_public_key = self._GetRemotePublicKey(self.se...
[ "Returns", "the", "cipher", "for", "self", ".", "server_name", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L308-L320
[ "def", "_GetServerCipher", "(", "self", ")", ":", "if", "self", ".", "server_cipher", "is", "not", "None", ":", "expiry", "=", "self", ".", "server_cipher_age", "+", "rdfvalue", ".", "Duration", "(", "\"1d\"", ")", "if", "expiry", ">", "rdfvalue", ".", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Communicator.EncodeMessages
Accepts a list of messages and encodes for transmission. This function signs and then encrypts the payload. Args: message_list: A MessageList rdfvalue containing a list of GrrMessages. result: A ClientCommunication rdfvalue which will be filled in. destination: The CN of the remote system...
grr/core/grr_response_core/lib/communicator.py
def EncodeMessages(self, message_list, result, destination=None, timestamp=None, api_version=3): """Accepts a list of messages and encodes for transmission. This function signs and then encrypts the payload...
def EncodeMessages(self, message_list, result, destination=None, timestamp=None, api_version=3): """Accepts a list of messages and encodes for transmission. This function signs and then encrypts the payload...
[ "Accepts", "a", "list", "of", "messages", "and", "encodes", "for", "transmission", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L322-L399
[ "def", "EncodeMessages", "(", "self", ",", "message_list", ",", "result", ",", "destination", "=", "None", ",", "timestamp", "=", "None", ",", "api_version", "=", "3", ")", ":", "if", "api_version", "not", "in", "[", "3", "]", ":", "raise", "RuntimeError...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Communicator.DecryptMessage
Decrypt the serialized, encrypted string. Args: encrypted_response: A serialized and encrypted string. Returns: a Packed_Message_List rdfvalue
grr/core/grr_response_core/lib/communicator.py
def DecryptMessage(self, encrypted_response): """Decrypt the serialized, encrypted string. Args: encrypted_response: A serialized and encrypted string. Returns: a Packed_Message_List rdfvalue """ try: response_comms = rdf_flows.ClientCommunication.FromSerializedString( ...
def DecryptMessage(self, encrypted_response): """Decrypt the serialized, encrypted string. Args: encrypted_response: A serialized and encrypted string. Returns: a Packed_Message_List rdfvalue """ try: response_comms = rdf_flows.ClientCommunication.FromSerializedString( ...
[ "Decrypt", "the", "serialized", "encrypted", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L401-L416
[ "def", "DecryptMessage", "(", "self", ",", "encrypted_response", ")", ":", "try", ":", "response_comms", "=", "rdf_flows", ".", "ClientCommunication", ".", "FromSerializedString", "(", "encrypted_response", ")", "return", "self", ".", "DecodeMessages", "(", "respons...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Communicator.DecompressMessageList
Decompress the message data from packed_message_list. Args: packed_message_list: A PackedMessageList rdfvalue with some data in it. Returns: a MessageList rdfvalue. Raises: DecodingError: If decompression fails.
grr/core/grr_response_core/lib/communicator.py
def DecompressMessageList(cls, packed_message_list): """Decompress the message data from packed_message_list. Args: packed_message_list: A PackedMessageList rdfvalue with some data in it. Returns: a MessageList rdfvalue. Raises: DecodingError: If decompression fails. """ com...
def DecompressMessageList(cls, packed_message_list): """Decompress the message data from packed_message_list. Args: packed_message_list: A PackedMessageList rdfvalue with some data in it. Returns: a MessageList rdfvalue. Raises: DecodingError: If decompression fails. """ com...
[ "Decompress", "the", "message", "data", "from", "packed_message_list", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L419-L449
[ "def", "DecompressMessageList", "(", "cls", ",", "packed_message_list", ")", ":", "compression", "=", "packed_message_list", ".", "compression", "if", "compression", "==", "rdf_flows", ".", "PackedMessageList", ".", "CompressionType", ".", "UNCOMPRESSED", ":", "data",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Communicator.DecodeMessages
Extract and verify server message. Args: response_comms: A ClientCommunication rdfvalue Returns: list of messages and the CN where they came from. Raises: DecryptionError: If the message failed to decrypt properly.
grr/core/grr_response_core/lib/communicator.py
def DecodeMessages(self, response_comms): """Extract and verify server message. Args: response_comms: A ClientCommunication rdfvalue Returns: list of messages and the CN where they came from. Raises: DecryptionError: If the message failed to decrypt properly. """ # Have ...
def DecodeMessages(self, response_comms): """Extract and verify server message. Args: response_comms: A ClientCommunication rdfvalue Returns: list of messages and the CN where they came from. Raises: DecryptionError: If the message failed to decrypt properly. """ # Have ...
[ "Extract", "and", "verify", "server", "message", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L451-L524
[ "def", "DecodeMessages", "(", "self", ",", "response_comms", ")", ":", "# Have we seen this cipher before?", "cipher_verified", "=", "False", "try", ":", "cipher", "=", "self", ".", "encrypted_cipher_cache", ".", "Get", "(", "response_comms", ".", "encrypted_cipher", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Communicator.VerifyMessageSignature
Verify the message list signature. This is the way the messages are verified in the client. In the client we also check that the nonce returned by the server is correct (the timestamp doubles as a nonce). If the nonce fails we deem the response unauthenticated since it might have resulted from a repla...
grr/core/grr_response_core/lib/communicator.py
def VerifyMessageSignature(self, unused_response_comms, packed_message_list, cipher, cipher_verified, api_version, remote_public_key): """Verify the message list signature. This is the way the messages are verified in the client. In the client we a...
def VerifyMessageSignature(self, unused_response_comms, packed_message_list, cipher, cipher_verified, api_version, remote_public_key): """Verify the message list signature. This is the way the messages are verified in the client. In the client we a...
[ "Verify", "the", "message", "list", "signature", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/communicator.py#L526-L569
[ "def", "VerifyMessageSignature", "(", "self", ",", "unused_response_comms", ",", "packed_message_list", ",", "cipher", ",", "cipher_verified", ",", "api_version", ",", "remote_public_key", ")", ":", "# This is not used atm since we only support a single api version (3).", "_", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RegisterLateBindingCallback
Registers a callback to be invoked when the RDFValue named is declared.
grr/core/grr_response_core/lib/rdfvalue.py
def RegisterLateBindingCallback(target_name, callback, **kwargs): """Registers a callback to be invoked when the RDFValue named is declared.""" _LATE_BINDING_STORE.setdefault(target_name, []).append((callback, kwargs))
def RegisterLateBindingCallback(target_name, callback, **kwargs): """Registers a callback to be invoked when the RDFValue named is declared.""" _LATE_BINDING_STORE.setdefault(target_name, []).append((callback, kwargs))
[ "Registers", "a", "callback", "to", "be", "invoked", "when", "the", "RDFValue", "named", "is", "declared", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalue.py#L55-L57
[ "def", "RegisterLateBindingCallback", "(", "target_name", ",", "callback", ",", "*", "*", "kwargs", ")", ":", "_LATE_BINDING_STORE", ".", "setdefault", "(", "target_name", ",", "[", "]", ")", ".", "append", "(", "(", "callback", ",", "kwargs", ")", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ByteSize.ParseFromHumanReadable
Parse a human readable string of a byte string. Args: string: The string to parse. Raises: DecodeError: If the string can not be parsed.
grr/core/grr_response_core/lib/rdfvalue.py
def ParseFromHumanReadable(self, string): """Parse a human readable string of a byte string. Args: string: The string to parse. Raises: DecodeError: If the string can not be parsed. """ if not string: return None match = self.REGEX.match(string.strip().lower()) if not ma...
def ParseFromHumanReadable(self, string): """Parse a human readable string of a byte string. Args: string: The string to parse. Raises: DecodeError: If the string can not be parsed. """ if not string: return None match = self.REGEX.match(string.strip().lower()) if not ma...
[ "Parse", "a", "human", "readable", "string", "of", "a", "byte", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalue.py#L1013-L1040
[ "def", "ParseFromHumanReadable", "(", "self", ",", "string", ")", ":", "if", "not", "string", ":", "return", "None", "match", "=", "self", ".", "REGEX", ".", "match", "(", "string", ".", "strip", "(", ")", ".", "lower", "(", ")", ")", "if", "not", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
OSXLaunchdJobDict.FilterItem
Should this job be filtered. Args: launchditem: job NSCFDictionary Returns: True if the item should be filtered (dropped)
grr/core/grr_response_core/lib/parsers/osx_launchd.py
def FilterItem(self, launchditem): """Should this job be filtered. Args: launchditem: job NSCFDictionary Returns: True if the item should be filtered (dropped) """ for regex in self.blacklist_regex: if regex.match(launchditem.get("Label", "")): return True return False
def FilterItem(self, launchditem): """Should this job be filtered. Args: launchditem: job NSCFDictionary Returns: True if the item should be filtered (dropped) """ for regex in self.blacklist_regex: if regex.match(launchditem.get("Label", "")): return True return False
[ "Should", "this", "job", "be", "filtered", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/osx_launchd.py#L53-L64
[ "def", "FilterItem", "(", "self", ",", "launchditem", ")", ":", "for", "regex", "in", "self", ".", "blacklist_regex", ":", "if", "regex", ".", "match", "(", "launchditem", ".", "get", "(", "\"Label\"", ",", "\"\"", ")", ")", ":", "return", "True", "ret...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DarwinPersistenceMechanismsParser.Parse
Convert persistence collector output to downloadable rdfvalues.
grr/core/grr_response_core/lib/parsers/osx_launchd.py
def Parse(self, persistence, knowledge_base, download_pathtype): """Convert persistence collector output to downloadable rdfvalues.""" pathspecs = [] if isinstance(persistence, rdf_client.OSXServiceInformation): if persistence.program: pathspecs = rdf_paths.PathSpec( path=persiste...
def Parse(self, persistence, knowledge_base, download_pathtype): """Convert persistence collector output to downloadable rdfvalues.""" pathspecs = [] if isinstance(persistence, rdf_client.OSXServiceInformation): if persistence.program: pathspecs = rdf_paths.PathSpec( path=persiste...
[ "Convert", "persistence", "collector", "output", "to", "downloadable", "rdfvalues", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/osx_launchd.py#L72-L85
[ "def", "Parse", "(", "self", ",", "persistence", ",", "knowledge_base", ",", "download_pathtype", ")", ":", "pathspecs", "=", "[", "]", "if", "isinstance", "(", "persistence", ",", "rdf_client", ".", "OSXServiceInformation", ")", ":", "if", "persistence", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Trim
Trims a given list so that it is not longer than given limit. Args: lst: A list to trim. limit: A maximum number of elements in the list after trimming. Returns: A suffix of the input list that was trimmed.
grr/core/grr_response_core/lib/util/collection.py
def Trim(lst, limit): """Trims a given list so that it is not longer than given limit. Args: lst: A list to trim. limit: A maximum number of elements in the list after trimming. Returns: A suffix of the input list that was trimmed. """ limit = max(0, limit) clipping = lst[limit:] del lst[li...
def Trim(lst, limit): """Trims a given list so that it is not longer than given limit. Args: lst: A list to trim. limit: A maximum number of elements in the list after trimming. Returns: A suffix of the input list that was trimmed. """ limit = max(0, limit) clipping = lst[limit:] del lst[li...
[ "Trims", "a", "given", "list", "so", "that", "it", "is", "not", "longer", "than", "given", "limit", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/collection.py#L39-L53
[ "def", "Trim", "(", "lst", ",", "limit", ")", ":", "limit", "=", "max", "(", "0", ",", "limit", ")", "clipping", "=", "lst", "[", "limit", ":", "]", "del", "lst", "[", "limit", ":", "]", "return", "clipping" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Group
Groups items by given key function. Args: items: An iterable or an iterator of items. key: A function which given each item will return the key. Returns: A dict with keys being each unique key and values being a list of items of that key.
grr/core/grr_response_core/lib/util/collection.py
def Group(items, key): """Groups items by given key function. Args: items: An iterable or an iterator of items. key: A function which given each item will return the key. Returns: A dict with keys being each unique key and values being a list of items of that key. """ result = {} for item...
def Group(items, key): """Groups items by given key function. Args: items: An iterable or an iterator of items. key: A function which given each item will return the key. Returns: A dict with keys being each unique key and values being a list of items of that key. """ result = {} for item...
[ "Groups", "items", "by", "given", "key", "function", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/collection.py#L56-L72
[ "def", "Group", "(", "items", ",", "key", ")", ":", "result", "=", "{", "}", "for", "item", "in", "items", ":", "result", ".", "setdefault", "(", "key", "(", "item", ")", ",", "[", "]", ")", ".", "append", "(", "item", ")", "return", "result" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Batch
Divide items into batches of specified size. In case where number of items is not evenly divisible by the batch size, the last batch is going to be shorter. Args: items: An iterable or an iterator of items. size: A size of the returned batches. Yields: Lists of items with specified size.
grr/core/grr_response_core/lib/util/collection.py
def Batch(items, size): """Divide items into batches of specified size. In case where number of items is not evenly divisible by the batch size, the last batch is going to be shorter. Args: items: An iterable or an iterator of items. size: A size of the returned batches. Yields: Lists of items ...
def Batch(items, size): """Divide items into batches of specified size. In case where number of items is not evenly divisible by the batch size, the last batch is going to be shorter. Args: items: An iterable or an iterator of items. size: A size of the returned batches. Yields: Lists of items ...
[ "Divide", "items", "into", "batches", "of", "specified", "size", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/collection.py#L75-L97
[ "def", "Batch", "(", "items", ",", "size", ")", ":", "batch", "=", "[", "]", "for", "item", "in", "items", ":", "batch", ".", "append", "(", "item", ")", "if", "len", "(", "batch", ")", "==", "size", ":", "yield", "batch", "batch", "=", "[", "]...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StartsWith
Checks whether an items of one iterable are a prefix of another. Args: this: An iterable that needs to be checked. that: An iterable of which items must match the prefix of `this`. Returns: `True` if `that` is a prefix of `this`, `False` otherwise.
grr/core/grr_response_core/lib/util/collection.py
def StartsWith(this, that): """Checks whether an items of one iterable are a prefix of another. Args: this: An iterable that needs to be checked. that: An iterable of which items must match the prefix of `this`. Returns: `True` if `that` is a prefix of `this`, `False` otherwise. """ this_iter = ...
def StartsWith(this, that): """Checks whether an items of one iterable are a prefix of another. Args: this: An iterable that needs to be checked. that: An iterable of which items must match the prefix of `this`. Returns: `True` if `that` is a prefix of `this`, `False` otherwise. """ this_iter = ...
[ "Checks", "whether", "an", "items", "of", "one", "iterable", "are", "a", "prefix", "of", "another", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/collection.py#L100-L125
[ "def", "StartsWith", "(", "this", ",", "that", ")", ":", "this_iter", "=", "iter", "(", "this", ")", "that_iter", "=", "iter", "(", "that", ")", "while", "True", ":", "try", ":", "this_value", "=", "next", "(", "that_iter", ")", "except", "StopIteratio...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Unzip
Unzips specified iterable of pairs to pair of two iterables. This function is an inversion of the standard `zip` function and the following hold: * ∀ l, r. l, r == unzip(zip(l, r)) * ∀ p. p == zip(unzip(p)) Examples: >>> Unzip([("foo", 1), ("bar", 2), ("baz", 3)]) (["foo", "bar", "baz"], [1, 2,...
grr/core/grr_response_core/lib/util/collection.py
def Unzip(iterable): """Unzips specified iterable of pairs to pair of two iterables. This function is an inversion of the standard `zip` function and the following hold: * ∀ l, r. l, r == unzip(zip(l, r)) * ∀ p. p == zip(unzip(p)) Examples: >>> Unzip([("foo", 1), ("bar", 2), ("baz", 3)]) (["f...
def Unzip(iterable): """Unzips specified iterable of pairs to pair of two iterables. This function is an inversion of the standard `zip` function and the following hold: * ∀ l, r. l, r == unzip(zip(l, r)) * ∀ p. p == zip(unzip(p)) Examples: >>> Unzip([("foo", 1), ("bar", 2), ("baz", 3)]) (["f...
[ "Unzips", "specified", "iterable", "of", "pairs", "to", "pair", "of", "two", "iterables", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/collection.py#L128-L154
[ "def", "Unzip", "(", "iterable", ")", ":", "lefts", "=", "[", "]", "rights", "=", "[", "]", "for", "left", ",", "right", "in", "iterable", ":", "lefts", ".", "append", "(", "left", ")", "rights", ".", "append", "(", "right", ")", "return", "lefts",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DictProduct
Computes a cartesian product of dict with iterable values. This utility function, accepts a dictionary with iterable values, computes cartesian products of these values and yields dictionaries of expanded values. Examples: >>> list(DictProduct({"a": [1, 2], "b": [3, 4]})) [{"a": 1, "b": 3}, {"a": 1, "b"...
grr/core/grr_response_core/lib/util/collection.py
def DictProduct(dictionary): """Computes a cartesian product of dict with iterable values. This utility function, accepts a dictionary with iterable values, computes cartesian products of these values and yields dictionaries of expanded values. Examples: >>> list(DictProduct({"a": [1, 2], "b": [3, 4]})) ...
def DictProduct(dictionary): """Computes a cartesian product of dict with iterable values. This utility function, accepts a dictionary with iterable values, computes cartesian products of these values and yields dictionaries of expanded values. Examples: >>> list(DictProduct({"a": [1, 2], "b": [3, 4]})) ...
[ "Computes", "a", "cartesian", "product", "of", "dict", "with", "iterable", "values", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/collection.py#L157-L176
[ "def", "DictProduct", "(", "dictionary", ")", ":", "keys", ",", "values", "=", "Unzip", "(", "iteritems", "(", "dictionary", ")", ")", "for", "product_values", "in", "itertools", ".", "product", "(", "*", "values", ")", ":", "yield", "dict", "(", "zip", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
main
Main.
grr/server/grr_response_server/bin/console.py
def main(argv): """Main.""" del argv # Unused. if flags.FLAGS.version: print("GRR console {}".format(config_server.VERSION["packageversion"])) return banner = ("\nWelcome to the GRR console\n") config.CONFIG.AddContext(contexts.COMMAND_LINE_CONTEXT) config.CONFIG.AddContext(contexts.CONSOLE_CONT...
def main(argv): """Main.""" del argv # Unused. if flags.FLAGS.version: print("GRR console {}".format(config_server.VERSION["packageversion"])) return banner = ("\nWelcome to the GRR console\n") config.CONFIG.AddContext(contexts.COMMAND_LINE_CONTEXT) config.CONFIG.AddContext(contexts.CONSOLE_CONT...
[ "Main", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/console.py#L100-L153
[ "def", "main", "(", "argv", ")", ":", "del", "argv", "# Unused.", "if", "flags", ".", "FLAGS", ".", "version", ":", "print", "(", "\"GRR console {}\"", ".", "format", "(", "config_server", ".", "VERSION", "[", "\"packageversion\"", "]", ")", ")", "return",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AsIter
Encapsulates an argument in a tuple, if it's not already iterable.
grr/core/grr_response_core/lib/parsers/config_file.py
def AsIter(arg): """Encapsulates an argument in a tuple, if it's not already iterable.""" if isinstance(arg, string_types): rslt = [arg] elif isinstance(arg, collections.Iterable): rslt = arg elif not arg: rslt = [] else: rslt = [arg] return tuple(rslt)
def AsIter(arg): """Encapsulates an argument in a tuple, if it's not already iterable.""" if isinstance(arg, string_types): rslt = [arg] elif isinstance(arg, collections.Iterable): rslt = arg elif not arg: rslt = [] else: rslt = [arg] return tuple(rslt)
[ "Encapsulates", "an", "argument", "in", "a", "tuple", "if", "it", "s", "not", "already", "iterable", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L30-L40
[ "def", "AsIter", "(", "arg", ")", ":", "if", "isinstance", "(", "arg", ",", "string_types", ")", ":", "rslt", "=", "[", "arg", "]", "elif", "isinstance", "(", "arg", ",", "collections", ".", "Iterable", ")", ":", "rslt", "=", "arg", "elif", "not", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FieldParser._GenStates
Generate the lexer states.
grr/core/grr_response_core/lib/parsers/config_file.py
def _GenStates(self): """Generate the lexer states.""" self.GenCommentState() self.GenFwdState() self.GenQuotedState() self.GenCatchallState()
def _GenStates(self): """Generate the lexer states.""" self.GenCommentState() self.GenFwdState() self.GenQuotedState() self.GenCatchallState()
[ "Generate", "the", "lexer", "states", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L113-L118
[ "def", "_GenStates", "(", "self", ")", ":", "self", ".", "GenCommentState", "(", ")", "self", ".", "GenFwdState", "(", ")", "self", ".", "GenQuotedState", "(", ")", "self", ".", "GenCatchallState", "(", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FieldParser.GenFwdState
Generates forwarding state rules. The lexer will fast forward until there is string content. The string content will be returned to the string processor.
grr/core/grr_response_core/lib/parsers/config_file.py
def GenFwdState(self): """Generates forwarding state rules. The lexer will fast forward until there is string content. The string content will be returned to the string processor. """ for c in self.cont: self._AddToken("FWD", c, None, None) for s in self.sep: self._AddToken("FWD", s...
def GenFwdState(self): """Generates forwarding state rules. The lexer will fast forward until there is string content. The string content will be returned to the string processor. """ for c in self.cont: self._AddToken("FWD", c, None, None) for s in self.sep: self._AddToken("FWD", s...
[ "Generates", "forwarding", "state", "rules", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L128-L138
[ "def", "GenFwdState", "(", "self", ")", ":", "for", "c", "in", "self", ".", "cont", ":", "self", ".", "_AddToken", "(", "\"FWD\"", ",", "c", ",", "None", ",", "None", ")", "for", "s", "in", "self", ".", "sep", ":", "self", ".", "_AddToken", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FieldParser.GenQuotedState
Generate string matching state rules.
grr/core/grr_response_core/lib/parsers/config_file.py
def GenQuotedState(self): """Generate string matching state rules.""" for i, q in enumerate(self.quot): label = "%s_STRING" % i escaped = re.escape(q) self._AddToken(label, escaped, "PopState", None) self._AddToken(label, q, "PopState", None) if self.ml_quote: self._AddToke...
def GenQuotedState(self): """Generate string matching state rules.""" for i, q in enumerate(self.quot): label = "%s_STRING" % i escaped = re.escape(q) self._AddToken(label, escaped, "PopState", None) self._AddToken(label, q, "PopState", None) if self.ml_quote: self._AddToke...
[ "Generate", "string", "matching", "state", "rules", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L140-L151
[ "def", "GenQuotedState", "(", "self", ")", ":", "for", "i", ",", "q", "in", "enumerate", "(", "self", ".", "quot", ")", ":", "label", "=", "\"%s_STRING\"", "%", "i", "escaped", "=", "re", ".", "escape", "(", "q", ")", "self", ".", "_AddToken", "(",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FieldParser.GenCatchallState
Generate string matching state rules. This sets up initial state handlers that cover both the 'INITIAL' state and the intermediate content between fields. The lexer acts on items with precedence: - continuation characters: use the fast forward state rules. - field separators: finalize processi...
grr/core/grr_response_core/lib/parsers/config_file.py
def GenCatchallState(self): """Generate string matching state rules. This sets up initial state handlers that cover both the 'INITIAL' state and the intermediate content between fields. The lexer acts on items with precedence: - continuation characters: use the fast forward state rules. - ...
def GenCatchallState(self): """Generate string matching state rules. This sets up initial state handlers that cover both the 'INITIAL' state and the intermediate content between fields. The lexer acts on items with precedence: - continuation characters: use the fast forward state rules. - ...
[ "Generate", "string", "matching", "state", "rules", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L153-L174
[ "def", "GenCatchallState", "(", "self", ")", ":", "for", "c", "in", "self", ".", "comments", ":", "self", ".", "_AddToken", "(", "\".\"", ",", "c", ",", "\"PushState,EndField\"", ",", "\"COMMENT\"", ")", "for", "c", "in", "self", ".", "cont", ":", "sel...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SshdFieldParser.ParseLine
Extracts keyword/value settings from the sshd config. The keyword is always the first string item. Values are the remainder of the string. In cases where an sshd config allows multiple values, these are split according to whatever separator(s) sshd_config permits for that value. Keywords and value...
grr/core/grr_response_core/lib/parsers/config_file.py
def ParseLine(self, line): """Extracts keyword/value settings from the sshd config. The keyword is always the first string item. Values are the remainder of the string. In cases where an sshd config allows multiple values, these are split according to whatever separator(s) sshd_config permits for t...
def ParseLine(self, line): """Extracts keyword/value settings from the sshd config. The keyword is always the first string item. Values are the remainder of the string. In cases where an sshd config allows multiple values, these are split according to whatever separator(s) sshd_config permits for t...
[ "Extracts", "keyword", "/", "value", "settings", "from", "the", "sshd", "config", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L445-L490
[ "def", "ParseLine", "(", "self", ",", "line", ")", ":", "kv", "=", "line", ".", "split", "(", "None", ",", "1", ")", "keyword", "=", "kv", "[", "0", "]", ".", "lower", "(", ")", "# Safely set the argument string if it wasn't found.", "values", "=", "kv",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SshdFieldParser._ParseEntry
Adds an entry for a configuration setting. Args: key: The name of the setting. val: The value of the setting.
grr/core/grr_response_core/lib/parsers/config_file.py
def _ParseEntry(self, key, val): """Adds an entry for a configuration setting. Args: key: The name of the setting. val: The value of the setting. """ if key in self._repeated: setting = self.section.setdefault(key, []) setting.extend(val) else: self.section.setdefault(...
def _ParseEntry(self, key, val): """Adds an entry for a configuration setting. Args: key: The name of the setting. val: The value of the setting. """ if key in self._repeated: setting = self.section.setdefault(key, []) setting.extend(val) else: self.section.setdefault(...
[ "Adds", "an", "entry", "for", "a", "configuration", "setting", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L492-L503
[ "def", "_ParseEntry", "(", "self", ",", "key", ",", "val", ")", ":", "if", "key", "in", "self", ".", "_repeated", ":", "setting", "=", "self", ".", "section", ".", "setdefault", "(", "key", ",", "[", "]", ")", "setting", ".", "extend", "(", "val", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SshdFieldParser._ParseMatchGrp
Adds valid match group parameters to the configuration.
grr/core/grr_response_core/lib/parsers/config_file.py
def _ParseMatchGrp(self, key, val): """Adds valid match group parameters to the configuration.""" if key in self._match_keywords: self._ParseEntry(key, val)
def _ParseMatchGrp(self, key, val): """Adds valid match group parameters to the configuration.""" if key in self._match_keywords: self._ParseEntry(key, val)
[ "Adds", "valid", "match", "group", "parameters", "to", "the", "configuration", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L505-L508
[ "def", "_ParseMatchGrp", "(", "self", ",", "key", ",", "val", ")", ":", "if", "key", "in", "self", ".", "_match_keywords", ":", "self", ".", "_ParseEntry", "(", "key", ",", "val", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SshdFieldParser._NewMatchSection
Create a new configuration section for each match clause. Each match clause is added to the main config, and the criterion that will trigger the match is recorded, as is the configuration. Args: val: The value following the 'match' keyword.
grr/core/grr_response_core/lib/parsers/config_file.py
def _NewMatchSection(self, val): """Create a new configuration section for each match clause. Each match clause is added to the main config, and the criterion that will trigger the match is recorded, as is the configuration. Args: val: The value following the 'match' keyword. """ section...
def _NewMatchSection(self, val): """Create a new configuration section for each match clause. Each match clause is added to the main config, and the criterion that will trigger the match is recorded, as is the configuration. Args: val: The value following the 'match' keyword. """ section...
[ "Create", "a", "new", "configuration", "section", "for", "each", "match", "clause", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L510-L524
[ "def", "_NewMatchSection", "(", "self", ",", "val", ")", ":", "section", "=", "{", "\"criterion\"", ":", "val", ",", "\"config\"", ":", "{", "}", "}", "self", ".", "matches", ".", "append", "(", "section", ")", "# Now add configuration items to config section ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SshdConfigParser.Parse
Parse the sshd configuration. Process each of the lines in the configuration file. Assembes an sshd_config file into a dictionary with the configuration keyword as the key, and the configuration settings as value(s). Args: stat: unused file_object: An open configuration file object. ...
grr/core/grr_response_core/lib/parsers/config_file.py
def Parse(self, stat, file_object, knowledge_base): """Parse the sshd configuration. Process each of the lines in the configuration file. Assembes an sshd_config file into a dictionary with the configuration keyword as the key, and the configuration settings as value(s). Args: stat: unused ...
def Parse(self, stat, file_object, knowledge_base): """Parse the sshd configuration. Process each of the lines in the configuration file. Assembes an sshd_config file into a dictionary with the configuration keyword as the key, and the configuration settings as value(s). Args: stat: unused ...
[ "Parse", "the", "sshd", "configuration", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L545-L574
[ "def", "Parse", "(", "self", ",", "stat", ",", "file_object", ",", "knowledge_base", ")", ":", "_", ",", "_", "=", "stat", ",", "knowledge_base", "# Clean out any residual state.", "self", ".", "_field_parser", ".", "Flush", "(", ")", "lines", "=", "[", "l...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MountCmdParser.Parse
Parse the mount command output.
grr/core/grr_response_core/lib/parsers/config_file.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the mount command output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) result = rdf_protodict.AttributedDict() for entry in self._field_parser.Pars...
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the mount command output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) result = rdf_protodict.AttributedDict() for entry in self._field_parser.Pars...
[ "Parse", "the", "mount", "command", "output", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L637-L660
[ "def", "Parse", "(", "self", ",", "cmd", ",", "args", ",", "stdout", ",", "stderr", ",", "return_val", ",", "time_taken", ",", "knowledge_base", ")", ":", "_", "=", "stderr", ",", "time_taken", ",", "args", ",", "knowledge_base", "# Unused.", "self", "."...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RsyslogFieldParser.ParseAction
Extract log configuration data from rsyslog actions. Actions have the format: <facility>/<severity> <type_def><destination>;<template> e.g. *.* @@loghost.example.com.:514;RSYSLOG_ForwardFormat Actions are selected by a type definition. These include: "@@": TCP syslog "@": UDP syslog ...
grr/core/grr_response_core/lib/parsers/config_file.py
def ParseAction(self, action): """Extract log configuration data from rsyslog actions. Actions have the format: <facility>/<severity> <type_def><destination>;<template> e.g. *.* @@loghost.example.com.:514;RSYSLOG_ForwardFormat Actions are selected by a type definition. These include: "@@...
def ParseAction(self, action): """Extract log configuration data from rsyslog actions. Actions have the format: <facility>/<severity> <type_def><destination>;<template> e.g. *.* @@loghost.example.com.:514;RSYSLOG_ForwardFormat Actions are selected by a type definition. These include: "@@...
[ "Extract", "log", "configuration", "data", "from", "rsyslog", "actions", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L677-L706
[ "def", "ParseAction", "(", "self", ",", "action", ")", ":", "rslt", "=", "rdf_config_file", ".", "LogTarget", "(", ")", "for", "dst_str", ",", "dst_re", "in", "iteritems", "(", "self", ".", "destinations", ")", ":", "dst", "=", "dst_re", ".", "match", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PackageSourceParser.ParseURIFromKeyValues
Parse key/value formatted source listing and return potential URLs. The fundamental shape of this format is as follows: key: value # here : = separator key : value URI: [URL] # here URI = uri_key [URL] # this is where it becomes trickey because [URL] [URL] # can contain 'separ...
grr/core/grr_response_core/lib/parsers/config_file.py
def ParseURIFromKeyValues(self, data, separator, uri_key): """Parse key/value formatted source listing and return potential URLs. The fundamental shape of this format is as follows: key: value # here : = separator key : value URI: [URL] # here URI = uri_key [URL] # this is where it b...
def ParseURIFromKeyValues(self, data, separator, uri_key): """Parse key/value formatted source listing and return potential URLs. The fundamental shape of this format is as follows: key: value # here : = separator key : value URI: [URL] # here URI = uri_key [URL] # this is where it b...
[ "Parse", "key", "/", "value", "formatted", "source", "listing", "and", "return", "potential", "URLs", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L763-L808
[ "def", "ParseURIFromKeyValues", "(", "self", ",", "data", ",", "separator", ",", "uri_key", ")", ":", "precondition", ".", "AssertType", "(", "data", ",", "Text", ")", "precondition", ".", "AssertType", "(", "separator", ",", "Text", ")", "kv_entries", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
APTPackageSourceParser.FindPotentialURIs
Given a file, this will return all potenial APT source URIs.
grr/core/grr_response_core/lib/parsers/config_file.py
def FindPotentialURIs(self, file_obj): """Given a file, this will return all potenial APT source URIs.""" rfc822_format = "" # will contain all lines not in legacy format uris_to_parse = [] for line in utils.ReadFileBytesAsUnicode(file_obj).splitlines(True): # check if legacy style line - if it ...
def FindPotentialURIs(self, file_obj): """Given a file, this will return all potenial APT source URIs.""" rfc822_format = "" # will contain all lines not in legacy format uris_to_parse = [] for line in utils.ReadFileBytesAsUnicode(file_obj).splitlines(True): # check if legacy style line - if it ...
[ "Given", "a", "file", "this", "will", "return", "all", "potenial", "APT", "source", "URIs", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L815-L829
[ "def", "FindPotentialURIs", "(", "self", ",", "file_obj", ")", ":", "rfc822_format", "=", "\"\"", "# will contain all lines not in legacy format", "uris_to_parse", "=", "[", "]", "for", "line", "in", "utils", ".", "ReadFileBytesAsUnicode", "(", "file_obj", ")", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
NtpdFieldParser.ParseLine
Extracts keyword/value settings from the ntpd config. The keyword is always the first entry item. Values are the remainder of the entries. In cases where an ntpd config allows multiple values, these are split according to whitespace or duplicate entries. Keywords and values are normalized. Keyword...
grr/core/grr_response_core/lib/parsers/config_file.py
def ParseLine(self, entries): """Extracts keyword/value settings from the ntpd config. The keyword is always the first entry item. Values are the remainder of the entries. In cases where an ntpd config allows multiple values, these are split according to whitespace or duplicate entries. Keywor...
def ParseLine(self, entries): """Extracts keyword/value settings from the ntpd config. The keyword is always the first entry item. Values are the remainder of the entries. In cases where an ntpd config allows multiple values, these are split according to whitespace or duplicate entries. Keywor...
[ "Extracts", "keyword", "/", "value", "settings", "from", "the", "ntpd", "config", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L925-L993
[ "def", "ParseLine", "(", "self", ",", "entries", ")", ":", "# If no entries were found, short circuit.", "if", "not", "entries", ":", "return", "keyword", "=", "entries", "[", "0", "]", ".", "lower", "(", ")", "# Set the argument string if it wasn't found.", "values...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
NtpdParser.Parse
Parse a ntp config into rdf.
grr/core/grr_response_core/lib/parsers/config_file.py
def Parse(self, stat, file_object, knowledge_base): """Parse a ntp config into rdf.""" _, _ = stat, knowledge_base # TODO(hanuszczak): This parser only allows single use because it messes # with its state. This should be fixed. field_parser = NtpdFieldParser() for line in field_parser.ParseEntr...
def Parse(self, stat, file_object, knowledge_base): """Parse a ntp config into rdf.""" _, _ = stat, knowledge_base # TODO(hanuszczak): This parser only allows single use because it messes # with its state. This should be fixed. field_parser = NtpdFieldParser() for line in field_parser.ParseEntr...
[ "Parse", "a", "ntp", "config", "into", "rdf", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L999-L1018
[ "def", "Parse", "(", "self", ",", "stat", ",", "file_object", ",", "knowledge_base", ")", ":", "_", ",", "_", "=", "stat", ",", "knowledge_base", "# TODO(hanuszczak): This parser only allows single use because it messes", "# with its state. This should be fixed.", "field_pa...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SudoersFieldParser._ExtractList
Extract a list from the given fields.
grr/core/grr_response_core/lib/parsers/config_file.py
def _ExtractList(self, fields, ignores=(",",), terminators=()): """Extract a list from the given fields.""" extracted = [] i = 0 for i, field in enumerate(fields): # Space-separated comma; ignore, but this is not a finished list. # Similar for any other specified ignores (eg, equals sign). ...
def _ExtractList(self, fields, ignores=(",",), terminators=()): """Extract a list from the given fields.""" extracted = [] i = 0 for i, field in enumerate(fields): # Space-separated comma; ignore, but this is not a finished list. # Similar for any other specified ignores (eg, equals sign). ...
[ "Extract", "a", "list", "from", "the", "given", "fields", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L1058-L1080
[ "def", "_ExtractList", "(", "self", ",", "fields", ",", "ignores", "=", "(", "\",\"", ",", ")", ",", "terminators", "=", "(", ")", ")", ":", "extracted", "=", "[", "]", "i", "=", "0", "for", "i", ",", "field", "in", "enumerate", "(", "fields", ")...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SudoersFieldParser.ParseSudoersEntry
Parse an entry and add it to the given SudoersConfig rdfvalue.
grr/core/grr_response_core/lib/parsers/config_file.py
def ParseSudoersEntry(self, entry, sudoers_config): """Parse an entry and add it to the given SudoersConfig rdfvalue.""" key = entry[0] if key in SudoersFieldParser.ALIAS_TYPES: # Alias. alias_entry = rdf_config_file.SudoersAlias( type=SudoersFieldParser.ALIAS_TYPES.get(key), name=ent...
def ParseSudoersEntry(self, entry, sudoers_config): """Parse an entry and add it to the given SudoersConfig rdfvalue.""" key = entry[0] if key in SudoersFieldParser.ALIAS_TYPES: # Alias. alias_entry = rdf_config_file.SudoersAlias( type=SudoersFieldParser.ALIAS_TYPES.get(key), name=ent...
[ "Parse", "an", "entry", "and", "add", "it", "to", "the", "given", "SudoersConfig", "rdfvalue", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L1082-L1137
[ "def", "ParseSudoersEntry", "(", "self", ",", "entry", ",", "sudoers_config", ")", ":", "key", "=", "entry", "[", "0", "]", "if", "key", "in", "SudoersFieldParser", ".", "ALIAS_TYPES", ":", "# Alias.", "alias_entry", "=", "rdf_config_file", ".", "SudoersAlias"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SudoersFieldParser.Preprocess
Preprocess the given data, ready for parsing.
grr/core/grr_response_core/lib/parsers/config_file.py
def Preprocess(self, data): """Preprocess the given data, ready for parsing.""" # Add whitespace to line continuations. data = data.replace(":\\", ": \\") # Strip comments manually because sudoers has multiple meanings for '#'. data = SudoersFieldParser.COMMENTS_RE.sub("", data) return data
def Preprocess(self, data): """Preprocess the given data, ready for parsing.""" # Add whitespace to line continuations. data = data.replace(":\\", ": \\") # Strip comments manually because sudoers has multiple meanings for '#'. data = SudoersFieldParser.COMMENTS_RE.sub("", data) return data
[ "Preprocess", "the", "given", "data", "ready", "for", "parsing", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/config_file.py#L1139-L1146
[ "def", "Preprocess", "(", "self", ",", "data", ")", ":", "# Add whitespace to line continuations.", "data", "=", "data", ".", "replace", "(", "\":\\\\\"", ",", "\": \\\\\"", ")", "# Strip comments manually because sudoers has multiple meanings for '#'.", "data", "=", "Sud...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFValueType.Validate
Validate an RDFValue instance. Args: value: An RDFValue instance or something which may be used to instantiate the correct instance. Raises: TypeValueError: If the value is not a valid RDFValue instance or the required type. Returns: A Valid RDFValue instance.
grr/core/grr_response_core/lib/type_info.py
def Validate(self, value): """Validate an RDFValue instance. Args: value: An RDFValue instance or something which may be used to instantiate the correct instance. Raises: TypeValueError: If the value is not a valid RDFValue instance or the required type. Returns: A V...
def Validate(self, value): """Validate an RDFValue instance. Args: value: An RDFValue instance or something which may be used to instantiate the correct instance. Raises: TypeValueError: If the value is not a valid RDFValue instance or the required type. Returns: A V...
[ "Validate", "an", "RDFValue", "instance", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/type_info.py#L130-L156
[ "def", "Validate", "(", "self", ",", "value", ")", ":", "# Allow None as a default.", "if", "value", "is", "None", ":", "return", "if", "not", "isinstance", "(", "value", ",", "self", ".", "rdfclass", ")", ":", "# Try to coerce the type to the correct rdf_class.",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFStructDictType.Validate
Validate the value. Args: value: Value is expected to be a dict-like object that a given RDFStruct can be initialized from. Raises: TypeValueError: If the value is not a valid dict-like object that a given RDFStruct can be initialized from. Returns: A valid instance of s...
grr/core/grr_response_core/lib/type_info.py
def Validate(self, value): """Validate the value. Args: value: Value is expected to be a dict-like object that a given RDFStruct can be initialized from. Raises: TypeValueError: If the value is not a valid dict-like object that a given RDFStruct can be initialized from. Re...
def Validate(self, value): """Validate the value. Args: value: Value is expected to be a dict-like object that a given RDFStruct can be initialized from. Raises: TypeValueError: If the value is not a valid dict-like object that a given RDFStruct can be initialized from. Re...
[ "Validate", "the", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/type_info.py#L177-L207
[ "def", "Validate", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "not", "isinstance", "(", "value", ",", "self", ".", "rdfclass", ")", ":", "# Try to coerce the type to the correct rdf_class.", "try", ":", "r"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TypeDescriptorSet.Add
Returns a copy of this set with a new element added.
grr/core/grr_response_core/lib/type_info.py
def Add(self, other): """Returns a copy of this set with a new element added.""" new_descriptors = [] for desc in self.descriptors + other.descriptors: if desc not in new_descriptors: new_descriptors.append(desc) return TypeDescriptorSet(*new_descriptors)
def Add(self, other): """Returns a copy of this set with a new element added.""" new_descriptors = [] for desc in self.descriptors + other.descriptors: if desc not in new_descriptors: new_descriptors.append(desc) return TypeDescriptorSet(*new_descriptors)
[ "Returns", "a", "copy", "of", "this", "set", "with", "a", "new", "element", "added", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/type_info.py#L253-L260
[ "def", "Add", "(", "self", ",", "other", ")", ":", "new_descriptors", "=", "[", "]", "for", "desc", "in", "self", ".", "descriptors", "+", "other", ".", "descriptors", ":", "if", "desc", "not", "in", "new_descriptors", ":", "new_descriptors", ".", "appen...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TypeDescriptorSet.Append
Append the descriptor to this set.
grr/core/grr_response_core/lib/type_info.py
def Append(self, desc): """Append the descriptor to this set.""" if desc not in self.descriptors: self.descriptors.append(desc) self.descriptor_map[desc.name] = desc self.descriptor_names.append(desc.name)
def Append(self, desc): """Append the descriptor to this set.""" if desc not in self.descriptors: self.descriptors.append(desc) self.descriptor_map[desc.name] = desc self.descriptor_names.append(desc.name)
[ "Append", "the", "descriptor", "to", "this", "set", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/type_info.py#L262-L267
[ "def", "Append", "(", "self", ",", "desc", ")", ":", "if", "desc", "not", "in", "self", ".", "descriptors", ":", "self", ".", "descriptors", ".", "append", "(", "desc", ")", "self", ".", "descriptor_map", "[", "desc", ".", "name", "]", "=", "desc", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TypeDescriptorSet.Remove
Returns a copy of this set without elements with given names.
grr/core/grr_response_core/lib/type_info.py
def Remove(self, *descriptor_names): """Returns a copy of this set without elements with given names.""" new_descriptor_map = self.descriptor_map.copy() for name in descriptor_names: new_descriptor_map.pop(name, None) new_descriptors = [ desc for desc in self.descriptors if desc i...
def Remove(self, *descriptor_names): """Returns a copy of this set without elements with given names.""" new_descriptor_map = self.descriptor_map.copy() for name in descriptor_names: new_descriptor_map.pop(name, None) new_descriptors = [ desc for desc in self.descriptors if desc i...
[ "Returns", "a", "copy", "of", "this", "set", "without", "elements", "with", "given", "names", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/type_info.py#L273-L283
[ "def", "Remove", "(", "self", ",", "*", "descriptor_names", ")", ":", "new_descriptor_map", "=", "self", ".", "descriptor_map", ".", "copy", "(", ")", "for", "name", "in", "descriptor_names", ":", "new_descriptor_map", ".", "pop", "(", "name", ",", "None", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TypeDescriptorSet.ParseArgs
Parse and validate the args. Note we pop all the args we consume here - so if there are any args we dont know about, args will not be an empty dict after this. This allows the same args to be parsed by several TypeDescriptorSets. Args: args: A dictionary of arguments that this TypeDescriptorSet ...
grr/core/grr_response_core/lib/type_info.py
def ParseArgs(self, args): """Parse and validate the args. Note we pop all the args we consume here - so if there are any args we dont know about, args will not be an empty dict after this. This allows the same args to be parsed by several TypeDescriptorSets. Args: args: A dictionary of argu...
def ParseArgs(self, args): """Parse and validate the args. Note we pop all the args we consume here - so if there are any args we dont know about, args will not be an empty dict after this. This allows the same args to be parsed by several TypeDescriptorSets. Args: args: A dictionary of argu...
[ "Parse", "and", "validate", "the", "args", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/type_info.py#L285-L316
[ "def", "ParseArgs", "(", "self", ",", "args", ")", ":", "for", "descriptor", "in", "self", ":", "# Get the value from the kwargs or, if not specified, the default.", "value", "=", "args", ".", "pop", "(", "descriptor", ".", "name", ",", "None", ")", "if", "value...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Bool.FromString
Parse a bool from a string.
grr/core/grr_response_core/lib/type_info.py
def FromString(self, string): """Parse a bool from a string.""" if string.lower() in ("false", "no", "n"): return False if string.lower() in ("true", "yes", "y"): return True raise TypeValueError("%s is not recognized as a boolean value." % string)
def FromString(self, string): """Parse a bool from a string.""" if string.lower() in ("false", "no", "n"): return False if string.lower() in ("true", "yes", "y"): return True raise TypeValueError("%s is not recognized as a boolean value." % string)
[ "Parse", "a", "bool", "from", "a", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/type_info.py#L330-L338
[ "def", "FromString", "(", "self", ",", "string", ")", ":", "if", "string", ".", "lower", "(", ")", "in", "(", "\"false\"", ",", "\"no\"", ",", "\"n\"", ")", ":", "return", "False", "if", "string", ".", "lower", "(", ")", "in", "(", "\"true\"", ",",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
List.Validate
Validate a potential list.
grr/core/grr_response_core/lib/type_info.py
def Validate(self, value): """Validate a potential list.""" if isinstance(value, string_types): raise TypeValueError("Value must be an iterable not a string.") elif not isinstance(value, (list, tuple)): raise TypeValueError("%r not a valid List" % value) # Validate each value in the list v...
def Validate(self, value): """Validate a potential list.""" if isinstance(value, string_types): raise TypeValueError("Value must be an iterable not a string.") elif not isinstance(value, (list, tuple)): raise TypeValueError("%r not a valid List" % value) # Validate each value in the list v...
[ "Validate", "a", "potential", "list", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/type_info.py#L350-L359
[ "def", "Validate", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "string_types", ")", ":", "raise", "TypeValueError", "(", "\"Value must be an iterable not a string.\"", ")", "elif", "not", "isinstance", "(", "value", ",", "(", "l...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Register
Adds all known parsers to the registry.
grr/core/grr_response_core/lib/parsers/all.py
def Register(): """Adds all known parsers to the registry.""" # pyformat: disable # Command parsers. parsers.SINGLE_RESPONSE_PARSER_FACTORY.Register( "Dpkg", linux_cmd_parser.DpkgCmdParser) parsers.SINGLE_RESPONSE_PARSER_FACTORY.Register( "Dmidecode", linux_cmd_parser.DmidecodeCmdParser) parser...
def Register(): """Adds all known parsers to the registry.""" # pyformat: disable # Command parsers. parsers.SINGLE_RESPONSE_PARSER_FACTORY.Register( "Dpkg", linux_cmd_parser.DpkgCmdParser) parsers.SINGLE_RESPONSE_PARSER_FACTORY.Register( "Dmidecode", linux_cmd_parser.DmidecodeCmdParser) parser...
[ "Adds", "all", "known", "parsers", "to", "the", "registry", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/all.py#L27-L181
[ "def", "Register", "(", ")", ":", "# pyformat: disable", "# Command parsers.", "parsers", ".", "SINGLE_RESPONSE_PARSER_FACTORY", ".", "Register", "(", "\"Dpkg\"", ",", "linux_cmd_parser", ".", "DpkgCmdParser", ")", "parsers", ".", "SINGLE_RESPONSE_PARSER_FACTORY", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_CurrentAuditLog
Get the rdfurn of the current audit log.
grr/server/grr_response_server/flows/general/audit.py
def _CurrentAuditLog(): """Get the rdfurn of the current audit log.""" now_sec = rdfvalue.RDFDatetime.Now().AsSecondsSinceEpoch() rollover_seconds = AUDIT_ROLLOVER_TIME.seconds # This gives us a filename that only changes every # AUDIT_ROLLOVER_TIfilME seconds, but is still a valid timestamp. current_log = ...
def _CurrentAuditLog(): """Get the rdfurn of the current audit log.""" now_sec = rdfvalue.RDFDatetime.Now().AsSecondsSinceEpoch() rollover_seconds = AUDIT_ROLLOVER_TIME.seconds # This gives us a filename that only changes every # AUDIT_ROLLOVER_TIfilME seconds, but is still a valid timestamp. current_log = ...
[ "Get", "the", "rdfurn", "of", "the", "current", "audit", "log", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/audit.py#L82-L89
[ "def", "_CurrentAuditLog", "(", ")", ":", "now_sec", "=", "rdfvalue", ".", "RDFDatetime", ".", "Now", "(", ")", ".", "AsSecondsSinceEpoch", "(", ")", "rollover_seconds", "=", "AUDIT_ROLLOVER_TIME", ".", "seconds", "# This gives us a filename that only changes every", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UnicodeFromCodePage
Attempt to coerce string into a unicode object.
grr/client/grr_response_client/client_actions/windows/windows.py
def UnicodeFromCodePage(string): """Attempt to coerce string into a unicode object.""" # get the current code page codepage = ctypes.windll.kernel32.GetOEMCP() try: return string.decode("cp%s" % codepage) except UnicodeError: try: return string.decode("utf16", "ignore") except UnicodeError: ...
def UnicodeFromCodePage(string): """Attempt to coerce string into a unicode object.""" # get the current code page codepage = ctypes.windll.kernel32.GetOEMCP() try: return string.decode("cp%s" % codepage) except UnicodeError: try: return string.decode("utf16", "ignore") except UnicodeError: ...
[ "Attempt", "to", "coerce", "string", "into", "a", "unicode", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/windows/windows.py#L43-L54
[ "def", "UnicodeFromCodePage", "(", "string", ")", ":", "# get the current code page", "codepage", "=", "ctypes", ".", "windll", ".", "kernel32", ".", "GetOEMCP", "(", ")", "try", ":", "return", "string", ".", "decode", "(", "\"cp%s\"", "%", "codepage", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EnumerateInterfacesFromClient
Enumerate all MAC addresses of all NICs. Args: args: Unused. Yields: `rdf_client_network.Interface` instances.
grr/client/grr_response_client/client_actions/windows/windows.py
def EnumerateInterfacesFromClient(args): """Enumerate all MAC addresses of all NICs. Args: args: Unused. Yields: `rdf_client_network.Interface` instances. """ del args # Unused. pythoncom.CoInitialize() for interface in (wmi.WMI().Win32_NetworkAdapterConfiguration() or []): addresses = [] ...
def EnumerateInterfacesFromClient(args): """Enumerate all MAC addresses of all NICs. Args: args: Unused. Yields: `rdf_client_network.Interface` instances. """ del args # Unused. pythoncom.CoInitialize() for interface in (wmi.WMI().Win32_NetworkAdapterConfiguration() or []): addresses = [] ...
[ "Enumerate", "all", "MAC", "addresses", "of", "all", "NICs", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/windows/windows.py#L71-L96
[ "def", "EnumerateInterfacesFromClient", "(", "args", ")", ":", "del", "args", "# Unused.", "pythoncom", ".", "CoInitialize", "(", ")", "for", "interface", "in", "(", "wmi", ".", "WMI", "(", ")", ".", "Win32_NetworkAdapterConfiguration", "(", ")", "or", "[", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EnumerateFilesystemsFromClient
List all local filesystems mounted on this system.
grr/client/grr_response_client/client_actions/windows/windows.py
def EnumerateFilesystemsFromClient(args): """List all local filesystems mounted on this system.""" del args # Unused. for drive in win32api.GetLogicalDriveStrings().split("\x00"): if not drive: continue try: volume = win32file.GetVolumeNameForVolumeMountPoint(drive).rstrip("\\") label,...
def EnumerateFilesystemsFromClient(args): """List all local filesystems mounted on this system.""" del args # Unused. for drive in win32api.GetLogicalDriveStrings().split("\x00"): if not drive: continue try: volume = win32file.GetVolumeNameForVolumeMountPoint(drive).rstrip("\\") label,...
[ "List", "all", "local", "filesystems", "mounted", "on", "this", "system", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/windows/windows.py#L112-L128
[ "def", "EnumerateFilesystemsFromClient", "(", "args", ")", ":", "del", "args", "# Unused.", "for", "drive", "in", "win32api", ".", "GetLogicalDriveStrings", "(", ")", ".", "split", "(", "\"\\x00\"", ")", ":", "if", "not", "drive", ":", "continue", "try", ":"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
QueryService
Query service and get its config.
grr/client/grr_response_client/client_actions/windows/windows.py
def QueryService(svc_name): """Query service and get its config.""" hscm = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_ALL_ACCESS) result = None try: hs = win32serviceutil.SmartOpenService(hscm, svc_name, win32...
def QueryService(svc_name): """Query service and get its config.""" hscm = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_ALL_ACCESS) result = None try: hs = win32serviceutil.SmartOpenService(hscm, svc_name, win32...
[ "Query", "service", "and", "get", "its", "config", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/windows/windows.py#L161-L174
[ "def", "QueryService", "(", "svc_name", ")", ":", "hscm", "=", "win32service", ".", "OpenSCManager", "(", "None", ",", "None", ",", "win32service", ".", "SC_MANAGER_ALL_ACCESS", ")", "result", "=", "None", "try", ":", "hs", "=", "win32serviceutil", ".", "Sma...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WmiQueryFromClient
Run the WMI query and return the data.
grr/client/grr_response_client/client_actions/windows/windows.py
def WmiQueryFromClient(args): """Run the WMI query and return the data.""" query = args.query base_object = args.base_object or r"winmgmts:\root\cimv2" if not query.upper().startswith("SELECT "): raise RuntimeError("Only SELECT WMI queries allowed.") for response_dict in RunWMIQuery(query, baseobj=base_...
def WmiQueryFromClient(args): """Run the WMI query and return the data.""" query = args.query base_object = args.base_object or r"winmgmts:\root\cimv2" if not query.upper().startswith("SELECT "): raise RuntimeError("Only SELECT WMI queries allowed.") for response_dict in RunWMIQuery(query, baseobj=base_...
[ "Run", "the", "WMI", "query", "and", "return", "the", "data", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/windows/windows.py#L177-L186
[ "def", "WmiQueryFromClient", "(", "args", ")", ":", "query", "=", "args", ".", "query", "base_object", "=", "args", ".", "base_object", "or", "r\"winmgmts:\\root\\cimv2\"", "if", "not", "query", ".", "upper", "(", ")", ".", "startswith", "(", "\"SELECT \"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RunWMIQuery
Run a WMI query and return a result. Args: query: the WMI query to run. baseobj: the base object for the WMI query. Yields: rdf_protodict.Dicts containing key value pairs from the resulting COM objects.
grr/client/grr_response_client/client_actions/windows/windows.py
def RunWMIQuery(query, baseobj=r"winmgmts:\root\cimv2"): """Run a WMI query and return a result. Args: query: the WMI query to run. baseobj: the base object for the WMI query. Yields: rdf_protodict.Dicts containing key value pairs from the resulting COM objects. """ pythoncom.CoInitialize() ...
def RunWMIQuery(query, baseobj=r"winmgmts:\root\cimv2"): """Run a WMI query and return a result. Args: query: the WMI query to run. baseobj: the base object for the WMI query. Yields: rdf_protodict.Dicts containing key value pairs from the resulting COM objects. """ pythoncom.CoInitialize() ...
[ "Run", "a", "WMI", "query", "and", "return", "a", "result", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/windows/windows.py#L199-L240
[ "def", "RunWMIQuery", "(", "query", ",", "baseobj", "=", "r\"winmgmts:\\root\\cimv2\"", ")", ":", "pythoncom", ".", "CoInitialize", "(", ")", "# Needs to be called if using com from a thread.", "wmi_obj", "=", "win32com", ".", "client", ".", "GetObject", "(", "baseobj...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetInstallDate.Run
Estimate the install date of this system.
grr/client/grr_response_client/client_actions/windows/windows.py
def Run(self, unused_args): """Estimate the install date of this system.""" # Don't use winreg.KEY_WOW64_64KEY since it breaks on Windows 2000 subkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, winr...
def Run(self, unused_args): """Estimate the install date of this system.""" # Don't use winreg.KEY_WOW64_64KEY since it breaks on Windows 2000 subkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, winr...
[ "Estimate", "the", "install", "date", "of", "this", "system", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/windows/windows.py#L61-L68
[ "def", "Run", "(", "self", ",", "unused_args", ")", ":", "# Don't use winreg.KEY_WOW64_64KEY since it breaks on Windows 2000", "subkey", "=", "winreg", ".", "OpenKey", "(", "winreg", ".", "HKEY_LOCAL_MACHINE", ",", "\"Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Uninstall.Run
This kills us with no cleanups.
grr/client/grr_response_client/client_actions/windows/windows.py
def Run(self, unused_arg): """This kills us with no cleanups.""" logging.debug("Disabling service") win32serviceutil.ChangeServiceConfig( None, config.CONFIG["Nanny.service_name"], startType=win32service.SERVICE_DISABLED) svc_config = QueryService(config.CONFIG["Nanny.service_na...
def Run(self, unused_arg): """This kills us with no cleanups.""" logging.debug("Disabling service") win32serviceutil.ChangeServiceConfig( None, config.CONFIG["Nanny.service_name"], startType=win32service.SERVICE_DISABLED) svc_config = QueryService(config.CONFIG["Nanny.service_na...
[ "This", "kills", "us", "with", "no", "cleanups", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/windows/windows.py#L144-L158
[ "def", "Run", "(", "self", ",", "unused_arg", ")", ":", "logging", ".", "debug", "(", "\"Disabling service\"", ")", "win32serviceutil", ".", "ChangeServiceConfig", "(", "None", ",", "config", ".", "CONFIG", "[", "\"Nanny.service_name\"", "]", ",", "startType", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74