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
BigQueryOutputPlugin.WriteValuesToJSONFile
Write newline separated JSON dicts for each value. We write each dict separately so we don't have to hold all of the output streams in memory. We open and close the JSON array manually with []. Args: state: rdf_protodict.AttributedDict with the plugin's state. values: RDF values to export.
grr/server/grr_response_server/output_plugins/bigquery_plugin.py
def WriteValuesToJSONFile(self, state, values): """Write newline separated JSON dicts for each value. We write each dict separately so we don't have to hold all of the output streams in memory. We open and close the JSON array manually with []. Args: state: rdf_protodict.AttributedDict with the ...
def WriteValuesToJSONFile(self, state, values): """Write newline separated JSON dicts for each value. We write each dict separately so we don't have to hold all of the output streams in memory. We open and close the JSON array manually with []. Args: state: rdf_protodict.AttributedDict with the ...
[ "Write", "newline", "separated", "JSON", "dicts", "for", "each", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/output_plugins/bigquery_plugin.py#L254-L296
[ "def", "WriteValuesToJSONFile", "(", "self", ",", "state", ",", "values", ")", ":", "value_counters", "=", "{", "}", "max_post_size", "=", "config", ".", "CONFIG", "[", "\"BigQuery.max_file_post_size\"", "]", "for", "value", "in", "values", ":", "class_name", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FilterArgsFromSemanticProtobuf
Assign kwargs to the protobuf, and remove them from the kwargs dict.
grr/server/grr_response_server/flow.py
def FilterArgsFromSemanticProtobuf(protobuf, kwargs): """Assign kwargs to the protobuf, and remove them from the kwargs dict.""" for descriptor in protobuf.type_infos: value = kwargs.pop(descriptor.name, None) if value is not None: setattr(protobuf, descriptor.name, value)
def FilterArgsFromSemanticProtobuf(protobuf, kwargs): """Assign kwargs to the protobuf, and remove them from the kwargs dict.""" for descriptor in protobuf.type_infos: value = kwargs.pop(descriptor.name, None) if value is not None: setattr(protobuf, descriptor.name, value)
[ "Assign", "kwargs", "to", "the", "protobuf", "and", "remove", "them", "from", "the", "kwargs", "dict", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L181-L186
[ "def", "FilterArgsFromSemanticProtobuf", "(", "protobuf", ",", "kwargs", ")", ":", "for", "descriptor", "in", "protobuf", ".", "type_infos", ":", "value", "=", "kwargs", ".", "pop", "(", "descriptor", ".", "name", ",", "None", ")", "if", "value", "is", "no...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetOutputPluginStates
Initializes state for a list of output plugins.
grr/server/grr_response_server/flow.py
def GetOutputPluginStates(output_plugins, source=None, token=None): """Initializes state for a list of output plugins.""" output_plugins_states = [] for plugin_descriptor in output_plugins: plugin_class = plugin_descriptor.GetPluginClass() try: _, plugin_state = plugin_class.CreatePluginAndDefaultSt...
def GetOutputPluginStates(output_plugins, source=None, token=None): """Initializes state for a list of output plugins.""" output_plugins_states = [] for plugin_descriptor in output_plugins: plugin_class = plugin_descriptor.GetPluginClass() try: _, plugin_state = plugin_class.CreatePluginAndDefaultSt...
[ "Initializes", "state", "for", "a", "list", "of", "output", "plugins", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L189-L210
[ "def", "GetOutputPluginStates", "(", "output_plugins", ",", "source", "=", "None", ",", "token", "=", "None", ")", ":", "output_plugins_states", "=", "[", "]", "for", "plugin_descriptor", "in", "output_plugins", ":", "plugin_class", "=", "plugin_descriptor", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StartAFF4Flow
The main factory function for creating and executing a new flow. Args: args: An arg protocol buffer which is an instance of the required flow's args_type class attribute. runner_args: an instance of FlowRunnerArgs() protocol buffer which is used to initialize the runner for this flow. parent_...
grr/server/grr_response_server/flow.py
def StartAFF4Flow(args=None, runner_args=None, parent_flow=None, sync=True, token=None, **kwargs): """The main factory function for creating and executing a new flow. Args: args: An arg protocol buffer which is an instanc...
def StartAFF4Flow(args=None, runner_args=None, parent_flow=None, sync=True, token=None, **kwargs): """The main factory function for creating and executing a new flow. Args: args: An arg protocol buffer which is an instanc...
[ "The", "main", "factory", "function", "for", "creating", "and", "executing", "a", "new", "flow", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L213-L330
[ "def", "StartAFF4Flow", "(", "args", "=", "None", ",", "runner_args", "=", "None", ",", "parent_flow", "=", "None", ",", "sync", "=", "True", ",", "token", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Build the runner args from the keywords.", "if", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StartFlow
The main factory function for creating and executing a new flow. Args: client_id: ID of the client this flow should run on. cpu_limit: CPU limit in seconds for this flow. creator: Username that requested this flow. flow_args: An arg protocol buffer which is an instance of the required flow's ar...
grr/server/grr_response_server/flow.py
def StartFlow(client_id=None, cpu_limit=None, creator=None, flow_args=None, flow_cls=None, network_bytes_limit=None, original_flow=None, output_plugins=None, start_at=None, parent_flow_obj=None,...
def StartFlow(client_id=None, cpu_limit=None, creator=None, flow_args=None, flow_cls=None, network_bytes_limit=None, original_flow=None, output_plugins=None, start_at=None, parent_flow_obj=None,...
[ "The", "main", "factory", "function", "for", "creating", "and", "executing", "a", "new", "flow", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L338-L508
[ "def", "StartFlow", "(", "client_id", "=", "None", ",", "cpu_limit", "=", "None", ",", "creator", "=", "None", ",", "flow_args", "=", "None", ",", "flow_cls", "=", "None", ",", "network_bytes_limit", "=", "None", ",", "original_flow", "=", "None", ",", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FlowBase.Flush
Flushes the flow/hunt and all its requests to the data_store.
grr/server/grr_response_server/flow.py
def Flush(self): """Flushes the flow/hunt and all its requests to the data_store.""" self._CheckLeaseAndFlush() self.Load() super(FlowBase, self).Flush() # Writing the messages queued in the queue_manager of the runner always has # to be the last thing that happens or we will have a race conditi...
def Flush(self): """Flushes the flow/hunt and all its requests to the data_store.""" self._CheckLeaseAndFlush() self.Load() super(FlowBase, self).Flush() # Writing the messages queued in the queue_manager of the runner always has # to be the last thing that happens or we will have a race conditi...
[ "Flushes", "the", "flow", "/", "hunt", "and", "all", "its", "requests", "to", "the", "data_store", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L551-L558
[ "def", "Flush", "(", "self", ")", ":", "self", ".", "_CheckLeaseAndFlush", "(", ")", "self", ".", "Load", "(", ")", "super", "(", "FlowBase", ",", "self", ")", ".", "Flush", "(", ")", "# Writing the messages queued in the queue_manager of the runner always has", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FlowBase.Close
Flushes the flow and all its requests to the data_store.
grr/server/grr_response_server/flow.py
def Close(self): """Flushes the flow and all its requests to the data_store.""" self._CheckLeaseAndFlush() super(FlowBase, self).Close() # Writing the messages queued in the queue_manager of the runner always has # to be the last thing that happens or we will have a race condition. self.FlushMes...
def Close(self): """Flushes the flow and all its requests to the data_store.""" self._CheckLeaseAndFlush() super(FlowBase, self).Close() # Writing the messages queued in the queue_manager of the runner always has # to be the last thing that happens or we will have a race condition. self.FlushMes...
[ "Flushes", "the", "flow", "and", "all", "its", "requests", "to", "the", "data_store", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L560-L566
[ "def", "Close", "(", "self", ")", ":", "self", ".", "_CheckLeaseAndFlush", "(", ")", "super", "(", "FlowBase", ",", "self", ")", ".", "Close", "(", ")", "# Writing the messages queued in the queue_manager of the runner always has", "# to be the last thing that happens or ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRFlow.Initialize
The initialization method.
grr/server/grr_response_server/flow.py
def Initialize(self): """The initialization method.""" super(GRRFlow, self).Initialize() self._client_version = None self._client_os = None self._client_knowledge_base = None if "r" in self.mode: state = self.Get(self.Schema.FLOW_STATE_DICT) self.context = self.Get(self.Schema.FLOW_...
def Initialize(self): """The initialization method.""" super(GRRFlow, self).Initialize() self._client_version = None self._client_os = None self._client_knowledge_base = None if "r" in self.mode: state = self.Get(self.Schema.FLOW_STATE_DICT) self.context = self.Get(self.Schema.FLOW_...
[ "The", "initialization", "method", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L751-L774
[ "def", "Initialize", "(", "self", ")", ":", "super", "(", "GRRFlow", ",", "self", ")", ".", "Initialize", "(", ")", "self", ".", "_client_version", "=", "None", "self", ".", "_client_os", "=", "None", "self", ".", "_client_knowledge_base", "=", "None", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRFlow.CreateRunner
Make a new runner.
grr/server/grr_response_server/flow.py
def CreateRunner(self, **kw): """Make a new runner.""" self.runner = flow_runner.FlowRunner(self, token=self.token, **kw) return self.runner
def CreateRunner(self, **kw): """Make a new runner.""" self.runner = flow_runner.FlowRunner(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/flow.py#L776-L779
[ "def", "CreateRunner", "(", "self", ",", "*", "*", "kw", ")", ":", "self", ".", "runner", "=", "flow_runner", ".", "FlowRunner", "(", "self", ",", "token", "=", "self", ".", "token", ",", "*", "*", "kw", ")", "return", "self", ".", "runner" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRFlow.NotifyAboutEnd
Send out a final notification about the end of this flow.
grr/server/grr_response_server/flow.py
def NotifyAboutEnd(self): """Send out a final notification about the end of this flow.""" flow_ref = None if self.runner_args.client_id: flow_ref = rdf_objects.FlowReference( client_id=self.client_id, flow_id=self.urn.Basename()) num_results = len(self.ResultCollection()) notificati...
def NotifyAboutEnd(self): """Send out a final notification about the end of this flow.""" flow_ref = None if self.runner_args.client_id: flow_ref = rdf_objects.FlowReference( client_id=self.client_id, flow_id=self.urn.Basename()) num_results = len(self.ResultCollection()) notificati...
[ "Send", "out", "a", "final", "notification", "about", "the", "end", "of", "this", "flow", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L795-L810
[ "def", "NotifyAboutEnd", "(", "self", ")", ":", "flow_ref", "=", "None", "if", "self", ".", "runner_args", ".", "client_id", ":", "flow_ref", "=", "rdf_objects", ".", "FlowReference", "(", "client_id", "=", "self", ".", "client_id", ",", "flow_id", "=", "s...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRFlow.MarkForTermination
Mark the flow for termination as soon as any of its states are called.
grr/server/grr_response_server/flow.py
def MarkForTermination(cls, flow_urn, reason=None, mutation_pool=None): """Mark the flow for termination as soon as any of its states are called.""" # Doing a blind write here using low-level data store API. Accessing # the flow via AFF4 is not really possible here, because it forces a state # to be wri...
def MarkForTermination(cls, flow_urn, reason=None, mutation_pool=None): """Mark the flow for termination as soon as any of its states are called.""" # Doing a blind write here using low-level data store API. Accessing # the flow via AFF4 is not really possible here, because it forces a state # to be wri...
[ "Mark", "the", "flow", "for", "termination", "as", "soon", "as", "any", "of", "its", "states", "are", "called", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L887-L899
[ "def", "MarkForTermination", "(", "cls", ",", "flow_urn", ",", "reason", "=", "None", ",", "mutation_pool", "=", "None", ")", ":", "# Doing a blind write here using low-level data store API. Accessing", "# the flow via AFF4 is not really possible here, because it forces a state", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRFlow.TerminateAFF4Flow
Terminate a flow. Args: flow_id: The flow session_id to terminate. reason: A reason to log. status: Status code used in the generated status message. token: The access token to be used for this request. Raises: FlowError: If the flow can not be found.
grr/server/grr_response_server/flow.py
def TerminateAFF4Flow(cls, flow_id, reason=None, status=None, token=None): """Terminate a flow. Args: flow_id: The flow session_id to terminate. reason: A reason to log. status: Status code used in the generated status message. token: The access token to be used for this request. R...
def TerminateAFF4Flow(cls, flow_id, reason=None, status=None, token=None): """Terminate a flow. Args: flow_id: The flow session_id to terminate. reason: A reason to log. status: Status code used in the generated status message. token: The access token to be used for this request. R...
[ "Terminate", "a", "flow", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L902-L946
[ "def", "TerminateAFF4Flow", "(", "cls", ",", "flow_id", ",", "reason", "=", "None", ",", "status", "=", "None", ",", "token", "=", "None", ")", ":", "flow_obj", "=", "aff4", ".", "FACTORY", ".", "Open", "(", "flow_id", ",", "aff4_type", "=", "GRRFlow",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRFlow.ResultCollectionForFID
Returns the ResultCollection for the flow with a given flow_id. Args: flow_id: The id of the flow, a RDFURN of the form aff4:/flows/F:123456. Returns: The collection containing the results for the flow identified by the id.
grr/server/grr_response_server/flow.py
def ResultCollectionForFID(cls, flow_id): """Returns the ResultCollection for the flow with a given flow_id. Args: flow_id: The id of the flow, a RDFURN of the form aff4:/flows/F:123456. Returns: The collection containing the results for the flow identified by the id. """ # TODO: Disal...
def ResultCollectionForFID(cls, flow_id): """Returns the ResultCollection for the flow with a given flow_id. Args: flow_id: The id of the flow, a RDFURN of the form aff4:/flows/F:123456. Returns: The collection containing the results for the flow identified by the id. """ # TODO: Disal...
[ "Returns", "the", "ResultCollection", "for", "the", "flow", "with", "a", "given", "flow_id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L956-L970
[ "def", "ResultCollectionForFID", "(", "cls", ",", "flow_id", ")", ":", "# TODO: Disallow/remove URNs after migration.", "if", "not", "isinstance", "(", "flow_id", ",", "rdfvalue", ".", "RDFURN", ")", ":", "flow_id", "=", "rdfvalue", ".", "RDFURN", "(", "flow_id", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WellKnownFlow.GetAllWellKnownFlows
Get instances of all well known flows.
grr/server/grr_response_server/flow.py
def GetAllWellKnownFlows(cls, token=None): """Get instances of all well known flows.""" well_known_flows = {} for cls in itervalues(registry.AFF4FlowRegistry.FLOW_REGISTRY): if issubclass(cls, WellKnownFlow) and cls.well_known_session_id: well_known_flow = cls(cls.well_known_session_id, mode="...
def GetAllWellKnownFlows(cls, token=None): """Get instances of all well known flows.""" well_known_flows = {} for cls in itervalues(registry.AFF4FlowRegistry.FLOW_REGISTRY): if issubclass(cls, WellKnownFlow) and cls.well_known_session_id: well_known_flow = cls(cls.well_known_session_id, mode="...
[ "Get", "instances", "of", "all", "well", "known", "flows", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L1027-L1035
[ "def", "GetAllWellKnownFlows", "(", "cls", ",", "token", "=", "None", ")", ":", "well_known_flows", "=", "{", "}", "for", "cls", "in", "itervalues", "(", "registry", ".", "AFF4FlowRegistry", ".", "FLOW_REGISTRY", ")", ":", "if", "issubclass", "(", "cls", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WellKnownFlow.FetchAndRemoveRequestsAndResponses
Removes WellKnownFlow messages from the queue and returns them.
grr/server/grr_response_server/flow.py
def FetchAndRemoveRequestsAndResponses(self, session_id): """Removes WellKnownFlow messages from the queue and returns them.""" messages = [] with queue_manager.WellKnownQueueManager(token=self.token) as manager: for response in manager.FetchResponses(session_id): messages.append(response) ...
def FetchAndRemoveRequestsAndResponses(self, session_id): """Removes WellKnownFlow messages from the queue and returns them.""" messages = [] with queue_manager.WellKnownQueueManager(token=self.token) as manager: for response in manager.FetchResponses(session_id): messages.append(response) ...
[ "Removes", "WellKnownFlow", "messages", "from", "the", "queue", "and", "returns", "them", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L1060-L1068
[ "def", "FetchAndRemoveRequestsAndResponses", "(", "self", ",", "session_id", ")", ":", "messages", "=", "[", "]", "with", "queue_manager", ".", "WellKnownQueueManager", "(", "token", "=", "self", ".", "token", ")", "as", "manager", ":", "for", "response", "in"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WellKnownFlow.ProcessResponses
For WellKnownFlows we receive these messages directly.
grr/server/grr_response_server/flow.py
def ProcessResponses(self, responses, thread_pool): """For WellKnownFlows we receive these messages directly.""" for response in responses: thread_pool.AddTask( target=self._SafeProcessMessage, args=(response,), name=self.__class__.__name__)
def ProcessResponses(self, responses, thread_pool): """For WellKnownFlows we receive these messages directly.""" for response in responses: thread_pool.AddTask( target=self._SafeProcessMessage, args=(response,), name=self.__class__.__name__)
[ "For", "WellKnownFlows", "we", "receive", "these", "messages", "directly", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L1070-L1076
[ "def", "ProcessResponses", "(", "self", ",", "responses", ",", "thread_pool", ")", ":", "for", "response", "in", "responses", ":", "thread_pool", ".", "AddTask", "(", "target", "=", "self", ".", "_SafeProcessMessage", ",", "args", "=", "(", "response", ",", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
NetworkAddress.AsIPAddr
Returns the IP as an `IPAddress` object (if packed bytes are defined).
grr/core/grr_response_core/lib/rdfvalues/client_network.py
def AsIPAddr(self): """Returns the IP as an `IPAddress` object (if packed bytes are defined).""" if self.packed_bytes is None: return None packed_bytes = self.packed_bytes.AsBytes() if self.address_type == NetworkAddress.Family.INET: return ipaddress.IPv4Address(packed_bytes) if self.a...
def AsIPAddr(self): """Returns the IP as an `IPAddress` object (if packed bytes are defined).""" if self.packed_bytes is None: return None packed_bytes = self.packed_bytes.AsBytes() if self.address_type == NetworkAddress.Family.INET: return ipaddress.IPv4Address(packed_bytes) if self.a...
[ "Returns", "the", "IP", "as", "an", "IPAddress", "object", "(", "if", "packed", "bytes", "are", "defined", ")", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client_network.py#L82-L95
[ "def", "AsIPAddr", "(", "self", ")", ":", "if", "self", ".", "packed_bytes", "is", "None", ":", "return", "None", "packed_bytes", "=", "self", ".", "packed_bytes", ".", "AsBytes", "(", ")", "if", "self", ".", "address_type", "==", "NetworkAddress", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Interface.GetIPAddresses
Return a list of IP addresses.
grr/core/grr_response_core/lib/rdfvalues/client_network.py
def GetIPAddresses(self): """Return a list of IP addresses.""" results = [] for address in self.addresses: human_readable_address = address.human_readable_address if human_readable_address is not None: results.append(human_readable_address) return results
def GetIPAddresses(self): """Return a list of IP addresses.""" results = [] for address in self.addresses: human_readable_address = address.human_readable_address if human_readable_address is not None: results.append(human_readable_address) return results
[ "Return", "a", "list", "of", "IP", "addresses", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client_network.py#L125-L133
[ "def", "GetIPAddresses", "(", "self", ")", ":", "results", "=", "[", "]", "for", "address", "in", "self", ".", "addresses", ":", "human_readable_address", "=", "address", ".", "human_readable_address", "if", "human_readable_address", "is", "not", "None", ":", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_CheckConditionsShortCircuit
Checks all `content_conditions` until one yields no matches.
grr/client/grr_response_client/client_actions/vfs_file_finder.py
def _CheckConditionsShortCircuit(content_conditions, pathspec): """Checks all `content_conditions` until one yields no matches.""" matches = [] for cond in content_conditions: with vfs.VFSOpen(pathspec) as vfs_file: cur_matches = list(cond.Search(vfs_file)) if cur_matches: matches.extend(cur_m...
def _CheckConditionsShortCircuit(content_conditions, pathspec): """Checks all `content_conditions` until one yields no matches.""" matches = [] for cond in content_conditions: with vfs.VFSOpen(pathspec) as vfs_file: cur_matches = list(cond.Search(vfs_file)) if cur_matches: matches.extend(cur_m...
[ "Checks", "all", "content_conditions", "until", "one", "yields", "no", "matches", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/vfs_file_finder.py#L68-L78
[ "def", "_CheckConditionsShortCircuit", "(", "content_conditions", ",", "pathspec", ")", ":", "matches", "=", "[", "]", "for", "cond", "in", "content_conditions", ":", "with", "vfs", ".", "VFSOpen", "(", "pathspec", ")", "as", "vfs_file", ":", "cur_matches", "=...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_GetExpandedPaths
Yields all possible expansions from given path patterns.
grr/client/grr_response_client/client_actions/vfs_file_finder.py
def _GetExpandedPaths(args): """Yields all possible expansions from given path patterns.""" opts = globbing.PathOpts( follow_links=args.follow_links, pathtype=args.pathtype) for path in args.paths: for expanded_path in globbing.ExpandPath(str(path), opts): yield expanded_path
def _GetExpandedPaths(args): """Yields all possible expansions from given path patterns.""" opts = globbing.PathOpts( follow_links=args.follow_links, pathtype=args.pathtype) for path in args.paths: for expanded_path in globbing.ExpandPath(str(path), opts): yield expanded_path
[ "Yields", "all", "possible", "expansions", "from", "given", "path", "patterns", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/vfs_file_finder.py#L81-L88
[ "def", "_GetExpandedPaths", "(", "args", ")", ":", "opts", "=", "globbing", ".", "PathOpts", "(", "follow_links", "=", "args", ".", "follow_links", ",", "pathtype", "=", "args", ".", "pathtype", ")", "for", "path", "in", "args", ".", "paths", ":", "for",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RegistryKeyFromClient
This function expands paths from the args and returns registry keys. Args: args: An `rdf_file_finder.FileFinderArgs` object. Yields: `rdf_client_fs.StatEntry` instances.
grr/client/grr_response_client/client_actions/vfs_file_finder.py
def RegistryKeyFromClient(args): """This function expands paths from the args and returns registry keys. Args: args: An `rdf_file_finder.FileFinderArgs` object. Yields: `rdf_client_fs.StatEntry` instances. """ for path in _GetExpandedPaths(args): pathspec = rdf_paths.PathSpec( path=path,...
def RegistryKeyFromClient(args): """This function expands paths from the args and returns registry keys. Args: args: An `rdf_file_finder.FileFinderArgs` object. Yields: `rdf_client_fs.StatEntry` instances. """ for path in _GetExpandedPaths(args): pathspec = rdf_paths.PathSpec( path=path,...
[ "This", "function", "expands", "paths", "from", "the", "args", "and", "returns", "registry", "keys", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/vfs_file_finder.py#L93-L106
[ "def", "RegistryKeyFromClient", "(", "args", ")", ":", "for", "path", "in", "_GetExpandedPaths", "(", "args", ")", ":", "pathspec", "=", "rdf_paths", ".", "PathSpec", "(", "path", "=", "path", ",", "pathtype", "=", "rdf_paths", ".", "PathSpec", ".", "PathT...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetClientVersion
Returns last known GRR version that the client used.
grr/server/grr_response_server/data_store_utils.py
def GetClientVersion(client_id, token=None): """Returns last known GRR version that the client used.""" if data_store.RelationalDBEnabled(): sinfo = data_store.REL_DB.ReadClientStartupInfo(client_id=client_id) if sinfo is not None: return sinfo.client_info.client_version else: return config....
def GetClientVersion(client_id, token=None): """Returns last known GRR version that the client used.""" if data_store.RelationalDBEnabled(): sinfo = data_store.REL_DB.ReadClientStartupInfo(client_id=client_id) if sinfo is not None: return sinfo.client_info.client_version else: return config....
[ "Returns", "last", "known", "GRR", "version", "that", "the", "client", "used", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store_utils.py#L18-L32
[ "def", "GetClientVersion", "(", "client_id", ",", "token", "=", "None", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "sinfo", "=", "data_store", ".", "REL_DB", ".", "ReadClientStartupInfo", "(", "client_id", "=", "client_id", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetClientOs
Returns last known operating system name that the client used.
grr/server/grr_response_server/data_store_utils.py
def GetClientOs(client_id, token=None): """Returns last known operating system name that the client used.""" if data_store.RelationalDBEnabled(): kb = data_store.REL_DB.ReadClientSnapshot(client_id).knowledge_base else: with aff4.FACTORY.Open(client_id, token=token) as client: kb = client.Get(client...
def GetClientOs(client_id, token=None): """Returns last known operating system name that the client used.""" if data_store.RelationalDBEnabled(): kb = data_store.REL_DB.ReadClientSnapshot(client_id).knowledge_base else: with aff4.FACTORY.Open(client_id, token=token) as client: kb = client.Get(client...
[ "Returns", "last", "known", "operating", "system", "name", "that", "the", "client", "used", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store_utils.py#L35-L43
[ "def", "GetClientOs", "(", "client_id", ",", "token", "=", "None", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "kb", "=", "data_store", ".", "REL_DB", ".", "ReadClientSnapshot", "(", "client_id", ")", ".", "knowledge_base", "else...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetFileHashEntry
Returns an `rdf_crypto.Hash` instance for given AFF4 file descriptor.
grr/server/grr_response_server/data_store_utils.py
def GetFileHashEntry(fd): """Returns an `rdf_crypto.Hash` instance for given AFF4 file descriptor.""" # Hash file store is not migrated to RELDB just yet, hence the first check. if (not fd.urn.Path().startswith("/files/hash/generic") and data_store.RelationalDBEnabled()): return GetUrnHashEntry(fd.urn) ...
def GetFileHashEntry(fd): """Returns an `rdf_crypto.Hash` instance for given AFF4 file descriptor.""" # Hash file store is not migrated to RELDB just yet, hence the first check. if (not fd.urn.Path().startswith("/files/hash/generic") and data_store.RelationalDBEnabled()): return GetUrnHashEntry(fd.urn) ...
[ "Returns", "an", "rdf_crypto", ".", "Hash", "instance", "for", "given", "AFF4", "file", "descriptor", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store_utils.py#L46-L53
[ "def", "GetFileHashEntry", "(", "fd", ")", ":", "# Hash file store is not migrated to RELDB just yet, hence the first check.", "if", "(", "not", "fd", ".", "urn", ".", "Path", "(", ")", ".", "startswith", "(", "\"/files/hash/generic\"", ")", "and", "data_store", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetUrnHashEntry
Returns an `rdf_crypto.Hash` instance for given URN of an AFF4 file.
grr/server/grr_response_server/data_store_utils.py
def GetUrnHashEntry(urn, token=None): """Returns an `rdf_crypto.Hash` instance for given URN of an AFF4 file.""" if data_store.RelationalDBEnabled(): client_id, vfs_path = urn.Split(2) path_type, components = rdf_objects.ParseCategorizedPath(vfs_path) path_info = data_store.REL_DB.ReadPathInfo(client_i...
def GetUrnHashEntry(urn, token=None): """Returns an `rdf_crypto.Hash` instance for given URN of an AFF4 file.""" if data_store.RelationalDBEnabled(): client_id, vfs_path = urn.Split(2) path_type, components = rdf_objects.ParseCategorizedPath(vfs_path) path_info = data_store.REL_DB.ReadPathInfo(client_i...
[ "Returns", "an", "rdf_crypto", ".", "Hash", "instance", "for", "given", "URN", "of", "an", "AFF4", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store_utils.py#L56-L66
[ "def", "GetUrnHashEntry", "(", "urn", ",", "token", "=", "None", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "client_id", ",", "vfs_path", "=", "urn", ".", "Split", "(", "2", ")", "path_type", ",", "components", "=", "rdf_obj...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EnumMissingModules
Enumerate all modules which match the patterns MODULE_PATTERNS. PyInstaller often fails to locate all dlls which are required at runtime. We import all the client modules here, we simply introspect all the modules we have loaded in our current running process, and all the ones matching the patterns are copied ...
grr/client_builder/grr_response_client_builder/builders/windows.py
def EnumMissingModules(): """Enumerate all modules which match the patterns MODULE_PATTERNS. PyInstaller often fails to locate all dlls which are required at runtime. We import all the client modules here, we simply introspect all the modules we have loaded in our current running process, and all the ones ma...
def EnumMissingModules(): """Enumerate all modules which match the patterns MODULE_PATTERNS. PyInstaller often fails to locate all dlls which are required at runtime. We import all the client modules here, we simply introspect all the modules we have loaded in our current running process, and all the ones ma...
[ "Enumerate", "all", "modules", "which", "match", "the", "patterns", "MODULE_PATTERNS", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/builders/windows.py#L39-L82
[ "def", "EnumMissingModules", "(", ")", ":", "module_handle", "=", "ctypes", ".", "c_ulong", "(", ")", "count", "=", "ctypes", ".", "c_ulong", "(", ")", "process_handle", "=", "ctypes", ".", "windll", ".", "kernel32", ".", "OpenProcess", "(", "PROCESS_QUERY_I...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CopyFileInZip
Read a file from a ZipFile and write it to a new ZipFile.
grr/client_builder/grr_response_client_builder/builders/windows.py
def CopyFileInZip(from_zip, from_name, to_zip, to_name=None): """Read a file from a ZipFile and write it to a new ZipFile.""" data = from_zip.read(from_name) if to_name is None: to_name = from_name to_zip.writestr(to_name, data)
def CopyFileInZip(from_zip, from_name, to_zip, to_name=None): """Read a file from a ZipFile and write it to a new ZipFile.""" data = from_zip.read(from_name) if to_name is None: to_name = from_name to_zip.writestr(to_name, data)
[ "Read", "a", "file", "from", "a", "ZipFile", "and", "write", "it", "to", "a", "new", "ZipFile", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/builders/windows.py#L185-L190
[ "def", "CopyFileInZip", "(", "from_zip", ",", "from_name", ",", "to_zip", ",", "to_name", "=", "None", ")", ":", "data", "=", "from_zip", ".", "read", "(", "from_name", ")", "if", "to_name", "is", "None", ":", "to_name", "=", "from_name", "to_zip", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WindowsClientBuilder.BuildNanny
Use VS2010 to build the windows Nanny service.
grr/client_builder/grr_response_client_builder/builders/windows.py
def BuildNanny(self): """Use VS2010 to build the windows Nanny service.""" # When running under cygwin, the following environment variables are not set # (since they contain invalid chars). Visual Studio requires these or it # will fail. os.environ["ProgramFiles(x86)"] = r"C:\Program Files (x86)" ...
def BuildNanny(self): """Use VS2010 to build the windows Nanny service.""" # When running under cygwin, the following environment variables are not set # (since they contain invalid chars). Visual Studio requires these or it # will fail. os.environ["ProgramFiles(x86)"] = r"C:\Program Files (x86)" ...
[ "Use", "VS2010", "to", "build", "the", "windows", "Nanny", "service", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/builders/windows.py#L92-L147
[ "def", "BuildNanny", "(", "self", ")", ":", "# When running under cygwin, the following environment variables are not set", "# (since they contain invalid chars). Visual Studio requires these or it", "# will fail.", "os", ".", "environ", "[", "\"ProgramFiles(x86)\"", "]", "=", "r\"C:...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WindowsClientBuilder.MakeExecutableTemplate
Windows templates also include the nanny.
grr/client_builder/grr_response_client_builder/builders/windows.py
def MakeExecutableTemplate(self, output_file=None): """Windows templates also include the nanny.""" super(WindowsClientBuilder, self).MakeExecutableTemplate(output_file=output_file) self.MakeBuildDirectory() self.BuildWithPyInstaller() # Get any dll's that pyinstaller forgot: for mod...
def MakeExecutableTemplate(self, output_file=None): """Windows templates also include the nanny.""" super(WindowsClientBuilder, self).MakeExecutableTemplate(output_file=output_file) self.MakeBuildDirectory() self.BuildWithPyInstaller() # Get any dll's that pyinstaller forgot: for mod...
[ "Windows", "templates", "also", "include", "the", "nanny", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/builders/windows.py#L149-L182
[ "def", "MakeExecutableTemplate", "(", "self", ",", "output_file", "=", "None", ")", ":", "super", "(", "WindowsClientBuilder", ",", "self", ")", ".", "MakeExecutableTemplate", "(", "output_file", "=", "output_file", ")", "self", ".", "MakeBuildDirectory", "(", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CryptedPassword._CheckLegacyPassword
Check password with legacy crypt based method.
grr/server/grr_response_server/aff4_objects/users.py
def _CheckLegacyPassword(self, password): """Check password with legacy crypt based method.""" # This import will fail on Windows. import crypt # pylint: disable=g-import-not-at-top salt = self._value[:2] return crypt.crypt(password, salt) == self._value
def _CheckLegacyPassword(self, password): """Check password with legacy crypt based method.""" # This import will fail on Windows. import crypt # pylint: disable=g-import-not-at-top salt = self._value[:2] return crypt.crypt(password, salt) == self._value
[ "Check", "password", "with", "legacy", "crypt", "based", "method", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/users.py#L54-L59
[ "def", "_CheckLegacyPassword", "(", "self", ",", "password", ")", ":", "# This import will fail on Windows.", "import", "crypt", "# pylint: disable=g-import-not-at-top", "salt", "=", "self", ".", "_value", "[", ":", "2", "]", "return", "crypt", ".", "crypt", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRUser.Notify
Send an AFF4-based notification to the user in the UI. Args: message_type: One of aff4_grr.Notification.notification_types e.g. "ViewObject", "HostInformation", "GrantAccess" or the same with an added ":[new-style notification type] suffix, e.g. "ViewObject:TYPE_CLIENT_INTERROGATED". ...
grr/server/grr_response_server/aff4_objects/users.py
def Notify(self, message_type, subject, msg, source): """Send an AFF4-based notification to the user in the UI. Args: message_type: One of aff4_grr.Notification.notification_types e.g. "ViewObject", "HostInformation", "GrantAccess" or the same with an added ":[new-style notification type]...
def Notify(self, message_type, subject, msg, source): """Send an AFF4-based notification to the user in the UI. Args: message_type: One of aff4_grr.Notification.notification_types e.g. "ViewObject", "HostInformation", "GrantAccess" or the same with an added ":[new-style notification type]...
[ "Send", "an", "AFF4", "-", "based", "notification", "to", "the", "user", "in", "the", "UI", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/users.py#L111-L160
[ "def", "Notify", "(", "self", ",", "message_type", ",", "subject", ",", "msg", ",", "source", ")", ":", "pending", "=", "self", ".", "Get", "(", "self", ".", "Schema", ".", "PENDING_NOTIFICATIONS", ")", "if", "pending", "is", "None", ":", "pending", "=...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRUser.DeletePendingNotification
Deletes the pending notification with the given timestamp. Args: timestamp: The timestamp of the notification. Assumed to be unique. Raises: UniqueKeyError: Raised if multiple notifications have the timestamp.
grr/server/grr_response_server/aff4_objects/users.py
def DeletePendingNotification(self, timestamp): """Deletes the pending notification with the given timestamp. Args: timestamp: The timestamp of the notification. Assumed to be unique. Raises: UniqueKeyError: Raised if multiple notifications have the timestamp. """ shown_notifications =...
def DeletePendingNotification(self, timestamp): """Deletes the pending notification with the given timestamp. Args: timestamp: The timestamp of the notification. Assumed to be unique. Raises: UniqueKeyError: Raised if multiple notifications have the timestamp. """ shown_notifications =...
[ "Deletes", "the", "pending", "notification", "with", "the", "given", "timestamp", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/users.py#L162-L192
[ "def", "DeletePendingNotification", "(", "self", ",", "timestamp", ")", ":", "shown_notifications", "=", "self", ".", "Get", "(", "self", ".", "Schema", ".", "SHOWN_NOTIFICATIONS", ")", "if", "not", "shown_notifications", ":", "shown_notifications", "=", "self", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRUser.ShowNotifications
A generator of current notifications.
grr/server/grr_response_server/aff4_objects/users.py
def ShowNotifications(self, reset=True): """A generator of current notifications.""" shown_notifications = self.Schema.SHOWN_NOTIFICATIONS() # Pending notifications first pending = self.Get(self.Schema.PENDING_NOTIFICATIONS, []) for notification in pending: shown_notifications.Append(notifica...
def ShowNotifications(self, reset=True): """A generator of current notifications.""" shown_notifications = self.Schema.SHOWN_NOTIFICATIONS() # Pending notifications first pending = self.Get(self.Schema.PENDING_NOTIFICATIONS, []) for notification in pending: shown_notifications.Append(notifica...
[ "A", "generator", "of", "current", "notifications", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/users.py#L194-L213
[ "def", "ShowNotifications", "(", "self", ",", "reset", "=", "True", ")", ":", "shown_notifications", "=", "self", ".", "Schema", ".", "SHOWN_NOTIFICATIONS", "(", ")", "# Pending notifications first", "pending", "=", "self", ".", "Get", "(", "self", ".", "Schem...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRUser.Describe
Return a description of this user.
grr/server/grr_response_server/aff4_objects/users.py
def Describe(self): """Return a description of this user.""" result = ["\nUsername: %s" % self.urn.Basename()] labels = [l.name for l in self.GetLabels()] result.append("Labels: %s" % ",".join(labels)) if self.Get(self.Schema.PASSWORD) is None: result.append("Password: not set") else: ...
def Describe(self): """Return a description of this user.""" result = ["\nUsername: %s" % self.urn.Basename()] labels = [l.name for l in self.GetLabels()] result.append("Labels: %s" % ",".join(labels)) if self.Get(self.Schema.PASSWORD) is None: result.append("Password: not set") else: ...
[ "Return", "a", "description", "of", "this", "user", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/users.py#L215-L226
[ "def", "Describe", "(", "self", ")", ":", "result", "=", "[", "\"\\nUsername: %s\"", "%", "self", ".", "urn", ".", "Basename", "(", ")", "]", "labels", "=", "[", "l", ".", "name", "for", "l", "in", "self", ".", "GetLabels", "(", ")", "]", "result",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_Metric.Get
Gets the metric value corresponding to the given field values.
grr/core/grr_response_core/stats/default_stats_collector.py
def Get(self, fields=None): """Gets the metric value corresponding to the given field values.""" if not self._field_defs and fields: raise ValueError("Metric was registered without fields, " "but following fields were provided: %s." % (fields,)) if self._field_defs and not fiel...
def Get(self, fields=None): """Gets the metric value corresponding to the given field values.""" if not self._field_defs and fields: raise ValueError("Metric was registered without fields, " "but following fields were provided: %s." % (fields,)) if self._field_defs and not fiel...
[ "Gets", "the", "metric", "value", "corresponding", "to", "the", "given", "field", "values", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L47-L64
[ "def", "Get", "(", "self", ",", "fields", "=", "None", ")", ":", "if", "not", "self", ".", "_field_defs", "and", "fields", ":", "raise", "ValueError", "(", "\"Metric was registered without fields, \"", "\"but following fields were provided: %s.\"", "%", "(", "fields...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_CounterMetric.Increment
Increments counter value by a given delta.
grr/core/grr_response_core/stats/default_stats_collector.py
def Increment(self, delta, fields=None): """Increments counter value by a given delta.""" if delta < 0: raise ValueError( "Counter increment should not be < 0 (received: %d)" % delta) self._metric_values[_FieldsToKey(fields)] = self.Get(fields=fields) + delta
def Increment(self, delta, fields=None): """Increments counter value by a given delta.""" if delta < 0: raise ValueError( "Counter increment should not be < 0 (received: %d)" % delta) self._metric_values[_FieldsToKey(fields)] = self.Get(fields=fields) + delta
[ "Increments", "counter", "value", "by", "a", "given", "delta", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L77-L83
[ "def", "Increment", "(", "self", ",", "delta", ",", "fields", "=", "None", ")", ":", "if", "delta", "<", "0", ":", "raise", "ValueError", "(", "\"Counter increment should not be < 0 (received: %d)\"", "%", "delta", ")", "self", ".", "_metric_values", "[", "_Fi...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_EventMetric.Record
Records the given observation in a distribution.
grr/core/grr_response_core/stats/default_stats_collector.py
def Record(self, value, fields=None): """Records the given observation in a distribution.""" key = _FieldsToKey(fields) metric_value = self._metric_values.get(key) if metric_value is None: metric_value = self._DefaultValue() self._metric_values[key] = metric_value metric_value.Record(val...
def Record(self, value, fields=None): """Records the given observation in a distribution.""" key = _FieldsToKey(fields) metric_value = self._metric_values.get(key) if metric_value is None: metric_value = self._DefaultValue() self._metric_values[key] = metric_value metric_value.Record(val...
[ "Records", "the", "given", "observation", "in", "a", "distribution", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L108-L115
[ "def", "Record", "(", "self", ",", "value", ",", "fields", "=", "None", ")", ":", "key", "=", "_FieldsToKey", "(", "fields", ")", "metric_value", "=", "self", ".", "_metric_values", ".", "get", "(", "key", ")", "if", "metric_value", "is", "None", ":", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_GaugeMetric.Set
Sets the metric's current value.
grr/core/grr_response_core/stats/default_stats_collector.py
def Set(self, value, fields=None): """Sets the metric's current value.""" self._metric_values[_FieldsToKey(fields)] = self._value_type(value)
def Set(self, value, fields=None): """Sets the metric's current value.""" self._metric_values[_FieldsToKey(fields)] = self._value_type(value)
[ "Sets", "the", "metric", "s", "current", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L136-L138
[ "def", "Set", "(", "self", ",", "value", ",", "fields", "=", "None", ")", ":", "self", ".", "_metric_values", "[", "_FieldsToKey", "(", "fields", ")", "]", "=", "self", ".", "_value_type", "(", "value", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_GaugeMetric.Get
Returns current metric's value (executing a callback if needed).
grr/core/grr_response_core/stats/default_stats_collector.py
def Get(self, fields=None): """Returns current metric's value (executing a callback if needed).""" result = super(_GaugeMetric, self).Get(fields=fields) if callable(result): return result() else: return result
def Get(self, fields=None): """Returns current metric's value (executing a callback if needed).""" result = super(_GaugeMetric, self).Get(fields=fields) if callable(result): return result() else: return result
[ "Returns", "current", "metric", "s", "value", "(", "executing", "a", "callback", "if", "needed", ")", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L144-L150
[ "def", "Get", "(", "self", ",", "fields", "=", "None", ")", ":", "result", "=", "super", "(", "_GaugeMetric", ",", "self", ")", ".", "Get", "(", "fields", "=", "fields", ")", "if", "callable", "(", "result", ")", ":", "return", "result", "(", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DefaultStatsCollector._InitializeMetric
See base class.
grr/core/grr_response_core/stats/default_stats_collector.py
def _InitializeMetric(self, metadata): """See base class.""" field_defs = stats_utils.FieldDefinitionTuplesFromProtos( metadata.fields_defs) if metadata.metric_type == rdf_stats.MetricMetadata.MetricType.COUNTER: self._counter_metrics[metadata.varname] = _CounterMetric(field_defs) elif met...
def _InitializeMetric(self, metadata): """See base class.""" field_defs = stats_utils.FieldDefinitionTuplesFromProtos( metadata.fields_defs) if metadata.metric_type == rdf_stats.MetricMetadata.MetricType.COUNTER: self._counter_metrics[metadata.varname] = _CounterMetric(field_defs) elif met...
[ "See", "base", "class", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L165-L180
[ "def", "_InitializeMetric", "(", "self", ",", "metadata", ")", ":", "field_defs", "=", "stats_utils", ".", "FieldDefinitionTuplesFromProtos", "(", "metadata", ".", "fields_defs", ")", "if", "metadata", ".", "metric_type", "==", "rdf_stats", ".", "MetricMetadata", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DefaultStatsCollector.IncrementCounter
See base class.
grr/core/grr_response_core/stats/default_stats_collector.py
def IncrementCounter(self, metric_name, delta=1, fields=None): """See base class.""" if delta < 0: raise ValueError("Invalid increment for counter: %d." % delta) self._counter_metrics[metric_name].Increment(delta, fields)
def IncrementCounter(self, metric_name, delta=1, fields=None): """See base class.""" if delta < 0: raise ValueError("Invalid increment for counter: %d." % delta) self._counter_metrics[metric_name].Increment(delta, fields)
[ "See", "base", "class", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L183-L187
[ "def", "IncrementCounter", "(", "self", ",", "metric_name", ",", "delta", "=", "1", ",", "fields", "=", "None", ")", ":", "if", "delta", "<", "0", ":", "raise", "ValueError", "(", "\"Invalid increment for counter: %d.\"", "%", "delta", ")", "self", ".", "_...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DefaultStatsCollector.RecordEvent
See base class.
grr/core/grr_response_core/stats/default_stats_collector.py
def RecordEvent(self, metric_name, value, fields=None): """See base class.""" self._event_metrics[metric_name].Record(value, fields)
def RecordEvent(self, metric_name, value, fields=None): """See base class.""" self._event_metrics[metric_name].Record(value, fields)
[ "See", "base", "class", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L190-L192
[ "def", "RecordEvent", "(", "self", ",", "metric_name", ",", "value", ",", "fields", "=", "None", ")", ":", "self", ".", "_event_metrics", "[", "metric_name", "]", ".", "Record", "(", "value", ",", "fields", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DefaultStatsCollector.SetGaugeValue
See base class.
grr/core/grr_response_core/stats/default_stats_collector.py
def SetGaugeValue(self, metric_name, value, fields=None): """See base class.""" self._gauge_metrics[metric_name].Set(value, fields)
def SetGaugeValue(self, metric_name, value, fields=None): """See base class.""" self._gauge_metrics[metric_name].Set(value, fields)
[ "See", "base", "class", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L195-L197
[ "def", "SetGaugeValue", "(", "self", ",", "metric_name", ",", "value", ",", "fields", "=", "None", ")", ":", "self", ".", "_gauge_metrics", "[", "metric_name", "]", ".", "Set", "(", "value", ",", "fields", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DefaultStatsCollector.SetGaugeCallback
See base class.
grr/core/grr_response_core/stats/default_stats_collector.py
def SetGaugeCallback(self, metric_name, callback, fields=None): """See base class.""" self._gauge_metrics[metric_name].SetCallback(callback, fields)
def SetGaugeCallback(self, metric_name, callback, fields=None): """See base class.""" self._gauge_metrics[metric_name].SetCallback(callback, fields)
[ "See", "base", "class", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L200-L202
[ "def", "SetGaugeCallback", "(", "self", ",", "metric_name", ",", "callback", ",", "fields", "=", "None", ")", ":", "self", ".", "_gauge_metrics", "[", "metric_name", "]", ".", "SetCallback", "(", "callback", ",", "fields", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DefaultStatsCollector._GetMetric
Fetches the metric object corresponding to the given name.
grr/core/grr_response_core/stats/default_stats_collector.py
def _GetMetric(self, metric_name): """Fetches the metric object corresponding to the given name.""" if metric_name in self._counter_metrics: return self._counter_metrics[metric_name] elif metric_name in self._event_metrics: return self._event_metrics[metric_name] elif metric_name in self._ga...
def _GetMetric(self, metric_name): """Fetches the metric object corresponding to the given name.""" if metric_name in self._counter_metrics: return self._counter_metrics[metric_name] elif metric_name in self._event_metrics: return self._event_metrics[metric_name] elif metric_name in self._ga...
[ "Fetches", "the", "metric", "object", "corresponding", "to", "the", "given", "name", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/default_stats_collector.py#L212-L221
[ "def", "_GetMetric", "(", "self", ",", "metric_name", ")", ":", "if", "metric_name", "in", "self", ".", "_counter_metrics", ":", "return", "self", ".", "_counter_metrics", "[", "metric_name", "]", "elif", "metric_name", "in", "self", ".", "_event_metrics", ":"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
YumListCmdParser.Parse
Parse the yum output.
grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the yum output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) packages = [] for line in stdout.decode("utf-8").splitlines()[1:]: # Ignore first lin...
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the yum output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) packages = [] for line in stdout.decode("utf-8").splitlines()[1:]: # Ignore first lin...
[ "Parse", "the", "yum", "output", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py#L32-L53
[ "def", "Parse", "(", "self", ",", "cmd", ",", "args", ",", "stdout", ",", "stderr", ",", "return_val", ",", "time_taken", ",", "knowledge_base", ")", ":", "_", "=", "stderr", ",", "time_taken", ",", "args", ",", "knowledge_base", "# Unused.", "self", "."...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
YumRepolistCmdParser.Parse
Parse the yum repolist output.
grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the yum repolist output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) output = iter(stdout.decode("utf-8").splitlines()) repo_regexes = { ...
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the yum repolist output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) output = iter(stdout.decode("utf-8").splitlines()) repo_regexes = { ...
[ "Parse", "the", "yum", "repolist", "output", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py#L70-L101
[ "def", "Parse", "(", "self", ",", "cmd", ",", "args", ",", "stdout", ",", "stderr", ",", "return_val", ",", "time_taken", ",", "knowledge_base", ")", ":", "_", "=", "stderr", ",", "time_taken", ",", "args", ",", "knowledge_base", "# Unused.", "self", "."...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RpmCmdParser.Parse
Parse the rpm -qa output.
grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the rpm -qa output.""" _ = time_taken, args, knowledge_base # Unused. rpm_re = re.compile(r"^(\w[-\w\+]+?)-(\d.*)$") self.CheckReturn(cmd, return_val) packages = [] for line in stdout.splitl...
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the rpm -qa output.""" _ = time_taken, args, knowledge_base # Unused. rpm_re = re.compile(r"^(\w[-\w\+]+?)-(\d.*)$") self.CheckReturn(cmd, return_val) packages = [] for line in stdout.splitl...
[ "Parse", "the", "rpm", "-", "qa", "output", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py#L110-L132
[ "def", "Parse", "(", "self", ",", "cmd", ",", "args", ",", "stdout", ",", "stderr", ",", "return_val", ",", "time_taken", ",", "knowledge_base", ")", ":", "_", "=", "time_taken", ",", "args", ",", "knowledge_base", "# Unused.", "rpm_re", "=", "re", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DpkgCmdParser.Parse
Parse the dpkg output.
grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the dpkg output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) column_lengths = [] i = 0 for i, line in enumerate(stdout.decode("utf-8").splitli...
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the dpkg output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) column_lengths = [] i = 0 for i, line in enumerate(stdout.decode("utf-8").splitli...
[ "Parse", "the", "dpkg", "output", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py#L141-L194
[ "def", "Parse", "(", "self", ",", "cmd", ",", "args", ",", "stdout", ",", "stderr", ",", "return_val", ",", "time_taken", ",", "knowledge_base", ")", ":", "_", "=", "stderr", ",", "time_taken", ",", "args", ",", "knowledge_base", "# Unused.", "self", "."...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DmidecodeCmdParser.Parse
Parse the dmidecode output. All data is parsed into a dictionary.
grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the dmidecode output. All data is parsed into a dictionary.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) output = iter(stdout.decode("utf-8").splitline...
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the dmidecode output. All data is parsed into a dictionary.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) output = iter(stdout.decode("utf-8").splitline...
[ "Parse", "the", "dmidecode", "output", ".", "All", "data", "is", "parsed", "into", "a", "dictionary", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py#L206-L258
[ "def", "Parse", "(", "self", ",", "cmd", ",", "args", ",", "stdout", ",", "stderr", ",", "return_val", ",", "time_taken", ",", "knowledge_base", ")", ":", "_", "=", "stderr", ",", "time_taken", ",", "args", ",", "knowledge_base", "# Unused.", "self", "."...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PsCmdParser.Parse
Parse the ps output. Note that cmdline consumes every field up to the end of line and as it is string, we can't perfectly see what the arguments on the command line really were. We just assume a space is the arg seperator. It's imperfect, but it's better than nothing. Obviously, if cmd/cmdline is s...
grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the ps output. Note that cmdline consumes every field up to the end of line and as it is string, we can't perfectly see what the arguments on the command line really were. We just assume a space is ...
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the ps output. Note that cmdline consumes every field up to the end of line and as it is string, we can't perfectly see what the arguments on the command line really were. We just assume a space is ...
[ "Parse", "the", "ps", "output", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py#L267-L309
[ "def", "Parse", "(", "self", ",", "cmd", ",", "args", ",", "stdout", ",", "stderr", ",", "return_val", ",", "time_taken", ",", "knowledge_base", ")", ":", "_", "=", "stderr", ",", "time_taken", ",", "knowledge_base", "# Unused.", "self", ".", "CheckReturn"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ValidateIapJwtFromComputeEngine
Validates an IAP JWT for your (Compute|Container) Engine service. Args: iap_jwt: The contents of the X-Goog-IAP-JWT-Assertion header. cloud_project_number: The project *number* for your Google Cloud project. This is returned by 'gcloud projects describe $PROJECT_ID', or in the Project Info card i...
grr/server/grr_response_server/gui/validate_iap.py
def ValidateIapJwtFromComputeEngine(iap_jwt, cloud_project_number, backend_service_id): """Validates an IAP JWT for your (Compute|Container) Engine service. Args: iap_jwt: The contents of the X-Goog-IAP-JWT-Assertion header. cloud_project_number: The project *number* for...
def ValidateIapJwtFromComputeEngine(iap_jwt, cloud_project_number, backend_service_id): """Validates an IAP JWT for your (Compute|Container) Engine service. Args: iap_jwt: The contents of the X-Goog-IAP-JWT-Assertion header. cloud_project_number: The project *number* for...
[ "Validates", "an", "IAP", "JWT", "for", "your", "(", "Compute|Container", ")", "Engine", "service", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/validate_iap.py#L41-L62
[ "def", "ValidateIapJwtFromComputeEngine", "(", "iap_jwt", ",", "cloud_project_number", ",", "backend_service_id", ")", ":", "expected_audience", "=", "\"/projects/{}/global/backendServices/{}\"", ".", "format", "(", "cloud_project_number", ",", "backend_service_id", ")", "ret...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ValidateIapJwt
Validates an IAP JWT.
grr/server/grr_response_server/gui/validate_iap.py
def ValidateIapJwt(iap_jwt, expected_audience): """Validates an IAP JWT.""" try: key_id = jwt.get_unverified_header(iap_jwt).get("kid") if not key_id: raise IAPValidationFailedError("No key ID") key = GetIapKey(key_id) decoded_jwt = jwt.decode( iap_jwt, key, algorithms=["ES256"], audi...
def ValidateIapJwt(iap_jwt, expected_audience): """Validates an IAP JWT.""" try: key_id = jwt.get_unverified_header(iap_jwt).get("kid") if not key_id: raise IAPValidationFailedError("No key ID") key = GetIapKey(key_id) decoded_jwt = jwt.decode( iap_jwt, key, algorithms=["ES256"], audi...
[ "Validates", "an", "IAP", "JWT", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/validate_iap.py#L65-L78
[ "def", "ValidateIapJwt", "(", "iap_jwt", ",", "expected_audience", ")", ":", "try", ":", "key_id", "=", "jwt", ".", "get_unverified_header", "(", "iap_jwt", ")", ".", "get", "(", "\"kid\"", ")", "if", "not", "key_id", ":", "raise", "IAPValidationFailedError", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetIapKey
Retrieves a public key from the list published by Identity-Aware Proxy. The key file is re-fetched if necessary. Args: key_id: Key id. Returns: String with a key. Raises: KeyNotFoundError: if the key is not found in the key file. KeysCanNotBeFetchedError: if the key file can't be fetched.
grr/server/grr_response_server/gui/validate_iap.py
def GetIapKey(key_id): """Retrieves a public key from the list published by Identity-Aware Proxy. The key file is re-fetched if necessary. Args: key_id: Key id. Returns: String with a key. Raises: KeyNotFoundError: if the key is not found in the key file. KeysCanNotBeFetchedError: if the k...
def GetIapKey(key_id): """Retrieves a public key from the list published by Identity-Aware Proxy. The key file is re-fetched if necessary. Args: key_id: Key id. Returns: String with a key. Raises: KeyNotFoundError: if the key is not found in the key file. KeysCanNotBeFetchedError: if the k...
[ "Retrieves", "a", "public", "key", "from", "the", "list", "published", "by", "Identity", "-", "Aware", "Proxy", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/validate_iap.py#L81-L109
[ "def", "GetIapKey", "(", "key_id", ")", ":", "global", "_KEY_CACHE", "key", "=", "_KEY_CACHE", ".", "get", "(", "key_id", ")", "if", "not", "key", ":", "# Re-fetch the key file.", "resp", "=", "requests", ".", "get", "(", "\"https://www.gstatic.com/iap/verify/pu...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InitHttp
Inits an GRR API object with a HTTP connector.
api_client/python/grr_api_client/api.py
def InitHttp(api_endpoint=None, page_size=None, auth=None, proxies=None, verify=None, cert=None, trust_env=True): """Inits an GRR API object with a HTTP connector.""" connector = http_connector.HttpConnector( api_endpoint=api_endpo...
def InitHttp(api_endpoint=None, page_size=None, auth=None, proxies=None, verify=None, cert=None, trust_env=True): """Inits an GRR API object with a HTTP connector.""" connector = http_connector.HttpConnector( api_endpoint=api_endpo...
[ "Inits", "an", "GRR", "API", "object", "with", "a", "HTTP", "connector", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/api.py#L60-L78
[ "def", "InitHttp", "(", "api_endpoint", "=", "None", ",", "page_size", "=", "None", ",", "auth", "=", "None", ",", "proxies", "=", "None", ",", "verify", "=", "None", ",", "cert", "=", "None", ",", "trust_env", "=", "True", ")", ":", "connector", "="...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
NetshStaticIp
Changes interface to a staticly set IP. Sets IP configs to local if no paramaters passed. Args: interface: Name of the interface. ip: IP address. subnet: Subnet mask. gw: IP address of the default gateway. Returns: A tuple of stdout, stderr, exit_status.
grr/core/executables/python_hacks/modify_network.py
def NetshStaticIp(interface, ip=u'127.0.0.9', subnet=u'255.255.255.255', gw=u'127.0.0.1'): """Changes interface to a staticly set IP. Sets IP configs to local if no paramaters passed. Args: interface: Name of the interface. ip: IP address. subnet...
def NetshStaticIp(interface, ip=u'127.0.0.9', subnet=u'255.255.255.255', gw=u'127.0.0.1'): """Changes interface to a staticly set IP. Sets IP configs to local if no paramaters passed. Args: interface: Name of the interface. ip: IP address. subnet...
[ "Changes", "interface", "to", "a", "staticly", "set", "IP", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/executables/python_hacks/modify_network.py#L12-L36
[ "def", "NetshStaticIp", "(", "interface", ",", "ip", "=", "u'127.0.0.9'", ",", "subnet", "=", "u'255.255.255.255'", ",", "gw", "=", "u'127.0.0.1'", ")", ":", "args", "=", "[", "'/c'", ",", "'netsh'", ",", "'interface'", ",", "'ip'", ",", "'set'", ",", "'...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DisableInterfaces
Tries to disable an interface. Only works on Vista and 7. Args: interface: Name of the interface to disable. Returns: res which is a tuple of (stdout, stderr, exit_status, time_taken).
grr/core/executables/python_hacks/modify_network.py
def DisableInterfaces(interface): """Tries to disable an interface. Only works on Vista and 7. Args: interface: Name of the interface to disable. Returns: res which is a tuple of (stdout, stderr, exit_status, time_taken). """ set_tested_versions = ['vista', '2008'] set_args = ['/c', 'netsh', 'set...
def DisableInterfaces(interface): """Tries to disable an interface. Only works on Vista and 7. Args: interface: Name of the interface to disable. Returns: res which is a tuple of (stdout, stderr, exit_status, time_taken). """ set_tested_versions = ['vista', '2008'] set_args = ['/c', 'netsh', 'set...
[ "Tries", "to", "disable", "an", "interface", ".", "Only", "works", "on", "Vista", "and", "7", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/executables/python_hacks/modify_network.py#L39-L57
[ "def", "DisableInterfaces", "(", "interface", ")", ":", "set_tested_versions", "=", "[", "'vista'", ",", "'2008'", "]", "set_args", "=", "[", "'/c'", ",", "'netsh'", ",", "'set'", ",", "'interface'", ",", "interface", ",", "'DISABLED'", "]", "host_version", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetEnabledInterfaces
Gives a list of enabled interfaces. Should work on all windows versions. Returns: interfaces: Names of interfaces found enabled.
grr/core/executables/python_hacks/modify_network.py
def GetEnabledInterfaces(): """Gives a list of enabled interfaces. Should work on all windows versions. Returns: interfaces: Names of interfaces found enabled. """ interfaces = [] show_args = ['/c', 'netsh', 'show', 'interface'] # pylint: disable=undefined-variable res = client_utils_common.Execute( ...
def GetEnabledInterfaces(): """Gives a list of enabled interfaces. Should work on all windows versions. Returns: interfaces: Names of interfaces found enabled. """ interfaces = [] show_args = ['/c', 'netsh', 'show', 'interface'] # pylint: disable=undefined-variable res = client_utils_common.Execute( ...
[ "Gives", "a", "list", "of", "enabled", "interfaces", ".", "Should", "work", "on", "all", "windows", "versions", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/executables/python_hacks/modify_network.py#L60-L76
[ "def", "GetEnabledInterfaces", "(", ")", ":", "interfaces", "=", "[", "]", "show_args", "=", "[", "'/c'", ",", "'netsh'", ",", "'show'", ",", "'interface'", "]", "# pylint: disable=undefined-variable", "res", "=", "client_utils_common", ".", "Execute", "(", "'cm...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MsgUser
Sends a message to a user. Args: msg: Message to be displaied to user. Returns: res which is a tuple of (stdout, stderr, exit_status, time_taken).
grr/core/executables/python_hacks/modify_network.py
def MsgUser(msg): """Sends a message to a user. Args: msg: Message to be displaied to user. Returns: res which is a tuple of (stdout, stderr, exit_status, time_taken). """ msg_tested_versions = ['xp', 'vista', '2008', '2003'] msg_args = ['/c', '%SystemRoot%\\System32\\msg.exe', '*', '/TIME:0'] h...
def MsgUser(msg): """Sends a message to a user. Args: msg: Message to be displaied to user. Returns: res which is a tuple of (stdout, stderr, exit_status, time_taken). """ msg_tested_versions = ['xp', 'vista', '2008', '2003'] msg_args = ['/c', '%SystemRoot%\\System32\\msg.exe', '*', '/TIME:0'] h...
[ "Sends", "a", "message", "to", "a", "user", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/executables/python_hacks/modify_network.py#L79-L101
[ "def", "MsgUser", "(", "msg", ")", ":", "msg_tested_versions", "=", "[", "'xp'", ",", "'vista'", ",", "'2008'", ",", "'2003'", "]", "msg_args", "=", "[", "'/c'", ",", "'%SystemRoot%\\\\System32\\\\msg.exe'", ",", "'*'", ",", "'/TIME:0'", "]", "host_version", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RepackConfig.GetConfigFromTemplate
Apply build.yaml settings from the template.
grr/client_builder/grr_response_client_builder/repacking.py
def GetConfigFromTemplate(self, template_path): """Apply build.yaml settings from the template.""" with zipfile.ZipFile(template_path) as template_zip: build_yaml = None for name in template_zip.namelist(): if name.endswith("build.yaml"): build_yaml = name break if ...
def GetConfigFromTemplate(self, template_path): """Apply build.yaml settings from the template.""" with zipfile.ZipFile(template_path) as template_zip: build_yaml = None for name in template_zip.namelist(): if name.endswith("build.yaml"): build_yaml = name break if ...
[ "Apply", "build", ".", "yaml", "settings", "from", "the", "template", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/repacking.py#L35-L52
[ "def", "GetConfigFromTemplate", "(", "self", ",", "template_path", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "template_path", ")", "as", "template_zip", ":", "build_yaml", "=", "None", "for", "name", "in", "template_zip", ".", "namelist", "(", ")", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TemplateRepacker.GetRepacker
Get the appropriate client deployer based on the selected flags.
grr/client_builder/grr_response_client_builder/repacking.py
def GetRepacker(self, context, signer=None): """Get the appropriate client deployer based on the selected flags.""" if "Target:Darwin" in context: deployer_class = build.DarwinClientRepacker elif "Target:Windows" in context: deployer_class = build.WindowsClientRepacker elif "Target:LinuxDeb"...
def GetRepacker(self, context, signer=None): """Get the appropriate client deployer based on the selected flags.""" if "Target:Darwin" in context: deployer_class = build.DarwinClientRepacker elif "Target:Windows" in context: deployer_class = build.WindowsClientRepacker elif "Target:LinuxDeb"...
[ "Get", "the", "appropriate", "client", "deployer", "based", "on", "the", "selected", "flags", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/repacking.py#L58-L71
[ "def", "GetRepacker", "(", "self", ",", "context", ",", "signer", "=", "None", ")", ":", "if", "\"Target:Darwin\"", "in", "context", ":", "deployer_class", "=", "build", ".", "DarwinClientRepacker", "elif", "\"Target:Windows\"", "in", "context", ":", "deployer_c...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TemplateRepacker.RepackTemplate
Repack binaries based on the configuration. We repack all templates in the templates directory. We expect to find only functioning templates, all other files should be removed. Each template contains a build.yaml that specifies how it was built and how it should be repacked. Args: template_p...
grr/client_builder/grr_response_client_builder/repacking.py
def RepackTemplate(self, template_path, output_dir, upload=False, token=None, sign=False, context=None, signed_template=False): """Repack binaries based on the configura...
def RepackTemplate(self, template_path, output_dir, upload=False, token=None, sign=False, context=None, signed_template=False): """Repack binaries based on the configura...
[ "Repack", "binaries", "based", "on", "the", "configuration", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/repacking.py#L137-L228
[ "def", "RepackTemplate", "(", "self", ",", "template_path", ",", "output_dir", ",", "upload", "=", "False", ",", "token", "=", "None", ",", "sign", "=", "False", ",", "context", "=", "None", ",", "signed_template", "=", "False", ")", ":", "orig_config", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TemplateRepacker.RepackAllTemplates
Repack all the templates in ClientBuilder.template_dir.
grr/client_builder/grr_response_client_builder/repacking.py
def RepackAllTemplates(self, upload=False, token=None): """Repack all the templates in ClientBuilder.template_dir.""" for template in os.listdir(config.CONFIG["ClientBuilder.template_dir"]): template_path = os.path.join(config.CONFIG["ClientBuilder.template_dir"], templa...
def RepackAllTemplates(self, upload=False, token=None): """Repack all the templates in ClientBuilder.template_dir.""" for template in os.listdir(config.CONFIG["ClientBuilder.template_dir"]): template_path = os.path.join(config.CONFIG["ClientBuilder.template_dir"], templa...
[ "Repack", "all", "the", "templates", "in", "ClientBuilder", ".", "template_dir", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/repacking.py#L230-L251
[ "def", "RepackAllTemplates", "(", "self", ",", "upload", "=", "False", ",", "token", "=", "None", ")", ":", "for", "template", "in", "os", ".", "listdir", "(", "config", ".", "CONFIG", "[", "\"ClientBuilder.template_dir\"", "]", ")", ":", "template_path", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_MakeArgs
Build metadata requests list from collection maps.
grr/core/grr_response_core/lib/rdfvalues/cloud.py
def _MakeArgs(amazon_collection_map, google_collection_map): """Build metadata requests list from collection maps.""" request_list = [] for url, label in iteritems(amazon_collection_map): request_list.append( CloudMetadataRequest( bios_version_regex=AMAZON_BIOS_REGEX, service_n...
def _MakeArgs(amazon_collection_map, google_collection_map): """Build metadata requests list from collection maps.""" request_list = [] for url, label in iteritems(amazon_collection_map): request_list.append( CloudMetadataRequest( bios_version_regex=AMAZON_BIOS_REGEX, service_n...
[ "Build", "metadata", "requests", "list", "from", "collection", "maps", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/cloud.py#L65-L87
[ "def", "_MakeArgs", "(", "amazon_collection_map", ",", "google_collection_map", ")", ":", "request_list", "=", "[", "]", "for", "url", ",", "label", "in", "iteritems", "(", "amazon_collection_map", ")", ":", "request_list", ".", "append", "(", "CloudMetadataReques...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MakeGoogleUniqueID
Make the google unique ID of zone/project/id.
grr/core/grr_response_core/lib/rdfvalues/cloud.py
def MakeGoogleUniqueID(cloud_instance): """Make the google unique ID of zone/project/id.""" if not (cloud_instance.zone and cloud_instance.project_id and cloud_instance.instance_id): raise ValueError("Bad zone/project_id/id: '%s/%s/%s'" % (cloud_instance.zone, cloud_instance.proje...
def MakeGoogleUniqueID(cloud_instance): """Make the google unique ID of zone/project/id.""" if not (cloud_instance.zone and cloud_instance.project_id and cloud_instance.instance_id): raise ValueError("Bad zone/project_id/id: '%s/%s/%s'" % (cloud_instance.zone, cloud_instance.proje...
[ "Make", "the", "google", "unique", "ID", "of", "zone", "/", "project", "/", "id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/cloud.py#L90-L100
[ "def", "MakeGoogleUniqueID", "(", "cloud_instance", ")", ":", "if", "not", "(", "cloud_instance", ".", "zone", "and", "cloud_instance", ".", "project_id", "and", "cloud_instance", ".", "instance_id", ")", ":", "raise", "ValueError", "(", "\"Bad zone/project_id/id: '...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BuildCloudMetadataRequests
Build the standard set of cloud metadata to collect during interrogate.
grr/core/grr_response_core/lib/rdfvalues/cloud.py
def BuildCloudMetadataRequests(): """Build the standard set of cloud metadata to collect during interrogate.""" amazon_collection_map = { "/".join((AMAZON_URL_BASE, "instance-id")): "instance_id", "/".join((AMAZON_URL_BASE, "ami-id")): "ami_id", "/".join((AMAZON_URL_BASE, "hostname")): "hostname",...
def BuildCloudMetadataRequests(): """Build the standard set of cloud metadata to collect during interrogate.""" amazon_collection_map = { "/".join((AMAZON_URL_BASE, "instance-id")): "instance_id", "/".join((AMAZON_URL_BASE, "ami-id")): "ami_id", "/".join((AMAZON_URL_BASE, "hostname")): "hostname",...
[ "Build", "the", "standard", "set", "of", "cloud", "metadata", "to", "collect", "during", "interrogate", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/cloud.py#L103-L121
[ "def", "BuildCloudMetadataRequests", "(", ")", ":", "amazon_collection_map", "=", "{", "\"/\"", ".", "join", "(", "(", "AMAZON_URL_BASE", ",", "\"instance-id\"", ")", ")", ":", "\"instance_id\"", ",", "\"/\"", ".", "join", "(", "(", "AMAZON_URL_BASE", ",", "\"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ConvertCloudMetadataResponsesToCloudInstance
Convert CloudMetadataResponses to CloudInstance proto. Ideally we'd just get the client to fill out a CloudInstance proto, but we need to keep the flexibility of collecting new metadata and creating new fields without a client push. So instead we bring back essentially a dict of results and fill the proto on t...
grr/core/grr_response_core/lib/rdfvalues/cloud.py
def ConvertCloudMetadataResponsesToCloudInstance(metadata_responses): """Convert CloudMetadataResponses to CloudInstance proto. Ideally we'd just get the client to fill out a CloudInstance proto, but we need to keep the flexibility of collecting new metadata and creating new fields without a client push. So in...
def ConvertCloudMetadataResponsesToCloudInstance(metadata_responses): """Convert CloudMetadataResponses to CloudInstance proto. Ideally we'd just get the client to fill out a CloudInstance proto, but we need to keep the flexibility of collecting new metadata and creating new fields without a client push. So in...
[ "Convert", "CloudMetadataResponses", "to", "CloudInstance", "proto", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/cloud.py#L124-L155
[ "def", "ConvertCloudMetadataResponsesToCloudInstance", "(", "metadata_responses", ")", ":", "if", "metadata_responses", ".", "instance_type", "==", "\"GOOGLE\"", ":", "cloud_instance", "=", "GoogleCloudInstance", "(", ")", "result", "=", "CloudInstance", "(", "cloud_type"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Distribution.Record
Records given value.
grr/core/grr_response_core/lib/rdfvalues/stats.py
def Record(self, value): """Records given value.""" self.sum += value self.count += 1 pos = bisect.bisect(self.bins, value) - 1 if pos < 0: pos = 0 elif pos == len(self.bins): pos = len(self.bins) - 1 self.heights[pos] += 1
def Record(self, value): """Records given value.""" self.sum += value self.count += 1 pos = bisect.bisect(self.bins, value) - 1 if pos < 0: pos = 0 elif pos == len(self.bins): pos = len(self.bins) - 1 self.heights[pos] += 1
[ "Records", "given", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/stats.py#L40-L51
[ "def", "Record", "(", "self", ",", "value", ")", ":", "self", ".", "sum", "+=", "value", "self", ".", "count", "+=", "1", "pos", "=", "bisect", ".", "bisect", "(", "self", ".", "bins", ",", "value", ")", "-", "1", "if", "pos", "<", "0", ":", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StatsHistogram.RegisterValue
Puts a given value into an appropriate bin.
grr/core/grr_response_core/lib/rdfvalues/stats.py
def RegisterValue(self, value): """Puts a given value into an appropriate bin.""" if self.bins: for b in self.bins: if b.range_max_value > value: b.num += 1 return self.bins[-1].num += 1
def RegisterValue(self, value): """Puts a given value into an appropriate bin.""" if self.bins: for b in self.bins: if b.range_max_value > value: b.num += 1 return self.bins[-1].num += 1
[ "Puts", "a", "given", "value", "into", "an", "appropriate", "bin", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/stats.py#L101-L109
[ "def", "RegisterValue", "(", "self", ",", "value", ")", ":", "if", "self", ".", "bins", ":", "for", "b", "in", "self", ".", "bins", ":", "if", "b", ".", "range_max_value", ">", "value", ":", "b", ".", "num", "+=", "1", "return", "self", ".", "bin...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientResourcesStats.RegisterResources
Update stats with info about resources consumed by a single client.
grr/core/grr_response_core/lib/rdfvalues/stats.py
def RegisterResources(self, client_resources): """Update stats with info about resources consumed by a single client.""" self.user_cpu_stats.RegisterValue(client_resources.cpu_usage.user_cpu_time) self.system_cpu_stats.RegisterValue( client_resources.cpu_usage.system_cpu_time) self.network_bytes...
def RegisterResources(self, client_resources): """Update stats with info about resources consumed by a single client.""" self.user_cpu_stats.RegisterValue(client_resources.cpu_usage.user_cpu_time) self.system_cpu_stats.RegisterValue( client_resources.cpu_usage.system_cpu_time) self.network_bytes...
[ "Update", "stats", "with", "info", "about", "resources", "consumed", "by", "a", "single", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/stats.py#L182-L195
[ "def", "RegisterResources", "(", "self", ",", "client_resources", ")", ":", "self", ".", "user_cpu_stats", ".", "RegisterValue", "(", "client_resources", ".", "cpu_usage", ".", "user_cpu_time", ")", "self", ".", "system_cpu_stats", ".", "RegisterValue", "(", "clie...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EmbeddedRDFValue.payload
Extracts and returns the serialized object.
grr/core/grr_response_core/lib/rdfvalues/protodict.py
def payload(self): """Extracts and returns the serialized object.""" try: rdf_cls = self.classes.get(self.name) if rdf_cls: value = rdf_cls.FromSerializedString(self.data) value.age = self.embedded_age return value except TypeError: return None
def payload(self): """Extracts and returns the serialized object.""" try: rdf_cls = self.classes.get(self.name) if rdf_cls: value = rdf_cls.FromSerializedString(self.data) value.age = self.embedded_age return value except TypeError: return None
[ "Extracts", "and", "returns", "the", "serialized", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/protodict.py#L45-L55
[ "def", "payload", "(", "self", ")", ":", "try", ":", "rdf_cls", "=", "self", ".", "classes", ".", "get", "(", "self", ".", "name", ")", "if", "rdf_cls", ":", "value", "=", "rdf_cls", ".", "FromSerializedString", "(", "self", ".", "data", ")", "value"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataBlob.SetValue
Receives a value and fills it into a DataBlob. Args: value: value to set raise_on_error: if True, raise if we can't serialize. If False, set the key to an error string. Returns: self Raises: TypeError: if the value can't be serialized and raise_on_error is True
grr/core/grr_response_core/lib/rdfvalues/protodict.py
def SetValue(self, value, raise_on_error=True): """Receives a value and fills it into a DataBlob. Args: value: value to set raise_on_error: if True, raise if we can't serialize. If False, set the key to an error string. Returns: self Raises: TypeError: if the value can...
def SetValue(self, value, raise_on_error=True): """Receives a value and fills it into a DataBlob. Args: value: value to set raise_on_error: if True, raise if we can't serialize. If False, set the key to an error string. Returns: self Raises: TypeError: if the value can...
[ "Receives", "a", "value", "and", "fills", "it", "into", "a", "DataBlob", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/protodict.py#L76-L127
[ "def", "SetValue", "(", "self", ",", "value", ",", "raise_on_error", "=", "True", ")", ":", "type_mappings", "=", "[", "(", "Text", ",", "\"string\"", ")", ",", "(", "bytes", ",", "\"data\"", ")", ",", "(", "bool", ",", "\"boolean\"", ")", ",", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataBlob.GetValue
Extracts and returns a single value from a DataBlob.
grr/core/grr_response_core/lib/rdfvalues/protodict.py
def GetValue(self, ignore_error=True): """Extracts and returns a single value from a DataBlob.""" if self.HasField("none"): return None field_names = [ "integer", "string", "data", "boolean", "list", "dict", "rdf_value", "float", "set" ] values = [getattr(self, x) for x in fi...
def GetValue(self, ignore_error=True): """Extracts and returns a single value from a DataBlob.""" if self.HasField("none"): return None field_names = [ "integer", "string", "data", "boolean", "list", "dict", "rdf_value", "float", "set" ] values = [getattr(self, x) for x in fi...
[ "Extracts", "and", "returns", "a", "single", "value", "from", "a", "DataBlob", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/protodict.py#L129-L166
[ "def", "GetValue", "(", "self", ",", "ignore_error", "=", "True", ")", ":", "if", "self", ".", "HasField", "(", "\"none\"", ")", ":", "return", "None", "field_names", "=", "[", "\"integer\"", ",", "\"string\"", ",", "\"data\"", ",", "\"boolean\"", ",", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFValueArray.Append
Add another member to the array. Args: value: The new data to append to the array. **kwarg: Create a new element from these keywords. Returns: The value which was added. This can be modified further by the caller and changes will be propagated here. Raises: ValueError: If t...
grr/core/grr_response_core/lib/rdfvalues/protodict.py
def Append(self, value=None, **kwarg): """Add another member to the array. Args: value: The new data to append to the array. **kwarg: Create a new element from these keywords. Returns: The value which was added. This can be modified further by the caller and changes will be propag...
def Append(self, value=None, **kwarg): """Add another member to the array. Args: value: The new data to append to the array. **kwarg: Create a new element from these keywords. Returns: The value which was added. This can be modified further by the caller and changes will be propag...
[ "Add", "another", "member", "to", "the", "array", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/protodict.py#L423-L449
[ "def", "Append", "(", "self", ",", "value", "=", "None", ",", "*", "*", "kwarg", ")", ":", "if", "self", ".", "rdf_type", "is", "not", "None", ":", "if", "(", "isinstance", "(", "value", ",", "rdfvalue", ".", "RDFValue", ")", "and", "value", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CpuSample.FromMany
Constructs a single sample that best represents a list of samples. Args: samples: An iterable collection of `CpuSample` instances. Returns: A `CpuSample` instance representing `samples`. Raises: ValueError: If `samples` is empty.
grr/core/grr_response_core/lib/rdfvalues/client_stats.py
def FromMany(cls, samples): """Constructs a single sample that best represents a list of samples. Args: samples: An iterable collection of `CpuSample` instances. Returns: A `CpuSample` instance representing `samples`. Raises: ValueError: If `samples` is empty. """ if not sam...
def FromMany(cls, samples): """Constructs a single sample that best represents a list of samples. Args: samples: An iterable collection of `CpuSample` instances. Returns: A `CpuSample` instance representing `samples`. Raises: ValueError: If `samples` is empty. """ if not sam...
[ "Constructs", "a", "single", "sample", "that", "best", "represents", "a", "list", "of", "samples", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client_stats.py#L31-L54
[ "def", "FromMany", "(", "cls", ",", "samples", ")", ":", "if", "not", "samples", ":", "raise", "ValueError", "(", "\"Empty `samples` argument\"", ")", "# It only makes sense to average the CPU percentage. For all other values", "# we simply take the biggest of them.", "cpu_perc...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
IOSample.FromMany
Constructs a single sample that best represents a list of samples. Args: samples: An iterable collection of `IOSample` instances. Returns: An `IOSample` instance representing `samples`. Raises: ValueError: If `samples` is empty.
grr/core/grr_response_core/lib/rdfvalues/client_stats.py
def FromMany(cls, samples): """Constructs a single sample that best represents a list of samples. Args: samples: An iterable collection of `IOSample` instances. Returns: An `IOSample` instance representing `samples`. Raises: ValueError: If `samples` is empty. """ if not samp...
def FromMany(cls, samples): """Constructs a single sample that best represents a list of samples. Args: samples: An iterable collection of `IOSample` instances. Returns: An `IOSample` instance representing `samples`. Raises: ValueError: If `samples` is empty. """ if not samp...
[ "Constructs", "a", "single", "sample", "that", "best", "represents", "a", "list", "of", "samples", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client_stats.py#L66-L84
[ "def", "FromMany", "(", "cls", ",", "samples", ")", ":", "if", "not", "samples", ":", "raise", "ValueError", "(", "\"Empty `samples` argument\"", ")", "return", "IOSample", "(", "timestamp", "=", "max", "(", "sample", ".", "timestamp", "for", "sample", "in",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientStats.Downsampled
Constructs a copy of given stats but downsampled to given interval. Args: stats: A `ClientStats` instance. interval: A downsampling interval. Returns: A downsampled `ClientStats` instance.
grr/core/grr_response_core/lib/rdfvalues/client_stats.py
def Downsampled(cls, stats, interval=None): """Constructs a copy of given stats but downsampled to given interval. Args: stats: A `ClientStats` instance. interval: A downsampling interval. Returns: A downsampled `ClientStats` instance. """ interval = interval or cls.DEFAULT_SAMPL...
def Downsampled(cls, stats, interval=None): """Constructs a copy of given stats but downsampled to given interval. Args: stats: A `ClientStats` instance. interval: A downsampling interval. Returns: A downsampled `ClientStats` instance. """ interval = interval or cls.DEFAULT_SAMPL...
[ "Constructs", "a", "copy", "of", "given", "stats", "but", "downsampled", "to", "given", "interval", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client_stats.py#L99-L116
[ "def", "Downsampled", "(", "cls", ",", "stats", ",", "interval", "=", "None", ")", ":", "interval", "=", "interval", "or", "cls", ".", "DEFAULT_SAMPLING_INTERVAL", "result", "=", "cls", "(", "stats", ")", "result", ".", "cpu_samples", "=", "cls", ".", "_...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetUserInfo
Get a User protobuf for a specific user. Args: knowledge_base: An rdf_client.KnowledgeBase object. user: Username as string. May contain domain like DOMAIN\\user. Returns: A User rdfvalue or None
grr/server/grr_response_server/flow_utils.py
def GetUserInfo(knowledge_base, user): # TODO: This docstring cannot be a raw literal because there are # issues with raw unicode literals on Python 2. Once support for Python 2 is # dropped, it can be made raw again. # pylint: disable=g-docstring-has-escape """Get a User protobuf for a specific user. Args...
def GetUserInfo(knowledge_base, user): # TODO: This docstring cannot be a raw literal because there are # issues with raw unicode literals on Python 2. Once support for Python 2 is # dropped, it can be made raw again. # pylint: disable=g-docstring-has-escape """Get a User protobuf for a specific user. Args...
[ "Get", "a", "User", "protobuf", "for", "a", "specific", "user", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_utils.py#L18-L45
[ "def", "GetUserInfo", "(", "knowledge_base", ",", "user", ")", ":", "# TODO: This docstring cannot be a raw literal because there are", "# issues with raw unicode literals on Python 2. Once support for Python 2 is", "# dropped, it can be made raw again.", "# pylint: disable=g-docstring-has-esc...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UpdateVFSFileAndWait
Waits for a file to be updated on the client. Calls the UpdateVFSFile flow on a urn and waits for both it and the ListDirectory flow it calls to finish. Note that this is needed because any flows UpdateVFSFile calls via VFS Update methods will not become child flows of UpdateVFSFile, and therefore waiting f...
grr/server/grr_response_server/flow_utils.py
def UpdateVFSFileAndWait(client_id, vfs_file_urn, token=None, timeout=DEFAULT_TIMEOUT): """Waits for a file to be updated on the client. Calls the UpdateVFSFile flow on a urn and waits for both it and the ListDirectory flow it calls to fi...
def UpdateVFSFileAndWait(client_id, vfs_file_urn, token=None, timeout=DEFAULT_TIMEOUT): """Waits for a file to be updated on the client. Calls the UpdateVFSFile flow on a urn and waits for both it and the ListDirectory flow it calls to fi...
[ "Waits", "for", "a", "file", "to", "be", "updated", "on", "the", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_utils.py#L48-L85
[ "def", "UpdateVFSFileAndWait", "(", "client_id", ",", "vfs_file_urn", ",", "token", "=", "None", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "# Wait for the UpdateVFSFile flow.", "update_flow_urn", "=", "StartFlowAndWait", "(", "client_id", ",", "token", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WaitForFlow
Waits for a flow to finish, polling while we wait. Args: flow_urn: The urn of the flow to wait for. token: The datastore access token. timeout: How long to wait before giving up, usually because the client has gone away. max_sleep_time: The initial and longest time to wait in between polls. ...
grr/server/grr_response_server/flow_utils.py
def WaitForFlow(flow_urn, token=None, timeout=DEFAULT_TIMEOUT, max_sleep_time=1, min_sleep_time=0.2, dampening_multiplier=0.9): """Waits for a flow to finish, polling while we wait. Args: flow_urn: The urn of the flow to wait for. ...
def WaitForFlow(flow_urn, token=None, timeout=DEFAULT_TIMEOUT, max_sleep_time=1, min_sleep_time=0.2, dampening_multiplier=0.9): """Waits for a flow to finish, polling while we wait. Args: flow_urn: The urn of the flow to wait for. ...
[ "Waits", "for", "a", "flow", "to", "finish", "polling", "while", "we", "wait", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_utils.py#L88-L130
[ "def", "WaitForFlow", "(", "flow_urn", ",", "token", "=", "None", ",", "timeout", "=", "DEFAULT_TIMEOUT", ",", "max_sleep_time", "=", "1", ",", "min_sleep_time", "=", "0.2", ",", "dampening_multiplier", "=", "0.9", ")", ":", "start_time", "=", "time", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StartFlowAndWait
Runs a flow and waits for it to finish. Args: client_id: The client id of the client to run on. token: The datastore access token. timeout: How long to wait for a flow to complete, maximum. **flow_args: Pass through to flow. Returns: The urn of the flow that was run.
grr/server/grr_response_server/flow_utils.py
def StartFlowAndWait(client_id, token=None, timeout=DEFAULT_TIMEOUT, **flow_args): """Runs a flow and waits for it to finish. Args: client_id: The client id of the client to run on. token: The datastore access token. timeout: How long to wa...
def StartFlowAndWait(client_id, token=None, timeout=DEFAULT_TIMEOUT, **flow_args): """Runs a flow and waits for it to finish. Args: client_id: The client id of the client to run on. token: The datastore access token. timeout: How long to wa...
[ "Runs", "a", "flow", "and", "waits", "for", "it", "to", "finish", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_utils.py#L133-L153
[ "def", "StartFlowAndWait", "(", "client_id", ",", "token", "=", "None", ",", "timeout", "=", "DEFAULT_TIMEOUT", ",", "*", "*", "flow_args", ")", ":", "flow_urn", "=", "flow", ".", "StartAFF4Flow", "(", "client_id", "=", "client_id", ",", "token", "=", "tok...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InterpolatePath
Take a string as a path on a client and interpolate with client data. Args: path: A single string/unicode to be interpolated. knowledge_base: An rdf_client.KnowledgeBase object. users: A list of string usernames, or None. path_args: A dict of additional args to use in interpolation. These take ...
grr/server/grr_response_server/flow_utils.py
def InterpolatePath(path, knowledge_base, users=None, path_args=None, depth=0): """Take a string as a path on a client and interpolate with client data. Args: path: A single string/unicode to be interpolated. knowledge_base: An rdf_client.KnowledgeBase object. users: A list of string usernames, or None...
def InterpolatePath(path, knowledge_base, users=None, path_args=None, depth=0): """Take a string as a path on a client and interpolate with client data. Args: path: A single string/unicode to be interpolated. knowledge_base: An rdf_client.KnowledgeBase object. users: A list of string usernames, or None...
[ "Take", "a", "string", "as", "a", "path", "on", "a", "client", "and", "interpolate", "with", "client", "data", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_utils.py#L158-L210
[ "def", "InterpolatePath", "(", "path", ",", "knowledge_base", ",", "users", "=", "None", ",", "path_args", "=", "None", ",", "depth", "=", "0", ")", ":", "sys_formatters", "=", "{", "# TODO(user): Collect this during discovery from the registry.", "# HKEY_LOCAL_MACHIN...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Find.ListDirectory
A recursive generator of files.
grr/client/grr_response_client/client_actions/searching.py
def ListDirectory(self, pathspec, depth=0): """A recursive generator of files.""" # Limit recursion depth if depth >= self.request.max_depth: return try: fd = vfs.VFSOpen(pathspec, progress_callback=self.Progress) files = fd.ListFiles(ext_attrs=self.request.collect_ext_attrs) exce...
def ListDirectory(self, pathspec, depth=0): """A recursive generator of files.""" # Limit recursion depth if depth >= self.request.max_depth: return try: fd = vfs.VFSOpen(pathspec, progress_callback=self.Progress) files = fd.ListFiles(ext_attrs=self.request.collect_ext_attrs) exce...
[ "A", "recursive", "generator", "of", "files", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/searching.py#L28-L64
[ "def", "ListDirectory", "(", "self", ",", "pathspec", ",", "depth", "=", "0", ")", ":", "# Limit recursion depth", "if", "depth", ">=", "self", ".", "request", ".", "max_depth", ":", "return", "try", ":", "fd", "=", "vfs", ".", "VFSOpen", "(", "pathspec"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Find.BuildChecks
Parses request and returns a list of filter callables. Each callable will be called with the StatEntry and returns True if the entry should be suppressed. Args: request: A FindSpec that describes the search. Returns: a list of callables which return True if the file is to be suppressed.
grr/client/grr_response_client/client_actions/searching.py
def BuildChecks(self, request): """Parses request and returns a list of filter callables. Each callable will be called with the StatEntry and returns True if the entry should be suppressed. Args: request: A FindSpec that describes the search. Returns: a list of callables which return ...
def BuildChecks(self, request): """Parses request and returns a list of filter callables. Each callable will be called with the StatEntry and returns True if the entry should be suppressed. Args: request: A FindSpec that describes the search. Returns: a list of callables which return ...
[ "Parses", "request", "and", "returns", "a", "list", "of", "filter", "callables", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/searching.py#L96-L165
[ "def", "BuildChecks", "(", "self", ",", "request", ")", ":", "result", "=", "[", "]", "if", "request", ".", "HasField", "(", "\"start_time\"", ")", "or", "request", ".", "HasField", "(", "\"end_time\"", ")", ":", "def", "FilterTimestamp", "(", "file_stat",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Find.Run
Runs the Find action.
grr/client/grr_response_client/client_actions/searching.py
def Run(self, request): """Runs the Find action.""" self.request = request filters = self.BuildChecks(request) files_checked = 0 for f in self.ListDirectory(request.pathspec): self.Progress() # Ignore this file if any of the checks fail. if not any((check(f) for check in filters...
def Run(self, request): """Runs the Find action.""" self.request = request filters = self.BuildChecks(request) files_checked = 0 for f in self.ListDirectory(request.pathspec): self.Progress() # Ignore this file if any of the checks fail. if not any((check(f) for check in filters...
[ "Runs", "the", "Find", "action", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/searching.py#L171-L187
[ "def", "Run", "(", "self", ",", "request", ")", ":", "self", ".", "request", "=", "request", "filters", "=", "self", ".", "BuildChecks", "(", "request", ")", "files_checked", "=", "0", "for", "f", "in", "self", ".", "ListDirectory", "(", "request", "."...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Grep.FindRegex
Search the data for a hit.
grr/client/grr_response_client/client_actions/searching.py
def FindRegex(self, regex, data): """Search the data for a hit.""" for match in re.finditer(regex, data, flags=re.I | re.S | re.M): yield (match.start(), match.end())
def FindRegex(self, regex, data): """Search the data for a hit.""" for match in re.finditer(regex, data, flags=re.I | re.S | re.M): yield (match.start(), match.end())
[ "Search", "the", "data", "for", "a", "hit", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/searching.py#L195-L198
[ "def", "FindRegex", "(", "self", ",", "regex", ",", "data", ")", ":", "for", "match", "in", "re", ".", "finditer", "(", "regex", ",", "data", ",", "flags", "=", "re", ".", "I", "|", "re", ".", "S", "|", "re", ".", "M", ")", ":", "yield", "(",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Grep.FindLiteral
Search the data for a hit.
grr/client/grr_response_client/client_actions/searching.py
def FindLiteral(self, pattern, data): """Search the data for a hit.""" pattern = utils.Xor(pattern, self.xor_in_key) offset = 0 while 1: # We assume here that data.find does not make a copy of pattern. offset = data.find(pattern, offset) if offset < 0: break yield (off...
def FindLiteral(self, pattern, data): """Search the data for a hit.""" pattern = utils.Xor(pattern, self.xor_in_key) offset = 0 while 1: # We assume here that data.find does not make a copy of pattern. offset = data.find(pattern, offset) if offset < 0: break yield (off...
[ "Search", "the", "data", "for", "a", "hit", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/searching.py#L200-L214
[ "def", "FindLiteral", "(", "self", ",", "pattern", ",", "data", ")", ":", "pattern", "=", "utils", ".", "Xor", "(", "pattern", ",", "self", ".", "xor_in_key", ")", "offset", "=", "0", "while", "1", ":", "# We assume here that data.find does not make a copy of ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Grep.Run
Search the file for the pattern. This implements the grep algorithm used to scan files. It reads the data in chunks of BUFF_SIZE (10 MB currently) and can use different functions to search for matching patterns. In every step, a buffer that is a bit bigger than the block size is used in order to re...
grr/client/grr_response_client/client_actions/searching.py
def Run(self, args): """Search the file for the pattern. This implements the grep algorithm used to scan files. It reads the data in chunks of BUFF_SIZE (10 MB currently) and can use different functions to search for matching patterns. In every step, a buffer that is a bit bigger than the block siz...
def Run(self, args): """Search the file for the pattern. This implements the grep algorithm used to scan files. It reads the data in chunks of BUFF_SIZE (10 MB currently) and can use different functions to search for matching patterns. In every step, a buffer that is a bit bigger than the block siz...
[ "Search", "the", "file", "for", "the", "pattern", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/searching.py#L220-L352
[ "def", "Run", "(", "self", ",", "args", ")", ":", "fd", "=", "vfs", ".", "VFSOpen", "(", "args", ".", "target", ",", "progress_callback", "=", "self", ".", "Progress", ")", "fd", ".", "Seek", "(", "args", ".", "start_offset", ")", "base_offset", "=",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StopHuntIfCrashLimitExceeded
Stops the hunt if number of crashes exceeds the limit.
grr/server/grr_response_server/hunt.py
def StopHuntIfCrashLimitExceeded(hunt_id): """Stops the hunt if number of crashes exceeds the limit.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) # Do nothing if the hunt is already stopped. if hunt_obj.hunt_state == rdf_hunt_objects.Hunt.HuntState.STOPPED: return hunt_obj if hunt_obj.crash_l...
def StopHuntIfCrashLimitExceeded(hunt_id): """Stops the hunt if number of crashes exceeds the limit.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) # Do nothing if the hunt is already stopped. if hunt_obj.hunt_state == rdf_hunt_objects.Hunt.HuntState.STOPPED: return hunt_obj if hunt_obj.crash_l...
[ "Stops", "the", "hunt", "if", "number", "of", "crashes", "exceeds", "the", "limit", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L94-L111
[ "def", "StopHuntIfCrashLimitExceeded", "(", "hunt_id", ")", ":", "hunt_obj", "=", "data_store", ".", "REL_DB", ".", "ReadHuntObject", "(", "hunt_id", ")", "# Do nothing if the hunt is already stopped.", "if", "hunt_obj", ".", "hunt_state", "==", "rdf_hunt_objects", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StopHuntIfCPUOrNetworkLimitsExceeded
Stops the hunt if average limites are exceeded.
grr/server/grr_response_server/hunt.py
def StopHuntIfCPUOrNetworkLimitsExceeded(hunt_id): """Stops the hunt if average limites are exceeded.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) # Do nothing if the hunt is already stopped. if hunt_obj.hunt_state == rdf_hunt_objects.Hunt.HuntState.STOPPED: return hunt_obj hunt_counters = da...
def StopHuntIfCPUOrNetworkLimitsExceeded(hunt_id): """Stops the hunt if average limites are exceeded.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) # Do nothing if the hunt is already stopped. if hunt_obj.hunt_state == rdf_hunt_objects.Hunt.HuntState.STOPPED: return hunt_obj hunt_counters = da...
[ "Stops", "the", "hunt", "if", "average", "limites", "are", "exceeded", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L118-L177
[ "def", "StopHuntIfCPUOrNetworkLimitsExceeded", "(", "hunt_id", ")", ":", "hunt_obj", "=", "data_store", ".", "REL_DB", ".", "ReadHuntObject", "(", "hunt_id", ")", "# Do nothing if the hunt is already stopped.", "if", "hunt_obj", ".", "hunt_state", "==", "rdf_hunt_objects"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CompleteHuntIfExpirationTimeReached
Marks the hunt as complete if it's past its expiry time.
grr/server/grr_response_server/hunt.py
def CompleteHuntIfExpirationTimeReached(hunt_obj): """Marks the hunt as complete if it's past its expiry time.""" # TODO(hanuszczak): This should not set the hunt state to `COMPLETED` but we # should have a sparate `EXPIRED` state instead and set that. if (hunt_obj.hunt_state not in [ rdf_hunt_objects.Hun...
def CompleteHuntIfExpirationTimeReached(hunt_obj): """Marks the hunt as complete if it's past its expiry time.""" # TODO(hanuszczak): This should not set the hunt state to `COMPLETED` but we # should have a sparate `EXPIRED` state instead and set that. if (hunt_obj.hunt_state not in [ rdf_hunt_objects.Hun...
[ "Marks", "the", "hunt", "as", "complete", "if", "it", "s", "past", "its", "expiry", "time", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L180-L194
[ "def", "CompleteHuntIfExpirationTimeReached", "(", "hunt_obj", ")", ":", "# TODO(hanuszczak): This should not set the hunt state to `COMPLETED` but we", "# should have a sparate `EXPIRED` state instead and set that.", "if", "(", "hunt_obj", ".", "hunt_state", "not", "in", "[", "rdf_h...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CreateHunt
Creates a hunt using a given hunt object.
grr/server/grr_response_server/hunt.py
def CreateHunt(hunt_obj): """Creates a hunt using a given hunt object.""" data_store.REL_DB.WriteHuntObject(hunt_obj) if hunt_obj.HasField("output_plugins"): output_plugins_states = flow.GetOutputPluginStates( hunt_obj.output_plugins, source="hunts/%s" % hunt_obj.hunt_id, token=access...
def CreateHunt(hunt_obj): """Creates a hunt using a given hunt object.""" data_store.REL_DB.WriteHuntObject(hunt_obj) if hunt_obj.HasField("output_plugins"): output_plugins_states = flow.GetOutputPluginStates( hunt_obj.output_plugins, source="hunts/%s" % hunt_obj.hunt_id, token=access...
[ "Creates", "a", "hunt", "using", "a", "given", "hunt", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L197-L207
[ "def", "CreateHunt", "(", "hunt_obj", ")", ":", "data_store", ".", "REL_DB", ".", "WriteHuntObject", "(", "hunt_obj", ")", "if", "hunt_obj", ".", "HasField", "(", "\"output_plugins\"", ")", ":", "output_plugins_states", "=", "flow", ".", "GetOutputPluginStates", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CreateAndStartHunt
Creates and starts a new hunt.
grr/server/grr_response_server/hunt.py
def CreateAndStartHunt(flow_name, flow_args, creator, **kwargs): """Creates and starts a new hunt.""" # This interface takes a time when the hunt expires. However, the legacy hunt # starting interface took an rdfvalue.Duration object which was then added to # the current time to get the expiry. This check exis...
def CreateAndStartHunt(flow_name, flow_args, creator, **kwargs): """Creates and starts a new hunt.""" # This interface takes a time when the hunt expires. However, the legacy hunt # starting interface took an rdfvalue.Duration object which was then added to # the current time to get the expiry. This check exis...
[ "Creates", "and", "starts", "a", "new", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L210-L234
[ "def", "CreateAndStartHunt", "(", "flow_name", ",", "flow_args", ",", "creator", ",", "*", "*", "kwargs", ")", ":", "# This interface takes a time when the hunt expires. However, the legacy hunt", "# starting interface took an rdfvalue.Duration object which was then added to", "# the...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ScheduleGenericHunt
Adds foreman rules for a generic hunt.
grr/server/grr_response_server/hunt.py
def _ScheduleGenericHunt(hunt_obj): """Adds foreman rules for a generic hunt.""" # TODO: Migrate foreman conditions to use relation expiration # durations instead of absolute timestamps. foreman_condition = foreman_rules.ForemanCondition( creation_time=rdfvalue.RDFDatetime.Now(), expiration_time=hun...
def _ScheduleGenericHunt(hunt_obj): """Adds foreman rules for a generic hunt.""" # TODO: Migrate foreman conditions to use relation expiration # durations instead of absolute timestamps. foreman_condition = foreman_rules.ForemanCondition( creation_time=rdfvalue.RDFDatetime.Now(), expiration_time=hun...
[ "Adds", "foreman", "rules", "for", "a", "generic", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L237-L251
[ "def", "_ScheduleGenericHunt", "(", "hunt_obj", ")", ":", "# TODO: Migrate foreman conditions to use relation expiration", "# durations instead of absolute timestamps.", "foreman_condition", "=", "foreman_rules", ".", "ForemanCondition", "(", "creation_time", "=", "rdfvalue", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ScheduleVariableHunt
Schedules flows for a variable hunt.
grr/server/grr_response_server/hunt.py
def _ScheduleVariableHunt(hunt_obj): """Schedules flows for a variable hunt.""" if hunt_obj.client_rate != 0: raise VariableHuntCanNotHaveClientRateError(hunt_obj.hunt_id, hunt_obj.client_rate) seen_clients = set() for flow_group in hunt_obj.args.variable.flo...
def _ScheduleVariableHunt(hunt_obj): """Schedules flows for a variable hunt.""" if hunt_obj.client_rate != 0: raise VariableHuntCanNotHaveClientRateError(hunt_obj.hunt_id, hunt_obj.client_rate) seen_clients = set() for flow_group in hunt_obj.args.variable.flo...
[ "Schedules", "flows", "for", "a", "variable", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L254-L285
[ "def", "_ScheduleVariableHunt", "(", "hunt_obj", ")", ":", "if", "hunt_obj", ".", "client_rate", "!=", "0", ":", "raise", "VariableHuntCanNotHaveClientRateError", "(", "hunt_obj", ".", "hunt_id", ",", "hunt_obj", ".", "client_rate", ")", "seen_clients", "=", "set"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StartHunt
Starts a hunt with a given id.
grr/server/grr_response_server/hunt.py
def StartHunt(hunt_id): """Starts a hunt with a given id.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) num_hunt_clients = data_store.REL_DB.CountHuntFlows(hunt_id) if hunt_obj.hunt_state != hunt_obj.HuntState.PAUSED: raise OnlyPausedHuntCanBeStartedError(hunt_obj) data_store.REL_DB.UpdateHun...
def StartHunt(hunt_id): """Starts a hunt with a given id.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) num_hunt_clients = data_store.REL_DB.CountHuntFlows(hunt_id) if hunt_obj.hunt_state != hunt_obj.HuntState.PAUSED: raise OnlyPausedHuntCanBeStartedError(hunt_obj) data_store.REL_DB.UpdateHun...
[ "Starts", "a", "hunt", "with", "a", "given", "id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L288-L313
[ "def", "StartHunt", "(", "hunt_id", ")", ":", "hunt_obj", "=", "data_store", ".", "REL_DB", ".", "ReadHuntObject", "(", "hunt_id", ")", "num_hunt_clients", "=", "data_store", ".", "REL_DB", ".", "CountHuntFlows", "(", "hunt_id", ")", "if", "hunt_obj", ".", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PauseHunt
Pauses a hunt with a given id.
grr/server/grr_response_server/hunt.py
def PauseHunt(hunt_id, reason=None): """Pauses a hunt with a given id.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) if hunt_obj.hunt_state != hunt_obj.HuntState.STARTED: raise OnlyStartedHuntCanBePausedError(hunt_obj) data_store.REL_DB.UpdateHuntObject( hunt_id, hunt_state=hunt_obj.HuntSt...
def PauseHunt(hunt_id, reason=None): """Pauses a hunt with a given id.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) if hunt_obj.hunt_state != hunt_obj.HuntState.STARTED: raise OnlyStartedHuntCanBePausedError(hunt_obj) data_store.REL_DB.UpdateHuntObject( hunt_id, hunt_state=hunt_obj.HuntSt...
[ "Pauses", "a", "hunt", "with", "a", "given", "id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L316-L327
[ "def", "PauseHunt", "(", "hunt_id", ",", "reason", "=", "None", ")", ":", "hunt_obj", "=", "data_store", ".", "REL_DB", ".", "ReadHuntObject", "(", "hunt_id", ")", "if", "hunt_obj", ".", "hunt_state", "!=", "hunt_obj", ".", "HuntState", ".", "STARTED", ":"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StopHunt
Stops a hunt with a given id.
grr/server/grr_response_server/hunt.py
def StopHunt(hunt_id, reason=None): """Stops a hunt with a given id.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) if hunt_obj.hunt_state not in [ hunt_obj.HuntState.STARTED, hunt_obj.HuntState.PAUSED ]: raise OnlyStartedOrPausedHuntCanBeStoppedError(hunt_obj) data_store.REL_DB.UpdateHun...
def StopHunt(hunt_id, reason=None): """Stops a hunt with a given id.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) if hunt_obj.hunt_state not in [ hunt_obj.HuntState.STARTED, hunt_obj.HuntState.PAUSED ]: raise OnlyStartedOrPausedHuntCanBeStoppedError(hunt_obj) data_store.REL_DB.UpdateHun...
[ "Stops", "a", "hunt", "with", "a", "given", "id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L330-L352
[ "def", "StopHunt", "(", "hunt_id", ",", "reason", "=", "None", ")", ":", "hunt_obj", "=", "data_store", ".", "REL_DB", ".", "ReadHuntObject", "(", "hunt_id", ")", "if", "hunt_obj", ".", "hunt_state", "not", "in", "[", "hunt_obj", ".", "HuntState", ".", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UpdateHunt
Updates a hunt (it must be paused to be updated).
grr/server/grr_response_server/hunt.py
def UpdateHunt(hunt_id, client_limit=None, client_rate=None, duration=None): """Updates a hunt (it must be paused to be updated).""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) if hunt_obj.hunt_state != hunt_obj.HuntState.PAUSED: raise OnlyPausedHuntCanBeModifiedError(hunt_obj) data_store.REL_DB....
def UpdateHunt(hunt_id, client_limit=None, client_rate=None, duration=None): """Updates a hunt (it must be paused to be updated).""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) if hunt_obj.hunt_state != hunt_obj.HuntState.PAUSED: raise OnlyPausedHuntCanBeModifiedError(hunt_obj) data_store.REL_DB....
[ "Updates", "a", "hunt", "(", "it", "must", "be", "paused", "to", "be", "updated", ")", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L355-L367
[ "def", "UpdateHunt", "(", "hunt_id", ",", "client_limit", "=", "None", ",", "client_rate", "=", "None", ",", "duration", "=", "None", ")", ":", "hunt_obj", "=", "data_store", ".", "REL_DB", ".", "ReadHuntObject", "(", "hunt_id", ")", "if", "hunt_obj", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StartHuntFlowOnClient
Starts a flow corresponding to a given hunt on a given client.
grr/server/grr_response_server/hunt.py
def StartHuntFlowOnClient(client_id, hunt_id): """Starts a flow corresponding to a given hunt on a given client.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) hunt_obj = CompleteHuntIfExpirationTimeReached(hunt_obj) # There may be a little race between foreman rules being removed and # foreman sche...
def StartHuntFlowOnClient(client_id, hunt_id): """Starts a flow corresponding to a given hunt on a given client.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) hunt_obj = CompleteHuntIfExpirationTimeReached(hunt_obj) # There may be a little race between foreman rules being removed and # foreman sche...
[ "Starts", "a", "flow", "corresponding", "to", "a", "given", "hunt", "on", "a", "given", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L378-L432
[ "def", "StartHuntFlowOnClient", "(", "client_id", ",", "hunt_id", ")", ":", "hunt_obj", "=", "data_store", ".", "REL_DB", ".", "ReadHuntObject", "(", "hunt_id", ")", "hunt_obj", "=", "CompleteHuntIfExpirationTimeReached", "(", "hunt_obj", ")", "# There may be a little...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74