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
ValueExpander._AtLeaf
Called when at a leaf value. Should yield a value.
grr/core/grr_response_core/lib/objectfilter.py
def _AtLeaf(self, attr_value): """Called when at a leaf value. Should yield a value.""" if isinstance(attr_value, collections.Mapping): # If the result is a dict, return each key/value pair as a new dict. for k, v in iteritems(attr_value): yield {k: v} else: yield attr_value
def _AtLeaf(self, attr_value): """Called when at a leaf value. Should yield a value.""" if isinstance(attr_value, collections.Mapping): # If the result is a dict, return each key/value pair as a new dict. for k, v in iteritems(attr_value): yield {k: v} else: yield attr_value
[ "Called", "when", "at", "a", "leaf", "value", ".", "Should", "yield", "a", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L492-L499
[ "def", "_AtLeaf", "(", "self", ",", "attr_value", ")", ":", "if", "isinstance", "(", "attr_value", ",", "collections", ".", "Mapping", ")", ":", "# If the result is a dict, return each key/value pair as a new dict.", "for", "k", ",", "v", "in", "iteritems", "(", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ValueExpander._AtNonLeaf
Called when at a non-leaf value. Should recurse and yield values.
grr/core/grr_response_core/lib/objectfilter.py
def _AtNonLeaf(self, attr_value, path): """Called when at a non-leaf value. Should recurse and yield values.""" try: if isinstance(attr_value, collections.Mapping): # If it's dictionary-like, treat the dict key as the attribute.. sub_obj = attr_value.get(path[1]) if len(path) > 2: ...
def _AtNonLeaf(self, attr_value, path): """Called when at a non-leaf value. Should recurse and yield values.""" try: if isinstance(attr_value, collections.Mapping): # If it's dictionary-like, treat the dict key as the attribute.. sub_obj = attr_value.get(path[1]) if len(path) > 2: ...
[ "Called", "when", "at", "a", "non", "-", "leaf", "value", ".", "Should", "recurse", "and", "yield", "values", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L501-L527
[ "def", "_AtNonLeaf", "(", "self", ",", "attr_value", ",", "path", ")", ":", "try", ":", "if", "isinstance", "(", "attr_value", ",", "collections", ".", "Mapping", ")", ":", "# If it's dictionary-like, treat the dict key as the attribute..", "sub_obj", "=", "attr_val...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BinaryExpression.Compile
Compile the binary expression into a filter object.
grr/core/grr_response_core/lib/objectfilter.py
def Compile(self, filter_implemention): """Compile the binary expression into a filter object.""" operator = self.operator.lower() if operator == "and" or operator == "&&": method = "AndFilter" elif operator == "or" or operator == "||": method = "OrFilter" else: raise ParseError("I...
def Compile(self, filter_implemention): """Compile the binary expression into a filter object.""" operator = self.operator.lower() if operator == "and" or operator == "&&": method = "AndFilter" elif operator == "or" or operator == "||": method = "OrFilter" else: raise ParseError("I...
[ "Compile", "the", "binary", "expression", "into", "a", "filter", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L631-L642
[ "def", "Compile", "(", "self", ",", "filter_implemention", ")", ":", "operator", "=", "self", ".", "operator", ".", "lower", "(", ")", "if", "operator", "==", "\"and\"", "or", "operator", "==", "\"&&\"", ":", "method", "=", "\"AndFilter\"", "elif", "operat...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Parser.InsertArg
Insert an arg to the current expression.
grr/core/grr_response_core/lib/objectfilter.py
def InsertArg(self, string="", **_): """Insert an arg to the current expression.""" if self.state == "LIST_ARG": self.list_args.append(string) elif self.current_expression.AddArg(string): # This expression is complete self.stack.append(self.current_expression) self.current_expression...
def InsertArg(self, string="", **_): """Insert an arg to the current expression.""" if self.state == "LIST_ARG": self.list_args.append(string) elif self.current_expression.AddArg(string): # This expression is complete self.stack.append(self.current_expression) self.current_expression...
[ "Insert", "an", "arg", "to", "the", "current", "expression", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L721-L730
[ "def", "InsertArg", "(", "self", ",", "string", "=", "\"\"", ",", "*", "*", "_", ")", ":", "if", "self", ".", "state", "==", "\"LIST_ARG\"", ":", "self", ".", "list_args", ".", "append", "(", "string", ")", "elif", "self", ".", "current_expression", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Parser.InsertFloatArg
Inserts a Float argument.
grr/core/grr_response_core/lib/objectfilter.py
def InsertFloatArg(self, string="", **_): """Inserts a Float argument.""" try: float_value = float(string) return self.InsertArg(float_value) except (TypeError, ValueError): raise ParseError("%s is not a valid float." % string)
def InsertFloatArg(self, string="", **_): """Inserts a Float argument.""" try: float_value = float(string) return self.InsertArg(float_value) except (TypeError, ValueError): raise ParseError("%s is not a valid float." % string)
[ "Inserts", "a", "Float", "argument", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L732-L738
[ "def", "InsertFloatArg", "(", "self", ",", "string", "=", "\"\"", ",", "*", "*", "_", ")", ":", "try", ":", "float_value", "=", "float", "(", "string", ")", "return", "self", ".", "InsertArg", "(", "float_value", ")", "except", "(", "TypeError", ",", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Parser.InsertInt16Arg
Inserts an Integer in base16 argument.
grr/core/grr_response_core/lib/objectfilter.py
def InsertInt16Arg(self, string="", **_): """Inserts an Integer in base16 argument.""" try: int_value = int(string, 16) return self.InsertArg(int_value) except (TypeError, ValueError): raise ParseError("%s is not a valid base16 integer." % string)
def InsertInt16Arg(self, string="", **_): """Inserts an Integer in base16 argument.""" try: int_value = int(string, 16) return self.InsertArg(int_value) except (TypeError, ValueError): raise ParseError("%s is not a valid base16 integer." % string)
[ "Inserts", "an", "Integer", "in", "base16", "argument", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L748-L754
[ "def", "InsertInt16Arg", "(", "self", ",", "string", "=", "\"\"", ",", "*", "*", "_", ")", ":", "try", ":", "int_value", "=", "int", "(", "string", ",", "16", ")", "return", "self", ".", "InsertArg", "(", "int_value", ")", "except", "(", "TypeError",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Parser.StringEscape
Escape backslashes found inside a string quote. Backslashes followed by anything other than [\'"rnbt] will raise an Error. Args: string: The string that matched. match: The match object (m.group(1) is the escaped code) Raises: ParseError: For strings other than those used to define a re...
grr/core/grr_response_core/lib/objectfilter.py
def StringEscape(self, string, match, **_): """Escape backslashes found inside a string quote. Backslashes followed by anything other than [\'"rnbt] will raise an Error. Args: string: The string that matched. match: The match object (m.group(1) is the escaped code) Raises: ParseErro...
def StringEscape(self, string, match, **_): """Escape backslashes found inside a string quote. Backslashes followed by anything other than [\'"rnbt] will raise an Error. Args: string: The string that matched. match: The match object (m.group(1) is the escaped code) Raises: ParseErro...
[ "Escape", "backslashes", "found", "inside", "a", "string", "quote", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L769-L792
[ "def", "StringEscape", "(", "self", ",", "string", ",", "match", ",", "*", "*", "_", ")", ":", "precondition", ".", "AssertType", "(", "string", ",", "Text", ")", "# Allow unfiltered strings for regexp operations so that escaped special", "# characters (e.g. \\*) or spe...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Parser.HexEscape
Converts a hex escaped string.
grr/core/grr_response_core/lib/objectfilter.py
def HexEscape(self, string, match, **_): """Converts a hex escaped string.""" hex_string = match.group(1) try: self.string += binascii.unhexlify(hex_string).decode("utf-8") # TODO: In Python 2 `binascii` throws `TypeError` for invalid # input values (for whathever reason). This behaviour is fi...
def HexEscape(self, string, match, **_): """Converts a hex escaped string.""" hex_string = match.group(1) try: self.string += binascii.unhexlify(hex_string).decode("utf-8") # TODO: In Python 2 `binascii` throws `TypeError` for invalid # input values (for whathever reason). This behaviour is fi...
[ "Converts", "a", "hex", "escaped", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L794-L805
[ "def", "HexEscape", "(", "self", ",", "string", ",", "match", ",", "*", "*", "_", ")", ":", "hex_string", "=", "match", ".", "group", "(", "1", ")", "try", ":", "self", ".", "string", "+=", "binascii", ".", "unhexlify", "(", "hex_string", ")", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GenerateCSRFToken
Generates a CSRF token based on a secret key, id and time.
grr/server/grr_response_server/gui/wsgiapp.py
def GenerateCSRFToken(user_id, time): """Generates a CSRF token based on a secret key, id and time.""" precondition.AssertType(user_id, Text) precondition.AssertOptionalType(time, int) time = time or rdfvalue.RDFDatetime.Now().AsMicrosecondsSinceEpoch() secret = config.CONFIG.Get("AdminUI.csrf_secret_key", ...
def GenerateCSRFToken(user_id, time): """Generates a CSRF token based on a secret key, id and time.""" precondition.AssertType(user_id, Text) precondition.AssertOptionalType(time, int) time = time or rdfvalue.RDFDatetime.Now().AsMicrosecondsSinceEpoch() secret = config.CONFIG.Get("AdminUI.csrf_secret_key", ...
[ "Generates", "a", "CSRF", "token", "based", "on", "a", "secret", "key", "id", "and", "time", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L44-L62
[ "def", "GenerateCSRFToken", "(", "user_id", ",", "time", ")", ":", "precondition", ".", "AssertType", "(", "user_id", ",", "Text", ")", "precondition", ".", "AssertOptionalType", "(", "time", ",", "int", ")", "time", "=", "time", "or", "rdfvalue", ".", "RD...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StoreCSRFCookie
Decorator for WSGI handler that inserts CSRF cookie into response.
grr/server/grr_response_server/gui/wsgiapp.py
def StoreCSRFCookie(user, response): """Decorator for WSGI handler that inserts CSRF cookie into response.""" csrf_token = GenerateCSRFToken(user, None) response.set_cookie( "csrftoken", csrf_token, max_age=CSRF_TOKEN_DURATION.seconds)
def StoreCSRFCookie(user, response): """Decorator for WSGI handler that inserts CSRF cookie into response.""" csrf_token = GenerateCSRFToken(user, None) response.set_cookie( "csrftoken", csrf_token, max_age=CSRF_TOKEN_DURATION.seconds)
[ "Decorator", "for", "WSGI", "handler", "that", "inserts", "CSRF", "cookie", "into", "response", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L65-L70
[ "def", "StoreCSRFCookie", "(", "user", ",", "response", ")", ":", "csrf_token", "=", "GenerateCSRFToken", "(", "user", ",", "None", ")", "response", ".", "set_cookie", "(", "\"csrftoken\"", ",", "csrf_token", ",", "max_age", "=", "CSRF_TOKEN_DURATION", ".", "s...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ValidateCSRFTokenOrRaise
Decorator for WSGI handler that checks CSRF cookie against the request.
grr/server/grr_response_server/gui/wsgiapp.py
def ValidateCSRFTokenOrRaise(request): """Decorator for WSGI handler that checks CSRF cookie against the request.""" # CSRF check doesn't make sense for GET/HEAD methods, because they can # (and are) used when downloading files through <a href> links - and # there's no way to set X-CSRFToken header in this cas...
def ValidateCSRFTokenOrRaise(request): """Decorator for WSGI handler that checks CSRF cookie against the request.""" # CSRF check doesn't make sense for GET/HEAD methods, because they can # (and are) used when downloading files through <a href> links - and # there's no way to set X-CSRFToken header in this cas...
[ "Decorator", "for", "WSGI", "handler", "that", "checks", "CSRF", "cookie", "against", "the", "request", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L73-L119
[ "def", "ValidateCSRFTokenOrRaise", "(", "request", ")", ":", "# CSRF check doesn't make sense for GET/HEAD methods, because they can", "# (and are) used when downloading files through <a href> links - and", "# there's no way to set X-CSRFToken header in this case.", "if", "request", ".", "me...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
LogAccessWrapper
Decorator that ensures that HTTP access is logged.
grr/server/grr_response_server/gui/wsgiapp.py
def LogAccessWrapper(func): """Decorator that ensures that HTTP access is logged.""" def Wrapper(request, *args, **kwargs): """Wrapping function.""" try: response = func(request, *args, **kwargs) server_logging.LOGGER.LogHttpAdminUIAccess(request, response) except Exception: # pylint: disa...
def LogAccessWrapper(func): """Decorator that ensures that HTTP access is logged.""" def Wrapper(request, *args, **kwargs): """Wrapping function.""" try: response = func(request, *args, **kwargs) server_logging.LOGGER.LogHttpAdminUIAccess(request, response) except Exception: # pylint: disa...
[ "Decorator", "that", "ensures", "that", "HTTP", "access", "is", "logged", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L162-L181
[ "def", "LogAccessWrapper", "(", "func", ")", ":", "def", "Wrapper", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrapping function.\"\"\"", "try", ":", "response", "=", "func", "(", "request", ",", "*", "args", ",", "*", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AdminUIApp._BuildToken
Build an ACLToken from the request.
grr/server/grr_response_server/gui/wsgiapp.py
def _BuildToken(self, request, execution_time): """Build an ACLToken from the request.""" token = access_control.ACLToken( username=request.user, reason=request.args.get("reason", ""), process="GRRAdminUI", expiry=rdfvalue.RDFDatetime.Now() + execution_time) for field in ["R...
def _BuildToken(self, request, execution_time): """Build an ACLToken from the request.""" token = access_control.ACLToken( username=request.user, reason=request.args.get("reason", ""), process="GRRAdminUI", expiry=rdfvalue.RDFDatetime.Now() + execution_time) for field in ["R...
[ "Build", "an", "ACLToken", "from", "the", "request", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L212-L224
[ "def", "_BuildToken", "(", "self", ",", "request", ",", "execution_time", ")", ":", "token", "=", "access_control", ".", "ACLToken", "(", "username", "=", "request", ".", "user", ",", "reason", "=", "request", ".", "args", ".", "get", "(", "\"reason\"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AdminUIApp._HandleHomepage
Renders GRR home page by rendering base.html Jinja template.
grr/server/grr_response_server/gui/wsgiapp.py
def _HandleHomepage(self, request): """Renders GRR home page by rendering base.html Jinja template.""" _ = request env = jinja2.Environment( loader=jinja2.FileSystemLoader(config.CONFIG["AdminUI.template_root"]), autoescape=True) create_time = psutil.Process(os.getpid()).create_time()...
def _HandleHomepage(self, request): """Renders GRR home page by rendering base.html Jinja template.""" _ = request env = jinja2.Environment( loader=jinja2.FileSystemLoader(config.CONFIG["AdminUI.template_root"]), autoescape=True) create_time = psutil.Process(os.getpid()).create_time()...
[ "Renders", "GRR", "home", "page", "by", "rendering", "base", ".", "html", "Jinja", "template", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L226-L269
[ "def", "_HandleHomepage", "(", "self", ",", "request", ")", ":", "_", "=", "request", "env", "=", "jinja2", ".", "Environment", "(", "loader", "=", "jinja2", ".", "FileSystemLoader", "(", "config", ".", "CONFIG", "[", "\"AdminUI.template_root\"", "]", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AdminUIApp._HandleApi
Handles API requests.
grr/server/grr_response_server/gui/wsgiapp.py
def _HandleApi(self, request): """Handles API requests.""" # Checks CSRF token. CSRF token cookie is updated when homepage is visited # or via GetPendingUserNotificationsCount API call. ValidateCSRFTokenOrRaise(request) response = http_api.RenderHttpResponse(request) # GetPendingUserNotificati...
def _HandleApi(self, request): """Handles API requests.""" # Checks CSRF token. CSRF token cookie is updated when homepage is visited # or via GetPendingUserNotificationsCount API call. ValidateCSRFTokenOrRaise(request) response = http_api.RenderHttpResponse(request) # GetPendingUserNotificati...
[ "Handles", "API", "requests", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L271-L287
[ "def", "_HandleApi", "(", "self", ",", "request", ")", ":", "# Checks CSRF token. CSRF token cookie is updated when homepage is visited", "# or via GetPendingUserNotificationsCount API call.", "ValidateCSRFTokenOrRaise", "(", "request", ")", "response", "=", "http_api", ".", "Ren...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AdminUIApp._RedirectToRemoteHelp
Redirect to GitHub-hosted documentation.
grr/server/grr_response_server/gui/wsgiapp.py
def _RedirectToRemoteHelp(self, path): """Redirect to GitHub-hosted documentation.""" allowed_chars = set(string.ascii_letters + string.digits + "._-/") if not set(path) <= allowed_chars: raise RuntimeError("Unusual chars in path %r - " "possible exploit attempt." % path) ...
def _RedirectToRemoteHelp(self, path): """Redirect to GitHub-hosted documentation.""" allowed_chars = set(string.ascii_letters + string.digits + "._-/") if not set(path) <= allowed_chars: raise RuntimeError("Unusual chars in path %r - " "possible exploit attempt." % path) ...
[ "Redirect", "to", "GitHub", "-", "hosted", "documentation", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L289-L307
[ "def", "_RedirectToRemoteHelp", "(", "self", ",", "path", ")", ":", "allowed_chars", "=", "set", "(", "string", ".", "ascii_letters", "+", "string", ".", "digits", "+", "\"._-/\"", ")", "if", "not", "set", "(", "path", ")", "<=", "allowed_chars", ":", "r...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AdminUIApp._HandleHelp
Handles help requests.
grr/server/grr_response_server/gui/wsgiapp.py
def _HandleHelp(self, request): """Handles help requests.""" help_path = request.path.split("/", 2)[-1] if not help_path: raise werkzeug_exceptions.Forbidden("Error: Invalid help path.") # Proxy remote documentation. return self._RedirectToRemoteHelp(help_path)
def _HandleHelp(self, request): """Handles help requests.""" help_path = request.path.split("/", 2)[-1] if not help_path: raise werkzeug_exceptions.Forbidden("Error: Invalid help path.") # Proxy remote documentation. return self._RedirectToRemoteHelp(help_path)
[ "Handles", "help", "requests", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L309-L316
[ "def", "_HandleHelp", "(", "self", ",", "request", ")", ":", "help_path", "=", "request", ".", "path", ".", "split", "(", "\"/\"", ",", "2", ")", "[", "-", "1", "]", "if", "not", "help_path", ":", "raise", "werkzeug_exceptions", ".", "Forbidden", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AdminUIApp.WSGIHandler
Returns GRR's WSGI handler.
grr/server/grr_response_server/gui/wsgiapp.py
def WSGIHandler(self): """Returns GRR's WSGI handler.""" sdm = werkzeug_wsgi.SharedDataMiddleware(self, { "/": config.CONFIG["AdminUI.document_root"], }) # Use DispatcherMiddleware to make sure that SharedDataMiddleware is not # used at all if the URL path doesn't start with "/static". This ...
def WSGIHandler(self): """Returns GRR's WSGI handler.""" sdm = werkzeug_wsgi.SharedDataMiddleware(self, { "/": config.CONFIG["AdminUI.document_root"], }) # Use DispatcherMiddleware to make sure that SharedDataMiddleware is not # used at all if the URL path doesn't start with "/static". This ...
[ "Returns", "GRR", "s", "WSGI", "handler", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L331-L345
[ "def", "WSGIHandler", "(", "self", ")", ":", "sdm", "=", "werkzeug_wsgi", ".", "SharedDataMiddleware", "(", "self", ",", "{", "\"/\"", ":", "config", ".", "CONFIG", "[", "\"AdminUI.document_root\"", "]", ",", "}", ")", "# Use DispatcherMiddleware to make sure that...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GuiPluginsInit.RunOnce
Import the plugins once only.
grr/server/grr_response_server/gui/wsgiapp.py
def RunOnce(self): """Import the plugins once only.""" # pylint: disable=unused-variable,g-import-not-at-top from grr_response_server.gui import gui_plugins # pylint: enable=unused-variable,g-import-not-at-top if config.CONFIG.Get("AdminUI.django_secret_key", None): logging.warning( ...
def RunOnce(self): """Import the plugins once only.""" # pylint: disable=unused-variable,g-import-not-at-top from grr_response_server.gui import gui_plugins # pylint: enable=unused-variable,g-import-not-at-top if config.CONFIG.Get("AdminUI.django_secret_key", None): logging.warning( ...
[ "Import", "the", "plugins", "once", "only", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L351-L360
[ "def", "RunOnce", "(", "self", ")", ":", "# pylint: disable=unused-variable,g-import-not-at-top", "from", "grr_response_server", ".", "gui", "import", "gui_plugins", "# pylint: enable=unused-variable,g-import-not-at-top", "if", "config", ".", "CONFIG", ".", "Get", "(", "\"A...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ListGrrBinaries
Lists all registered Grr binaries.
api_client/python/grr_api_client/config.py
def ListGrrBinaries(context=None): """Lists all registered Grr binaries.""" items = context.SendIteratorRequest("ListGrrBinaries", None) return utils.MapItemsIterator( lambda data: GrrBinary(data=data, context=context), items)
def ListGrrBinaries(context=None): """Lists all registered Grr binaries.""" items = context.SendIteratorRequest("ListGrrBinaries", None) return utils.MapItemsIterator( lambda data: GrrBinary(data=data, context=context), items)
[ "Lists", "all", "registered", "Grr", "binaries", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/config.py#L58-L63
[ "def", "ListGrrBinaries", "(", "context", "=", "None", ")", ":", "items", "=", "context", ".", "SendIteratorRequest", "(", "\"ListGrrBinaries\"", ",", "None", ")", "return", "utils", ".", "MapItemsIterator", "(", "lambda", "data", ":", "GrrBinary", "(", "data"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ActionPlugin.Execute
This function parses the RDFValue from the server. The Run method will be called with the specified RDFValue. Args: message: The GrrMessage that we are called to process. Returns: Upon return a callback will be called on the server to register the end of the function and pass back...
grr/client/grr_response_client/actions.py
def Execute(self, message): """This function parses the RDFValue from the server. The Run method will be called with the specified RDFValue. Args: message: The GrrMessage that we are called to process. Returns: Upon return a callback will be called on the server to register th...
def Execute(self, message): """This function parses the RDFValue from the server. The Run method will be called with the specified RDFValue. Args: message: The GrrMessage that we are called to process. Returns: Upon return a callback will be called on the server to register th...
[ "This", "function", "parses", "the", "RDFValue", "from", "the", "server", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/actions.py#L96-L179
[ "def", "Execute", "(", "self", ",", "message", ")", ":", "self", ".", "message", "=", "message", "if", "message", ":", "self", ".", "require_fastpoll", "=", "message", ".", "require_fastpoll", "args", "=", "None", "try", ":", "if", "self", ".", "message"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ActionPlugin.SetStatus
Set a status to report back to the server.
grr/client/grr_response_client/actions.py
def SetStatus(self, status, message="", backtrace=None): """Set a status to report back to the server.""" self.status.status = status self.status.error_message = utils.SmartUnicode(message) if backtrace: self.status.backtrace = utils.SmartUnicode(backtrace)
def SetStatus(self, status, message="", backtrace=None): """Set a status to report back to the server.""" self.status.status = status self.status.error_message = utils.SmartUnicode(message) if backtrace: self.status.backtrace = utils.SmartUnicode(backtrace)
[ "Set", "a", "status", "to", "report", "back", "to", "the", "server", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/actions.py#L208-L213
[ "def", "SetStatus", "(", "self", ",", "status", ",", "message", "=", "\"\"", ",", "backtrace", "=", "None", ")", ":", "self", ".", "status", ".", "status", "=", "status", "self", ".", "status", ".", "error_message", "=", "utils", ".", "SmartUnicode", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ActionPlugin.SendReply
Send response back to the server.
grr/client/grr_response_client/actions.py
def SendReply(self, rdf_value=None, session_id=None, message_type=rdf_flows.GrrMessage.Type.MESSAGE): """Send response back to the server.""" # TODO(hanuszczak): This is pretty bad. Here we assume that if the session # id is not none we are "replying" to a wel...
def SendReply(self, rdf_value=None, session_id=None, message_type=rdf_flows.GrrMessage.Type.MESSAGE): """Send response back to the server.""" # TODO(hanuszczak): This is pretty bad. Here we assume that if the session # id is not none we are "replying" to a wel...
[ "Send", "response", "back", "to", "the", "server", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/actions.py#L220-L257
[ "def", "SendReply", "(", "self", ",", "rdf_value", "=", "None", ",", "session_id", "=", "None", ",", "message_type", "=", "rdf_flows", ".", "GrrMessage", ".", "Type", ".", "MESSAGE", ")", ":", "# TODO(hanuszczak): This is pretty bad. Here we assume that if the session...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ActionPlugin.Progress
Indicate progress of the client action. This function should be called periodically during client actions that do not finish instantly. It will notify the nanny that the action is not stuck and avoid the timeout and it will also check if the action has reached its cpu limit. Raises: CPUExcee...
grr/client/grr_response_client/actions.py
def Progress(self): """Indicate progress of the client action. This function should be called periodically during client actions that do not finish instantly. It will notify the nanny that the action is not stuck and avoid the timeout and it will also check if the action has reached its cpu limit. ...
def Progress(self): """Indicate progress of the client action. This function should be called periodically during client actions that do not finish instantly. It will notify the nanny that the action is not stuck and avoid the timeout and it will also check if the action has reached its cpu limit. ...
[ "Indicate", "progress", "of", "the", "client", "action", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/actions.py#L259-L291
[ "def", "Progress", "(", "self", ")", ":", "now", "=", "time", ".", "time", "(", ")", "if", "now", "-", "self", ".", "last_progress_time", "<=", "2", ":", "return", "self", ".", "last_progress_time", "=", "now", "# Prevent the machine from sleeping while the ac...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBClientReportsMixin.WriteClientGraphSeries
Writes the provided graphs to the DB with the given client label.
grr/server/grr_response_server/databases/mysql_client_reports.py
def WriteClientGraphSeries( self, graph_series, client_label, timestamp, cursor=None, ): """Writes the provided graphs to the DB with the given client label.""" args = { "client_label": client_label, "report_type": graph_series.report_type.SerializeToDataStore(), ...
def WriteClientGraphSeries( self, graph_series, client_label, timestamp, cursor=None, ): """Writes the provided graphs to the DB with the given client label.""" args = { "client_label": client_label, "report_type": graph_series.report_type.SerializeToDataStore(), ...
[ "Writes", "the", "provided", "graphs", "to", "the", "DB", "with", "the", "given", "client", "label", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_client_reports.py#L21-L44
[ "def", "WriteClientGraphSeries", "(", "self", ",", "graph_series", ",", "client_label", ",", "timestamp", ",", "cursor", "=", "None", ",", ")", ":", "args", "=", "{", "\"client_label\"", ":", "client_label", ",", "\"report_type\"", ":", "graph_series", ".", "r...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBClientReportsMixin.ReadAllClientGraphSeries
Reads graph series for the given label and report-type from the DB.
grr/server/grr_response_server/databases/mysql_client_reports.py
def ReadAllClientGraphSeries( self, client_label, report_type, time_range = None, cursor=None): """Reads graph series for the given label and report-type from the DB.""" query = """ SELECT UNIX_TIMESTAMP(timestamp), graph_series FROM client_report_graphs WHERE cli...
def ReadAllClientGraphSeries( self, client_label, report_type, time_range = None, cursor=None): """Reads graph series for the given label and report-type from the DB.""" query = """ SELECT UNIX_TIMESTAMP(timestamp), graph_series FROM client_report_graphs WHERE cli...
[ "Reads", "graph", "series", "for", "the", "given", "label", "and", "report", "-", "type", "from", "the", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_client_reports.py#L47-L78
[ "def", "ReadAllClientGraphSeries", "(", "self", ",", "client_label", ",", "report_type", ",", "time_range", "=", "None", ",", "cursor", "=", "None", ")", ":", "query", "=", "\"\"\"\n SELECT UNIX_TIMESTAMP(timestamp), graph_series\n FROM client_report_graphs\n W...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBClientReportsMixin.ReadMostRecentClientGraphSeries
Fetches the latest graph series for a client-label from the DB.
grr/server/grr_response_server/databases/mysql_client_reports.py
def ReadMostRecentClientGraphSeries( self, client_label, report_type, cursor=None): """Fetches the latest graph series for a client-label from the DB.""" query = """ SELECT graph_series FROM client_report_graphs WHERE client_label = %s AND report_type = %s ORDER B...
def ReadMostRecentClientGraphSeries( self, client_label, report_type, cursor=None): """Fetches the latest graph series for a client-label from the DB.""" query = """ SELECT graph_series FROM client_report_graphs WHERE client_label = %s AND report_type = %s ORDER B...
[ "Fetches", "the", "latest", "graph", "series", "for", "a", "client", "-", "label", "from", "the", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_client_reports.py#L81-L100
[ "def", "ReadMostRecentClientGraphSeries", "(", "self", ",", "client_label", ",", "report_type", ",", "cursor", "=", "None", ")", ":", "query", "=", "\"\"\"\n SELECT graph_series\n FROM client_report_graphs\n WHERE client_label = %s AND report_type = %s\n ORDER BY ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CollectionItemToAff4Path
Converts given RDFValue to an RDFURN of a file to be downloaded.
grr/server/grr_response_server/flows/general/export.py
def CollectionItemToAff4Path(item, client_id=None): """Converts given RDFValue to an RDFURN of a file to be downloaded.""" if isinstance(item, rdf_flows.GrrMessage): client_id = item.source item = item.payload elif isinstance(item, rdf_flow_objects.FlowResult): client_id = item.client_id item = it...
def CollectionItemToAff4Path(item, client_id=None): """Converts given RDFValue to an RDFURN of a file to be downloaded.""" if isinstance(item, rdf_flows.GrrMessage): client_id = item.source item = item.payload elif isinstance(item, rdf_flow_objects.FlowResult): client_id = item.client_id item = it...
[ "Converts", "given", "RDFValue", "to", "an", "RDFURN", "of", "a", "file", "to", "be", "downloaded", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/export.py#L30-L52
[ "def", "CollectionItemToAff4Path", "(", "item", ",", "client_id", "=", "None", ")", ":", "if", "isinstance", "(", "item", ",", "rdf_flows", ".", "GrrMessage", ")", ":", "client_id", "=", "item", ".", "source", "item", "=", "item", ".", "payload", "elif", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CollectionItemToClientPath
Converts given RDFValue to a ClientPath of a file to be downloaded.
grr/server/grr_response_server/flows/general/export.py
def CollectionItemToClientPath(item, client_id=None): """Converts given RDFValue to a ClientPath of a file to be downloaded.""" if isinstance(item, rdf_flows.GrrMessage): client_id = item.source item = item.payload elif isinstance(item, rdf_flow_objects.FlowResult): client_id = item.client_id item...
def CollectionItemToClientPath(item, client_id=None): """Converts given RDFValue to a ClientPath of a file to be downloaded.""" if isinstance(item, rdf_flows.GrrMessage): client_id = item.source item = item.payload elif isinstance(item, rdf_flow_objects.FlowResult): client_id = item.client_id item...
[ "Converts", "given", "RDFValue", "to", "a", "ClientPath", "of", "a", "file", "to", "be", "downloaded", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/export.py#L55-L78
[ "def", "CollectionItemToClientPath", "(", "item", ",", "client_id", "=", "None", ")", ":", "if", "isinstance", "(", "item", ",", "rdf_flows", ".", "GrrMessage", ")", ":", "client_id", "=", "item", ".", "source", "item", "=", "item", ".", "payload", "elif",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetKnowledgeBase
Returns a knowledgebase from an rdf client object.
grr/server/grr_response_server/artifact.py
def GetKnowledgeBase(rdf_client_obj, allow_uninitialized=False): """Returns a knowledgebase from an rdf client object.""" if not allow_uninitialized: if rdf_client_obj is None: raise artifact_utils.KnowledgeBaseUninitializedError( "No client snapshot given.") if rdf_client_obj.knowledge_base...
def GetKnowledgeBase(rdf_client_obj, allow_uninitialized=False): """Returns a knowledgebase from an rdf client object.""" if not allow_uninitialized: if rdf_client_obj is None: raise artifact_utils.KnowledgeBaseUninitializedError( "No client snapshot given.") if rdf_client_obj.knowledge_base...
[ "Returns", "a", "knowledgebase", "from", "an", "rdf", "client", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact.py#L32-L58
[ "def", "GetKnowledgeBase", "(", "rdf_client_obj", ",", "allow_uninitialized", "=", "False", ")", ":", "if", "not", "allow_uninitialized", ":", "if", "rdf_client_obj", "is", "None", ":", "raise", "artifact_utils", ".", "KnowledgeBaseUninitializedError", "(", "\"No clie...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetArtifactKnowledgeBase
This generates an artifact knowledge base from a GRR client. Args: client_obj: A GRRClient object which is opened for reading. allow_uninitialized: If True we accept an uninitialized knowledge_base. Returns: A KnowledgeBase semantic value. Raises: ArtifactProcessingError: If called when the kno...
grr/server/grr_response_server/artifact.py
def GetArtifactKnowledgeBase(client_obj, allow_uninitialized=False): """This generates an artifact knowledge base from a GRR client. Args: client_obj: A GRRClient object which is opened for reading. allow_uninitialized: If True we accept an uninitialized knowledge_base. Returns: A KnowledgeBase sema...
def GetArtifactKnowledgeBase(client_obj, allow_uninitialized=False): """This generates an artifact knowledge base from a GRR client. Args: client_obj: A GRRClient object which is opened for reading. allow_uninitialized: If True we accept an uninitialized knowledge_base. Returns: A KnowledgeBase sema...
[ "This", "generates", "an", "artifact", "knowledge", "base", "from", "a", "GRR", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact.py#L61-L111
[ "def", "GetArtifactKnowledgeBase", "(", "client_obj", ",", "allow_uninitialized", "=", "False", ")", ":", "client_schema", "=", "client_obj", ".", "Schema", "kb", "=", "client_obj", ".", "Get", "(", "client_schema", ".", "KNOWLEDGE_BASE", ")", "if", "not", "allo...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SetCoreGRRKnowledgeBaseValues
Set core values from GRR into the knowledgebase.
grr/server/grr_response_server/artifact.py
def SetCoreGRRKnowledgeBaseValues(kb, client_obj): """Set core values from GRR into the knowledgebase.""" client_schema = client_obj.Schema kb.fqdn = utils.SmartUnicode(client_obj.Get(client_schema.FQDN, "")) if not kb.fqdn: kb.fqdn = utils.SmartUnicode(client_obj.Get(client_schema.HOSTNAME, "")) versions...
def SetCoreGRRKnowledgeBaseValues(kb, client_obj): """Set core values from GRR into the knowledgebase.""" client_schema = client_obj.Schema kb.fqdn = utils.SmartUnicode(client_obj.Get(client_schema.FQDN, "")) if not kb.fqdn: kb.fqdn = utils.SmartUnicode(client_obj.Get(client_schema.HOSTNAME, "")) versions...
[ "Set", "core", "values", "from", "GRR", "into", "the", "knowledgebase", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact.py#L114-L130
[ "def", "SetCoreGRRKnowledgeBaseValues", "(", "kb", ",", "client_obj", ")", ":", "client_schema", "=", "client_obj", ".", "Schema", "kb", ".", "fqdn", "=", "utils", ".", "SmartUnicode", "(", "client_obj", ".", "Get", "(", "client_schema", ".", "FQDN", ",", "\...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApplyParsersToResponses
Parse responses with applicable parsers. Args: parser_factory: A parser factory for specific artifact. responses: A list of responses from the client. flow_obj: An artifact collection flow. Returns: A list of (possibly parsed) responses.
grr/server/grr_response_server/artifact.py
def ApplyParsersToResponses(parser_factory, responses, flow_obj): """Parse responses with applicable parsers. Args: parser_factory: A parser factory for specific artifact. responses: A list of responses from the client. flow_obj: An artifact collection flow. Returns: A list of (possibly parsed) ...
def ApplyParsersToResponses(parser_factory, responses, flow_obj): """Parse responses with applicable parsers. Args: parser_factory: A parser factory for specific artifact. responses: A list of responses from the client. flow_obj: An artifact collection flow. Returns: A list of (possibly parsed) ...
[ "Parse", "responses", "with", "applicable", "parsers", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact.py#L404-L458
[ "def", "ApplyParsersToResponses", "(", "parser_factory", ",", "responses", ",", "flow_obj", ")", ":", "# We have some processors to run.", "knowledge_base", "=", "flow_obj", ".", "state", ".", "knowledge_base", "parsed_responses", "=", "[", "]", "if", "parser_factory", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UploadArtifactYamlFile
Upload a yaml or json file as an artifact to the datastore.
grr/server/grr_response_server/artifact.py
def UploadArtifactYamlFile(file_content, overwrite=True, overwrite_system_artifacts=False): """Upload a yaml or json file as an artifact to the datastore.""" loaded_artifacts = [] registry_obj = artifact_registry.REGISTRY # Make sure all artifacts are loaded...
def UploadArtifactYamlFile(file_content, overwrite=True, overwrite_system_artifacts=False): """Upload a yaml or json file as an artifact to the datastore.""" loaded_artifacts = [] registry_obj = artifact_registry.REGISTRY # Make sure all artifacts are loaded...
[ "Upload", "a", "yaml", "or", "json", "file", "as", "an", "artifact", "to", "the", "datastore", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact.py#L464-L514
[ "def", "UploadArtifactYamlFile", "(", "file_content", ",", "overwrite", "=", "True", ",", "overwrite_system_artifacts", "=", "False", ")", ":", "loaded_artifacts", "=", "[", "]", "registry_obj", "=", "artifact_registry", ".", "REGISTRY", "# Make sure all artifacts are l...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CallLoggedAndAccounted
Decorator to log and account for a DB call.
grr/server/grr_response_server/databases/db_utils.py
def CallLoggedAndAccounted(f): """Decorator to log and account for a DB call.""" @functools.wraps(f) def Decorator(*args, **kwargs): try: start_time = time.time() result = f(*args, **kwargs) latency = time.time() - start_time stats_collector_instance.Get().RecordEvent( "db_...
def CallLoggedAndAccounted(f): """Decorator to log and account for a DB call.""" @functools.wraps(f) def Decorator(*args, **kwargs): try: start_time = time.time() result = f(*args, **kwargs) latency = time.time() - start_time stats_collector_instance.Get().RecordEvent( "db_...
[ "Decorator", "to", "log", "and", "account", "for", "a", "DB", "call", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db_utils.py#L37-L65
[ "def", "CallLoggedAndAccounted", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "Decorator", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "start_time", "=", "time", ".", "time", "(", ")", "result", "="...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EscapeWildcards
Escapes wildcard characters for strings intended to be used with `LIKE`. Databases don't automatically escape wildcard characters ('%', '_'), so any non-literal string that is passed to `LIKE` and is expected to match literally has to be manually escaped. Args: string: A string to escape. Returns: ...
grr/server/grr_response_server/databases/db_utils.py
def EscapeWildcards(string): """Escapes wildcard characters for strings intended to be used with `LIKE`. Databases don't automatically escape wildcard characters ('%', '_'), so any non-literal string that is passed to `LIKE` and is expected to match literally has to be manually escaped. Args: string: A ...
def EscapeWildcards(string): """Escapes wildcard characters for strings intended to be used with `LIKE`. Databases don't automatically escape wildcard characters ('%', '_'), so any non-literal string that is passed to `LIKE` and is expected to match literally has to be manually escaped. Args: string: A ...
[ "Escapes", "wildcard", "characters", "for", "strings", "intended", "to", "be", "used", "with", "LIKE", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db_utils.py#L68-L82
[ "def", "EscapeWildcards", "(", "string", ")", ":", "precondition", ".", "AssertType", "(", "string", ",", "Text", ")", "return", "string", ".", "replace", "(", "\"%\"", ",", "r\"\\%\"", ")", ".", "replace", "(", "\"_\"", ",", "r\"\\_\"", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HuntIDToInt
Convert hunt id string to an integer.
grr/server/grr_response_server/databases/db_utils.py
def HuntIDToInt(hunt_id): """Convert hunt id string to an integer.""" # TODO(user): This code is only needed for a brief period of time when we # allow running new rel-db flows with old aff4-based hunts. In this scenario # parent_hunt_id is effectively not used, but it has to be an # integer. Stripping "H:" f...
def HuntIDToInt(hunt_id): """Convert hunt id string to an integer.""" # TODO(user): This code is only needed for a brief period of time when we # allow running new rel-db flows with old aff4-based hunts. In this scenario # parent_hunt_id is effectively not used, but it has to be an # integer. Stripping "H:" f...
[ "Convert", "hunt", "id", "string", "to", "an", "integer", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db_utils.py#L120-L133
[ "def", "HuntIDToInt", "(", "hunt_id", ")", ":", "# TODO(user): This code is only needed for a brief period of time when we", "# allow running new rel-db flows with old aff4-based hunts. In this scenario", "# parent_hunt_id is effectively not used, but it has to be an", "# integer. Stripping \"H:\"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.WriteClientMetadata
Write metadata about the client.
grr/server/grr_response_server/databases/mem_clients.py
def WriteClientMetadata(self, client_id, certificate=None, fleetspeak_enabled=None, first_seen=None, last_ping=None, last_clock=None, last...
def WriteClientMetadata(self, client_id, certificate=None, fleetspeak_enabled=None, first_seen=None, last_ping=None, last_clock=None, last...
[ "Write", "metadata", "about", "the", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L27-L62
[ "def", "WriteClientMetadata", "(", "self", ",", "client_id", ",", "certificate", "=", "None", ",", "fleetspeak_enabled", "=", "None", ",", "first_seen", "=", "None", ",", "last_ping", "=", "None", ",", "last_clock", "=", "None", ",", "last_ip", "=", "None", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.MultiReadClientMetadata
Reads ClientMetadata records for a list of clients.
grr/server/grr_response_server/databases/mem_clients.py
def MultiReadClientMetadata(self, client_ids): """Reads ClientMetadata records for a list of clients.""" res = {} for client_id in client_ids: md = self.metadatas.get(client_id, None) if md is None: continue res[client_id] = rdf_objects.ClientMetadata( certificate=md.get...
def MultiReadClientMetadata(self, client_ids): """Reads ClientMetadata records for a list of clients.""" res = {} for client_id in client_ids: md = self.metadatas.get(client_id, None) if md is None: continue res[client_id] = rdf_objects.ClientMetadata( certificate=md.get...
[ "Reads", "ClientMetadata", "records", "for", "a", "list", "of", "clients", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L65-L84
[ "def", "MultiReadClientMetadata", "(", "self", ",", "client_ids", ")", ":", "res", "=", "{", "}", "for", "client_id", "in", "client_ids", ":", "md", "=", "self", ".", "metadatas", ".", "get", "(", "client_id", ",", "None", ")", "if", "md", "is", "None"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.WriteClientSnapshot
Writes new client snapshot.
grr/server/grr_response_server/databases/mem_clients.py
def WriteClientSnapshot(self, snapshot): """Writes new client snapshot.""" client_id = snapshot.client_id if client_id not in self.metadatas: raise db.UnknownClientError(client_id) startup_info = snapshot.startup_info snapshot.startup_info = None ts = rdfvalue.RDFDatetime.Now() hist...
def WriteClientSnapshot(self, snapshot): """Writes new client snapshot.""" client_id = snapshot.client_id if client_id not in self.metadatas: raise db.UnknownClientError(client_id) startup_info = snapshot.startup_info snapshot.startup_info = None ts = rdfvalue.RDFDatetime.Now() hist...
[ "Writes", "new", "client", "snapshot", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L87-L104
[ "def", "WriteClientSnapshot", "(", "self", ",", "snapshot", ")", ":", "client_id", "=", "snapshot", ".", "client_id", "if", "client_id", "not", "in", "self", ".", "metadatas", ":", "raise", "db", ".", "UnknownClientError", "(", "client_id", ")", "startup_info"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.MultiReadClientSnapshot
Reads the latest client snapshots for a list of clients.
grr/server/grr_response_server/databases/mem_clients.py
def MultiReadClientSnapshot(self, client_ids): """Reads the latest client snapshots for a list of clients.""" res = {} for client_id in client_ids: history = self.clients.get(client_id, None) if not history: res[client_id] = None continue last_timestamp = max(history) ...
def MultiReadClientSnapshot(self, client_ids): """Reads the latest client snapshots for a list of clients.""" res = {} for client_id in client_ids: history = self.clients.get(client_id, None) if not history: res[client_id] = None continue last_timestamp = max(history) ...
[ "Reads", "the", "latest", "client", "snapshots", "for", "a", "list", "of", "clients", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L107-L123
[ "def", "MultiReadClientSnapshot", "(", "self", ",", "client_ids", ")", ":", "res", "=", "{", "}", "for", "client_id", "in", "client_ids", ":", "history", "=", "self", ".", "clients", ".", "get", "(", "client_id", ",", "None", ")", "if", "not", "history",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.MultiReadClientFullInfo
Reads full client information for a list of clients.
grr/server/grr_response_server/databases/mem_clients.py
def MultiReadClientFullInfo(self, client_ids, min_last_ping=None): """Reads full client information for a list of clients.""" res = {} for client_id in client_ids: try: md = self.ReadClientMetadata(client_id) except db.UnknownClientError: continue if md and min_last_ping a...
def MultiReadClientFullInfo(self, client_ids, min_last_ping=None): """Reads full client information for a list of clients.""" res = {} for client_id in client_ids: try: md = self.ReadClientMetadata(client_id) except db.UnknownClientError: continue if md and min_last_ping a...
[ "Reads", "full", "client", "information", "for", "a", "list", "of", "clients", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L126-L148
[ "def", "MultiReadClientFullInfo", "(", "self", ",", "client_ids", ",", "min_last_ping", "=", "None", ")", ":", "res", "=", "{", "}", "for", "client_id", "in", "client_ids", ":", "try", ":", "md", "=", "self", ".", "ReadClientMetadata", "(", "client_id", ")...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.ReadClientLastPings
Reads last-ping timestamps for clients in the DB.
grr/server/grr_response_server/databases/mem_clients.py
def ReadClientLastPings(self, min_last_ping=None, max_last_ping=None, fleetspeak_enabled=None): """Reads last-ping timestamps for clients in the DB.""" last_pings = {} for client_id, metadata in iteritems(self.metadatas): la...
def ReadClientLastPings(self, min_last_ping=None, max_last_ping=None, fleetspeak_enabled=None): """Reads last-ping timestamps for clients in the DB.""" last_pings = {} for client_id, metadata in iteritems(self.metadatas): la...
[ "Reads", "last", "-", "ping", "timestamps", "for", "clients", "in", "the", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L151-L169
[ "def", "ReadClientLastPings", "(", "self", ",", "min_last_ping", "=", "None", ",", "max_last_ping", "=", "None", ",", "fleetspeak_enabled", "=", "None", ")", ":", "last_pings", "=", "{", "}", "for", "client_id", ",", "metadata", "in", "iteritems", "(", "self...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.WriteClientSnapshotHistory
Writes the full history for a particular client.
grr/server/grr_response_server/databases/mem_clients.py
def WriteClientSnapshotHistory(self, clients): """Writes the full history for a particular client.""" if clients[0].client_id not in self.metadatas: raise db.UnknownClientError(clients[0].client_id) for client in clients: startup_info = client.startup_info client.startup_info = None ...
def WriteClientSnapshotHistory(self, clients): """Writes the full history for a particular client.""" if clients[0].client_id not in self.metadatas: raise db.UnknownClientError(clients[0].client_id) for client in clients: startup_info = client.startup_info client.startup_info = None ...
[ "Writes", "the", "full", "history", "for", "a", "particular", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L172-L187
[ "def", "WriteClientSnapshotHistory", "(", "self", ",", "clients", ")", ":", "if", "clients", "[", "0", "]", ".", "client_id", "not", "in", "self", ".", "metadatas", ":", "raise", "db", ".", "UnknownClientError", "(", "clients", "[", "0", "]", ".", "clien...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.ReadClientSnapshotHistory
Reads the full history for a particular client.
grr/server/grr_response_server/databases/mem_clients.py
def ReadClientSnapshotHistory(self, client_id, timerange=None): """Reads the full history for a particular client.""" from_time, to_time = self._ParseTimeRange(timerange) history = self.clients.get(client_id) if not history: return [] res = [] for ts in sorted(history, reverse=True): ...
def ReadClientSnapshotHistory(self, client_id, timerange=None): """Reads the full history for a particular client.""" from_time, to_time = self._ParseTimeRange(timerange) history = self.clients.get(client_id) if not history: return [] res = [] for ts in sorted(history, reverse=True): ...
[ "Reads", "the", "full", "history", "for", "a", "particular", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L190-L207
[ "def", "ReadClientSnapshotHistory", "(", "self", ",", "client_id", ",", "timerange", "=", "None", ")", ":", "from_time", ",", "to_time", "=", "self", ".", "_ParseTimeRange", "(", "timerange", ")", "history", "=", "self", ".", "clients", ".", "get", "(", "c...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.AddClientKeywords
Associates the provided keywords with the client.
grr/server/grr_response_server/databases/mem_clients.py
def AddClientKeywords(self, client_id, keywords): """Associates the provided keywords with the client.""" if client_id not in self.metadatas: raise db.UnknownClientError(client_id) for kw in keywords: self.keywords.setdefault(kw, {}) self.keywords[kw][client_id] = rdfvalue.RDFDatetime.Now...
def AddClientKeywords(self, client_id, keywords): """Associates the provided keywords with the client.""" if client_id not in self.metadatas: raise db.UnknownClientError(client_id) for kw in keywords: self.keywords.setdefault(kw, {}) self.keywords[kw][client_id] = rdfvalue.RDFDatetime.Now...
[ "Associates", "the", "provided", "keywords", "with", "the", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L210-L217
[ "def", "AddClientKeywords", "(", "self", ",", "client_id", ",", "keywords", ")", ":", "if", "client_id", "not", "in", "self", ".", "metadatas", ":", "raise", "db", ".", "UnknownClientError", "(", "client_id", ")", "for", "kw", "in", "keywords", ":", "self"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.ListClientsForKeywords
Lists the clients associated with keywords.
grr/server/grr_response_server/databases/mem_clients.py
def ListClientsForKeywords(self, keywords, start_time=None): """Lists the clients associated with keywords.""" res = {kw: [] for kw in keywords} for kw in keywords: for client_id, timestamp in iteritems(self.keywords.get(kw, {})): if start_time is not None and timestamp < start_time: ...
def ListClientsForKeywords(self, keywords, start_time=None): """Lists the clients associated with keywords.""" res = {kw: [] for kw in keywords} for kw in keywords: for client_id, timestamp in iteritems(self.keywords.get(kw, {})): if start_time is not None and timestamp < start_time: ...
[ "Lists", "the", "clients", "associated", "with", "keywords", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L220-L228
[ "def", "ListClientsForKeywords", "(", "self", ",", "keywords", ",", "start_time", "=", "None", ")", ":", "res", "=", "{", "kw", ":", "[", "]", "for", "kw", "in", "keywords", "}", "for", "kw", "in", "keywords", ":", "for", "client_id", ",", "timestamp",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.RemoveClientKeyword
Removes the association of a particular client to a keyword.
grr/server/grr_response_server/databases/mem_clients.py
def RemoveClientKeyword(self, client_id, keyword): """Removes the association of a particular client to a keyword.""" if keyword in self.keywords and client_id in self.keywords[keyword]: del self.keywords[keyword][client_id]
def RemoveClientKeyword(self, client_id, keyword): """Removes the association of a particular client to a keyword.""" if keyword in self.keywords and client_id in self.keywords[keyword]: del self.keywords[keyword][client_id]
[ "Removes", "the", "association", "of", "a", "particular", "client", "to", "a", "keyword", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L231-L234
[ "def", "RemoveClientKeyword", "(", "self", ",", "client_id", ",", "keyword", ")", ":", "if", "keyword", "in", "self", ".", "keywords", "and", "client_id", "in", "self", ".", "keywords", "[", "keyword", "]", ":", "del", "self", ".", "keywords", "[", "keyw...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.AddClientLabels
Attaches a user label to a client.
grr/server/grr_response_server/databases/mem_clients.py
def AddClientLabels(self, client_id, owner, labels): """Attaches a user label to a client.""" if client_id not in self.metadatas: raise db.UnknownClientError(client_id) labelset = self.labels.setdefault(client_id, {}).setdefault(owner, set()) for l in labels: labelset.add(utils.SmartUnicode...
def AddClientLabels(self, client_id, owner, labels): """Attaches a user label to a client.""" if client_id not in self.metadatas: raise db.UnknownClientError(client_id) labelset = self.labels.setdefault(client_id, {}).setdefault(owner, set()) for l in labels: labelset.add(utils.SmartUnicode...
[ "Attaches", "a", "user", "label", "to", "a", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L237-L244
[ "def", "AddClientLabels", "(", "self", ",", "client_id", ",", "owner", ",", "labels", ")", ":", "if", "client_id", "not", "in", "self", ".", "metadatas", ":", "raise", "db", ".", "UnknownClientError", "(", "client_id", ")", "labelset", "=", "self", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.MultiReadClientLabels
Reads the user labels for a list of clients.
grr/server/grr_response_server/databases/mem_clients.py
def MultiReadClientLabels(self, client_ids): """Reads the user labels for a list of clients.""" res = {} for client_id in client_ids: res[client_id] = [] owner_dict = self.labels.get(client_id, {}) for owner, labels in iteritems(owner_dict): for l in labels: res[client_id...
def MultiReadClientLabels(self, client_ids): """Reads the user labels for a list of clients.""" res = {} for client_id in client_ids: res[client_id] = [] owner_dict = self.labels.get(client_id, {}) for owner, labels in iteritems(owner_dict): for l in labels: res[client_id...
[ "Reads", "the", "user", "labels", "for", "a", "list", "of", "clients", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L247-L257
[ "def", "MultiReadClientLabels", "(", "self", ",", "client_ids", ")", ":", "res", "=", "{", "}", "for", "client_id", "in", "client_ids", ":", "res", "[", "client_id", "]", "=", "[", "]", "owner_dict", "=", "self", ".", "labels", ".", "get", "(", "client...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.RemoveClientLabels
Removes a list of user labels from a given client.
grr/server/grr_response_server/databases/mem_clients.py
def RemoveClientLabels(self, client_id, owner, labels): """Removes a list of user labels from a given client.""" labelset = self.labels.setdefault(client_id, {}).setdefault(owner, set()) for l in labels: labelset.discard(utils.SmartUnicode(l))
def RemoveClientLabels(self, client_id, owner, labels): """Removes a list of user labels from a given client.""" labelset = self.labels.setdefault(client_id, {}).setdefault(owner, set()) for l in labels: labelset.discard(utils.SmartUnicode(l))
[ "Removes", "a", "list", "of", "user", "labels", "from", "a", "given", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L260-L264
[ "def", "RemoveClientLabels", "(", "self", ",", "client_id", ",", "owner", ",", "labels", ")", ":", "labelset", "=", "self", ".", "labels", ".", "setdefault", "(", "client_id", ",", "{", "}", ")", ".", "setdefault", "(", "owner", ",", "set", "(", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.ReadAllClientLabels
Lists all client labels known to the system.
grr/server/grr_response_server/databases/mem_clients.py
def ReadAllClientLabels(self): """Lists all client labels known to the system.""" result = set() for labels_dict in itervalues(self.labels): for owner, names in iteritems(labels_dict): for name in names: result.add(rdf_objects.ClientLabel(owner=owner, name=name)) return list(res...
def ReadAllClientLabels(self): """Lists all client labels known to the system.""" result = set() for labels_dict in itervalues(self.labels): for owner, names in iteritems(labels_dict): for name in names: result.add(rdf_objects.ClientLabel(owner=owner, name=name)) return list(res...
[ "Lists", "all", "client", "labels", "known", "to", "the", "system", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L267-L275
[ "def", "ReadAllClientLabels", "(", "self", ")", ":", "result", "=", "set", "(", ")", "for", "labels_dict", "in", "itervalues", "(", "self", ".", "labels", ")", ":", "for", "owner", ",", "names", "in", "iteritems", "(", "labels_dict", ")", ":", "for", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.WriteClientStartupInfo
Writes a new client startup record.
grr/server/grr_response_server/databases/mem_clients.py
def WriteClientStartupInfo(self, client_id, startup_info): """Writes a new client startup record.""" if client_id not in self.metadatas: raise db.UnknownClientError(client_id) ts = rdfvalue.RDFDatetime.Now() self.metadatas[client_id]["startup_info_timestamp"] = ts history = self.startup_histo...
def WriteClientStartupInfo(self, client_id, startup_info): """Writes a new client startup record.""" if client_id not in self.metadatas: raise db.UnknownClientError(client_id) ts = rdfvalue.RDFDatetime.Now() self.metadatas[client_id]["startup_info_timestamp"] = ts history = self.startup_histo...
[ "Writes", "a", "new", "client", "startup", "record", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L278-L286
[ "def", "WriteClientStartupInfo", "(", "self", ",", "client_id", ",", "startup_info", ")", ":", "if", "client_id", "not", "in", "self", ".", "metadatas", ":", "raise", "db", ".", "UnknownClientError", "(", "client_id", ")", "ts", "=", "rdfvalue", ".", "RDFDat...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.ReadClientStartupInfo
Reads the latest client startup record for a single client.
grr/server/grr_response_server/databases/mem_clients.py
def ReadClientStartupInfo(self, client_id): """Reads the latest client startup record for a single client.""" history = self.startup_history.get(client_id, None) if not history: return None ts = max(history) res = rdf_client.StartupInfo.FromSerializedString(history[ts]) res.timestamp = ts...
def ReadClientStartupInfo(self, client_id): """Reads the latest client startup record for a single client.""" history = self.startup_history.get(client_id, None) if not history: return None ts = max(history) res = rdf_client.StartupInfo.FromSerializedString(history[ts]) res.timestamp = ts...
[ "Reads", "the", "latest", "client", "startup", "record", "for", "a", "single", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L289-L298
[ "def", "ReadClientStartupInfo", "(", "self", ",", "client_id", ")", ":", "history", "=", "self", ".", "startup_history", ".", "get", "(", "client_id", ",", "None", ")", "if", "not", "history", ":", "return", "None", "ts", "=", "max", "(", "history", ")",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.ReadClientStartupInfoHistory
Reads the full startup history for a particular client.
grr/server/grr_response_server/databases/mem_clients.py
def ReadClientStartupInfoHistory(self, client_id, timerange=None): """Reads the full startup history for a particular client.""" from_time, to_time = self._ParseTimeRange(timerange) history = self.startup_history.get(client_id) if not history: return [] res = [] for ts in sorted(history, ...
def ReadClientStartupInfoHistory(self, client_id, timerange=None): """Reads the full startup history for a particular client.""" from_time, to_time = self._ParseTimeRange(timerange) history = self.startup_history.get(client_id) if not history: return [] res = [] for ts in sorted(history, ...
[ "Reads", "the", "full", "startup", "history", "for", "a", "particular", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L301-L316
[ "def", "ReadClientStartupInfoHistory", "(", "self", ",", "client_id", ",", "timerange", "=", "None", ")", ":", "from_time", ",", "to_time", "=", "self", ".", "_ParseTimeRange", "(", "timerange", ")", "history", "=", "self", ".", "startup_history", ".", "get", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.WriteClientCrashInfo
Writes a new client crash record.
grr/server/grr_response_server/databases/mem_clients.py
def WriteClientCrashInfo(self, client_id, crash_info): """Writes a new client crash record.""" if client_id not in self.metadatas: raise db.UnknownClientError(client_id) ts = rdfvalue.RDFDatetime.Now() self.metadatas[client_id]["last_crash_timestamp"] = ts history = self.crash_history.setdefa...
def WriteClientCrashInfo(self, client_id, crash_info): """Writes a new client crash record.""" if client_id not in self.metadatas: raise db.UnknownClientError(client_id) ts = rdfvalue.RDFDatetime.Now() self.metadatas[client_id]["last_crash_timestamp"] = ts history = self.crash_history.setdefa...
[ "Writes", "a", "new", "client", "crash", "record", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L319-L327
[ "def", "WriteClientCrashInfo", "(", "self", ",", "client_id", ",", "crash_info", ")", ":", "if", "client_id", "not", "in", "self", ".", "metadatas", ":", "raise", "db", ".", "UnknownClientError", "(", "client_id", ")", "ts", "=", "rdfvalue", ".", "RDFDatetim...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.ReadClientCrashInfo
Reads the latest client crash record for a single client.
grr/server/grr_response_server/databases/mem_clients.py
def ReadClientCrashInfo(self, client_id): """Reads the latest client crash record for a single client.""" history = self.crash_history.get(client_id, None) if not history: return None ts = max(history) res = rdf_client.ClientCrash.FromSerializedString(history[ts]) res.timestamp = ts r...
def ReadClientCrashInfo(self, client_id): """Reads the latest client crash record for a single client.""" history = self.crash_history.get(client_id, None) if not history: return None ts = max(history) res = rdf_client.ClientCrash.FromSerializedString(history[ts]) res.timestamp = ts r...
[ "Reads", "the", "latest", "client", "crash", "record", "for", "a", "single", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L330-L339
[ "def", "ReadClientCrashInfo", "(", "self", ",", "client_id", ")", ":", "history", "=", "self", ".", "crash_history", ".", "get", "(", "client_id", ",", "None", ")", "if", "not", "history", ":", "return", "None", "ts", "=", "max", "(", "history", ")", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.ReadClientCrashInfoHistory
Reads the full crash history for a particular client.
grr/server/grr_response_server/databases/mem_clients.py
def ReadClientCrashInfoHistory(self, client_id): """Reads the full crash history for a particular client.""" history = self.crash_history.get(client_id) if not history: return [] res = [] for ts in sorted(history, reverse=True): client_data = rdf_client.ClientCrash.FromSerializedString(h...
def ReadClientCrashInfoHistory(self, client_id): """Reads the full crash history for a particular client.""" history = self.crash_history.get(client_id) if not history: return [] res = [] for ts in sorted(history, reverse=True): client_data = rdf_client.ClientCrash.FromSerializedString(h...
[ "Reads", "the", "full", "crash", "history", "for", "a", "particular", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L342-L352
[ "def", "ReadClientCrashInfoHistory", "(", "self", ",", "client_id", ")", ":", "history", "=", "self", ".", "crash_history", ".", "get", "(", "client_id", ")", "if", "not", "history", ":", "return", "[", "]", "res", "=", "[", "]", "for", "ts", "in", "so...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.WriteClientStats
Stores a ClientStats instance.
grr/server/grr_response_server/databases/mem_clients.py
def WriteClientStats(self, client_id, stats): """Stores a ClientStats instance.""" if client_id not in self.ReadAllClientIDs(): raise db.UnknownClientError(client_id) self.client_stats[client_id][rdfvalue.RDFDatetime.Now()] = stats
def WriteClientStats(self, client_id, stats): """Stores a ClientStats instance.""" if client_id not in self.ReadAllClientIDs(): raise db.UnknownClientError(client_id) self.client_stats[client_id][rdfvalue.RDFDatetime.Now()] = stats
[ "Stores", "a", "ClientStats", "instance", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L355-L361
[ "def", "WriteClientStats", "(", "self", ",", "client_id", ",", "stats", ")", ":", "if", "client_id", "not", "in", "self", ".", "ReadAllClientIDs", "(", ")", ":", "raise", "db", ".", "UnknownClientError", "(", "client_id", ")", "self", ".", "client_stats", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.ReadClientStats
Reads ClientStats for a given client and time range.
grr/server/grr_response_server/databases/mem_clients.py
def ReadClientStats(self, client_id, min_timestamp, max_timestamp ): """Reads ClientStats for a given client and time range.""" results = [] for timestamp, stats in iteritems(self.client_stats[client_id]): if min_timestamp <= timestamp <...
def ReadClientStats(self, client_id, min_timestamp, max_timestamp ): """Reads ClientStats for a given client and time range.""" results = [] for timestamp, stats in iteritems(self.client_stats[client_id]): if min_timestamp <= timestamp <...
[ "Reads", "ClientStats", "for", "a", "given", "client", "and", "time", "range", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L364-L373
[ "def", "ReadClientStats", "(", "self", ",", "client_id", ",", "min_timestamp", ",", "max_timestamp", ")", ":", "results", "=", "[", "]", "for", "timestamp", ",", "stats", "in", "iteritems", "(", "self", ".", "client_stats", "[", "client_id", "]", ")", ":",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.DeleteOldClientStats
Deletes ClientStats older than a given timestamp.
grr/server/grr_response_server/databases/mem_clients.py
def DeleteOldClientStats(self, yield_after_count, retention_time ): """Deletes ClientStats older than a given timestamp.""" deleted_count = 0 yielded = False for stats_dict in itervalues(self.client_stats): for timestamp in list(stats_dict.keys...
def DeleteOldClientStats(self, yield_after_count, retention_time ): """Deletes ClientStats older than a given timestamp.""" deleted_count = 0 yielded = False for stats_dict in itervalues(self.client_stats): for timestamp in list(stats_dict.keys...
[ "Deletes", "ClientStats", "older", "than", "a", "given", "timestamp", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L376-L395
[ "def", "DeleteOldClientStats", "(", "self", ",", "yield_after_count", ",", "retention_time", ")", ":", "deleted_count", "=", "0", "yielded", "=", "False", "for", "stats_dict", "in", "itervalues", "(", "self", ".", "client_stats", ")", ":", "for", "timestamp", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.CountClientVersionStringsByLabel
Computes client-activity stats for all GRR versions in the DB.
grr/server/grr_response_server/databases/mem_clients.py
def CountClientVersionStringsByLabel(self, day_buckets): """Computes client-activity stats for all GRR versions in the DB.""" def ExtractVersion(client_info): return client_info.last_snapshot.GetGRRVersionString() return self._CountClientStatisticByLabel(day_buckets, ExtractVersion)
def CountClientVersionStringsByLabel(self, day_buckets): """Computes client-activity stats for all GRR versions in the DB.""" def ExtractVersion(client_info): return client_info.last_snapshot.GetGRRVersionString() return self._CountClientStatisticByLabel(day_buckets, ExtractVersion)
[ "Computes", "client", "-", "activity", "stats", "for", "all", "GRR", "versions", "in", "the", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L398-L404
[ "def", "CountClientVersionStringsByLabel", "(", "self", ",", "day_buckets", ")", ":", "def", "ExtractVersion", "(", "client_info", ")", ":", "return", "client_info", ".", "last_snapshot", ".", "GetGRRVersionString", "(", ")", "return", "self", ".", "_CountClientStat...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.CountClientPlatformsByLabel
Computes client-activity stats for all client platforms in the DB.
grr/server/grr_response_server/databases/mem_clients.py
def CountClientPlatformsByLabel(self, day_buckets): """Computes client-activity stats for all client platforms in the DB.""" def ExtractPlatform(client_info): return client_info.last_snapshot.knowledge_base.os return self._CountClientStatisticByLabel(day_buckets, ExtractPlatform)
def CountClientPlatformsByLabel(self, day_buckets): """Computes client-activity stats for all client platforms in the DB.""" def ExtractPlatform(client_info): return client_info.last_snapshot.knowledge_base.os return self._CountClientStatisticByLabel(day_buckets, ExtractPlatform)
[ "Computes", "client", "-", "activity", "stats", "for", "all", "client", "platforms", "in", "the", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L407-L413
[ "def", "CountClientPlatformsByLabel", "(", "self", ",", "day_buckets", ")", ":", "def", "ExtractPlatform", "(", "client_info", ")", ":", "return", "client_info", ".", "last_snapshot", ".", "knowledge_base", ".", "os", "return", "self", ".", "_CountClientStatisticByL...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin.CountClientPlatformReleasesByLabel
Computes client-activity stats for OS-release strings in the DB.
grr/server/grr_response_server/databases/mem_clients.py
def CountClientPlatformReleasesByLabel(self, day_buckets): """Computes client-activity stats for OS-release strings in the DB.""" return self._CountClientStatisticByLabel( day_buckets, lambda client_info: client_info.last_snapshot.Uname())
def CountClientPlatformReleasesByLabel(self, day_buckets): """Computes client-activity stats for OS-release strings in the DB.""" return self._CountClientStatisticByLabel( day_buckets, lambda client_info: client_info.last_snapshot.Uname())
[ "Computes", "client", "-", "activity", "stats", "for", "OS", "-", "release", "strings", "in", "the", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L416-L419
[ "def", "CountClientPlatformReleasesByLabel", "(", "self", ",", "day_buckets", ")", ":", "return", "self", ".", "_CountClientStatisticByLabel", "(", "day_buckets", ",", "lambda", "client_info", ":", "client_info", ".", "last_snapshot", ".", "Uname", "(", ")", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBClientMixin._CountClientStatisticByLabel
Returns client-activity metrics for a particular statistic. Args: day_buckets: A set of n-day-active buckets. extract_statistic_fn: A function that extracts the statistic's value from a ClientFullInfo object.
grr/server/grr_response_server/databases/mem_clients.py
def _CountClientStatisticByLabel(self, day_buckets, extract_statistic_fn): """Returns client-activity metrics for a particular statistic. Args: day_buckets: A set of n-day-active buckets. extract_statistic_fn: A function that extracts the statistic's value from a ClientFullInfo object. ...
def _CountClientStatisticByLabel(self, day_buckets, extract_statistic_fn): """Returns client-activity metrics for a particular statistic. Args: day_buckets: A set of n-day-active buckets. extract_statistic_fn: A function that extracts the statistic's value from a ClientFullInfo object. ...
[ "Returns", "client", "-", "activity", "metrics", "for", "a", "particular", "statistic", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L421-L442
[ "def", "_CountClientStatisticByLabel", "(", "self", ",", "day_buckets", ",", "extract_statistic_fn", ")", ":", "counts", "=", "collections", ".", "defaultdict", "(", "int", ")", "now", "=", "rdfvalue", ".", "RDFDatetime", ".", "Now", "(", ")", "for", "info", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CreateServer
Start frontend http server.
grr/server/grr_response_server/bin/frontend.py
def CreateServer(frontend=None): """Start frontend http server.""" max_port = config.CONFIG.Get("Frontend.port_max", config.CONFIG["Frontend.bind_port"]) for port in range(config.CONFIG["Frontend.bind_port"], max_port + 1): server_address = (config.CONFIG["Frontend.bind_addres...
def CreateServer(frontend=None): """Start frontend http server.""" max_port = config.CONFIG.Get("Frontend.port_max", config.CONFIG["Frontend.bind_port"]) for port in range(config.CONFIG["Frontend.bind_port"], max_port + 1): server_address = (config.CONFIG["Frontend.bind_addres...
[ "Start", "frontend", "http", "server", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/frontend.py#L321-L341
[ "def", "CreateServer", "(", "frontend", "=", "None", ")", ":", "max_port", "=", "config", ".", "CONFIG", ".", "Get", "(", "\"Frontend.port_max\"", ",", "config", ".", "CONFIG", "[", "\"Frontend.bind_port\"", "]", ")", "for", "port", "in", "range", "(", "co...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
main
Main.
grr/server/grr_response_server/bin/frontend.py
def main(argv): """Main.""" del argv # Unused. if flags.FLAGS.version: print("GRR frontend {}".format(config_server.VERSION["packageversion"])) return config.CONFIG.AddContext("HTTPServer Context") server_startup.Init() httpd = CreateServer() server_startup.DropPrivileges() try: httpd...
def main(argv): """Main.""" del argv # Unused. if flags.FLAGS.version: print("GRR frontend {}".format(config_server.VERSION["packageversion"])) return config.CONFIG.AddContext("HTTPServer Context") server_startup.Init() httpd = CreateServer() server_startup.DropPrivileges() try: httpd...
[ "Main", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/frontend.py#L344-L363
[ "def", "main", "(", "argv", ")", ":", "del", "argv", "# Unused.", "if", "flags", ".", "FLAGS", ".", "version", ":", "print", "(", "\"GRR frontend {}\"", ".", "format", "(", "config_server", ".", "VERSION", "[", "\"packageversion\"", "]", ")", ")", "return"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHTTPServerHandler.Send
Sends a response to the client.
grr/server/grr_response_server/bin/frontend.py
def Send(self, data, status=200, ctype="application/octet-stream", additional_headers=None, last_modified=0): """Sends a response to the client.""" if additional_headers: additional_header_strings = [ "%s: %s\r\n" % (name, val) for...
def Send(self, data, status=200, ctype="application/octet-stream", additional_headers=None, last_modified=0): """Sends a response to the client.""" if additional_headers: additional_header_strings = [ "%s: %s\r\n" % (name, val) for...
[ "Sends", "a", "response", "to", "the", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/frontend.py#L76-L101
[ "def", "Send", "(", "self", ",", "data", ",", "status", "=", "200", ",", "ctype", "=", "\"application/octet-stream\"", ",", "additional_headers", "=", "None", ",", "last_modified", "=", "0", ")", ":", "if", "additional_headers", ":", "additional_header_strings",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHTTPServerHandler.do_GET
Serve the server pem with GET requests.
grr/server/grr_response_server/bin/frontend.py
def do_GET(self): # pylint: disable=g-bad-name """Serve the server pem with GET requests.""" self._IncrementActiveCount() try: if self.path.startswith("/server.pem"): stats_collector_instance.Get().IncrementCounter( "frontend_http_requests", fields=["cert", "http"]) self.S...
def do_GET(self): # pylint: disable=g-bad-name """Serve the server pem with GET requests.""" self._IncrementActiveCount() try: if self.path.startswith("/server.pem"): stats_collector_instance.Get().IncrementCounter( "frontend_http_requests", fields=["cert", "http"]) self.S...
[ "Serve", "the", "server", "pem", "with", "GET", "requests", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/frontend.py#L105-L118
[ "def", "do_GET", "(", "self", ")", ":", "# pylint: disable=g-bad-name", "self", ".", "_IncrementActiveCount", "(", ")", "try", ":", "if", "self", ".", "path", ".", "startswith", "(", "\"/server.pem\"", ")", ":", "stats_collector_instance", ".", "Get", "(", ")"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHTTPServerHandler._GenerateChunk
Generates data for a single chunk.
grr/server/grr_response_server/bin/frontend.py
def _GenerateChunk(self, length): """Generates data for a single chunk.""" while 1: to_read = min(length, self.RECV_BLOCK_SIZE) if to_read == 0: return data = self.rfile.read(to_read) if not data: return yield data length -= len(data)
def _GenerateChunk(self, length): """Generates data for a single chunk.""" while 1: to_read = min(length, self.RECV_BLOCK_SIZE) if to_read == 0: return data = self.rfile.read(to_read) if not data: return yield data length -= len(data)
[ "Generates", "data", "for", "a", "single", "chunk", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/frontend.py#L156-L169
[ "def", "_GenerateChunk", "(", "self", ",", "length", ")", ":", "while", "1", ":", "to_read", "=", "min", "(", "length", ",", "self", ".", "RECV_BLOCK_SIZE", ")", "if", "to_read", "==", "0", ":", "return", "data", "=", "self", ".", "rfile", ".", "read...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHTTPServerHandler.GenerateFileData
Generates the file data for a chunk encoded file.
grr/server/grr_response_server/bin/frontend.py
def GenerateFileData(self): """Generates the file data for a chunk encoded file.""" # Handle chunked encoding: # https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1 while 1: line = self.rfile.readline() # We do not support chunked extensions, just ignore them. chunk_size = ...
def GenerateFileData(self): """Generates the file data for a chunk encoded file.""" # Handle chunked encoding: # https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1 while 1: line = self.rfile.readline() # We do not support chunked extensions, just ignore them. chunk_size = ...
[ "Generates", "the", "file", "data", "for", "a", "chunk", "encoded", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/frontend.py#L171-L193
[ "def", "GenerateFileData", "(", "self", ")", ":", "# Handle chunked encoding:", "# https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1", "while", "1", ":", "line", "=", "self", ".", "rfile", ".", "readline", "(", ")", "# We do not support chunked extensions, just ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHTTPServerHandler.do_POST
Process encrypted message bundles.
grr/server/grr_response_server/bin/frontend.py
def do_POST(self): # pylint: disable=g-bad-name """Process encrypted message bundles.""" self._IncrementActiveCount() try: if self.path.startswith("/upload"): stats_collector_instance.Get().IncrementCounter( "frontend_http_requests", fields=["upload", "http"]) logging.err...
def do_POST(self): # pylint: disable=g-bad-name """Process encrypted message bundles.""" self._IncrementActiveCount() try: if self.path.startswith("/upload"): stats_collector_instance.Get().IncrementCounter( "frontend_http_requests", fields=["upload", "http"]) logging.err...
[ "Process", "encrypted", "message", "bundles", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/frontend.py#L195-L217
[ "def", "do_POST", "(", "self", ")", ":", "# pylint: disable=g-bad-name", "self", ".", "_IncrementActiveCount", "(", ")", "try", ":", "if", "self", ".", "path", ".", "startswith", "(", "\"/upload\"", ")", ":", "stats_collector_instance", ".", "Get", "(", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GRRHTTPServerHandler.Control
Handle POSTS.
grr/server/grr_response_server/bin/frontend.py
def Control(self): """Handle POSTS.""" # Get the api version try: api_version = int(urlparse.parse_qs(self.path.split("?")[1])["api"][0]) except (ValueError, KeyError, IndexError): # The oldest api version we support if not specified. api_version = 3 try: content_length = se...
def Control(self): """Handle POSTS.""" # Get the api version try: api_version = int(urlparse.parse_qs(self.path.split("?")[1])["api"][0]) except (ValueError, KeyError, IndexError): # The oldest api version we support if not specified. api_version = 3 try: content_length = se...
[ "Handle", "POSTS", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/frontend.py#L221-L280
[ "def", "Control", "(", "self", ")", ":", "# Get the api version", "try", ":", "api_version", "=", "int", "(", "urlparse", ".", "parse_qs", "(", "self", ".", "path", ".", "split", "(", "\"?\"", ")", "[", "1", "]", ")", "[", "\"api\"", "]", "[", "0", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Init
Initializes the Fleetspeak connector.
grr/server/grr_response_server/fleetspeak_connector.py
def Init(service_client=None): """Initializes the Fleetspeak connector.""" global CONN global label_map global unknown_label if service_client is None: service_client_cls = fs_client.InsecureGRPCServiceClient fleetspeak_message_listen_address = ( config.CONFIG["Server.fleetspeak_message_list...
def Init(service_client=None): """Initializes the Fleetspeak connector.""" global CONN global label_map global unknown_label if service_client is None: service_client_cls = fs_client.InsecureGRPCServiceClient fleetspeak_message_listen_address = ( config.CONFIG["Server.fleetspeak_message_list...
[ "Initializes", "the", "Fleetspeak", "connector", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/fleetspeak_connector.py#L19-L52
[ "def", "Init", "(", "service_client", "=", "None", ")", ":", "global", "CONN", "global", "label_map", "global", "unknown_label", "if", "service_client", "is", "None", ":", "service_client_cls", "=", "fs_client", ".", "InsecureGRPCServiceClient", "fleetspeak_message_li...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBSignedBinariesMixin.WriteSignedBinaryReferences
Writes blob references for a signed binary to the DB.
grr/server/grr_response_server/databases/mysql_signed_binaries.py
def WriteSignedBinaryReferences(self, binary_id, references, cursor=None): """Writes blob references for a signed binary to the DB.""" args = { "binary_type": binary_id.binary_type.Serialize...
def WriteSignedBinaryReferences(self, binary_id, references, cursor=None): """Writes blob references for a signed binary to the DB.""" args = { "binary_type": binary_id.binary_type.Serialize...
[ "Writes", "blob", "references", "for", "a", "signed", "binary", "to", "the", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_signed_binaries.py#L20-L43
[ "def", "WriteSignedBinaryReferences", "(", "self", ",", "binary_id", ",", "references", ",", "cursor", "=", "None", ")", ":", "args", "=", "{", "\"binary_type\"", ":", "binary_id", ".", "binary_type", ".", "SerializeToDataStore", "(", ")", ",", "\"binary_path\""...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBSignedBinariesMixin.ReadSignedBinaryReferences
Reads blob references for the signed binary with the given id.
grr/server/grr_response_server/databases/mysql_signed_binaries.py
def ReadSignedBinaryReferences( self, binary_id, cursor=None): """Reads blob references for the signed binary with the given id.""" cursor.execute( """ SELECT blob_references, UNIX_TIMESTAMP(timestamp) FROM signed_binary_references WHERE binary_type = %s AND binary_path_has...
def ReadSignedBinaryReferences( self, binary_id, cursor=None): """Reads blob references for the signed binary with the given id.""" cursor.execute( """ SELECT blob_references, UNIX_TIMESTAMP(timestamp) FROM signed_binary_references WHERE binary_type = %s AND binary_path_has...
[ "Reads", "blob", "references", "for", "the", "signed", "binary", "with", "the", "given", "id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_signed_binaries.py#L46-L71
[ "def", "ReadSignedBinaryReferences", "(", "self", ",", "binary_id", ",", "cursor", "=", "None", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\n SELECT blob_references, UNIX_TIMESTAMP(timestamp)\n FROM signed_binary_references\n WHERE binary_type = %s AND binary_path...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBSignedBinariesMixin.ReadIDsForAllSignedBinaries
Returns ids for all signed binaries in the DB.
grr/server/grr_response_server/databases/mysql_signed_binaries.py
def ReadIDsForAllSignedBinaries(self, cursor=None ): """Returns ids for all signed binaries in the DB.""" cursor.execute( "SELECT binary_type, binary_path FROM signed_binary_references") return [ rdf_objects.SignedBinaryID(binary_type=binary_type, path=binary...
def ReadIDsForAllSignedBinaries(self, cursor=None ): """Returns ids for all signed binaries in the DB.""" cursor.execute( "SELECT binary_type, binary_path FROM signed_binary_references") return [ rdf_objects.SignedBinaryID(binary_type=binary_type, path=binary...
[ "Returns", "ids", "for", "all", "signed", "binaries", "in", "the", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_signed_binaries.py#L74-L82
[ "def", "ReadIDsForAllSignedBinaries", "(", "self", ",", "cursor", "=", "None", ")", ":", "cursor", ".", "execute", "(", "\"SELECT binary_type, binary_path FROM signed_binary_references\"", ")", "return", "[", "rdf_objects", ".", "SignedBinaryID", "(", "binary_type", "="...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBSignedBinariesMixin.DeleteSignedBinaryReferences
Deletes blob references for the given signed binary from the DB.
grr/server/grr_response_server/databases/mysql_signed_binaries.py
def DeleteSignedBinaryReferences(self, binary_id, cursor=None): """Deletes blob references for the given signed binary from the DB.""" cursor.execute( """ DELETE FROM signed_binary_references WHERE binary_type = %s AND bin...
def DeleteSignedBinaryReferences(self, binary_id, cursor=None): """Deletes blob references for the given signed binary from the DB.""" cursor.execute( """ DELETE FROM signed_binary_references WHERE binary_type = %s AND bin...
[ "Deletes", "blob", "references", "for", "the", "given", "signed", "binary", "from", "the", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_signed_binaries.py#L85-L96
[ "def", "DeleteSignedBinaryReferences", "(", "self", ",", "binary_id", ",", "cursor", "=", "None", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\n DELETE FROM signed_binary_references\n WHERE binary_type = %s AND binary_path_hash = %s\n \"\"\"", ",", "[", "binary...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ListVolumeShadowCopies.Start
Query the client for available Volume Shadow Copies using a WMI query.
grr/server/grr_response_server/flows/general/windows_vsc.py
def Start(self): """Query the client for available Volume Shadow Copies using a WMI query.""" self.state.shadows = [] self.state.raw_device = None self.CallClient( server_stubs.WmiQuery, query="SELECT * FROM Win32_ShadowCopy", next_state="ListDeviceDirectories")
def Start(self): """Query the client for available Volume Shadow Copies using a WMI query.""" self.state.shadows = [] self.state.raw_device = None self.CallClient( server_stubs.WmiQuery, query="SELECT * FROM Win32_ShadowCopy", next_state="ListDeviceDirectories")
[ "Query", "the", "client", "for", "available", "Volume", "Shadow", "Copies", "using", "a", "WMI", "query", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/windows_vsc.py#L21-L29
[ "def", "Start", "(", "self", ")", ":", "self", ".", "state", ".", "shadows", "=", "[", "]", "self", ".", "state", ".", "raw_device", "=", "None", "self", ".", "CallClient", "(", "server_stubs", ".", "WmiQuery", ",", "query", "=", "\"SELECT * FROM Win32_S...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ListVolumeShadowCopies.ProcessListDirectory
Processes the results of the ListDirectory client action. Args: responses: a flow Responses object.
grr/server/grr_response_server/flows/general/windows_vsc.py
def ProcessListDirectory(self, responses): """Processes the results of the ListDirectory client action. Args: responses: a flow Responses object. """ if not responses.success: raise flow.FlowError("Unable to list directory.") with data_store.DB.GetMutationPool() as pool: for resp...
def ProcessListDirectory(self, responses): """Processes the results of the ListDirectory client action. Args: responses: a flow Responses object. """ if not responses.success: raise flow.FlowError("Unable to list directory.") with data_store.DB.GetMutationPool() as pool: for resp...
[ "Processes", "the", "results", "of", "the", "ListDirectory", "client", "action", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/windows_vsc.py#L61-L75
[ "def", "ProcessListDirectory", "(", "self", ",", "responses", ")", ":", "if", "not", "responses", ".", "success", ":", "raise", "flow", ".", "FlowError", "(", "\"Unable to list directory.\"", ")", "with", "data_store", ".", "DB", ".", "GetMutationPool", "(", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
LinuxReleaseParser.ParseMultiple
Parse the found release files.
grr/core/grr_response_core/lib/parsers/linux_release_parser.py
def ParseMultiple(self, stats, file_objects, knowledge_base): """Parse the found release files.""" _ = knowledge_base # Collate files into path: contents dictionary. found_files = self._Combine(stats, file_objects) # Determine collected files and apply weighting. weights = [w for w in self.WEI...
def ParseMultiple(self, stats, file_objects, knowledge_base): """Parse the found release files.""" _ = knowledge_base # Collate files into path: contents dictionary. found_files = self._Combine(stats, file_objects) # Determine collected files and apply weighting. weights = [w for w in self.WEI...
[ "Parse", "the", "found", "release", "files", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_release_parser.py#L177-L224
[ "def", "ParseMultiple", "(", "self", ",", "stats", ",", "file_objects", ",", "knowledge_base", ")", ":", "_", "=", "knowledge_base", "# Collate files into path: contents dictionary.", "found_files", "=", "self", ".", "_Combine", "(", "stats", ",", "file_objects", ")...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFX509Cert.Verify
Verifies the certificate using the given key. Args: public_key: The public key to use. Returns: True: Everything went well. Raises: VerificationError: The certificate did not verify.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def Verify(self, public_key): """Verifies the certificate using the given key. Args: public_key: The public key to use. Returns: True: Everything went well. Raises: VerificationError: The certificate did not verify. """ # TODO(amoser): We have to do this manually for now sin...
def Verify(self, public_key): """Verifies the certificate using the given key. Args: public_key: The public key to use. Returns: True: Everything went well. Raises: VerificationError: The certificate did not verify. """ # TODO(amoser): We have to do this manually for now sin...
[ "Verifies", "the", "certificate", "using", "the", "given", "key", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L132-L160
[ "def", "Verify", "(", "self", ",", "public_key", ")", ":", "# TODO(amoser): We have to do this manually for now since cryptography does", "# not yet support cert verification. There is PR 2460:", "# https://github.com/pyca/cryptography/pull/2460/files", "# that will add it, once it's in we sho...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFX509Cert.ClientCertFromCSR
Creates a new cert for the given common name. Args: csr: A CertificateSigningRequest. Returns: The signed cert.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def ClientCertFromCSR(cls, csr): """Creates a new cert for the given common name. Args: csr: A CertificateSigningRequest. Returns: The signed cert. """ builder = x509.CertificateBuilder() # Use the client CN for a cert serial_id. This will ensure we do # not have clashing cert ...
def ClientCertFromCSR(cls, csr): """Creates a new cert for the given common name. Args: csr: A CertificateSigningRequest. Returns: The signed cert. """ builder = x509.CertificateBuilder() # Use the client CN for a cert serial_id. This will ensure we do # not have clashing cert ...
[ "Creates", "a", "new", "cert", "for", "the", "given", "common", "name", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L163-L205
[ "def", "ClientCertFromCSR", "(", "cls", ",", "csr", ")", ":", "builder", "=", "x509", ".", "CertificateBuilder", "(", ")", "# Use the client CN for a cert serial_id. This will ensure we do", "# not have clashing cert id.", "common_name", "=", "csr", ".", "GetCN", "(", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RSAPublicKey.Verify
Verifies a given message.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def Verify(self, message, signature, hash_algorithm=None): """Verifies a given message.""" # This method accepts both PSS and PKCS1v15 padding. PSS is preferred but # old clients only support PKCS1v15. if hash_algorithm is None: hash_algorithm = hashes.SHA256() last_e = None for padding_...
def Verify(self, message, signature, hash_algorithm=None): """Verifies a given message.""" # This method accepts both PSS and PKCS1v15 padding. PSS is preferred but # old clients only support PKCS1v15. if hash_algorithm is None: hash_algorithm = hashes.SHA256() last_e = None for padding_...
[ "Verifies", "a", "given", "message", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L349-L372
[ "def", "Verify", "(", "self", ",", "message", ",", "signature", ",", "hash_algorithm", "=", "None", ")", ":", "# This method accepts both PSS and PKCS1v15 padding. PSS is preferred but", "# old clients only support PKCS1v15.", "if", "hash_algorithm", "is", "None", ":", "has...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RSAPrivateKey.Sign
Sign a given message.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def Sign(self, message, use_pss=False): """Sign a given message.""" precondition.AssertType(message, bytes) # TODO(amoser): This should use PSS by default at some point. if not use_pss: padding_algorithm = padding.PKCS1v15() else: padding_algorithm = padding.PSS( mgf=padding.M...
def Sign(self, message, use_pss=False): """Sign a given message.""" precondition.AssertType(message, bytes) # TODO(amoser): This should use PSS by default at some point. if not use_pss: padding_algorithm = padding.PKCS1v15() else: padding_algorithm = padding.PSS( mgf=padding.M...
[ "Sign", "a", "given", "message", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L402-L413
[ "def", "Sign", "(", "self", ",", "message", ",", "use_pss", "=", "False", ")", ":", "precondition", ".", "AssertType", "(", "message", ",", "bytes", ")", "# TODO(amoser): This should use PSS by default at some point.", "if", "not", "use_pss", ":", "padding_algorithm...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SignedBlob.Verify
Verify the data in this blob. Args: public_key: The public key to use for verification. Returns: True when verification succeeds. Raises: rdfvalue.DecodeError if the data is not suitable verified.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def Verify(self, public_key): """Verify the data in this blob. Args: public_key: The public key to use for verification. Returns: True when verification succeeds. Raises: rdfvalue.DecodeError if the data is not suitable verified. """ if self.digest_type != self.HashType.SHA2...
def Verify(self, public_key): """Verify the data in this blob. Args: public_key: The public key to use for verification. Returns: True when verification succeeds. Raises: rdfvalue.DecodeError if the data is not suitable verified. """ if self.digest_type != self.HashType.SHA2...
[ "Verify", "the", "data", "in", "this", "blob", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L535-L559
[ "def", "Verify", "(", "self", ",", "public_key", ")", ":", "if", "self", ".", "digest_type", "!=", "self", ".", "HashType", ".", "SHA256", ":", "raise", "rdfvalue", ".", "DecodeError", "(", "\"Unsupported digest.\"", ")", "if", "self", ".", "signature_type",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SignedBlob.Sign
Use the data to sign this blob. Args: data: String containing the blob data. signing_key: The key to sign with. verify_key: Key to verify with. If None we assume the signing key also contains the public key. Returns: self for call chaining.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def Sign(self, data, signing_key, verify_key=None): """Use the data to sign this blob. Args: data: String containing the blob data. signing_key: The key to sign with. verify_key: Key to verify with. If None we assume the signing key also contains the public key. Returns: se...
def Sign(self, data, signing_key, verify_key=None): """Use the data to sign this blob. Args: data: String containing the blob data. signing_key: The key to sign with. verify_key: Key to verify with. If None we assume the signing key also contains the public key. Returns: se...
[ "Use", "the", "data", "to", "sign", "this", "blob", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L561-L591
[ "def", "Sign", "(", "self", ",", "data", ",", "signing_key", ",", "verify_key", "=", "None", ")", ":", "if", "signing_key", ".", "KeyLen", "(", ")", "<", "2048", ":", "logging", ".", "warning", "(", "\"signing key is too short.\"", ")", "self", ".", "sig...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AES128CBCCipher.Encrypt
A convenience method which pads and encrypts at once.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def Encrypt(self, data): """A convenience method which pads and encrypts at once.""" encryptor = self.GetEncryptor() padded_data = self.Pad(data) try: return encryptor.update(padded_data) + encryptor.finalize() except ValueError as e: raise CipherError(e)
def Encrypt(self, data): """A convenience method which pads and encrypts at once.""" encryptor = self.GetEncryptor() padded_data = self.Pad(data) try: return encryptor.update(padded_data) + encryptor.finalize() except ValueError as e: raise CipherError(e)
[ "A", "convenience", "method", "which", "pads", "and", "encrypts", "at", "once", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L730-L738
[ "def", "Encrypt", "(", "self", ",", "data", ")", ":", "encryptor", "=", "self", ".", "GetEncryptor", "(", ")", "padded_data", "=", "self", ".", "Pad", "(", "data", ")", "try", ":", "return", "encryptor", ".", "update", "(", "padded_data", ")", "+", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AES128CBCCipher.Decrypt
A convenience method which pads and decrypts at once.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def Decrypt(self, data): """A convenience method which pads and decrypts at once.""" decryptor = self.GetDecryptor() try: padded_data = decryptor.update(data) + decryptor.finalize() return self.UnPad(padded_data) except ValueError as e: raise CipherError(e)
def Decrypt(self, data): """A convenience method which pads and decrypts at once.""" decryptor = self.GetDecryptor() try: padded_data = decryptor.update(data) + decryptor.finalize() return self.UnPad(padded_data) except ValueError as e: raise CipherError(e)
[ "A", "convenience", "method", "which", "pads", "and", "decrypts", "at", "once", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L745-L753
[ "def", "Decrypt", "(", "self", ",", "data", ")", ":", "decryptor", "=", "self", ".", "GetDecryptor", "(", ")", "try", ":", "padded_data", "=", "decryptor", ".", "update", "(", "data", ")", "+", "decryptor", ".", "finalize", "(", ")", "return", "self", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HMAC.HMAC
Calculates the HMAC for a given message.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def HMAC(self, message, use_sha256=False): """Calculates the HMAC for a given message.""" h = self._NewHMAC(use_sha256=use_sha256) h.update(message) return h.finalize()
def HMAC(self, message, use_sha256=False): """Calculates the HMAC for a given message.""" h = self._NewHMAC(use_sha256=use_sha256) h.update(message) return h.finalize()
[ "Calculates", "the", "HMAC", "for", "a", "given", "message", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L816-L820
[ "def", "HMAC", "(", "self", ",", "message", ",", "use_sha256", "=", "False", ")", ":", "h", "=", "self", ".", "_NewHMAC", "(", "use_sha256", "=", "use_sha256", ")", "h", ".", "update", "(", "message", ")", "return", "h", ".", "finalize", "(", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HMAC.Verify
Verifies the signature for a given message.
grr/core/grr_response_core/lib/rdfvalues/crypto.py
def Verify(self, message, signature): """Verifies the signature for a given message.""" siglen = len(signature) if siglen == 20: hash_algorithm = hashes.SHA1() elif siglen == 32: hash_algorithm = hashes.SHA256() else: raise VerificationError("Invalid signature length %d." % siglen)...
def Verify(self, message, signature): """Verifies the signature for a given message.""" siglen = len(signature) if siglen == 20: hash_algorithm = hashes.SHA1() elif siglen == 32: hash_algorithm = hashes.SHA256() else: raise VerificationError("Invalid signature length %d." % siglen)...
[ "Verifies", "the", "signature", "for", "a", "given", "message", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L822-L838
[ "def", "Verify", "(", "self", ",", "message", ",", "signature", ")", ":", "siglen", "=", "len", "(", "signature", ")", "if", "siglen", "==", "20", ":", "hash_algorithm", "=", "hashes", ".", "SHA1", "(", ")", "elif", "siglen", "==", "32", ":", "hash_a...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Aff4CollectionArchiveGenerator._ItemsToUrns
Converts collection items to aff4 urns suitable for downloading.
grr/server/grr_response_server/gui/archive_generator_aff4.py
def _ItemsToUrns(self, items): """Converts collection items to aff4 urns suitable for downloading.""" for item in items: try: yield flow_export.CollectionItemToAff4Path(item, self.client_id) except flow_export.ItemNotExportableError: pass
def _ItemsToUrns(self, items): """Converts collection items to aff4 urns suitable for downloading.""" for item in items: try: yield flow_export.CollectionItemToAff4Path(item, self.client_id) except flow_export.ItemNotExportableError: pass
[ "Converts", "collection", "items", "to", "aff4", "urns", "suitable", "for", "downloading", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/archive_generator_aff4.py#L88-L94
[ "def", "_ItemsToUrns", "(", "self", ",", "items", ")", ":", "for", "item", "in", "items", ":", "try", ":", "yield", "flow_export", ".", "CollectionItemToAff4Path", "(", "item", ",", "self", ".", "client_id", ")", "except", "flow_export", ".", "ItemNotExporta...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Aff4CollectionArchiveGenerator.Generate
Generates archive from a given collection. Iterates the collection and generates an archive by yielding contents of every referenced AFF4Stream. Args: items: Iterable with items that point to aff4 paths. token: User's ACLToken. Yields: Binary chunks comprising the generated archive.
grr/server/grr_response_server/gui/archive_generator_aff4.py
def Generate(self, items, token=None): """Generates archive from a given collection. Iterates the collection and generates an archive by yielding contents of every referenced AFF4Stream. Args: items: Iterable with items that point to aff4 paths. token: User's ACLToken. Yields: B...
def Generate(self, items, token=None): """Generates archive from a given collection. Iterates the collection and generates an archive by yielding contents of every referenced AFF4Stream. Args: items: Iterable with items that point to aff4 paths. token: User's ACLToken. Yields: B...
[ "Generates", "archive", "from", "a", "given", "collection", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/archive_generator_aff4.py#L137-L221
[ "def", "Generate", "(", "self", ",", "items", ",", "token", "=", "None", ")", ":", "clients", "=", "set", "(", ")", "for", "fd_urn_batch", "in", "collection", ".", "Batch", "(", "self", ".", "_ItemsToUrns", "(", "items", ")", ",", "self", ".", "BATCH...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiListArtifactsHandler.Handle
Get available artifact information for rendering.
grr/server/grr_response_server/gui/api_plugins/artifact.py
def Handle(self, args, token=None): """Get available artifact information for rendering.""" # Get all artifacts that aren't Bootstrap and aren't the base class. artifacts_list = sorted( artifact_registry.REGISTRY.GetArtifacts( reload_datastore_artifacts=True), key=lambda art: ar...
def Handle(self, args, token=None): """Get available artifact information for rendering.""" # Get all artifacts that aren't Bootstrap and aren't the base class. artifacts_list = sorted( artifact_registry.REGISTRY.GetArtifacts( reload_datastore_artifacts=True), key=lambda art: ar...
[ "Get", "available", "artifact", "information", "for", "rendering", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/artifact.py#L58-L75
[ "def", "Handle", "(", "self", ",", "args", ",", "token", "=", "None", ")", ":", "# Get all artifacts that aren't Bootstrap and aren't the base class.", "artifacts_list", "=", "sorted", "(", "artifact_registry", ".", "REGISTRY", ".", "GetArtifacts", "(", "reload_datastor...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PathSpec.Insert
Insert a single component at index.
grr/core/grr_response_core/lib/rdfvalues/paths.py
def Insert(self, index, rdfpathspec=None, **kwarg): """Insert a single component at index.""" if rdfpathspec is None: rdfpathspec = self.__class__(**kwarg) if index == 0: # Copy ourselves to a temp copy. nested_proto = self.__class__() nested_proto.SetRawData(self.GetRawData()) ...
def Insert(self, index, rdfpathspec=None, **kwarg): """Insert a single component at index.""" if rdfpathspec is None: rdfpathspec = self.__class__(**kwarg) if index == 0: # Copy ourselves to a temp copy. nested_proto = self.__class__() nested_proto.SetRawData(self.GetRawData()) ...
[ "Insert", "a", "single", "component", "at", "index", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/paths.py#L90-L108
[ "def", "Insert", "(", "self", ",", "index", ",", "rdfpathspec", "=", "None", ",", "*", "*", "kwarg", ")", ":", "if", "rdfpathspec", "is", "None", ":", "rdfpathspec", "=", "self", ".", "__class__", "(", "*", "*", "kwarg", ")", "if", "index", "==", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PathSpec.Append
Append a new pathspec component to this pathspec.
grr/core/grr_response_core/lib/rdfvalues/paths.py
def Append(self, component=None, **kwarg): """Append a new pathspec component to this pathspec.""" if component is None: component = self.__class__(**kwarg) if self.HasField("pathtype"): self.last.nested_path = component else: for k, v in iteritems(kwarg): setattr(self, k, v) ...
def Append(self, component=None, **kwarg): """Append a new pathspec component to this pathspec.""" if component is None: component = self.__class__(**kwarg) if self.HasField("pathtype"): self.last.nested_path = component else: for k, v in iteritems(kwarg): setattr(self, k, v) ...
[ "Append", "a", "new", "pathspec", "component", "to", "this", "pathspec", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/paths.py#L110-L123
[ "def", "Append", "(", "self", ",", "component", "=", "None", ",", "*", "*", "kwarg", ")", ":", "if", "component", "is", "None", ":", "component", "=", "self", ".", "__class__", "(", "*", "*", "kwarg", ")", "if", "self", ".", "HasField", "(", "\"pat...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PathSpec.Pop
Removes and returns the pathspec at the specified index.
grr/core/grr_response_core/lib/rdfvalues/paths.py
def Pop(self, index=0): """Removes and returns the pathspec at the specified index.""" if index < 0: index += len(self) if index == 0: result = self.__class__() result.SetRawData(self.GetRawData()) self.SetRawData(self.nested_path.GetRawData()) else: # Get the raw protob...
def Pop(self, index=0): """Removes and returns the pathspec at the specified index.""" if index < 0: index += len(self) if index == 0: result = self.__class__() result.SetRawData(self.GetRawData()) self.SetRawData(self.nested_path.GetRawData()) else: # Get the raw protob...
[ "Removes", "and", "returns", "the", "pathspec", "at", "the", "specified", "index", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/paths.py#L128-L150
[ "def", "Pop", "(", "self", ",", "index", "=", "0", ")", ":", "if", "index", "<", "0", ":", "index", "+=", "len", "(", "self", ")", "if", "index", "==", "0", ":", "result", "=", "self", ".", "__class__", "(", ")", "result", ".", "SetRawData", "(...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PathSpec.Dirname
Get a new copied object with only the directory path.
grr/core/grr_response_core/lib/rdfvalues/paths.py
def Dirname(self): """Get a new copied object with only the directory path.""" result = self.Copy() while 1: last_directory = posixpath.dirname(result.last.path) if last_directory != "/" or len(result) <= 1: result.last.path = last_directory # Make sure to clear the inode inform...
def Dirname(self): """Get a new copied object with only the directory path.""" result = self.Copy() while 1: last_directory = posixpath.dirname(result.last.path) if last_directory != "/" or len(result) <= 1: result.last.path = last_directory # Make sure to clear the inode inform...
[ "Get", "a", "new", "copied", "object", "with", "only", "the", "directory", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/paths.py#L164-L179
[ "def", "Dirname", "(", "self", ")", ":", "result", "=", "self", ".", "Copy", "(", ")", "while", "1", ":", "last_directory", "=", "posixpath", ".", "dirname", "(", "result", ".", "last", ".", "path", ")", "if", "last_directory", "!=", "\"/\"", "or", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PathSpec.AFF4Path
Returns the AFF4 URN this pathspec will be stored under. Args: client_urn: A ClientURN. Returns: A urn that corresponds to this pathspec. Raises: ValueError: If pathspec is not of the correct type.
grr/core/grr_response_core/lib/rdfvalues/paths.py
def AFF4Path(self, client_urn): """Returns the AFF4 URN this pathspec will be stored under. Args: client_urn: A ClientURN. Returns: A urn that corresponds to this pathspec. Raises: ValueError: If pathspec is not of the correct type. """ # If the first level is OS and the sec...
def AFF4Path(self, client_urn): """Returns the AFF4 URN this pathspec will be stored under. Args: client_urn: A ClientURN. Returns: A urn that corresponds to this pathspec. Raises: ValueError: If pathspec is not of the correct type. """ # If the first level is OS and the sec...
[ "Returns", "the", "AFF4", "URN", "this", "pathspec", "will", "be", "stored", "under", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/paths.py#L201-L261
[ "def", "AFF4Path", "(", "self", ",", "client_urn", ")", ":", "# If the first level is OS and the second level is TSK its probably a mount", "# point resolution. We map it into the tsk branch. For example if we get:", "# path: \\\\\\\\.\\\\Volume{1234}\\\\", "# pathtype: OS", "# mount_point: ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GlobExpression.Validate
GlobExpression is valid.
grr/core/grr_response_core/lib/rdfvalues/paths.py
def Validate(self): """GlobExpression is valid.""" if len(self.RECURSION_REGEX.findall(self._value)) > 1: raise ValueError("Only one ** is permitted per path: %s." % self._value)
def Validate(self): """GlobExpression is valid.""" if len(self.RECURSION_REGEX.findall(self._value)) > 1: raise ValueError("Only one ** is permitted per path: %s." % self._value)
[ "GlobExpression", "is", "valid", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/paths.py#L281-L284
[ "def", "Validate", "(", "self", ")", ":", "if", "len", "(", "self", ".", "RECURSION_REGEX", ".", "findall", "(", "self", ".", "_value", ")", ")", ">", "1", ":", "raise", "ValueError", "(", "\"Only one ** is permitted per path: %s.\"", "%", "self", ".", "_v...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74