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
AbstractClientStatsCronFlow.Start
Retrieve all the clients for the AbstractClientStatsCollectors.
grr/server/grr_response_server/flows/cron/system.py
def Start(self): """Retrieve all the clients for the AbstractClientStatsCollectors.""" try: self.stats = {} self.BeginProcessing() processed_count = 0 if data_store.RelationalDBEnabled(): for client_info_batch in _IterateAllClients( recency_window=self.recency_win...
def Start(self): """Retrieve all the clients for the AbstractClientStatsCollectors.""" try: self.stats = {} self.BeginProcessing() processed_count = 0 if data_store.RelationalDBEnabled(): for client_info_batch in _IterateAllClients( recency_window=self.recency_win...
[ "Retrieve", "all", "the", "clients", "for", "the", "AbstractClientStatsCollectors", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/system.py#L353-L394
[ "def", "Start", "(", "self", ")", ":", "try", ":", "self", ".", "stats", "=", "{", "}", "self", ".", "BeginProcessing", "(", ")", "processed_count", "=", "0", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "for", "client_info_batch", "in"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
OSBreakDown.ProcessLegacyClient
Update counters for system, version and release attributes.
grr/server/grr_response_server/flows/cron/system.py
def ProcessLegacyClient(self, ping, client): """Update counters for system, version and release attributes.""" labels = self._GetClientLabelsList(client) system = client.Get(client.Schema.SYSTEM, "Unknown") uname = client.Get(client.Schema.UNAME, "Unknown") self._Process(labels, ping, system, uname...
def ProcessLegacyClient(self, ping, client): """Update counters for system, version and release attributes.""" labels = self._GetClientLabelsList(client) system = client.Get(client.Schema.SYSTEM, "Unknown") uname = client.Get(client.Schema.UNAME, "Unknown") self._Process(labels, ping, system, uname...
[ "Update", "counters", "for", "system", "version", "and", "release", "attributes", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/system.py#L464-L470
[ "def", "ProcessLegacyClient", "(", "self", ",", "ping", ",", "client", ")", ":", "labels", "=", "self", ".", "_GetClientLabelsList", "(", "client", ")", "system", "=", "client", ".", "Get", "(", "client", ".", "Schema", ".", "SYSTEM", ",", "\"Unknown\"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InterrogationHuntMixin.StartInterrogationHunt
Starts an interrogation hunt on all available clients.
grr/server/grr_response_server/flows/cron/system.py
def StartInterrogationHunt(self): """Starts an interrogation hunt on all available clients.""" flow_name = compatibility.GetName(flows_discovery.Interrogate) flow_args = flows_discovery.InterrogateArgs(lightweight=False) description = "Interrogate run by cron to keep host info fresh." if data_store...
def StartInterrogationHunt(self): """Starts an interrogation hunt on all available clients.""" flow_name = compatibility.GetName(flows_discovery.Interrogate) flow_args = flows_discovery.InterrogateArgs(lightweight=False) description = "Interrogate run by cron to keep host info fresh." if data_store...
[ "Starts", "an", "interrogation", "hunt", "on", "all", "available", "clients", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/system.py#L552-L584
[ "def", "StartInterrogationHunt", "(", "self", ")", ":", "flow_name", "=", "compatibility", ".", "GetName", "(", "flows_discovery", ".", "Interrogate", ")", "flow_args", "=", "flows_discovery", ".", "InterrogateArgs", "(", "lightweight", "=", "False", ")", "descrip...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PurgeClientStats.ProcessClients
Does the work.
grr/server/grr_response_server/flows/cron/system.py
def ProcessClients(self, responses): """Does the work.""" del responses end = rdfvalue.RDFDatetime.Now() - db.CLIENT_STATS_RETENTION client_urns = export_utils.GetAllClients(token=self.token) for batch in collection.Batch(client_urns, 10000): with data_store.DB.GetMutationPool() as mutation_...
def ProcessClients(self, responses): """Does the work.""" del responses end = rdfvalue.RDFDatetime.Now() - db.CLIENT_STATS_RETENTION client_urns = export_utils.GetAllClients(token=self.token) for batch in collection.Batch(client_urns, 10000): with data_store.DB.GetMutationPool() as mutation_...
[ "Does", "the", "work", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/system.py#L624-L647
[ "def", "ProcessClients", "(", "self", ",", "responses", ")", ":", "del", "responses", "end", "=", "rdfvalue", ".", "RDFDatetime", ".", "Now", "(", ")", "-", "db", ".", "CLIENT_STATS_RETENTION", "client_urns", "=", "export_utils", ".", "GetAllClients", "(", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientApprovalAuthorizationManager.CheckApproversForLabel
Checks if requester and approvers have approval privileges for labels. Checks against list of approvers for each label defined in approvers.yaml to determine if the list of approvers is sufficient. Args: token: user token client_urn: ClientURN object of the client requester: username str...
grr/server/grr_response_server/authorization/client_approval_auth.py
def CheckApproversForLabel(self, token, client_urn, requester, approvers, label): """Checks if requester and approvers have approval privileges for labels. Checks against list of approvers for each label defined in approvers.yaml to determine if the list of approvers is suffici...
def CheckApproversForLabel(self, token, client_urn, requester, approvers, label): """Checks if requester and approvers have approval privileges for labels. Checks against list of approvers for each label defined in approvers.yaml to determine if the list of approvers is suffici...
[ "Checks", "if", "requester", "and", "approvers", "have", "approval", "privileges", "for", "labels", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/authorization/client_approval_auth.py#L108-L148
[ "def", "CheckApproversForLabel", "(", "self", ",", "token", ",", "client_urn", ",", "requester", ",", "approvers", ",", "label", ")", ":", "auth", "=", "self", ".", "reader", ".", "GetAuthorizationForSubject", "(", "label", ")", "if", "not", "auth", ":", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EnsureTempDirIsSane
Checks that the directory exists and has the correct permissions set.
grr/client/grr_response_client/client_actions/tempfiles.py
def EnsureTempDirIsSane(directory): """Checks that the directory exists and has the correct permissions set.""" if not os.path.isabs(directory): raise ErrorBadPath("Directory %s is not absolute" % directory) if os.path.isdir(directory): # The temp dir already exists, we probably created it already but ...
def EnsureTempDirIsSane(directory): """Checks that the directory exists and has the correct permissions set.""" if not os.path.isabs(directory): raise ErrorBadPath("Directory %s is not absolute" % directory) if os.path.isdir(directory): # The temp dir already exists, we probably created it already but ...
[ "Checks", "that", "the", "directory", "exists", "and", "has", "the", "correct", "permissions", "set", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/tempfiles.py#L63-L86
[ "def", "EnsureTempDirIsSane", "(", "directory", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "directory", ")", ":", "raise", "ErrorBadPath", "(", "\"Directory %s is not absolute\"", "%", "directory", ")", "if", "os", ".", "path", ".", "isdir"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CreateGRRTempFile
Open file with GRR prefix in directory to allow easy deletion. Missing parent dirs will be created. If an existing directory is specified its permissions won't be modified to avoid breaking system functionality. Permissions on the destination file will be set to root/SYSTEM rw. On windows the file is created,...
grr/client/grr_response_client/client_actions/tempfiles.py
def CreateGRRTempFile(filename=None, lifetime=0, mode="w+b", suffix=""): """Open file with GRR prefix in directory to allow easy deletion. Missing parent dirs will be created. If an existing directory is specified its permissions won't be modified to avoid breaking system functionality. Permissions on the dest...
def CreateGRRTempFile(filename=None, lifetime=0, mode="w+b", suffix=""): """Open file with GRR prefix in directory to allow easy deletion. Missing parent dirs will be created. If an existing directory is specified its permissions won't be modified to avoid breaking system functionality. Permissions on the dest...
[ "Open", "file", "with", "GRR", "prefix", "in", "directory", "to", "allow", "easy", "deletion", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/tempfiles.py#L120-L182
[ "def", "CreateGRRTempFile", "(", "filename", "=", "None", ",", "lifetime", "=", "0", ",", "mode", "=", "\"w+b\"", ",", "suffix", "=", "\"\"", ")", ":", "directory", "=", "GetDefaultGRRTempDirectory", "(", ")", "EnsureTempDirIsSane", "(", "directory", ")", "p...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CreateGRRTempFileVFS
Creates a GRR VFS temp file. This function is analogous to CreateGRRTempFile but returns an open VFS handle to the newly created file. Arguments are the same as for CreateGRRTempFile: Args: filename: The name of the file to use. Note that setting both filename and directory name is not allowed. ...
grr/client/grr_response_client/client_actions/tempfiles.py
def CreateGRRTempFileVFS(filename=None, lifetime=0, mode="w+b", suffix=""): """Creates a GRR VFS temp file. This function is analogous to CreateGRRTempFile but returns an open VFS handle to the newly created file. Arguments are the same as for CreateGRRTempFile: Args: filename: The name of the file to use...
def CreateGRRTempFileVFS(filename=None, lifetime=0, mode="w+b", suffix=""): """Creates a GRR VFS temp file. This function is analogous to CreateGRRTempFile but returns an open VFS handle to the newly created file. Arguments are the same as for CreateGRRTempFile: Args: filename: The name of the file to use...
[ "Creates", "a", "GRR", "VFS", "temp", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/tempfiles.py#L185-L209
[ "def", "CreateGRRTempFileVFS", "(", "filename", "=", "None", ",", "lifetime", "=", "0", ",", "mode", "=", "\"w+b\"", ",", "suffix", "=", "\"\"", ")", ":", "fd", "=", "CreateGRRTempFile", "(", "filename", "=", "filename", ",", "lifetime", "=", "lifetime", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_CheckIfPathIsValidForDeletion
Checks if given path is valid for deletion.
grr/client/grr_response_client/client_actions/tempfiles.py
def _CheckIfPathIsValidForDeletion(path, prefix=None, directories=None): """Checks if given path is valid for deletion.""" precondition.AssertType(path, Text) precondition.AssertType(prefix, Text) if prefix and os.path.basename(path).startswith(prefix): return True path = path.lower() for directory in...
def _CheckIfPathIsValidForDeletion(path, prefix=None, directories=None): """Checks if given path is valid for deletion.""" precondition.AssertType(path, Text) precondition.AssertType(prefix, Text) if prefix and os.path.basename(path).startswith(prefix): return True path = path.lower() for directory in...
[ "Checks", "if", "given", "path", "is", "valid", "for", "deletion", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/tempfiles.py#L212-L225
[ "def", "_CheckIfPathIsValidForDeletion", "(", "path", ",", "prefix", "=", "None", ",", "directories", "=", "None", ")", ":", "precondition", ".", "AssertType", "(", "path", ",", "Text", ")", "precondition", ".", "AssertType", "(", "prefix", ",", "Text", ")",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DeleteGRRTempFile
Delete a GRR temp file. To limit possible damage the path must be absolute and either the file must be within any of the Client.tempdir_roots or the file name must begin with Client.tempfile_prefix. Args: path: path string to file to be deleted. Raises: OSError: Permission denied, or file not found...
grr/client/grr_response_client/client_actions/tempfiles.py
def DeleteGRRTempFile(path): """Delete a GRR temp file. To limit possible damage the path must be absolute and either the file must be within any of the Client.tempdir_roots or the file name must begin with Client.tempfile_prefix. Args: path: path string to file to be deleted. Raises: OSError: Pe...
def DeleteGRRTempFile(path): """Delete a GRR temp file. To limit possible damage the path must be absolute and either the file must be within any of the Client.tempdir_roots or the file name must begin with Client.tempfile_prefix. Args: path: path string to file to be deleted. Raises: OSError: Pe...
[ "Delete", "a", "GRR", "temp", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/tempfiles.py#L228-L264
[ "def", "DeleteGRRTempFile", "(", "path", ")", ":", "precondition", ".", "AssertType", "(", "path", ",", "Text", ")", "if", "not", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "raise", "ErrorBadPath", "(", "\"Path must be absolute\"", ")", "prefi...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DeleteGRRTempFiles.Run
Delete all the GRR temp files in path. If path is a directory, look in the top level for filenames beginning with Client.tempfile_prefix, and delete them. If path is a regular file and starts with Client.tempfile_prefix delete it. Args: args: pathspec pointing to directory containing temp files...
grr/client/grr_response_client/client_actions/tempfiles.py
def Run(self, args): """Delete all the GRR temp files in path. If path is a directory, look in the top level for filenames beginning with Client.tempfile_prefix, and delete them. If path is a regular file and starts with Client.tempfile_prefix delete it. Args: args: pathspec pointing to dir...
def Run(self, args): """Delete all the GRR temp files in path. If path is a directory, look in the top level for filenames beginning with Client.tempfile_prefix, and delete them. If path is a regular file and starts with Client.tempfile_prefix delete it. Args: args: pathspec pointing to dir...
[ "Delete", "all", "the", "GRR", "temp", "files", "in", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/tempfiles.py#L272-L346
[ "def", "Run", "(", "self", ",", "args", ")", ":", "allowed_temp_dirs", "=", "[", "GetTempDirForRoot", "(", "root", ")", "for", "root", "in", "config", ".", "CONFIG", "[", "\"Client.tempdir_roots\"", "]", "]", "if", "args", ".", "path", ":", "# Normalize th...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PlistValueFilter.Start
Issue a request to list the directory.
grr/server/grr_response_server/flows/general/filetypes.py
def Start(self): """Issue a request to list the directory.""" self.CallClient( server_stubs.PlistQuery, request=self.args.request, next_state="Receive")
def Start(self): """Issue a request to list the directory.""" self.CallClient( server_stubs.PlistQuery, request=self.args.request, next_state="Receive")
[ "Issue", "a", "request", "to", "list", "the", "directory", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filetypes.py#L59-L64
[ "def", "Start", "(", "self", ")", ":", "self", ".", "CallClient", "(", "server_stubs", ".", "PlistQuery", ",", "request", "=", "self", ".", "args", ".", "request", ",", "next_state", "=", "\"Receive\"", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetRequestFormatMode
Returns JSON format mode corresponding to a given request and method.
grr/server/grr_response_server/gui/http_api.py
def GetRequestFormatMode(request, method_metadata): """Returns JSON format mode corresponding to a given request and method.""" if request.path.startswith("/api/v2/"): return JsonMode.PROTO3_JSON_MODE if request.args.get("strip_type_info", ""): return JsonMode.GRR_TYPE_STRIPPED_JSON_MODE for http_meth...
def GetRequestFormatMode(request, method_metadata): """Returns JSON format mode corresponding to a given request and method.""" if request.path.startswith("/api/v2/"): return JsonMode.PROTO3_JSON_MODE if request.args.get("strip_type_info", ""): return JsonMode.GRR_TYPE_STRIPPED_JSON_MODE for http_meth...
[ "Returns", "JSON", "format", "mode", "corresponding", "to", "a", "given", "request", "and", "method", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L229-L242
[ "def", "GetRequestFormatMode", "(", "request", ",", "method_metadata", ")", ":", "if", "request", ".", "path", ".", "startswith", "(", "\"/api/v2/\"", ")", ":", "return", "JsonMode", ".", "PROTO3_JSON_MODE", "if", "request", ".", "args", ".", "get", "(", "\"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RenderHttpResponse
Renders HTTP response to a given HTTP request.
grr/server/grr_response_server/gui/http_api.py
def RenderHttpResponse(request): """Renders HTTP response to a given HTTP request.""" start_time = time.time() response = HTTP_REQUEST_HANDLER.HandleRequest(request) total_time = time.time() - start_time method_name = response.headers.get("X-API-Method", "unknown") if response.status_code == 200: stat...
def RenderHttpResponse(request): """Renders HTTP response to a given HTTP request.""" start_time = time.time() response = HTTP_REQUEST_HANDLER.HandleRequest(request) total_time = time.time() - start_time method_name = response.headers.get("X-API-Method", "unknown") if response.status_code == 200: stat...
[ "Renders", "HTTP", "response", "to", "a", "given", "HTTP", "request", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L582-L609
[ "def", "RenderHttpResponse", "(", "request", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "response", "=", "HTTP_REQUEST_HANDLER", ".", "HandleRequest", "(", "request", ")", "total_time", "=", "time", ".", "time", "(", ")", "-", "start_time", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RouterMatcher._BuildHttpRoutingMap
Builds a werkzeug routing map out of a given router class.
grr/server/grr_response_server/gui/http_api.py
def _BuildHttpRoutingMap(self, router_cls): """Builds a werkzeug routing map out of a given router class.""" if not issubclass(router_cls, api_call_router.ApiCallRouter): raise ValueError("Router has to be an instance of ApiCallRouter.") routing_map = routing.Map() # Note: we traverse methods of...
def _BuildHttpRoutingMap(self, router_cls): """Builds a werkzeug routing map out of a given router class.""" if not issubclass(router_cls, api_call_router.ApiCallRouter): raise ValueError("Router has to be an instance of ApiCallRouter.") routing_map = routing.Map() # Note: we traverse methods of...
[ "Builds", "a", "werkzeug", "routing", "map", "out", "of", "a", "given", "router", "class", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L70-L93
[ "def", "_BuildHttpRoutingMap", "(", "self", ",", "router_cls", ")", ":", "if", "not", "issubclass", "(", "router_cls", ",", "api_call_router", ".", "ApiCallRouter", ")", ":", "raise", "ValueError", "(", "\"Router has to be an instance of ApiCallRouter.\"", ")", "routi...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RouterMatcher._GetRoutingMap
Returns a routing map for a given router instance.
grr/server/grr_response_server/gui/http_api.py
def _GetRoutingMap(self, router): """Returns a routing map for a given router instance.""" try: routing_map = self._routing_maps_cache.Get(router.__class__) except KeyError: routing_map = self._BuildHttpRoutingMap(router.__class__) self._routing_maps_cache.Put(router.__class__, routing_ma...
def _GetRoutingMap(self, router): """Returns a routing map for a given router instance.""" try: routing_map = self._routing_maps_cache.Get(router.__class__) except KeyError: routing_map = self._BuildHttpRoutingMap(router.__class__) self._routing_maps_cache.Put(router.__class__, routing_ma...
[ "Returns", "a", "routing", "map", "for", "a", "given", "router", "instance", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L95-L104
[ "def", "_GetRoutingMap", "(", "self", ",", "router", ")", ":", "try", ":", "routing_map", "=", "self", ".", "_routing_maps_cache", ".", "Get", "(", "router", ".", "__class__", ")", "except", "KeyError", ":", "routing_map", "=", "self", ".", "_BuildHttpRoutin...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RouterMatcher._SetField
Sets fields on the arg rdfvalue object.
grr/server/grr_response_server/gui/http_api.py
def _SetField(self, args, type_info, value): """Sets fields on the arg rdfvalue object.""" if hasattr(type_info, "enum"): try: coerced_obj = type_info.enum[value.upper()] except KeyError: # A bool is an enum but serializes to "1" / "0" which are both not in # enum or reverse_...
def _SetField(self, args, type_info, value): """Sets fields on the arg rdfvalue object.""" if hasattr(type_info, "enum"): try: coerced_obj = type_info.enum[value.upper()] except KeyError: # A bool is an enum but serializes to "1" / "0" which are both not in # enum or reverse_...
[ "Sets", "fields", "on", "the", "arg", "rdfvalue", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L106-L117
[ "def", "_SetField", "(", "self", ",", "args", ",", "type_info", ",", "value", ")", ":", "if", "hasattr", "(", "type_info", ",", "\"enum\"", ")", ":", "try", ":", "coerced_obj", "=", "type_info", ".", "enum", "[", "value", ".", "upper", "(", ")", "]",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RouterMatcher._GetArgsFromRequest
Builds args struct out of HTTP request.
grr/server/grr_response_server/gui/http_api.py
def _GetArgsFromRequest(self, request, method_metadata, route_args): """Builds args struct out of HTTP request.""" format_mode = GetRequestFormatMode(request, method_metadata) if request.method in ["GET", "HEAD"]: if method_metadata.args_type: unprocessed_request = request.args if has...
def _GetArgsFromRequest(self, request, method_metadata, route_args): """Builds args struct out of HTTP request.""" format_mode = GetRequestFormatMode(request, method_metadata) if request.method in ["GET", "HEAD"]: if method_metadata.args_type: unprocessed_request = request.args if has...
[ "Builds", "args", "struct", "out", "of", "HTTP", "request", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L119-L169
[ "def", "_GetArgsFromRequest", "(", "self", ",", "request", ",", "method_metadata", ",", "route_args", ")", ":", "format_mode", "=", "GetRequestFormatMode", "(", "request", ",", "method_metadata", ")", "if", "request", ".", "method", "in", "[", "\"GET\"", ",", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RouterMatcher.MatchRouter
Returns a router for a given HTTP request.
grr/server/grr_response_server/gui/http_api.py
def MatchRouter(self, request): """Returns a router for a given HTTP request.""" router = api_auth_manager.API_AUTH_MGR.GetRouterForUser(request.user) routing_map = self._GetRoutingMap(router) matcher = routing_map.bind( "%s:%s" % (request.environ["SERVER_NAME"], request.environ["SERVER...
def MatchRouter(self, request): """Returns a router for a given HTTP request.""" router = api_auth_manager.API_AUTH_MGR.GetRouterForUser(request.user) routing_map = self._GetRoutingMap(router) matcher = routing_map.bind( "%s:%s" % (request.environ["SERVER_NAME"], request.environ["SERVER...
[ "Returns", "a", "router", "for", "a", "given", "HTTP", "request", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L171-L188
[ "def", "MatchRouter", "(", "self", ",", "request", ")", ":", "router", "=", "api_auth_manager", ".", "API_AUTH_MGR", ".", "GetRouterForUser", "(", "request", ".", "user", ")", "routing_map", "=", "self", ".", "_GetRoutingMap", "(", "router", ")", "matcher", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HttpRequestHandler.BuildToken
Build an ACLToken from the request.
grr/server/grr_response_server/gui/http_api.py
def BuildToken(request, execution_time): """Build an ACLToken from the request.""" # The request.args dictionary will also be filled on HEAD calls. if request.method in ["GET", "HEAD"]: reason = request.args.get("reason", "") elif request.method in ["POST", "DELETE", "PATCH"]: # The header ...
def BuildToken(request, execution_time): """Build an ACLToken from the request.""" # The request.args dictionary will also be filled on HEAD calls. if request.method in ["GET", "HEAD"]: reason = request.args.get("reason", "") elif request.method in ["POST", "DELETE", "PATCH"]: # The header ...
[ "Build", "an", "ACLToken", "from", "the", "request", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L249-L278
[ "def", "BuildToken", "(", "request", ",", "execution_time", ")", ":", "# The request.args dictionary will also be filled on HEAD calls.", "if", "request", ".", "method", "in", "[", "\"GET\"", ",", "\"HEAD\"", "]", ":", "reason", "=", "request", ".", "args", ".", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HttpRequestHandler.CallApiHandler
Handles API call to a given handler with given args and token.
grr/server/grr_response_server/gui/http_api.py
def CallApiHandler(handler, args, token=None): """Handles API call to a given handler with given args and token.""" result = handler.Handle(args, token=token) expected_type = handler.result_type if expected_type is None: expected_type = None.__class__ if result.__class__ != expected_type: ...
def CallApiHandler(handler, args, token=None): """Handles API call to a given handler with given args and token.""" result = handler.Handle(args, token=token) expected_type = handler.result_type if expected_type is None: expected_type = None.__class__ if result.__class__ != expected_type: ...
[ "Handles", "API", "call", "to", "a", "given", "handler", "with", "given", "args", "and", "token", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L307-L321
[ "def", "CallApiHandler", "(", "handler", ",", "args", ",", "token", "=", "None", ")", ":", "result", "=", "handler", ".", "Handle", "(", "args", ",", "token", "=", "token", ")", "expected_type", "=", "handler", ".", "result_type", "if", "expected_type", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HttpRequestHandler._BuildResponse
Builds HTTPResponse object from rendered data and HTTP status.
grr/server/grr_response_server/gui/http_api.py
def _BuildResponse(self, status, rendered_data, method_name=None, headers=None, content_length=None, token=None, no_audit_log=False): """Builds HTTPResponse object from ...
def _BuildResponse(self, status, rendered_data, method_name=None, headers=None, content_length=None, token=None, no_audit_log=False): """Builds HTTPResponse object from ...
[ "Builds", "HTTPResponse", "object", "from", "rendered", "data", "and", "HTTP", "status", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L326-L368
[ "def", "_BuildResponse", "(", "self", ",", "status", ",", "rendered_data", ",", "method_name", "=", "None", ",", "headers", "=", "None", ",", "content_length", "=", "None", ",", "token", "=", "None", ",", "no_audit_log", "=", "False", ")", ":", "# To avoid...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HttpRequestHandler._BuildStreamingResponse
Builds HTTPResponse object for streaming.
grr/server/grr_response_server/gui/http_api.py
def _BuildStreamingResponse(self, binary_stream, method_name=None): """Builds HTTPResponse object for streaming.""" precondition.AssertType(method_name, Text) # We get a first chunk of the output stream. This way the likelihood # of catching an exception that may happen during response generation #...
def _BuildStreamingResponse(self, binary_stream, method_name=None): """Builds HTTPResponse object for streaming.""" precondition.AssertType(method_name, Text) # We get a first chunk of the output stream. This way the likelihood # of catching an exception that may happen during response generation #...
[ "Builds", "HTTPResponse", "object", "for", "streaming", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L370-L396
[ "def", "_BuildStreamingResponse", "(", "self", ",", "binary_stream", ",", "method_name", "=", "None", ")", ":", "precondition", ".", "AssertType", "(", "method_name", ",", "Text", ")", "# We get a first chunk of the output stream. This way the likelihood", "# of catching an...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HttpRequestHandler.HandleRequest
Handles given HTTP request.
grr/server/grr_response_server/gui/http_api.py
def HandleRequest(self, request): """Handles given HTTP request.""" impersonated_username = config.CONFIG["AdminUI.debug_impersonate_user"] if impersonated_username: logging.info("Overriding user as %s", impersonated_username) request.user = config.CONFIG["AdminUI.debug_impersonate_user"] i...
def HandleRequest(self, request): """Handles given HTTP request.""" impersonated_username = config.CONFIG["AdminUI.debug_impersonate_user"] if impersonated_username: logging.info("Overriding user as %s", impersonated_username) request.user = config.CONFIG["AdminUI.debug_impersonate_user"] i...
[ "Handles", "given", "HTTP", "request", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L398-L579
[ "def", "HandleRequest", "(", "self", ",", "request", ")", ":", "impersonated_username", "=", "config", ".", "CONFIG", "[", "\"AdminUI.debug_impersonate_user\"", "]", "if", "impersonated_username", ":", "logging", ".", "info", "(", "\"Overriding user as %s\"", ",", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetDefaultToken
Returns the provided token or the default token. Args: token: A token or None. Raises: access_control.UnauthorizedAccess: no token was provided.
grr/server/grr_response_server/data_store.py
def GetDefaultToken(token): """Returns the provided token or the default token. Args: token: A token or None. Raises: access_control.UnauthorizedAccess: no token was provided. """ if token is None: token = default_token if not isinstance(token, access_control.ACLToken): raise access_contr...
def GetDefaultToken(token): """Returns the provided token or the default token. Args: token: A token or None. Raises: access_control.UnauthorizedAccess: no token was provided. """ if token is None: token = default_token if not isinstance(token, access_control.ACLToken): raise access_contr...
[ "Returns", "the", "provided", "token", "or", "the", "default", "token", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L125-L142
[ "def", "GetDefaultToken", "(", "token", ")", ":", "if", "token", "is", "None", ":", "token", "=", "default_token", "if", "not", "isinstance", "(", "token", ",", "access_control", ".", "ACLToken", ")", ":", "raise", "access_control", ".", "UnauthorizedAccess", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MutationPool.Flush
Flushing actually applies all the operations in the pool.
grr/server/grr_response_server/data_store.py
def Flush(self): """Flushing actually applies all the operations in the pool.""" DB.DeleteSubjects(self.delete_subject_requests, sync=False) for req in self.delete_attributes_requests: subject, attributes, start, end = req DB.DeleteAttributes(subject, attributes, start=start, end=end, sync=Fals...
def Flush(self): """Flushing actually applies all the operations in the pool.""" DB.DeleteSubjects(self.delete_subject_requests, sync=False) for req in self.delete_attributes_requests: subject, attributes, start, end = req DB.DeleteAttributes(subject, attributes, start=start, end=end, sync=Fals...
[ "Flushing", "actually", "applies", "all", "the", "operations", "in", "the", "pool", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L197-L225
[ "def", "Flush", "(", "self", ")", ":", "DB", ".", "DeleteSubjects", "(", "self", ".", "delete_subject_requests", ",", "sync", "=", "False", ")", "for", "req", "in", "self", ".", "delete_attributes_requests", ":", "subject", ",", "attributes", ",", "start", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MutationPool.QueueClaimRecords
Claims records from a queue. See server/aff4_objects/queue.py.
grr/server/grr_response_server/data_store.py
def QueueClaimRecords(self, queue_id, item_rdf_type, limit=10000, timeout="30m", start_time=None, record_filter=lambda x: False, max_filtered=1000): ...
def QueueClaimRecords(self, queue_id, item_rdf_type, limit=10000, timeout="30m", start_time=None, record_filter=lambda x: False, max_filtered=1000): ...
[ "Claims", "records", "from", "a", "queue", ".", "See", "server", "/", "aff4_objects", "/", "queue", ".", "py", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L289-L345
[ "def", "QueueClaimRecords", "(", "self", ",", "queue_id", ",", "item_rdf_type", ",", "limit", "=", "10000", ",", "timeout", "=", "\"30m\"", ",", "start_time", "=", "None", ",", "record_filter", "=", "lambda", "x", ":", "False", ",", "max_filtered", "=", "1...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MutationPool.QueueDeleteTasks
Removes the given tasks from the queue.
grr/server/grr_response_server/data_store.py
def QueueDeleteTasks(self, queue, tasks): """Removes the given tasks from the queue.""" predicates = [] for task in tasks: task_id = getattr(task, "task_id", None) or int(task) predicates.append(DataStore.QueueTaskIdToColumn(task_id)) self.DeleteAttributes(queue, predicates)
def QueueDeleteTasks(self, queue, tasks): """Removes the given tasks from the queue.""" predicates = [] for task in tasks: task_id = getattr(task, "task_id", None) or int(task) predicates.append(DataStore.QueueTaskIdToColumn(task_id)) self.DeleteAttributes(queue, predicates)
[ "Removes", "the", "given", "tasks", "from", "the", "queue", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L372-L378
[ "def", "QueueDeleteTasks", "(", "self", ",", "queue", ",", "tasks", ")", ":", "predicates", "=", "[", "]", "for", "task", "in", "tasks", ":", "task_id", "=", "getattr", "(", "task", ",", "\"task_id\"", ",", "None", ")", "or", "int", "(", "task", ")",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MutationPool.QueueQueryAndOwn
Returns a list of Tasks leased for a certain time. Args: queue: The queue to query from. lease_seconds: The tasks will be leased for this long. limit: Number of values to fetch. timestamp: Range of times for consideration. Returns: A list of GrrMessage() objects leased.
grr/server/grr_response_server/data_store.py
def QueueQueryAndOwn(self, queue, lease_seconds, limit, timestamp): """Returns a list of Tasks leased for a certain time. Args: queue: The queue to query from. lease_seconds: The tasks will be leased for this long. limit: Number of values to fetch. timestamp: Range of times for consider...
def QueueQueryAndOwn(self, queue, lease_seconds, limit, timestamp): """Returns a list of Tasks leased for a certain time. Args: queue: The queue to query from. lease_seconds: The tasks will be leased for this long. limit: Number of values to fetch. timestamp: Range of times for consider...
[ "Returns", "a", "list", "of", "Tasks", "leased", "for", "a", "certain", "time", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L389-L416
[ "def", "QueueQueryAndOwn", "(", "self", ",", "queue", ",", "lease_seconds", ",", "limit", ",", "timestamp", ")", ":", "# Do the real work in a transaction", "try", ":", "lock", "=", "DB", ".", "LockRetryWrapper", "(", "queue", ",", "lease_time", "=", "lease_seco...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MutationPool._QueueQueryAndOwn
Business logic helper for QueueQueryAndOwn().
grr/server/grr_response_server/data_store.py
def _QueueQueryAndOwn(self, subject, lease_seconds=100, limit=1, timestamp=None): """Business logic helper for QueueQueryAndOwn().""" tasks = [] lease = int(lease_seconds * 1e6) # Only grab attributes with ...
def _QueueQueryAndOwn(self, subject, lease_seconds=100, limit=1, timestamp=None): """Business logic helper for QueueQueryAndOwn().""" tasks = [] lease = int(lease_seconds * 1e6) # Only grab attributes with ...
[ "Business", "logic", "helper", "for", "QueueQueryAndOwn", "()", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L418-L469
[ "def", "_QueueQueryAndOwn", "(", "self", ",", "subject", ",", "lease_seconds", "=", "100", ",", "limit", "=", "1", ",", "timestamp", "=", "None", ")", ":", "tasks", "=", "[", "]", "lease", "=", "int", "(", "lease_seconds", "*", "1e6", ")", "# Only grab...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MutationPool.AFF4AddChild
Adds a child to the specified parent.
grr/server/grr_response_server/data_store.py
def AFF4AddChild(self, subject, child, extra_attributes=None): """Adds a child to the specified parent.""" precondition.AssertType(child, Text) attributes = { DataStore.AFF4_INDEX_DIR_TEMPLATE % child: [DataStore.EMPTY_DATA_PLACEHOLDER] } if extra_attributes: attributes.update...
def AFF4AddChild(self, subject, child, extra_attributes=None): """Adds a child to the specified parent.""" precondition.AssertType(child, Text) attributes = { DataStore.AFF4_INDEX_DIR_TEMPLATE % child: [DataStore.EMPTY_DATA_PLACEHOLDER] } if extra_attributes: attributes.update...
[ "Adds", "a", "child", "to", "the", "specified", "parent", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L487-L497
[ "def", "AFF4AddChild", "(", "self", ",", "subject", ",", "child", ",", "extra_attributes", "=", "None", ")", ":", "precondition", ".", "AssertType", "(", "child", ",", "Text", ")", "attributes", "=", "{", "DataStore", ".", "AFF4_INDEX_DIR_TEMPLATE", "%", "ch...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.InitializeMonitorThread
Start the thread that registers the size of the DataStore.
grr/server/grr_response_server/data_store.py
def InitializeMonitorThread(self): """Start the thread that registers the size of the DataStore.""" if self.monitor_thread: return self.monitor_thread = utils.InterruptableThread( name="DataStore monitoring thread", target=self._RegisterSize, sleep_time=60) self.monitor_thr...
def InitializeMonitorThread(self): """Start the thread that registers the size of the DataStore.""" if self.monitor_thread: return self.monitor_thread = utils.InterruptableThread( name="DataStore monitoring thread", target=self._RegisterSize, sleep_time=60) self.monitor_thr...
[ "Start", "the", "thread", "that", "registers", "the", "size", "of", "the", "DataStore", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L551-L559
[ "def", "InitializeMonitorThread", "(", "self", ")", ":", "if", "self", ".", "monitor_thread", ":", "return", "self", ".", "monitor_thread", "=", "utils", ".", "InterruptableThread", "(", "name", "=", "\"DataStore monitoring thread\"", ",", "target", "=", "self", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.DeleteSubjects
Delete multiple subjects at once.
grr/server/grr_response_server/data_store.py
def DeleteSubjects(self, subjects, sync=False): """Delete multiple subjects at once.""" for subject in subjects: self.DeleteSubject(subject, sync=sync)
def DeleteSubjects(self, subjects, sync=False): """Delete multiple subjects at once.""" for subject in subjects: self.DeleteSubject(subject, sync=sync)
[ "Delete", "multiple", "subjects", "at", "once", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L582-L585
[ "def", "DeleteSubjects", "(", "self", ",", "subjects", ",", "sync", "=", "False", ")", ":", "for", "subject", "in", "subjects", ":", "self", ".", "DeleteSubject", "(", "subject", ",", "sync", "=", "sync", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.LockRetryWrapper
Retry a DBSubjectLock until it succeeds. Args: subject: The subject which the lock applies to. retrywrap_timeout: How long to wait before retrying the lock. retrywrap_max_timeout: The maximum time to wait for a retry until we raise. blocking: If False, raise on first lock failure. ...
grr/server/grr_response_server/data_store.py
def LockRetryWrapper(self, subject, retrywrap_timeout=1, retrywrap_max_timeout=10, blocking=True, lease_time=None): """Retry a DBSubjectLock until it succeeds. Args: subject: The subject whi...
def LockRetryWrapper(self, subject, retrywrap_timeout=1, retrywrap_max_timeout=10, blocking=True, lease_time=None): """Retry a DBSubjectLock until it succeeds. Args: subject: The subject whi...
[ "Retry", "a", "DBSubjectLock", "until", "it", "succeeds", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L612-L645
[ "def", "LockRetryWrapper", "(", "self", ",", "subject", ",", "retrywrap_timeout", "=", "1", ",", "retrywrap_max_timeout", "=", "10", ",", "blocking", "=", "True", ",", "lease_time", "=", "None", ")", ":", "timeout", "=", "0", "while", "timeout", "<", "retr...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.MultiSet
Set multiple attributes' values for this subject in one operation. Args: subject: The subject this applies to. values: A dict with keys containing attributes and values, serializations to be set. values can be a tuple of (value, timestamp). Value must be one of the supported types. ...
grr/server/grr_response_server/data_store.py
def MultiSet(self, subject, values, timestamp=None, replace=True, sync=True, to_delete=None): """Set multiple attributes' values for this subject in one operation. Args: subject: The subject this applies to. v...
def MultiSet(self, subject, values, timestamp=None, replace=True, sync=True, to_delete=None): """Set multiple attributes' values for this subject in one operation. Args: subject: The subject this applies to. v...
[ "Set", "multiple", "attributes", "values", "for", "this", "subject", "in", "one", "operation", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L669-L688
[ "def", "MultiSet", "(", "self", ",", "subject", ",", "values", ",", "timestamp", "=", "None", ",", "replace", "=", "True", ",", "sync", "=", "True", ",", "to_delete", "=", "None", ")", ":" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.MultiDeleteAttributes
Remove all specified attributes from a list of subjects. Args: subjects: The list of subjects that will have these attributes removed. attributes: A list of attributes. start: A timestamp, attributes older than start will not be deleted. end: A timestamp, attributes newer than end will not ...
grr/server/grr_response_server/data_store.py
def MultiDeleteAttributes(self, subjects, attributes, start=None, end=None, sync=True): """Remove all specified attributes from a list of subjects. Args: subjects: T...
def MultiDeleteAttributes(self, subjects, attributes, start=None, end=None, sync=True): """Remove all specified attributes from a list of subjects. Args: subjects: T...
[ "Remove", "all", "specified", "attributes", "from", "a", "list", "of", "subjects", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L690-L707
[ "def", "MultiDeleteAttributes", "(", "self", ",", "subjects", ",", "attributes", ",", "start", "=", "None", ",", "end", "=", "None", ",", "sync", "=", "True", ")", ":", "for", "subject", "in", "subjects", ":", "self", ".", "DeleteAttributes", "(", "subje...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.Resolve
Retrieve a value set for a subject's attribute. This method is easy to use but always gets the latest version of the attribute. It is more flexible and efficient to use the other Resolve methods. Args: subject: The subject URN. attribute: The attribute. Returns: A (value, timest...
grr/server/grr_response_server/data_store.py
def Resolve(self, subject, attribute): """Retrieve a value set for a subject's attribute. This method is easy to use but always gets the latest version of the attribute. It is more flexible and efficient to use the other Resolve methods. Args: subject: The subject URN. attribute: The a...
def Resolve(self, subject, attribute): """Retrieve a value set for a subject's attribute. This method is easy to use but always gets the latest version of the attribute. It is more flexible and efficient to use the other Resolve methods. Args: subject: The subject URN. attribute: The a...
[ "Retrieve", "a", "value", "set", "for", "a", "subject", "s", "attribute", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L726-L750
[ "def", "Resolve", "(", "self", ",", "subject", ",", "attribute", ")", ":", "for", "_", ",", "value", ",", "timestamp", "in", "self", ".", "ResolveMulti", "(", "subject", ",", "[", "attribute", "]", ",", "timestamp", "=", "self", ".", "NEWEST_TIMESTAMP", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.ResolvePrefix
Retrieve a set of value matching for this subject's attribute. Args: subject: The subject that we will search. attribute_prefix: The attribute prefix. timestamp: A range of times for consideration (In microseconds). Can be a constant such as ALL_TIMESTAMPS or NEWEST_TIMESTAMP or a tuple o...
grr/server/grr_response_server/data_store.py
def ResolvePrefix(self, subject, attribute_prefix, timestamp=None, limit=None): """Retrieve a set of value matching for this subject's attribute. Args: subject: The subject that we will search. attribute_prefix: The attribute prefix. timestamp: A range of times for conside...
def ResolvePrefix(self, subject, attribute_prefix, timestamp=None, limit=None): """Retrieve a set of value matching for this subject's attribute. Args: subject: The subject that we will search. attribute_prefix: The attribute prefix. timestamp: A range of times for conside...
[ "Retrieve", "a", "set", "of", "value", "matching", "for", "this", "subject", "s", "attribute", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L784-L813
[ "def", "ResolvePrefix", "(", "self", ",", "subject", ",", "attribute_prefix", ",", "timestamp", "=", "None", ",", "limit", "=", "None", ")", ":", "for", "_", ",", "values", "in", "self", ".", "MultiResolvePrefix", "(", "[", "subject", "]", ",", "attribut...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.ReadRequestsAndResponses
Fetches all Requests and Responses for a given session_id.
grr/server/grr_response_server/data_store.py
def ReadRequestsAndResponses(self, session_id, timestamp=None, request_limit=None, response_limit=None): """Fetches all Requests and Responses for a given session_id.""" subject = session_...
def ReadRequestsAndResponses(self, session_id, timestamp=None, request_limit=None, response_limit=None): """Fetches all Requests and Responses for a given session_id.""" subject = session_...
[ "Fetches", "all", "Requests", "and", "Responses", "for", "a", "given", "session_id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L961-L996
[ "def", "ReadRequestsAndResponses", "(", "self", ",", "session_id", ",", "timestamp", "=", "None", ",", "request_limit", "=", "None", ",", "response_limit", "=", "None", ")", ":", "subject", "=", "session_id", ".", "Add", "(", "\"state\"", ")", "requests", "=...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.ReadCompletedRequests
Fetches all the requests with a status message queued for them.
grr/server/grr_response_server/data_store.py
def ReadCompletedRequests(self, session_id, timestamp=None, limit=None): """Fetches all the requests with a status message queued for them.""" subject = session_id.Add("state") requests = {} status = {} for predicate, serialized, _ in self.ResolvePrefix( subject, [self.FLOW_REQUEST_PREFIX, ...
def ReadCompletedRequests(self, session_id, timestamp=None, limit=None): """Fetches all the requests with a status message queued for them.""" subject = session_id.Add("state") requests = {} status = {} for predicate, serialized, _ in self.ResolvePrefix( subject, [self.FLOW_REQUEST_PREFIX, ...
[ "Fetches", "all", "the", "requests", "with", "a", "status", "message", "queued", "for", "them", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L998-L1019
[ "def", "ReadCompletedRequests", "(", "self", ",", "session_id", ",", "timestamp", "=", "None", ",", "limit", "=", "None", ")", ":", "subject", "=", "session_id", ".", "Add", "(", "\"state\"", ")", "requests", "=", "{", "}", "status", "=", "{", "}", "fo...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.ReadResponsesForRequestId
Reads responses for one request. Args: session_id: The session id to use. request_id: The id of the request. timestamp: A timestamp as used in the data store. Yields: fetched responses for the request
grr/server/grr_response_server/data_store.py
def ReadResponsesForRequestId(self, session_id, request_id, timestamp=None): """Reads responses for one request. Args: session_id: The session id to use. request_id: The id of the request. timestamp: A timestamp as used in the data store. Yields: fetched responses for the request ...
def ReadResponsesForRequestId(self, session_id, request_id, timestamp=None): """Reads responses for one request. Args: session_id: The session id to use. request_id: The id of the request. timestamp: A timestamp as used in the data store. Yields: fetched responses for the request ...
[ "Reads", "responses", "for", "one", "request", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1021-L1034
[ "def", "ReadResponsesForRequestId", "(", "self", ",", "session_id", ",", "request_id", ",", "timestamp", "=", "None", ")", ":", "request", "=", "rdf_flow_runner", ".", "RequestState", "(", "id", "=", "request_id", ",", "session_id", "=", "session_id", ")", "fo...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.ReadResponses
Reads responses for multiple requests at the same time. Args: request_list: The list of requests the responses should be fetched for. timestamp: A timestamp as used in the data store. Yields: tuples (request, lists of fetched responses for the request)
grr/server/grr_response_server/data_store.py
def ReadResponses(self, request_list, timestamp=None): """Reads responses for multiple requests at the same time. Args: request_list: The list of requests the responses should be fetched for. timestamp: A timestamp as used in the data store. Yields: tuples (request, lists of fetched resp...
def ReadResponses(self, request_list, timestamp=None): """Reads responses for multiple requests at the same time. Args: request_list: The list of requests the responses should be fetched for. timestamp: A timestamp as used in the data store. Yields: tuples (request, lists of fetched resp...
[ "Reads", "responses", "for", "multiple", "requests", "at", "the", "same", "time", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1036-L1064
[ "def", "ReadResponses", "(", "self", ",", "request_list", ",", "timestamp", "=", "None", ")", ":", "response_subjects", "=", "{", "}", "for", "request", "in", "request_list", ":", "response_subject", "=", "self", ".", "GetFlowResponseSubject", "(", "request", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.StoreRequestsAndResponses
Stores new flow requests and responses to the data store. Args: new_requests: A list of tuples (request, timestamp) to store in the data store. new_responses: A list of tuples (response, timestamp) to store in the data store. requests_to_delete: A list of requests that should be d...
grr/server/grr_response_server/data_store.py
def StoreRequestsAndResponses(self, new_requests=None, new_responses=None, requests_to_delete=None): """Stores new flow requests and responses to the data store. Args: new_requests: A list of tuples (request, ...
def StoreRequestsAndResponses(self, new_requests=None, new_responses=None, requests_to_delete=None): """Stores new flow requests and responses to the data store. Args: new_requests: A list of tuples (request, ...
[ "Stores", "new", "flow", "requests", "and", "responses", "to", "the", "data", "store", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1066-L1118
[ "def", "StoreRequestsAndResponses", "(", "self", ",", "new_requests", "=", "None", ",", "new_responses", "=", "None", ",", "requests_to_delete", "=", "None", ")", ":", "to_write", "=", "{", "}", "if", "new_requests", "is", "not", "None", ":", "for", "request...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.CheckRequestsForCompletion
Checks if there is a status message queued for a number of requests.
grr/server/grr_response_server/data_store.py
def CheckRequestsForCompletion(self, requests): """Checks if there is a status message queued for a number of requests.""" subjects = [r.session_id.Add("state") for r in requests] statuses_found = {} for subject, result in self.MultiResolvePrefix(subjects, ...
def CheckRequestsForCompletion(self, requests): """Checks if there is a status message queued for a number of requests.""" subjects = [r.session_id.Add("state") for r in requests] statuses_found = {} for subject, result in self.MultiResolvePrefix(subjects, ...
[ "Checks", "if", "there", "is", "a", "status", "message", "queued", "for", "a", "number", "of", "requests", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1120-L1138
[ "def", "CheckRequestsForCompletion", "(", "self", ",", "requests", ")", ":", "subjects", "=", "[", "r", ".", "session_id", ".", "Add", "(", "\"state\"", ")", "for", "r", "in", "requests", "]", "statuses_found", "=", "{", "}", "for", "subject", ",", "resu...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.MultiDestroyFlowStates
Deletes all requests and responses for the given flows. Args: session_ids: A lists of flows to destroy. request_limit: A limit on the number of requests to delete. Returns: A list of requests that were deleted.
grr/server/grr_response_server/data_store.py
def MultiDestroyFlowStates(self, session_ids, request_limit=None): """Deletes all requests and responses for the given flows. Args: session_ids: A lists of flows to destroy. request_limit: A limit on the number of requests to delete. Returns: A list of requests that were deleted. """...
def MultiDestroyFlowStates(self, session_ids, request_limit=None): """Deletes all requests and responses for the given flows. Args: session_ids: A lists of flows to destroy. request_limit: A limit on the number of requests to delete. Returns: A list of requests that were deleted. """...
[ "Deletes", "all", "requests", "and", "responses", "for", "the", "given", "flows", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1155-L1187
[ "def", "MultiDestroyFlowStates", "(", "self", ",", "session_ids", ",", "request_limit", "=", "None", ")", ":", "subjects", "=", "[", "session_id", ".", "Add", "(", "\"state\"", ")", "for", "session_id", "in", "session_ids", "]", "to_delete", "=", "[", "]", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.IndexReadPostingLists
Finds all objects associated with any of the keywords. Args: index_urn: The base urn of the index. keywords: A collection of keywords that we are interested in. start_time: Only considers keywords added at or after this point in time. end_time: Only considers keywords at or before this poin...
grr/server/grr_response_server/data_store.py
def IndexReadPostingLists(self, index_urn, keywords, start_time, end_time, last_seen_map=None): """Finds all objects associated with any of the keywords. Args: index...
def IndexReadPostingLists(self, index_urn, keywords, start_time, end_time, last_seen_map=None): """Finds all objects associated with any of the keywords. Args: index...
[ "Finds", "all", "objects", "associated", "with", "any", "of", "the", "keywords", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1238-L1273
[ "def", "IndexReadPostingLists", "(", "self", ",", "index_urn", ",", "keywords", ",", "start_time", ",", "end_time", ",", "last_seen_map", "=", "None", ")", ":", "keyword_urns", "=", "{", "self", ".", "_KeywordToURN", "(", "index_urn", ",", "k", ")", ":", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.CollectionReadIndex
Reads all index entries for the given collection. Args: collection_id: ID of the collection for which the indexes should be retrieved. Yields: Tuples (index, ts, suffix).
grr/server/grr_response_server/data_store.py
def CollectionReadIndex(self, collection_id): """Reads all index entries for the given collection. Args: collection_id: ID of the collection for which the indexes should be retrieved. Yields: Tuples (index, ts, suffix). """ for (attr, value, ts) in self.ResolvePrefix(c...
def CollectionReadIndex(self, collection_id): """Reads all index entries for the given collection. Args: collection_id: ID of the collection for which the indexes should be retrieved. Yields: Tuples (index, ts, suffix). """ for (attr, value, ts) in self.ResolvePrefix(c...
[ "Reads", "all", "index", "entries", "for", "the", "given", "collection", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1338-L1352
[ "def", "CollectionReadIndex", "(", "self", ",", "collection_id", ")", ":", "for", "(", "attr", ",", "value", ",", "ts", ")", "in", "self", ".", "ResolvePrefix", "(", "collection_id", ",", "self", ".", "COLLECTION_INDEX_ATTRIBUTE_PREFIX", ")", ":", "i", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.QueueQueryTasks
Retrieves tasks from a queue without leasing them. This is good for a read only snapshot of the tasks. Args: queue: The task queue that this task belongs to, usually client.Queue() where client is the ClientURN object you want to schedule msgs on. limit: Number of values to fetch. Ret...
grr/server/grr_response_server/data_store.py
def QueueQueryTasks(self, queue, limit=1): """Retrieves tasks from a queue without leasing them. This is good for a read only snapshot of the tasks. Args: queue: The task queue that this task belongs to, usually client.Queue() where client is the ClientURN object you want to schedule msgs on...
def QueueQueryTasks(self, queue, limit=1): """Retrieves tasks from a queue without leasing them. This is good for a read only snapshot of the tasks. Args: queue: The task queue that this task belongs to, usually client.Queue() where client is the ClientURN object you want to schedule msgs on...
[ "Retrieves", "tasks", "from", "a", "queue", "without", "leasing", "them", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1368-L1390
[ "def", "QueueQueryTasks", "(", "self", ",", "queue", ",", "limit", "=", "1", ")", ":", "prefix", "=", "DataStore", ".", "QUEUE_TASK_PREDICATE_PREFIX", "all_tasks", "=", "[", "]", "for", "_", ",", "serialized", ",", "ts", "in", "self", ".", "ResolvePrefix",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStore.FileHashIndexQuery
Search the index for matches starting with target_prefix. Args: subject: The index to use. Should be a urn that points to the sha256 namespace. target_prefix: The prefix to match against the index. limit: Either a tuple of (start, limit) or a maximum number of results to retu...
grr/server/grr_response_server/data_store.py
def FileHashIndexQuery(self, subject, target_prefix, limit=100): """Search the index for matches starting with target_prefix. Args: subject: The index to use. Should be a urn that points to the sha256 namespace. target_prefix: The prefix to match against the index. limit: Either a...
def FileHashIndexQuery(self, subject, target_prefix, limit=100): """Search the index for matches starting with target_prefix. Args: subject: The index to use. Should be a urn that points to the sha256 namespace. target_prefix: The prefix to match against the index. limit: Either a...
[ "Search", "the", "index", "for", "matches", "starting", "with", "target_prefix", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1399-L1427
[ "def", "FileHashIndexQuery", "(", "self", ",", "subject", ",", "target_prefix", ",", "limit", "=", "100", ")", ":", "if", "isinstance", "(", "limit", ",", "(", "tuple", ",", "list", ")", ")", ":", "start", ",", "length", "=", "limit", "# pylint: disable=...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DataStoreInit.Run
Initialize the data_store.
grr/server/grr_response_server/data_store.py
def Run(self): """Initialize the data_store.""" global DB # pylint: disable=global-statement global REL_DB # pylint: disable=global-statement global BLOBS # pylint: disable=global-statement if flags.FLAGS.list_storage: self._ListStorageOptions() sys.exit(0) try: cls = Data...
def Run(self): """Initialize the data_store.""" global DB # pylint: disable=global-statement global REL_DB # pylint: disable=global-statement global BLOBS # pylint: disable=global-statement if flags.FLAGS.list_storage: self._ListStorageOptions() sys.exit(0) try: cls = Data...
[ "Initialize", "the", "data_store", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1545-L1592
[ "def", "Run", "(", "self", ")", ":", "global", "DB", "# pylint: disable=global-statement", "global", "REL_DB", "# pylint: disable=global-statement", "global", "BLOBS", "# pylint: disable=global-statement", "if", "flags", ".", "FLAGS", ".", "list_storage", ":", "self", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DownloadFile
Download an aff4 file to the local filesystem overwriting it if it exists. Args: file_obj: An aff4 object that supports the file interface (Read, Seek) target_path: Full path of file to write to. buffer_size: Read in chunks this size.
grr/server/grr_response_server/export_utils.py
def DownloadFile(file_obj, target_path, buffer_size=BUFFER_SIZE): """Download an aff4 file to the local filesystem overwriting it if it exists. Args: file_obj: An aff4 object that supports the file interface (Read, Seek) target_path: Full path of file to write to. buffer_size: Read in chunks this size....
def DownloadFile(file_obj, target_path, buffer_size=BUFFER_SIZE): """Download an aff4 file to the local filesystem overwriting it if it exists. Args: file_obj: An aff4 object that supports the file interface (Read, Seek) target_path: Full path of file to write to. buffer_size: Read in chunks this size....
[ "Download", "an", "aff4", "file", "to", "the", "local", "filesystem", "overwriting", "it", "if", "it", "exists", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L135-L157
[ "def", "DownloadFile", "(", "file_obj", ",", "target_path", ",", "buffer_size", "=", "BUFFER_SIZE", ")", ":", "logging", ".", "info", "(", "u\"Downloading: %s to: %s\"", ",", "file_obj", ".", "urn", ",", "target_path", ")", "target_file", "=", "open", "(", "ta...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RecursiveDownload
Recursively downloads a file entry to the target path. Args: dir_obj: An aff4 object that contains children. target_dir: Full path of the directory to write to. max_depth: Depth to download to. 1 means just the directory itself. depth: Current depth of recursion. overwrite: Should we overwrite fi...
grr/server/grr_response_server/export_utils.py
def RecursiveDownload(dir_obj, target_dir, max_depth=10, depth=1, overwrite=False, max_threads=10): """Recursively downloads a file entry to the target path. Args: dir_obj: An aff4 object that contains...
def RecursiveDownload(dir_obj, target_dir, max_depth=10, depth=1, overwrite=False, max_threads=10): """Recursively downloads a file entry to the target path. Args: dir_obj: An aff4 object that contains...
[ "Recursively", "downloads", "a", "file", "entry", "to", "the", "target", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L160-L212
[ "def", "RecursiveDownload", "(", "dir_obj", ",", "target_dir", ",", "max_depth", "=", "10", ",", "depth", "=", "1", ",", "overwrite", "=", "False", ",", "max_threads", "=", "10", ")", ":", "if", "not", "isinstance", "(", "dir_obj", ",", "aff4", ".", "A...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_OpenCollectionPath
Tries to open various types of collections at the given path.
grr/server/grr_response_server/export_utils.py
def _OpenCollectionPath(coll_path): """Tries to open various types of collections at the given path.""" hunt_collection = results.HuntResultCollection(coll_path) if hunt_collection and hunt_collection[0].payload: return hunt_collection indexed_collection = sequential_collection.GeneralIndexedCollection(col...
def _OpenCollectionPath(coll_path): """Tries to open various types of collections at the given path.""" hunt_collection = results.HuntResultCollection(coll_path) if hunt_collection and hunt_collection[0].payload: return hunt_collection indexed_collection = sequential_collection.GeneralIndexedCollection(col...
[ "Tries", "to", "open", "various", "types", "of", "collections", "at", "the", "given", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L215-L223
[ "def", "_OpenCollectionPath", "(", "coll_path", ")", ":", "hunt_collection", "=", "results", ".", "HuntResultCollection", "(", "coll_path", ")", "if", "hunt_collection", "and", "hunt_collection", "[", "0", "]", ".", "payload", ":", "return", "hunt_collection", "in...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DownloadCollection
Iterate through a Collection object downloading all files. Args: coll_path: Path to an AFF4 collection. target_path: Base directory to write to. token: Token for access. overwrite: If True, overwrite existing files. dump_client_info: If True, this will detect client paths, and dump a yaml v...
grr/server/grr_response_server/export_utils.py
def DownloadCollection(coll_path, target_path, token=None, overwrite=False, dump_client_info=False, flatten=False, max_threads=10): """Iterate through a Collection object downloadi...
def DownloadCollection(coll_path, target_path, token=None, overwrite=False, dump_client_info=False, flatten=False, max_threads=10): """Iterate through a Collection object downloadi...
[ "Iterate", "through", "a", "Collection", "object", "downloading", "all", "files", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L226-L332
[ "def", "DownloadCollection", "(", "coll_path", ",", "target_path", ",", "token", "=", "None", ",", "overwrite", "=", "False", ",", "dump_client_info", "=", "False", ",", "flatten", "=", "False", ",", "max_threads", "=", "10", ")", ":", "completed_clients", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CopyAFF4ToLocal
Copy an AFF4 object that supports a read interface to local filesystem. Args: aff4_urn: URN of thing to copy. target_dir: Directory to copy the file to. token: Auth token. overwrite: If True overwrite the file if it exists. Returns: If aff4_urn points to a file, returns path to the downloaded ...
grr/server/grr_response_server/export_utils.py
def CopyAFF4ToLocal(aff4_urn, target_dir, token=None, overwrite=False): """Copy an AFF4 object that supports a read interface to local filesystem. Args: aff4_urn: URN of thing to copy. target_dir: Directory to copy the file to. token: Auth token. overwrite: If True overwrite the file if it exists. ...
def CopyAFF4ToLocal(aff4_urn, target_dir, token=None, overwrite=False): """Copy an AFF4 object that supports a read interface to local filesystem. Args: aff4_urn: URN of thing to copy. target_dir: Directory to copy the file to. token: Auth token. overwrite: If True overwrite the file if it exists. ...
[ "Copy", "an", "AFF4", "object", "that", "supports", "a", "read", "interface", "to", "local", "filesystem", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L335-L385
[ "def", "CopyAFF4ToLocal", "(", "aff4_urn", ",", "target_dir", ",", "token", "=", "None", ",", "overwrite", "=", "False", ")", ":", "try", ":", "fd", "=", "aff4", ".", "FACTORY", ".", "Open", "(", "aff4_urn", ",", "token", "=", "token", ")", "filepath",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DumpClientYaml
Dump a yaml file containing client info.
grr/server/grr_response_server/export_utils.py
def DumpClientYaml(client_urn, target_dir, token=None, overwrite=False): """Dump a yaml file containing client info.""" fd = aff4.FACTORY.Open(client_urn, aff4_grr.VFSGRRClient, token=token) dirpath = os.path.join(target_dir, fd.urn.Split()[0]) try: # Due to threading this can actually be created by another...
def DumpClientYaml(client_urn, target_dir, token=None, overwrite=False): """Dump a yaml file containing client info.""" fd = aff4.FACTORY.Open(client_urn, aff4_grr.VFSGRRClient, token=token) dirpath = os.path.join(target_dir, fd.urn.Split()[0]) try: # Due to threading this can actually be created by another...
[ "Dump", "a", "yaml", "file", "containing", "client", "info", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L407-L419
[ "def", "DumpClientYaml", "(", "client_urn", ",", "target_dir", ",", "token", "=", "None", ",", "overwrite", "=", "False", ")", ":", "fd", "=", "aff4", ".", "FACTORY", ".", "Open", "(", "client_urn", ",", "aff4_grr", ".", "VFSGRRClient", ",", "token", "="...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
IterateAllClientUrns.GetInput
Yield client urns.
grr/server/grr_response_server/export_utils.py
def GetInput(self): """Yield client urns.""" clients = GetAllClients(token=self.token) logging.debug("Got %d clients", len(clients)) return clients
def GetInput(self): """Yield client urns.""" clients = GetAllClients(token=self.token) logging.debug("Got %d clients", len(clients)) return clients
[ "Yield", "client", "urns", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L68-L72
[ "def", "GetInput", "(", "self", ")", ":", "clients", "=", "GetAllClients", "(", "token", "=", "self", ".", "token", ")", "logging", ".", "debug", "(", "\"Got %d clients\"", ",", "len", "(", "clients", ")", ")", "return", "clients" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
IterateAllClientUrns.Run
Run the iteration.
grr/server/grr_response_server/export_utils.py
def Run(self): """Run the iteration.""" count = 0 for count, input_data in enumerate(self.GetInput()): if count % 2000 == 0: logging.debug("%d processed.", count) args = (input_data, self.out_queue, self.token) self.thread_pool.AddTask( target=self.IterFunction, args=args...
def Run(self): """Run the iteration.""" count = 0 for count, input_data in enumerate(self.GetInput()): if count % 2000 == 0: logging.debug("%d processed.", count) args = (input_data, self.out_queue, self.token) self.thread_pool.AddTask( target=self.IterFunction, args=args...
[ "Run", "the", "iteration", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L74-L96
[ "def", "Run", "(", "self", ")", ":", "count", "=", "0", "for", "count", ",", "input_data", "in", "enumerate", "(", "self", ".", "GetInput", "(", ")", ")", ":", "if", "count", "%", "2000", "==", "0", ":", "logging", ".", "debug", "(", "\"%d processe...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
IterateAllClients.GetInput
Yield client urns.
grr/server/grr_response_server/export_utils.py
def GetInput(self): """Yield client urns.""" client_list = GetAllClients(token=self.token) logging.debug("Got %d clients", len(client_list)) for client_group in collection.Batch(client_list, self.client_chunksize): for fd in aff4.FACTORY.MultiOpen( client_group, mode="r", ...
def GetInput(self): """Yield client urns.""" client_list = GetAllClients(token=self.token) logging.debug("Got %d clients", len(client_list)) for client_group in collection.Batch(client_list, self.client_chunksize): for fd in aff4.FACTORY.MultiOpen( client_group, mode="r", ...
[ "Yield", "client", "urns", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L118-L132
[ "def", "GetInput", "(", "self", ")", ":", "client_list", "=", "GetAllClients", "(", "token", "=", "self", ".", "token", ")", "logging", ".", "debug", "(", "\"Got %d clients\"", ",", "len", "(", "client_list", ")", ")", "for", "client_group", "in", "collect...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InterpolateKbAttributes
Interpolate all knowledgebase attributes in pattern. Args: pattern: A string with potential interpolation markers. For example: "/home/%%users.username%%/Downloads/" knowledge_base: The knowledge_base to interpolate parameters from. ignore_errors: Set this to true to log errors instead of raising. ...
grr/core/grr_response_core/lib/artifact_utils.py
def InterpolateKbAttributes(pattern, knowledge_base, ignore_errors=False): """Interpolate all knowledgebase attributes in pattern. Args: pattern: A string with potential interpolation markers. For example: "/home/%%users.username%%/Downloads/" knowledge_base: The knowledge_base to interpolate paramet...
def InterpolateKbAttributes(pattern, knowledge_base, ignore_errors=False): """Interpolate all knowledgebase attributes in pattern. Args: pattern: A string with potential interpolation markers. For example: "/home/%%users.username%%/Downloads/" knowledge_base: The knowledge_base to interpolate paramet...
[ "Interpolate", "all", "knowledgebase", "attributes", "in", "pattern", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/artifact_utils.py#L57-L128
[ "def", "InterpolateKbAttributes", "(", "pattern", ",", "knowledge_base", ",", "ignore_errors", "=", "False", ")", ":", "# TODO(hanuszczak): Control flow feels a bit awkward here because of error", "# handling that tries not to break any functionality. With the new utilities", "# it shoul...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetWindowsEnvironmentVariablesMap
Return a dictionary of environment variables and their values. Implementation maps variables mentioned in https://en.wikipedia.org/wiki/Environment_variable#Windows to known KB definitions. Args: knowledge_base: A knowledgebase object. Returns: A dictionary built from a given knowledgebase object w...
grr/core/grr_response_core/lib/artifact_utils.py
def GetWindowsEnvironmentVariablesMap(knowledge_base): """Return a dictionary of environment variables and their values. Implementation maps variables mentioned in https://en.wikipedia.org/wiki/Environment_variable#Windows to known KB definitions. Args: knowledge_base: A knowledgebase object. Returns...
def GetWindowsEnvironmentVariablesMap(knowledge_base): """Return a dictionary of environment variables and their values. Implementation maps variables mentioned in https://en.wikipedia.org/wiki/Environment_variable#Windows to known KB definitions. Args: knowledge_base: A knowledgebase object. Returns...
[ "Return", "a", "dictionary", "of", "environment", "variables", "and", "their", "values", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/artifact_utils.py#L131-L190
[ "def", "GetWindowsEnvironmentVariablesMap", "(", "knowledge_base", ")", ":", "environ_vars", "=", "{", "}", "if", "knowledge_base", ".", "environ_path", ":", "environ_vars", "[", "\"path\"", "]", "=", "knowledge_base", ".", "environ_path", "if", "knowledge_base", "....
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ExpandWindowsEnvironmentVariables
r"""Take a string and expand any windows environment variables. Args: data_string: A string, e.g. "%SystemRoot%\\LogFiles" knowledge_base: A knowledgebase object. Returns: A string with available environment variables expanded. If we can't expand we just return the string with the original variabl...
grr/core/grr_response_core/lib/artifact_utils.py
def ExpandWindowsEnvironmentVariables(data_string, knowledge_base): r"""Take a string and expand any windows environment variables. Args: data_string: A string, e.g. "%SystemRoot%\\LogFiles" knowledge_base: A knowledgebase object. Returns: A string with available environment variables expanded. If w...
def ExpandWindowsEnvironmentVariables(data_string, knowledge_base): r"""Take a string and expand any windows environment variables. Args: data_string: A string, e.g. "%SystemRoot%\\LogFiles" knowledge_base: A knowledgebase object. Returns: A string with available environment variables expanded. If w...
[ "r", "Take", "a", "string", "and", "expand", "any", "windows", "environment", "variables", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/artifact_utils.py#L193-L220
[ "def", "ExpandWindowsEnvironmentVariables", "(", "data_string", ",", "knowledge_base", ")", ":", "win_environ_regex", "=", "re", ".", "compile", "(", "r\"%([^%]+?)%\"", ")", "components", "=", "[", "]", "offset", "=", "0", "for", "match", "in", "win_environ_regex"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CheckCondition
Check if a condition matches an object. Args: condition: A string condition e.g. "os == 'Windows'" check_object: Object to validate, e.g. an rdf_client.KnowledgeBase() Returns: True or False depending on whether the condition matches. Raises: ConditionError: If condition is bad.
grr/core/grr_response_core/lib/artifact_utils.py
def CheckCondition(condition, check_object): """Check if a condition matches an object. Args: condition: A string condition e.g. "os == 'Windows'" check_object: Object to validate, e.g. an rdf_client.KnowledgeBase() Returns: True or False depending on whether the condition matches. Raises: Co...
def CheckCondition(condition, check_object): """Check if a condition matches an object. Args: condition: A string condition e.g. "os == 'Windows'" check_object: Object to validate, e.g. an rdf_client.KnowledgeBase() Returns: True or False depending on whether the condition matches. Raises: Co...
[ "Check", "if", "a", "condition", "matches", "an", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/artifact_utils.py#L223-L241
[ "def", "CheckCondition", "(", "condition", ",", "check_object", ")", ":", "try", ":", "of", "=", "objectfilter", ".", "Parser", "(", "condition", ")", ".", "Parse", "(", ")", "compiled_filter", "=", "of", ".", "Compile", "(", "objectfilter", ".", "BaseFilt...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ExpandWindowsUserEnvironmentVariables
r"""Take a string and expand windows user environment variables based. Args: data_string: A string, e.g. "%TEMP%\\LogFiles" knowledge_base: A knowledgebase object. sid: A Windows SID for a user to expand for. username: A Windows user name to expand for. Returns: A string with available environ...
grr/core/grr_response_core/lib/artifact_utils.py
def ExpandWindowsUserEnvironmentVariables(data_string, knowledge_base, sid=None, username=None): r"""Take a string and expand windows user environment variables based. Args: data_string...
def ExpandWindowsUserEnvironmentVariables(data_string, knowledge_base, sid=None, username=None): r"""Take a string and expand windows user environment variables based. Args: data_string...
[ "r", "Take", "a", "string", "and", "expand", "windows", "user", "environment", "variables", "based", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/artifact_utils.py#L244-L275
[ "def", "ExpandWindowsUserEnvironmentVariables", "(", "data_string", ",", "knowledge_base", ",", "sid", "=", "None", ",", "username", "=", "None", ")", ":", "win_environ_regex", "=", "re", ".", "compile", "(", "r\"%([^%]+?)%\"", ")", "components", "=", "[", "]", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetExtAttrs
Fetches extended file attributes. Args: filepath: A path to the file. Yields: `ExtAttr` pairs.
grr/client/grr_response_client/client_utils_osx_linux.py
def GetExtAttrs(filepath): """Fetches extended file attributes. Args: filepath: A path to the file. Yields: `ExtAttr` pairs. """ path = CanonicalPathToLocalPath(filepath) try: attr_names = xattr.listxattr(path) except (IOError, OSError, UnicodeDecodeError) as error: msg = "Failed to ret...
def GetExtAttrs(filepath): """Fetches extended file attributes. Args: filepath: A path to the file. Yields: `ExtAttr` pairs. """ path = CanonicalPathToLocalPath(filepath) try: attr_names = xattr.listxattr(path) except (IOError, OSError, UnicodeDecodeError) as error: msg = "Failed to ret...
[ "Fetches", "extended", "file", "attributes", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx_linux.py#L58-L97
[ "def", "GetExtAttrs", "(", "filepath", ")", ":", "path", "=", "CanonicalPathToLocalPath", "(", "filepath", ")", "try", ":", "attr_names", "=", "xattr", ".", "listxattr", "(", "path", ")", "except", "(", "IOError", ",", "OSError", ",", "UnicodeDecodeError", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
NannyThread.Sleep
Sleep a given time in 1 second intervals. When a machine is suspended during a time.sleep(n) call for more than n seconds, sometimes the sleep is interrupted and all threads wake up at the same time. This leads to race conditions between the threads issuing the heartbeat and the one checking for it. By...
grr/client/grr_response_client/client_utils_osx_linux.py
def Sleep(self, seconds): """Sleep a given time in 1 second intervals. When a machine is suspended during a time.sleep(n) call for more than n seconds, sometimes the sleep is interrupted and all threads wake up at the same time. This leads to race conditions between the threads issuing the heartbea...
def Sleep(self, seconds): """Sleep a given time in 1 second intervals. When a machine is suspended during a time.sleep(n) call for more than n seconds, sometimes the sleep is interrupted and all threads wake up at the same time. This leads to race conditions between the threads issuing the heartbea...
[ "Sleep", "a", "given", "time", "in", "1", "second", "intervals", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx_linux.py#L137-L160
[ "def", "Sleep", "(", "self", ",", "seconds", ")", ":", "time", ".", "sleep", "(", "seconds", "-", "int", "(", "seconds", ")", ")", "for", "_", "in", "range", "(", "int", "(", "seconds", ")", ")", ":", "time", ".", "sleep", "(", "1", ")", "# Che...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TransactionLog.Write
Write the message into the transaction log.
grr/client/grr_response_client/client_utils_osx_linux.py
def Write(self, grr_message): """Write the message into the transaction log.""" grr_message = grr_message.SerializeToString() try: with io.open(self.logfile, "wb") as fd: fd.write(grr_message) except (IOError, OSError): # Check if we're missing directories and try to create them. ...
def Write(self, grr_message): """Write the message into the transaction log.""" grr_message = grr_message.SerializeToString() try: with io.open(self.logfile, "wb") as fd: fd.write(grr_message) except (IOError, OSError): # Check if we're missing directories and try to create them. ...
[ "Write", "the", "message", "into", "the", "transaction", "log", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx_linux.py#L233-L249
[ "def", "Write", "(", "self", ",", "grr_message", ")", ":", "grr_message", "=", "grr_message", ".", "SerializeToString", "(", ")", "try", ":", "with", "io", ".", "open", "(", "self", ".", "logfile", ",", "\"wb\"", ")", "as", "fd", ":", "fd", ".", "wri...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TransactionLog.Clear
Wipes the transaction log.
grr/client/grr_response_client/client_utils_osx_linux.py
def Clear(self): """Wipes the transaction log.""" try: with io.open(self.logfile, "wb") as fd: fd.write(b"") except (IOError, OSError): pass
def Clear(self): """Wipes the transaction log.""" try: with io.open(self.logfile, "wb") as fd: fd.write(b"") except (IOError, OSError): pass
[ "Wipes", "the", "transaction", "log", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx_linux.py#L255-L261
[ "def", "Clear", "(", "self", ")", ":", "try", ":", "with", "io", ".", "open", "(", "self", ".", "logfile", ",", "\"wb\"", ")", "as", "fd", ":", "fd", ".", "write", "(", "b\"\"", ")", "except", "(", "IOError", ",", "OSError", ")", ":", "pass" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TransactionLog.Get
Return a GrrMessage instance from the transaction log or None.
grr/client/grr_response_client/client_utils_osx_linux.py
def Get(self): """Return a GrrMessage instance from the transaction log or None.""" try: with io.open(self.logfile, "rb") as fd: data = fd.read(self.max_log_size) except (IOError, OSError): return try: if data: return rdf_flows.GrrMessage.FromSerializedString(data) ...
def Get(self): """Return a GrrMessage instance from the transaction log or None.""" try: with io.open(self.logfile, "rb") as fd: data = fd.read(self.max_log_size) except (IOError, OSError): return try: if data: return rdf_flows.GrrMessage.FromSerializedString(data) ...
[ "Return", "a", "GrrMessage", "instance", "from", "the", "transaction", "log", "or", "None", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx_linux.py#L263-L275
[ "def", "Get", "(", "self", ")", ":", "try", ":", "with", "io", ".", "open", "(", "self", ".", "logfile", ",", "\"rb\"", ")", "as", "fd", ":", "data", "=", "fd", ".", "read", "(", "self", ".", "max_log_size", ")", "except", "(", "IOError", ",", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FilterFnTable
Remove a specific symbol from a fn_table.
grr/client/grr_response_client/osx/objc.py
def FilterFnTable(fn_table, symbol): """Remove a specific symbol from a fn_table.""" new_table = list() for entry in fn_table: # symbol[0] is a str with the symbol name if entry[0] != symbol: new_table.append(entry) return new_table
def FilterFnTable(fn_table, symbol): """Remove a specific symbol from a fn_table.""" new_table = list() for entry in fn_table: # symbol[0] is a str with the symbol name if entry[0] != symbol: new_table.append(entry) return new_table
[ "Remove", "a", "specific", "symbol", "from", "a", "fn_table", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/objc.py#L51-L58
[ "def", "FilterFnTable", "(", "fn_table", ",", "symbol", ")", ":", "new_table", "=", "list", "(", ")", "for", "entry", "in", "fn_table", ":", "# symbol[0] is a str with the symbol name", "if", "entry", "[", "0", "]", "!=", "symbol", ":", "new_table", ".", "ap...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SetCTypesForLibrary
Set function argument types and return types for an ObjC library. Args: libname: Library name string fn_table: List of (function, [arg types], return types) tuples Returns: ctypes.CDLL with types set according to fn_table Raises: ErrorLibNotFound: Can't find specified lib
grr/client/grr_response_client/osx/objc.py
def SetCTypesForLibrary(libname, fn_table): """Set function argument types and return types for an ObjC library. Args: libname: Library name string fn_table: List of (function, [arg types], return types) tuples Returns: ctypes.CDLL with types set according to fn_table Raises: ErrorLibNotFound: ...
def SetCTypesForLibrary(libname, fn_table): """Set function argument types and return types for an ObjC library. Args: libname: Library name string fn_table: List of (function, [arg types], return types) tuples Returns: ctypes.CDLL with types set according to fn_table Raises: ErrorLibNotFound: ...
[ "Set", "function", "argument", "types", "and", "return", "types", "for", "an", "ObjC", "library", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/objc.py#L61-L84
[ "def", "SetCTypesForLibrary", "(", "libname", ",", "fn_table", ")", ":", "libpath", "=", "ctypes", ".", "util", ".", "find_library", "(", "libname", ")", "if", "not", "libpath", ":", "raise", "ErrorLibNotFound", "(", "'Library %s not found'", "%", "libname", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Foundation.WrapCFTypeInPython
Package a CoreFoundation object in a Python wrapper. Args: obj: The CoreFoundation object. Returns: One of CFBoolean, CFNumber, CFString, CFDictionary, CFArray. Raises: TypeError: If the type is not supported.
grr/client/grr_response_client/osx/objc.py
def WrapCFTypeInPython(self, obj): """Package a CoreFoundation object in a Python wrapper. Args: obj: The CoreFoundation object. Returns: One of CFBoolean, CFNumber, CFString, CFDictionary, CFArray. Raises: TypeError: If the type is not supported. """ obj_type = self.dll.CFGet...
def WrapCFTypeInPython(self, obj): """Package a CoreFoundation object in a Python wrapper. Args: obj: The CoreFoundation object. Returns: One of CFBoolean, CFNumber, CFString, CFDictionary, CFArray. Raises: TypeError: If the type is not supported. """ obj_type = self.dll.CFGet...
[ "Package", "a", "CoreFoundation", "object", "in", "a", "Python", "wrapper", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/objc.py#L170-L192
[ "def", "WrapCFTypeInPython", "(", "self", ",", "obj", ")", ":", "obj_type", "=", "self", ".", "dll", ".", "CFGetTypeID", "(", "obj", ")", "if", "obj_type", "==", "self", ".", "dll", ".", "CFBooleanGetTypeID", "(", ")", ":", "return", "CFBoolean", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ServiceManagement.SMGetJobDictionaries
Copy all Job Dictionaries from the ServiceManagement. Args: domain: The name of a constant in Foundation referencing the domain. Will copy all launchd services by default. Returns: A marshalled python list of dicts containing the job dictionaries.
grr/client/grr_response_client/osx/objc.py
def SMGetJobDictionaries(self, domain='kSMDomainSystemLaunchd'): """Copy all Job Dictionaries from the ServiceManagement. Args: domain: The name of a constant in Foundation referencing the domain. Will copy all launchd services by default. Returns: A marshalled python list of dic...
def SMGetJobDictionaries(self, domain='kSMDomainSystemLaunchd'): """Copy all Job Dictionaries from the ServiceManagement. Args: domain: The name of a constant in Foundation referencing the domain. Will copy all launchd services by default. Returns: A marshalled python list of dic...
[ "Copy", "all", "Job", "Dictionaries", "from", "the", "ServiceManagement", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/objc.py#L225-L236
[ "def", "SMGetJobDictionaries", "(", "self", ",", "domain", "=", "'kSMDomainSystemLaunchd'", ")", ":", "cfstring_launchd", "=", "ctypes", ".", "c_void_p", ".", "in_dll", "(", "self", ".", "dll", ",", "domain", ")", "return", "CFArray", "(", "self", ".", "dll"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CFDictionary.get
Returns dictionary values or default. Args: key: string. Dictionary key to look up. default: string. Return this value if key not found. stringify: bool. Force all return values to string for compatibility reasons. Returns: python-wrapped CF object or default if not fou...
grr/client/grr_response_client/osx/objc.py
def get(self, key, default='', stringify=True): """Returns dictionary values or default. Args: key: string. Dictionary key to look up. default: string. Return this value if key not found. stringify: bool. Force all return values to string for compatibility reasons. Return...
def get(self, key, default='', stringify=True): """Returns dictionary values or default. Args: key: string. Dictionary key to look up. default: string. Return this value if key not found. stringify: bool. Force all return values to string for compatibility reasons. Return...
[ "Returns", "dictionary", "values", "or", "default", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/objc.py#L404-L420
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "''", ",", "stringify", "=", "True", ")", ":", "obj", "=", "self", ".", "__getitem__", "(", "key", ")", "if", "obj", "is", "None", ":", "obj", "=", "default", "elif", "stringify", ":", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
KextManager.SafeLoadKextManager
Load the kextmanager, replacing unavailable symbols.
grr/client/grr_response_client/osx/objc.py
def SafeLoadKextManager(self, fn_table): """Load the kextmanager, replacing unavailable symbols.""" dll = None try: dll = SetCTypesForLibrary('IOKit', fn_table) except AttributeError as ae: if 'KextManagerUnloadKextWithIdentifier' in str(ae): # Try without this symbol, as it is not a...
def SafeLoadKextManager(self, fn_table): """Load the kextmanager, replacing unavailable symbols.""" dll = None try: dll = SetCTypesForLibrary('IOKit', fn_table) except AttributeError as ae: if 'KextManagerUnloadKextWithIdentifier' in str(ae): # Try without this symbol, as it is not a...
[ "Load", "the", "kextmanager", "replacing", "unavailable", "symbols", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/objc.py#L461-L481
[ "def", "SafeLoadKextManager", "(", "self", ",", "fn_table", ")", ":", "dll", "=", "None", "try", ":", "dll", "=", "SetCTypesForLibrary", "(", "'IOKit'", ",", "fn_table", ")", "except", "AttributeError", "as", "ae", ":", "if", "'KextManagerUnloadKextWithIdentifie...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
KextManager.LegacyKextload
Load a kext by forking into kextload.
grr/client/grr_response_client/osx/objc.py
def LegacyKextload(self, cf_bundle_url, dependency_kext): """Load a kext by forking into kextload.""" _ = dependency_kext error_code = OS_SUCCESS cf_path = self.dll.CFURLCopyFileSystemPath(cf_bundle_url, POSIX_PATH_STYLE) path = self.CFStringToPystring(cf_path) self.dll.CFRelease(cf_path) tr...
def LegacyKextload(self, cf_bundle_url, dependency_kext): """Load a kext by forking into kextload.""" _ = dependency_kext error_code = OS_SUCCESS cf_path = self.dll.CFURLCopyFileSystemPath(cf_bundle_url, POSIX_PATH_STYLE) path = self.CFStringToPystring(cf_path) self.dll.CFRelease(cf_path) tr...
[ "Load", "a", "kext", "by", "forking", "into", "kextload", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/objc.py#L483-L495
[ "def", "LegacyKextload", "(", "self", ",", "cf_bundle_url", ",", "dependency_kext", ")", ":", "_", "=", "dependency_kext", "error_code", "=", "OS_SUCCESS", "cf_path", "=", "self", ".", "dll", ".", "CFURLCopyFileSystemPath", "(", "cf_bundle_url", ",", "POSIX_PATH_S...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
KextManager.LegacyKextunload
Unload a kext by forking into kextunload.
grr/client/grr_response_client/osx/objc.py
def LegacyKextunload(self, cf_bundle_identifier): """Unload a kext by forking into kextunload.""" error_code = OS_SUCCESS bundle_identifier = self.CFStringToPystring(cf_bundle_identifier) try: subprocess.check_call(['/sbin/kextunload', '-b', bundle_identifier]) except subprocess.CalledProcessE...
def LegacyKextunload(self, cf_bundle_identifier): """Unload a kext by forking into kextunload.""" error_code = OS_SUCCESS bundle_identifier = self.CFStringToPystring(cf_bundle_identifier) try: subprocess.check_call(['/sbin/kextunload', '-b', bundle_identifier]) except subprocess.CalledProcessE...
[ "Unload", "a", "kext", "by", "forking", "into", "kextunload", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/objc.py#L497-L506
[ "def", "LegacyKextunload", "(", "self", ",", "cf_bundle_identifier", ")", ":", "error_code", "=", "OS_SUCCESS", "bundle_identifier", "=", "self", ".", "CFStringToPystring", "(", "cf_bundle_identifier", ")", "try", ":", "subprocess", ".", "check_call", "(", "[", "'...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBPathMixin.ReadPathInfo
Retrieves a path info record for a given path.
grr/server/grr_response_server/databases/mysql_paths.py
def ReadPathInfo(self, client_id, path_type, components, timestamp=None, cursor=None): """Retrieves a path info record for a given path.""" if timestamp is None: path_infos = self.ReadPathInfos(client_id, path_t...
def ReadPathInfo(self, client_id, path_type, components, timestamp=None, cursor=None): """Retrieves a path info record for a given path.""" if timestamp is None: path_infos = self.ReadPathInfos(client_id, path_t...
[ "Retrieves", "a", "path", "info", "record", "for", "a", "given", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_paths.py#L26-L113
[ "def", "ReadPathInfo", "(", "self", ",", "client_id", ",", "path_type", ",", "components", ",", "timestamp", "=", "None", ",", "cursor", "=", "None", ")", ":", "if", "timestamp", "is", "None", ":", "path_infos", "=", "self", ".", "ReadPathInfos", "(", "c...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBPathMixin.ReadPathInfos
Retrieves path info records for given paths.
grr/server/grr_response_server/databases/mysql_paths.py
def ReadPathInfos(self, client_id, path_type, components_list, cursor=None): """Retrieves path info records for given paths.""" if not components_list: return {} path_ids = list(map(rdf_objects.PathID.FromComponents, components_list)) path_infos = {components: None for components in components_...
def ReadPathInfos(self, client_id, path_type, components_list, cursor=None): """Retrieves path info records for given paths.""" if not components_list: return {} path_ids = list(map(rdf_objects.PathID.FromComponents, components_list)) path_infos = {components: None for components in components_...
[ "Retrieves", "path", "info", "records", "for", "given", "paths", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_paths.py#L116-L184
[ "def", "ReadPathInfos", "(", "self", ",", "client_id", ",", "path_type", ",", "components_list", ",", "cursor", "=", "None", ")", ":", "if", "not", "components_list", ":", "return", "{", "}", "path_ids", "=", "list", "(", "map", "(", "rdf_objects", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBPathMixin.WritePathInfos
Writes a collection of path_info records for a client.
grr/server/grr_response_server/databases/mysql_paths.py
def WritePathInfos(self, client_id, path_infos): """Writes a collection of path_info records for a client.""" try: self._MultiWritePathInfos({client_id: path_infos}) except MySQLdb.IntegrityError as error: raise db.UnknownClientError(client_id=client_id, cause=error)
def WritePathInfos(self, client_id, path_infos): """Writes a collection of path_info records for a client.""" try: self._MultiWritePathInfos({client_id: path_infos}) except MySQLdb.IntegrityError as error: raise db.UnknownClientError(client_id=client_id, cause=error)
[ "Writes", "a", "collection", "of", "path_info", "records", "for", "a", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_paths.py#L186-L191
[ "def", "WritePathInfos", "(", "self", ",", "client_id", ",", "path_infos", ")", ":", "try", ":", "self", ".", "_MultiWritePathInfos", "(", "{", "client_id", ":", "path_infos", "}", ")", "except", "MySQLdb", ".", "IntegrityError", "as", "error", ":", "raise",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBPathMixin.MultiWritePathInfos
Writes a collection of path info records for specified clients.
grr/server/grr_response_server/databases/mysql_paths.py
def MultiWritePathInfos(self, path_infos): """Writes a collection of path info records for specified clients.""" try: self._MultiWritePathInfos(path_infos) except MySQLdb.IntegrityError as error: client_ids = list(iterkeys(path_infos)) raise db.AtLeastOneUnknownClientError(client_ids=clien...
def MultiWritePathInfos(self, path_infos): """Writes a collection of path info records for specified clients.""" try: self._MultiWritePathInfos(path_infos) except MySQLdb.IntegrityError as error: client_ids = list(iterkeys(path_infos)) raise db.AtLeastOneUnknownClientError(client_ids=clien...
[ "Writes", "a", "collection", "of", "path", "info", "records", "for", "specified", "clients", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_paths.py#L193-L199
[ "def", "MultiWritePathInfos", "(", "self", ",", "path_infos", ")", ":", "try", ":", "self", ".", "_MultiWritePathInfos", "(", "path_infos", ")", "except", "MySQLdb", ".", "IntegrityError", "as", "error", ":", "client_ids", "=", "list", "(", "iterkeys", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBPathMixin._MultiWritePathInfos
Writes a collection of path info records for specified clients.
grr/server/grr_response_server/databases/mysql_paths.py
def _MultiWritePathInfos(self, path_infos, connection=None): """Writes a collection of path info records for specified clients.""" query = "" path_info_count = 0 path_info_values = [] parent_path_info_count = 0 parent_path_info_values = [] has_stat_entries = False has_hash_entries = F...
def _MultiWritePathInfos(self, path_infos, connection=None): """Writes a collection of path info records for specified clients.""" query = "" path_info_count = 0 path_info_values = [] parent_path_info_count = 0 parent_path_info_values = [] has_stat_entries = False has_hash_entries = F...
[ "Writes", "a", "collection", "of", "path", "info", "records", "for", "specified", "clients", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_paths.py#L202-L346
[ "def", "_MultiWritePathInfos", "(", "self", ",", "path_infos", ",", "connection", "=", "None", ")", ":", "query", "=", "\"\"", "path_info_count", "=", "0", "path_info_values", "=", "[", "]", "parent_path_info_count", "=", "0", "parent_path_info_values", "=", "["...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBPathMixin.ListDescendentPathInfos
Lists path info records that correspond to descendants of given path.
grr/server/grr_response_server/databases/mysql_paths.py
def ListDescendentPathInfos(self, client_id, path_type, components, timestamp=None, max_depth=None, cursor=None): """Lists path info rec...
def ListDescendentPathInfos(self, client_id, path_type, components, timestamp=None, max_depth=None, cursor=None): """Lists path info rec...
[ "Lists", "path", "info", "records", "that", "correspond", "to", "descendants", "of", "given", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_paths.py#L357-L500
[ "def", "ListDescendentPathInfos", "(", "self", ",", "client_id", ",", "path_type", ",", "components", ",", "timestamp", "=", "None", ",", "max_depth", "=", "None", ",", "cursor", "=", "None", ")", ":", "path_infos", "=", "[", "]", "query", "=", "\"\"", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBPathMixin.ReadPathInfosHistories
Reads a collection of hash and stat entries for given paths.
grr/server/grr_response_server/databases/mysql_paths.py
def ReadPathInfosHistories(self, client_id, path_type, components_list, cursor=None): """Reads a collection of hash and stat entries for given paths.""" # MySQL does not handle well empty `IN` cla...
def ReadPathInfosHistories(self, client_id, path_type, components_list, cursor=None): """Reads a collection of hash and stat entries for given paths.""" # MySQL does not handle well empty `IN` cla...
[ "Reads", "a", "collection", "of", "hash", "and", "stat", "entries", "for", "given", "paths", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_paths.py#L506-L592
[ "def", "ReadPathInfosHistories", "(", "self", ",", "client_id", ",", "path_type", ",", "components_list", ",", "cursor", "=", "None", ")", ":", "# MySQL does not handle well empty `IN` clauses so we guard against that.", "if", "not", "components_list", ":", "return", "{",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EnumerateInterfacesFromClient
Enumerate all interfaces and collect their MAC addresses.
grr/client/grr_response_client/client_actions/linux/linux.py
def EnumerateInterfacesFromClient(args): """Enumerate all interfaces and collect their MAC addresses.""" del args # Unused libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) ifa = Ifaddrs() p_ifa = ctypes.pointer(ifa) libc.getifaddrs(ctypes.pointer(p_ifa)) addresses = {} macs = {} ifs = ...
def EnumerateInterfacesFromClient(args): """Enumerate all interfaces and collect their MAC addresses.""" del args # Unused libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) ifa = Ifaddrs() p_ifa = ctypes.pointer(ifa) libc.getifaddrs(ctypes.pointer(p_ifa)) addresses = {} macs = {} ifs = ...
[ "Enumerate", "all", "interfaces", "and", "collect", "their", "MAC", "addresses", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/linux/linux.py#L119-L176
[ "def", "EnumerateInterfacesFromClient", "(", "args", ")", ":", "del", "args", "# Unused", "libc", "=", "ctypes", ".", "cdll", ".", "LoadLibrary", "(", "ctypes", ".", "util", ".", "find_library", "(", "\"c\"", ")", ")", "ifa", "=", "Ifaddrs", "(", ")", "p...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EnumerateUsersFromClient
Enumerates all the users on this system.
grr/client/grr_response_client/client_actions/linux/linux.py
def EnumerateUsersFromClient(args): """Enumerates all the users on this system.""" del args # Unused users = _ParseWtmp() for user, last_login in iteritems(users): # Lose the null termination username, _ = user.split(b"\x00", 1) username = username.decode("utf-8") if username: # Someh...
def EnumerateUsersFromClient(args): """Enumerates all the users on this system.""" del args # Unused users = _ParseWtmp() for user, last_login in iteritems(users): # Lose the null termination username, _ = user.split(b"\x00", 1) username = username.decode("utf-8") if username: # Someh...
[ "Enumerates", "all", "the", "users", "on", "this", "system", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/linux/linux.py#L216-L248
[ "def", "EnumerateUsersFromClient", "(", "args", ")", ":", "del", "args", "# Unused", "users", "=", "_ParseWtmp", "(", ")", "for", "user", ",", "last_login", "in", "iteritems", "(", "users", ")", ":", "# Lose the null termination", "username", ",", "_", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CheckMounts
Parses the currently mounted devices.
grr/client/grr_response_client/client_actions/linux/linux.py
def CheckMounts(filename): """Parses the currently mounted devices.""" with io.open(filename, "r") as fd: for line in fd: try: device, mnt_point, fs_type, _ = line.split(" ", 3) except ValueError: continue if fs_type in ACCEPTABLE_FILESYSTEMS: if os.path.exists(device):...
def CheckMounts(filename): """Parses the currently mounted devices.""" with io.open(filename, "r") as fd: for line in fd: try: device, mnt_point, fs_type, _ = line.split(" ", 3) except ValueError: continue if fs_type in ACCEPTABLE_FILESYSTEMS: if os.path.exists(device):...
[ "Parses", "the", "currently", "mounted", "devices", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/linux/linux.py#L282-L292
[ "def", "CheckMounts", "(", "filename", ")", ":", "with", "io", ".", "open", "(", "filename", ",", "\"r\"", ")", "as", "fd", ":", "for", "line", "in", "fd", ":", "try", ":", "device", ",", "mnt_point", ",", "fs_type", ",", "_", "=", "line", ".", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EnumerateFilesystemsFromClient
List all the filesystems mounted on the system.
grr/client/grr_response_client/client_actions/linux/linux.py
def EnumerateFilesystemsFromClient(args): """List all the filesystems mounted on the system.""" del args # Unused. filenames = ["/proc/mounts", "/etc/mtab"] for filename in filenames: for device, fs_type, mnt_point in CheckMounts(filename): yield rdf_client_fs.Filesystem( mount_point=mnt_...
def EnumerateFilesystemsFromClient(args): """List all the filesystems mounted on the system.""" del args # Unused. filenames = ["/proc/mounts", "/etc/mtab"] for filename in filenames: for device, fs_type, mnt_point in CheckMounts(filename): yield rdf_client_fs.Filesystem( mount_point=mnt_...
[ "List", "all", "the", "filesystems", "mounted", "on", "the", "system", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/linux/linux.py#L295-L304
[ "def", "EnumerateFilesystemsFromClient", "(", "args", ")", ":", "del", "args", "# Unused.", "filenames", "=", "[", "\"/proc/mounts\"", ",", "\"/etc/mtab\"", "]", "for", "filename", "in", "filenames", ":", "for", "device", ",", "fs_type", ",", "mnt_point", "in", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ParseWtmp
Parse wtmp and utmp and extract the last logon time.
grr/client/grr_response_client/client_actions/linux/linux.py
def _ParseWtmp(): """Parse wtmp and utmp and extract the last logon time.""" users = {} wtmp_struct_size = UtmpStruct.GetSize() filenames = glob.glob("/var/log/wtmp*") + ["/var/run/utmp"] for filename in filenames: try: wtmp = open(filename, "rb").read() except IOError: continue for...
def _ParseWtmp(): """Parse wtmp and utmp and extract the last logon time.""" users = {} wtmp_struct_size = UtmpStruct.GetSize() filenames = glob.glob("/var/log/wtmp*") + ["/var/run/utmp"] for filename in filenames: try: wtmp = open(filename, "rb").read() except IOError: continue for...
[ "Parse", "wtmp", "and", "utmp", "and", "extract", "the", "last", "logon", "time", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/linux/linux.py#L407-L436
[ "def", "_ParseWtmp", "(", ")", ":", "users", "=", "{", "}", "wtmp_struct_size", "=", "UtmpStruct", ".", "GetSize", "(", ")", "filenames", "=", "glob", ".", "glob", "(", "\"/var/log/wtmp*\"", ")", "+", "[", "\"/var/run/utmp\"", "]", "for", "filename", "in",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UpdateAgent._InstallRpm
Client update for rpm based distros. Upgrading rpms is a bit more tricky than upgrading deb packages since there is a preinstall script that kills the running GRR daemon and, thus, also the installer process. We need to make sure we detach the child process properly and therefore cannot use client_util...
grr/client/grr_response_client/client_actions/linux/linux.py
def _InstallRpm(self, path): """Client update for rpm based distros. Upgrading rpms is a bit more tricky than upgrading deb packages since there is a preinstall script that kills the running GRR daemon and, thus, also the installer process. We need to make sure we detach the child process properly ...
def _InstallRpm(self, path): """Client update for rpm based distros. Upgrading rpms is a bit more tricky than upgrading deb packages since there is a preinstall script that kills the running GRR daemon and, thus, also the installer process. We need to make sure we detach the child process properly ...
[ "Client", "update", "for", "rpm", "based", "distros", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/linux/linux.py#L372-L404
[ "def", "_InstallRpm", "(", "self", ",", "path", ")", ":", "pid", "=", "os", ".", "fork", "(", ")", "if", "pid", "==", "0", ":", "# This is the child that will become the installer process.", "cmd", "=", "\"/bin/rpm\"", "cmd_args", "=", "[", "cmd", ",", "\"-U...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_TempRootPath
Returns a default root path for storing temporary files.
grr/core/grr_response_core/lib/util/temp.py
def _TempRootPath(): """Returns a default root path for storing temporary files.""" # `FLAGS.test_tmpdir` is defined only in test environment, so we can't expect # for it to be always defined. test_tmpdir = ( compatibility.Environ("TEST_TMPDIR", default=None) or FLAGS.get_flag_value("test_tmpdir", d...
def _TempRootPath(): """Returns a default root path for storing temporary files.""" # `FLAGS.test_tmpdir` is defined only in test environment, so we can't expect # for it to be always defined. test_tmpdir = ( compatibility.Environ("TEST_TMPDIR", default=None) or FLAGS.get_flag_value("test_tmpdir", d...
[ "Returns", "a", "default", "root", "path", "for", "storing", "temporary", "files", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/temp.py#L24-L47
[ "def", "_TempRootPath", "(", ")", ":", "# `FLAGS.test_tmpdir` is defined only in test environment, so we can't expect", "# for it to be always defined.", "test_tmpdir", "=", "(", "compatibility", ".", "Environ", "(", "\"TEST_TMPDIR\"", ",", "default", "=", "None", ")", "or", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TempDirPath
Creates a temporary directory based on the environment configuration. The directory will be placed in folder as specified by the `TEST_TMPDIR` environment variable if available or fallback to `Test.tmpdir` of the current configuration if not. Args: suffix: A suffix to end the directory name with. pref...
grr/core/grr_response_core/lib/util/temp.py
def TempDirPath(suffix = "", prefix = "tmp"): """Creates a temporary directory based on the environment configuration. The directory will be placed in folder as specified by the `TEST_TMPDIR` environment variable if available or fallback to `Test.tmpdir` of the current configuration if not. Args: suffix...
def TempDirPath(suffix = "", prefix = "tmp"): """Creates a temporary directory based on the environment configuration. The directory will be placed in folder as specified by the `TEST_TMPDIR` environment variable if available or fallback to `Test.tmpdir` of the current configuration if not. Args: suffix...
[ "Creates", "a", "temporary", "directory", "based", "on", "the", "environment", "configuration", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/temp.py#L50-L67
[ "def", "TempDirPath", "(", "suffix", "=", "\"\"", ",", "prefix", "=", "\"tmp\"", ")", ":", "precondition", ".", "AssertType", "(", "suffix", ",", "Text", ")", "precondition", ".", "AssertType", "(", "prefix", ",", "Text", ")", "return", "tempfile", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TempFilePath
Creates a temporary file based on the environment configuration. If no directory is specified the file will be placed in folder as specified by the `TEST_TMPDIR` environment variable if available or fallback to `Test.tmpdir` of the current configuration if not. If directory is specified it must be part of the...
grr/core/grr_response_core/lib/util/temp.py
def TempFilePath(suffix = "", prefix = "tmp", dir = None): # pylint: disable=redefined-builtin """Creates a temporary file based on the environment configuration. If no directory is specified the file will be placed in folder as specified by the `TEST_TMPDIR` environment variable if available o...
def TempFilePath(suffix = "", prefix = "tmp", dir = None): # pylint: disable=redefined-builtin """Creates a temporary file based on the environment configuration. If no directory is specified the file will be placed in folder as specified by the `TEST_TMPDIR` environment variable if available o...
[ "Creates", "a", "temporary", "file", "based", "on", "the", "environment", "configuration", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/temp.py#L70-L108
[ "def", "TempFilePath", "(", "suffix", "=", "\"\"", ",", "prefix", "=", "\"tmp\"", ",", "dir", "=", "None", ")", ":", "# pylint: disable=redefined-builtin", "precondition", ".", "AssertType", "(", "suffix", ",", "Text", ")", "precondition", ".", "AssertType", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Volume.Name
Return the best available name for this volume.
grr/core/grr_response_core/lib/rdfvalues/client_fs.py
def Name(self): """Return the best available name for this volume.""" return (self.name or self.device_path or self.windowsvolume.drive_letter or self.unixvolume.mount_point or None)
def Name(self): """Return the best available name for this volume.""" return (self.name or self.device_path or self.windowsvolume.drive_letter or self.unixvolume.mount_point or None)
[ "Return", "the", "best", "available", "name", "for", "this", "volume", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client_fs.py#L96-L99
[ "def", "Name", "(", "self", ")", ":", "return", "(", "self", ".", "name", "or", "self", ".", "device_path", "or", "self", ".", "windowsvolume", ".", "drive_letter", "or", "self", ".", "unixvolume", ".", "mount_point", "or", "None", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FindSpec.Validate
Ensure the pathspec is valid.
grr/core/grr_response_core/lib/rdfvalues/client_fs.py
def Validate(self): """Ensure the pathspec is valid.""" self.pathspec.Validate() if (self.HasField("start_time") and self.HasField("end_time") and self.start_time > self.end_time): raise ValueError("Start time must be before end time.") if not self.path_regex and not self.data_regex and ...
def Validate(self): """Ensure the pathspec is valid.""" self.pathspec.Validate() if (self.HasField("start_time") and self.HasField("end_time") and self.start_time > self.end_time): raise ValueError("Start time must be before end time.") if not self.path_regex and not self.data_regex and ...
[ "Ensure", "the", "pathspec", "is", "valid", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client_fs.py#L213-L223
[ "def", "Validate", "(", "self", ")", ":", "self", ".", "pathspec", ".", "Validate", "(", ")", "if", "(", "self", ".", "HasField", "(", "\"start_time\"", ")", "and", "self", ".", "HasField", "(", "\"end_time\"", ")", "and", "self", ".", "start_time", ">...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BigQueryOutputPlugin._GetNestedDict
Turn Exported* protos with embedded metadata into a nested dict.
grr/server/grr_response_server/output_plugins/bigquery_plugin.py
def _GetNestedDict(self, value): """Turn Exported* protos with embedded metadata into a nested dict.""" row = {} for type_info in value.__class__.type_infos: # We only expect the metadata proto to be included as ProtoEmbedded. if type_info.__class__.__name__ == "ProtoEmbedded": row[type_...
def _GetNestedDict(self, value): """Turn Exported* protos with embedded metadata into a nested dict.""" row = {} for type_info in value.__class__.type_infos: # We only expect the metadata proto to be included as ProtoEmbedded. if type_info.__class__.__name__ == "ProtoEmbedded": row[type_...
[ "Turn", "Exported", "*", "protos", "with", "embedded", "metadata", "into", "a", "nested", "dict", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/output_plugins/bigquery_plugin.py#L117-L127
[ "def", "_GetNestedDict", "(", "self", ",", "value", ")", ":", "row", "=", "{", "}", "for", "type_info", "in", "value", ".", "__class__", ".", "type_infos", ":", "# We only expect the metadata proto to be included as ProtoEmbedded.", "if", "type_info", ".", "__class_...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BigQueryOutputPlugin._CreateOutputFileHandles
Creates a new gzipped output tempfile for the output type. We write to JSON data to gzip_filehandle to get compressed data. We hold a reference to the original filehandle (gzip_filehandle_parent) so we can pass the gzip data to bigquery. Args: output_type: string of export type to be used in fil...
grr/server/grr_response_server/output_plugins/bigquery_plugin.py
def _CreateOutputFileHandles(self, output_type): """Creates a new gzipped output tempfile for the output type. We write to JSON data to gzip_filehandle to get compressed data. We hold a reference to the original filehandle (gzip_filehandle_parent) so we can pass the gzip data to bigquery. Args: ...
def _CreateOutputFileHandles(self, output_type): """Creates a new gzipped output tempfile for the output type. We write to JSON data to gzip_filehandle to get compressed data. We hold a reference to the original filehandle (gzip_filehandle_parent) so we can pass the gzip data to bigquery. Args: ...
[ "Creates", "a", "new", "gzipped", "output", "tempfile", "for", "the", "output", "type", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/output_plugins/bigquery_plugin.py#L139-L161
[ "def", "_CreateOutputFileHandles", "(", "self", ",", "output_type", ")", ":", "gzip_filehandle_parent", "=", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "output_type", ")", "gzip_filehandle", "=", "gzip", ".", "GzipFile", "(", "gzip_filehandle_parent", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BigQueryOutputPlugin._GetTempOutputFileHandles
Returns the tracker for a given value type.
grr/server/grr_response_server/output_plugins/bigquery_plugin.py
def _GetTempOutputFileHandles(self, value_type): """Returns the tracker for a given value type.""" try: return self.temp_output_trackers[value_type], False except KeyError: return self._CreateOutputFileHandles(value_type), True
def _GetTempOutputFileHandles(self, value_type): """Returns the tracker for a given value type.""" try: return self.temp_output_trackers[value_type], False except KeyError: return self._CreateOutputFileHandles(value_type), True
[ "Returns", "the", "tracker", "for", "a", "given", "value", "type", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/output_plugins/bigquery_plugin.py#L163-L168
[ "def", "_GetTempOutputFileHandles", "(", "self", ",", "value_type", ")", ":", "try", ":", "return", "self", ".", "temp_output_trackers", "[", "value_type", "]", ",", "False", "except", "KeyError", ":", "return", "self", ".", "_CreateOutputFileHandles", "(", "val...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BigQueryOutputPlugin.Flush
Finish writing JSON files, upload to cloudstorage and bigquery.
grr/server/grr_response_server/output_plugins/bigquery_plugin.py
def Flush(self, state): """Finish writing JSON files, upload to cloudstorage and bigquery.""" self.bigquery = bigquery.GetBigQueryClient() # BigQuery job ids must be alphanum plus dash and underscore. urn_str = self.source_urn.RelativeName("aff4:/").replace("/", "_").replace( ":", "").replace("....
def Flush(self, state): """Finish writing JSON files, upload to cloudstorage and bigquery.""" self.bigquery = bigquery.GetBigQueryClient() # BigQuery job ids must be alphanum plus dash and underscore. urn_str = self.source_urn.RelativeName("aff4:/").replace("/", "_").replace( ":", "").replace("....
[ "Finish", "writing", "JSON", "files", "upload", "to", "cloudstorage", "and", "bigquery", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/output_plugins/bigquery_plugin.py#L170-L213
[ "def", "Flush", "(", "self", ",", "state", ")", ":", "self", ".", "bigquery", "=", "bigquery", ".", "GetBigQueryClient", "(", ")", "# BigQuery job ids must be alphanum plus dash and underscore.", "urn_str", "=", "self", ".", "source_urn", ".", "RelativeName", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BigQueryOutputPlugin.RDFValueToBigQuerySchema
Convert Exported* rdfvalue into a BigQuery schema.
grr/server/grr_response_server/output_plugins/bigquery_plugin.py
def RDFValueToBigQuerySchema(self, value): """Convert Exported* rdfvalue into a BigQuery schema.""" fields_array = [] for type_info in value.__class__.type_infos: # Nested structures are indicated by setting type "RECORD" if type_info.__class__.__name__ == "ProtoEmbedded": fields_array.a...
def RDFValueToBigQuerySchema(self, value): """Convert Exported* rdfvalue into a BigQuery schema.""" fields_array = [] for type_info in value.__class__.type_infos: # Nested structures are indicated by setting type "RECORD" if type_info.__class__.__name__ == "ProtoEmbedded": fields_array.a...
[ "Convert", "Exported", "*", "rdfvalue", "into", "a", "BigQuery", "schema", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/output_plugins/bigquery_plugin.py#L215-L251
[ "def", "RDFValueToBigQuerySchema", "(", "self", ",", "value", ")", ":", "fields_array", "=", "[", "]", "for", "type_info", "in", "value", ".", "__class__", ".", "type_infos", ":", "# Nested structures are indicated by setting type \"RECORD\"", "if", "type_info", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74