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
OpenKey
This calls the Windows OpenKeyEx function in a Unicode safe way.
grr/client/grr_response_client/vfs_handlers/registry.py
def OpenKey(key, sub_key): """This calls the Windows OpenKeyEx function in a Unicode safe way.""" regopenkeyex = advapi32["RegOpenKeyExW"] regopenkeyex.restype = ctypes.c_long regopenkeyex.argtypes = [ ctypes.c_void_p, ctypes.c_wchar_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(ctypes.c_void_p)...
def OpenKey(key, sub_key): """This calls the Windows OpenKeyEx function in a Unicode safe way.""" regopenkeyex = advapi32["RegOpenKeyExW"] regopenkeyex.restype = ctypes.c_long regopenkeyex.argtypes = [ ctypes.c_void_p, ctypes.c_wchar_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(ctypes.c_void_p)...
[ "This", "calls", "the", "Windows", "OpenKeyEx", "function", "in", "a", "Unicode", "safe", "way", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/registry.py#L95-L113
[ "def", "OpenKey", "(", "key", ",", "sub_key", ")", ":", "regopenkeyex", "=", "advapi32", "[", "\"RegOpenKeyExW\"", "]", "regopenkeyex", ".", "restype", "=", "ctypes", ".", "c_long", "regopenkeyex", ".", "argtypes", "=", "[", "ctypes", ".", "c_void_p", ",", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
QueryInfoKey
This calls the Windows RegQueryInfoKey function in a Unicode safe way.
grr/client/grr_response_client/vfs_handlers/registry.py
def QueryInfoKey(key): """This calls the Windows RegQueryInfoKey function in a Unicode safe way.""" regqueryinfokey = advapi32["RegQueryInfoKeyW"] regqueryinfokey.restype = ctypes.c_long regqueryinfokey.argtypes = [ ctypes.c_void_p, ctypes.c_wchar_p, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDW...
def QueryInfoKey(key): """This calls the Windows RegQueryInfoKey function in a Unicode safe way.""" regqueryinfokey = advapi32["RegQueryInfoKeyW"] regqueryinfokey.restype = ctypes.c_long regqueryinfokey.argtypes = [ ctypes.c_void_p, ctypes.c_wchar_p, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDW...
[ "This", "calls", "the", "Windows", "RegQueryInfoKey", "function", "in", "a", "Unicode", "safe", "way", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/registry.py#L122-L146
[ "def", "QueryInfoKey", "(", "key", ")", ":", "regqueryinfokey", "=", "advapi32", "[", "\"RegQueryInfoKeyW\"", "]", "regqueryinfokey", ".", "restype", "=", "ctypes", ".", "c_long", "regqueryinfokey", ".", "argtypes", "=", "[", "ctypes", ".", "c_void_p", ",", "c...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
QueryValueEx
This calls the Windows QueryValueEx function in a Unicode safe way.
grr/client/grr_response_client/vfs_handlers/registry.py
def QueryValueEx(key, value_name): """This calls the Windows QueryValueEx function in a Unicode safe way.""" regqueryvalueex = advapi32["RegQueryValueExW"] regqueryvalueex.restype = ctypes.c_long regqueryvalueex.argtypes = [ ctypes.c_void_p, ctypes.c_wchar_p, LPDWORD, LPDWORD, LPBYTE, LPDWORD ] size ...
def QueryValueEx(key, value_name): """This calls the Windows QueryValueEx function in a Unicode safe way.""" regqueryvalueex = advapi32["RegQueryValueExW"] regqueryvalueex.restype = ctypes.c_long regqueryvalueex.argtypes = [ ctypes.c_void_p, ctypes.c_wchar_p, LPDWORD, LPDWORD, LPBYTE, LPDWORD ] size ...
[ "This", "calls", "the", "Windows", "QueryValueEx", "function", "in", "a", "Unicode", "safe", "way", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/registry.py#L149-L177
[ "def", "QueryValueEx", "(", "key", ",", "value_name", ")", ":", "regqueryvalueex", "=", "advapi32", "[", "\"RegQueryValueExW\"", "]", "regqueryvalueex", ".", "restype", "=", "ctypes", ".", "c_long", "regqueryvalueex", ".", "argtypes", "=", "[", "ctypes", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EnumKey
This calls the Windows RegEnumKeyEx function in a Unicode safe way.
grr/client/grr_response_client/vfs_handlers/registry.py
def EnumKey(key, index): """This calls the Windows RegEnumKeyEx function in a Unicode safe way.""" regenumkeyex = advapi32["RegEnumKeyExW"] regenumkeyex.restype = ctypes.c_long regenumkeyex.argtypes = [ ctypes.c_void_p, ctypes.wintypes.DWORD, ctypes.c_wchar_p, LPDWORD, LPDWORD, ctypes.c_wchar_p, LPD...
def EnumKey(key, index): """This calls the Windows RegEnumKeyEx function in a Unicode safe way.""" regenumkeyex = advapi32["RegEnumKeyExW"] regenumkeyex.restype = ctypes.c_long regenumkeyex.argtypes = [ ctypes.c_void_p, ctypes.wintypes.DWORD, ctypes.c_wchar_p, LPDWORD, LPDWORD, ctypes.c_wchar_p, LPD...
[ "This", "calls", "the", "Windows", "RegEnumKeyEx", "function", "in", "a", "Unicode", "safe", "way", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/registry.py#L180-L199
[ "def", "EnumKey", "(", "key", ",", "index", ")", ":", "regenumkeyex", "=", "advapi32", "[", "\"RegEnumKeyExW\"", "]", "regenumkeyex", ".", "restype", "=", "ctypes", ".", "c_long", "regenumkeyex", ".", "argtypes", "=", "[", "ctypes", ".", "c_void_p", ",", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
EnumValue
This calls the Windows RegEnumValue function in a Unicode safe way.
grr/client/grr_response_client/vfs_handlers/registry.py
def EnumValue(key, index): """This calls the Windows RegEnumValue function in a Unicode safe way.""" regenumvalue = advapi32["RegEnumValueW"] regenumvalue.restype = ctypes.c_long regenumvalue.argtypes = [ ctypes.c_void_p, ctypes.wintypes.DWORD, ctypes.c_wchar_p, LPDWORD, LPDWORD, LPDWORD, LPBYTE, LP...
def EnumValue(key, index): """This calls the Windows RegEnumValue function in a Unicode safe way.""" regenumvalue = advapi32["RegEnumValueW"] regenumvalue.restype = ctypes.c_long regenumvalue.argtypes = [ ctypes.c_void_p, ctypes.wintypes.DWORD, ctypes.c_wchar_p, LPDWORD, LPDWORD, LPDWORD, LPBYTE, LP...
[ "This", "calls", "the", "Windows", "RegEnumValue", "function", "in", "a", "Unicode", "safe", "way", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/registry.py#L202-L255
[ "def", "EnumValue", "(", "key", ",", "index", ")", ":", "regenumvalue", "=", "advapi32", "[", "\"RegEnumValueW\"", "]", "regenumvalue", ".", "restype", "=", "ctypes", ".", "c_long", "regenumvalue", ".", "argtypes", "=", "[", "ctypes", ".", "c_void_p", ",", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_Reg2Py
Converts a Windows Registry value to the corresponding Python data type.
grr/client/grr_response_client/vfs_handlers/registry.py
def _Reg2Py(data, size, data_type): """Converts a Windows Registry value to the corresponding Python data type.""" if data_type == winreg.REG_DWORD: if size == 0: return 0 # DWORD is an unsigned 32-bit integer, see: # https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/262627d8-34...
def _Reg2Py(data, size, data_type): """Converts a Windows Registry value to the corresponding Python data type.""" if data_type == winreg.REG_DWORD: if size == 0: return 0 # DWORD is an unsigned 32-bit integer, see: # https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/262627d8-34...
[ "Converts", "a", "Windows", "Registry", "value", "to", "the", "corresponding", "Python", "data", "type", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/registry.py#L258-L273
[ "def", "_Reg2Py", "(", "data", ",", "size", ",", "data_type", ")", ":", "if", "data_type", "==", "winreg", ".", "REG_DWORD", ":", "if", "size", "==", "0", ":", "return", "0", "# DWORD is an unsigned 32-bit integer, see:", "# https://docs.microsoft.com/en-us/openspec...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RegistryFile.ListNames
List the names of all keys and values.
grr/client/grr_response_client/vfs_handlers/registry.py
def ListNames(self): """List the names of all keys and values.""" # TODO: This check is flawed, because the current definition of # "IsDirectory" is the negation of "is a file". One registry path can # actually refer to a key ("directory"), a value of the same name ("file") # and the default value ...
def ListNames(self): """List the names of all keys and values.""" # TODO: This check is flawed, because the current definition of # "IsDirectory" is the negation of "is a file". One registry path can # actually refer to a key ("directory"), a value of the same name ("file") # and the default value ...
[ "List", "the", "names", "of", "all", "keys", "and", "values", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/registry.py#L405-L453
[ "def", "ListNames", "(", "self", ")", ":", "# TODO: This check is flawed, because the current definition of", "# \"IsDirectory\" is the negation of \"is a file\". One registry path can", "# actually refer to a key (\"directory\"), a value of the same name (\"file\")", "# and the default value of t...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RegistryFile.ListFiles
A generator of all keys and values.
grr/client/grr_response_client/vfs_handlers/registry.py
def ListFiles(self, ext_attrs=None): """A generator of all keys and values.""" del ext_attrs # Unused. if not self.IsDirectory(): return if self.hive is None: for name in dir(winreg): if name.startswith("HKEY_"): response = rdf_client_fs.StatEntry(st_mode=stat.S_IFDIR) ...
def ListFiles(self, ext_attrs=None): """A generator of all keys and values.""" del ext_attrs # Unused. if not self.IsDirectory(): return if self.hive is None: for name in dir(winreg): if name.startswith("HKEY_"): response = rdf_client_fs.StatEntry(st_mode=stat.S_IFDIR) ...
[ "A", "generator", "of", "all", "keys", "and", "values", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/registry.py#L455-L514
[ "def", "ListFiles", "(", "self", ",", "ext_attrs", "=", "None", ")", ":", "del", "ext_attrs", "# Unused.", "if", "not", "self", ".", "IsDirectory", "(", ")", ":", "return", "if", "self", ".", "hive", "is", "None", ":", "for", "name", "in", "dir", "("...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CreateAFF4Object
This creates a File or a Directory from a stat response.
grr/server/grr_response_server/flows/general/filesystem.py
def CreateAFF4Object(stat_response, client_id_urn, mutation_pool, token=None): """This creates a File or a Directory from a stat response.""" urn = stat_response.pathspec.AFF4Path(client_id_urn) if stat.S_ISDIR(stat_response.st_mode): ftype = standard.VFSDirectory else: ftype = aff4_grr.VFSFile wit...
def CreateAFF4Object(stat_response, client_id_urn, mutation_pool, token=None): """This creates a File or a Directory from a stat response.""" urn = stat_response.pathspec.AFF4Path(client_id_urn) if stat.S_ISDIR(stat_response.st_mode): ftype = standard.VFSDirectory else: ftype = aff4_grr.VFSFile wit...
[ "This", "creates", "a", "File", "or", "a", "Directory", "from", "a", "stat", "response", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L43-L56
[ "def", "CreateAFF4Object", "(", "stat_response", ",", "client_id_urn", ",", "mutation_pool", ",", "token", "=", "None", ")", ":", "urn", "=", "stat_response", ".", "pathspec", ".", "AFF4Path", "(", "client_id_urn", ")", "if", "stat", ".", "S_ISDIR", "(", "st...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_FilterOutPathInfoDuplicates
Filters out duplicates from passed PathInfo objects. Args: path_infos: An iterable with PathInfo objects. Returns: A list of PathInfo objects with duplicates removed. Duplicates are removed following this logic: they're sorted by (ctime, mtime, atime, inode number) in the descending order and then...
grr/server/grr_response_server/flows/general/filesystem.py
def _FilterOutPathInfoDuplicates(path_infos): """Filters out duplicates from passed PathInfo objects. Args: path_infos: An iterable with PathInfo objects. Returns: A list of PathInfo objects with duplicates removed. Duplicates are removed following this logic: they're sorted by (ctime, mtime, atime,...
def _FilterOutPathInfoDuplicates(path_infos): """Filters out duplicates from passed PathInfo objects. Args: path_infos: An iterable with PathInfo objects. Returns: A list of PathInfo objects with duplicates removed. Duplicates are removed following this logic: they're sorted by (ctime, mtime, atime,...
[ "Filters", "out", "duplicates", "from", "passed", "PathInfo", "objects", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L59-L89
[ "def", "_FilterOutPathInfoDuplicates", "(", "path_infos", ")", ":", "pi_dict", "=", "{", "}", "for", "pi", "in", "path_infos", ":", "path_key", "=", "(", "pi", ".", "path_type", ",", "pi", ".", "GetPathID", "(", ")", ")", "pi_dict", ".", "setdefault", "(...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WriteStatEntries
Persists information about stat entries. Args: stat_entries: A list of `StatEntry` instances. client_id: An id of a client the stat entries come from. mutation_pool: A mutation pool used for writing into the AFF4 data store. token: A token used for writing into the AFF4 data store.
grr/server/grr_response_server/flows/general/filesystem.py
def WriteStatEntries(stat_entries, client_id, mutation_pool, token=None): """Persists information about stat entries. Args: stat_entries: A list of `StatEntry` instances. client_id: An id of a client the stat entries come from. mutation_pool: A mutation pool used for writing into the AFF4 data store. ...
def WriteStatEntries(stat_entries, client_id, mutation_pool, token=None): """Persists information about stat entries. Args: stat_entries: A list of `StatEntry` instances. client_id: An id of a client the stat entries come from. mutation_pool: A mutation pool used for writing into the AFF4 data store. ...
[ "Persists", "information", "about", "stat", "entries", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L92-L132
[ "def", "WriteStatEntries", "(", "stat_entries", ",", "client_id", ",", "mutation_pool", ",", "token", "=", "None", ")", ":", "for", "stat_response", "in", "stat_entries", ":", "if", "stat_response", ".", "pathspec", ".", "last", ".", "stream_name", ":", "# Thi...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GlobLogic.GlobForPaths
Starts the Glob. This is the main entry point for this flow mixin. First we convert the pattern into regex components, and then we interpolate each component. Finally, we generate a cartesian product of all combinations. Args: paths: A list of GlobExpression instances. pathtype: The p...
grr/server/grr_response_server/flows/general/filesystem.py
def GlobForPaths(self, paths, pathtype="OS", root_path=None, process_non_regular_files=False, collect_ext_attrs=False): """Starts the Glob. This is the main entry point for this flow mixin. First we convert the ...
def GlobForPaths(self, paths, pathtype="OS", root_path=None, process_non_regular_files=False, collect_ext_attrs=False): """Starts the Glob. This is the main entry point for this flow mixin. First we convert the ...
[ "Starts", "the", "Glob", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L659-L736
[ "def", "GlobForPaths", "(", "self", ",", "paths", ",", "pathtype", "=", "\"OS\"", ",", "root_path", "=", "None", ",", "process_non_regular_files", "=", "False", ",", "collect_ext_attrs", "=", "False", ")", ":", "patterns", "=", "[", "]", "if", "not", "path...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GlobLogic.GlobReportMatch
Called when we've found a matching a StatEntry.
grr/server/grr_response_server/flows/general/filesystem.py
def GlobReportMatch(self, stat_response): """Called when we've found a matching a StatEntry.""" # By default write the stat_response to the AFF4 VFS. with data_store.DB.GetMutationPool() as pool: WriteStatEntries([stat_response], client_id=self.client_id, ...
def GlobReportMatch(self, stat_response): """Called when we've found a matching a StatEntry.""" # By default write the stat_response to the AFF4 VFS. with data_store.DB.GetMutationPool() as pool: WriteStatEntries([stat_response], client_id=self.client_id, ...
[ "Called", "when", "we", "ve", "found", "a", "matching", "a", "StatEntry", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L738-L745
[ "def", "GlobReportMatch", "(", "self", ",", "stat_response", ")", ":", "# By default write the stat_response to the AFF4 VFS.", "with", "data_store", ".", "DB", ".", "GetMutationPool", "(", ")", "as", "pool", ":", "WriteStatEntries", "(", "[", "stat_response", "]", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GlobLogic.ConvertGlobIntoPathComponents
r"""Converts a glob pattern into a list of pathspec components. Wildcards are also converted to regular expressions. The pathspec components do not span directories, and are marked as a regex or a literal component. We also support recursion into directories using the ** notation. For example, /home/...
grr/server/grr_response_server/flows/general/filesystem.py
def ConvertGlobIntoPathComponents(self, pattern): r"""Converts a glob pattern into a list of pathspec components. Wildcards are also converted to regular expressions. The pathspec components do not span directories, and are marked as a regex or a literal component. We also support recursion into direc...
def ConvertGlobIntoPathComponents(self, pattern): r"""Converts a glob pattern into a list of pathspec components. Wildcards are also converted to regular expressions. The pathspec components do not span directories, and are marked as a regex or a literal component. We also support recursion into direc...
[ "r", "Converts", "a", "glob", "pattern", "into", "a", "list", "of", "pathspec", "components", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L753-L812
[ "def", "ConvertGlobIntoPathComponents", "(", "self", ",", "pattern", ")", ":", "components", "=", "[", "]", "for", "path_component", "in", "pattern", ".", "split", "(", "\"/\"", ")", ":", "# A ** in the path component means recurse into directories that match the", "# p...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GlobLogic.FindNode
Find the node in the component_tree from component_path. Args: component_path: A list of components which reference a node in the component tree. This allows us to resume processing in the tree. Returns: A node in the component_tree.
grr/server/grr_response_server/flows/general/filesystem.py
def FindNode(self, component_path): """Find the node in the component_tree from component_path. Args: component_path: A list of components which reference a node in the component tree. This allows us to resume processing in the tree. Returns: A node in the component_tree. """ #...
def FindNode(self, component_path): """Find the node in the component_tree from component_path. Args: component_path: A list of components which reference a node in the component tree. This allows us to resume processing in the tree. Returns: A node in the component_tree. """ #...
[ "Find", "the", "node", "in", "the", "component_tree", "from", "component_path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L818-L833
[ "def", "FindNode", "(", "self", ",", "component_path", ")", ":", "# Find the node that the component path is referring to.", "node", "=", "self", ".", "state", ".", "component_tree", "for", "component", "in", "component_path", ":", "node", "=", "node", "[", "compone...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GlobLogic._MatchPath
Check if the responses matches the pathspec (considering options).
grr/server/grr_response_server/flows/general/filesystem.py
def _MatchPath(self, pathspec, response): """Check if the responses matches the pathspec (considering options).""" to_match = response.pathspec.Basename() if pathspec.path_options == rdf_paths.PathSpec.Options.CASE_INSENSITIVE: return to_match.lower() == pathspec.path.lower() elif pathspec.path_op...
def _MatchPath(self, pathspec, response): """Check if the responses matches the pathspec (considering options).""" to_match = response.pathspec.Basename() if pathspec.path_options == rdf_paths.PathSpec.Options.CASE_INSENSITIVE: return to_match.lower() == pathspec.path.lower() elif pathspec.path_op...
[ "Check", "if", "the", "responses", "matches", "the", "pathspec", "(", "considering", "options", ")", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L835-L846
[ "def", "_MatchPath", "(", "self", ",", "pathspec", ",", "response", ")", ":", "to_match", "=", "response", ".", "pathspec", ".", "Basename", "(", ")", "if", "pathspec", ".", "path_options", "==", "rdf_paths", ".", "PathSpec", ".", "Options", ".", "CASE_INS...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GlobLogic.ProcessEntry
Process the responses from the client.
grr/server/grr_response_server/flows/general/filesystem.py
def ProcessEntry(self, responses): """Process the responses from the client.""" if not responses.success: return # The Find client action does not return a StatEntry but a # FindSpec. Normalize to a StatEntry. stat_responses = [ r.hit if isinstance(r, rdf_client_fs.FindSpec) else r fo...
def ProcessEntry(self, responses): """Process the responses from the client.""" if not responses.success: return # The Find client action does not return a StatEntry but a # FindSpec. Normalize to a StatEntry. stat_responses = [ r.hit if isinstance(r, rdf_client_fs.FindSpec) else r fo...
[ "Process", "the", "responses", "from", "the", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L848-L887
[ "def", "ProcessEntry", "(", "self", ",", "responses", ")", ":", "if", "not", "responses", ".", "success", ":", "return", "# The Find client action does not return a StatEntry but a", "# FindSpec. Normalize to a StatEntry.", "stat_responses", "=", "[", "r", ".", "hit", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SQLiteFile.Query
Query the database file.
grr/core/grr_response_core/lib/parsers/sqlite_file.py
def Query(self, sql_query): """Query the database file.""" results = {} try: self._connection = sqlite.connect(self.name) self._connection.execute("PRAGMA journal_mode=%s" % self.journal_mode) self._cursor = self._connection.cursor() results = self._cursor.execute(sql_query).fetchal...
def Query(self, sql_query): """Query the database file.""" results = {} try: self._connection = sqlite.connect(self.name) self._connection.execute("PRAGMA journal_mode=%s" % self.journal_mode) self._cursor = self._connection.cursor() results = self._cursor.execute(sql_query).fetchal...
[ "Query", "the", "database", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/sqlite_file.py#L70-L83
[ "def", "Query", "(", "self", ",", "sql_query", ")", ":", "results", "=", "{", "}", "try", ":", "self", ".", "_connection", "=", "sqlite", ".", "connect", "(", "self", ".", "name", ")", "self", ".", "_connection", ".", "execute", "(", "\"PRAGMA journal_...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetClientURNsForHostnames
Gets all client_ids for a given list of hostnames or FQDNS. Args: hostnames: A list of hostnames / FQDNs. token: An ACL token. Returns: A dict with a list of all known GRR client_ids for each hostname.
grr/server/grr_response_server/client_index.py
def GetClientURNsForHostnames(hostnames, token=None): """Gets all client_ids for a given list of hostnames or FQDNS. Args: hostnames: A list of hostnames / FQDNs. token: An ACL token. Returns: A dict with a list of all known GRR client_ids for each hostname. """ if data_store.RelationalDBEnable...
def GetClientURNsForHostnames(hostnames, token=None): """Gets all client_ids for a given list of hostnames or FQDNS. Args: hostnames: A list of hostnames / FQDNs. token: An ACL token. Returns: A dict with a list of all known GRR client_ids for each hostname. """ if data_store.RelationalDBEnable...
[ "Gets", "all", "client_ids", "for", "a", "given", "list", "of", "hostnames", "or", "FQDNS", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L304-L331
[ "def", "GetClientURNsForHostnames", "(", "hostnames", ",", "token", "=", "None", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "index", "=", "ClientIndex", "(", ")", "else", ":", "index", "=", "CreateClientIndex", "(", "token", "="...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetMostRecentClient
Return most recent client from list of clients.
grr/server/grr_response_server/client_index.py
def GetMostRecentClient(client_list, token=None): """Return most recent client from list of clients.""" last = rdfvalue.RDFDatetime(0) client_urn = None for client in aff4.FACTORY.MultiOpen(client_list, token=token): client_last = client.Get(client.Schema.LAST) if client_last > last: last = client...
def GetMostRecentClient(client_list, token=None): """Return most recent client from list of clients.""" last = rdfvalue.RDFDatetime(0) client_urn = None for client in aff4.FACTORY.MultiOpen(client_list, token=token): client_last = client.Get(client.Schema.LAST) if client_last > last: last = client...
[ "Return", "most", "recent", "client", "from", "list", "of", "clients", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L334-L343
[ "def", "GetMostRecentClient", "(", "client_list", ",", "token", "=", "None", ")", ":", "last", "=", "rdfvalue", ".", "RDFDatetime", "(", "0", ")", "client_urn", "=", "None", "for", "client", "in", "aff4", ".", "FACTORY", ".", "MultiOpen", "(", "client_list...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BulkLabel
Assign a label to a group of clients based on hostname. Sets a label as an identifier to a group of clients. Removes the label from other clients. This can be used to automate labeling clients based on externally derived attributes, for example machines assigned to particular users, or machines fulfilling p...
grr/server/grr_response_server/client_index.py
def BulkLabel(label, hostnames, owner=None, token=None, client_index=None): """Assign a label to a group of clients based on hostname. Sets a label as an identifier to a group of clients. Removes the label from other clients. This can be used to automate labeling clients based on externally derived attribut...
def BulkLabel(label, hostnames, owner=None, token=None, client_index=None): """Assign a label to a group of clients based on hostname. Sets a label as an identifier to a group of clients. Removes the label from other clients. This can be used to automate labeling clients based on externally derived attribut...
[ "Assign", "a", "label", "to", "a", "group", "of", "clients", "based", "on", "hostname", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L556-L609
[ "def", "BulkLabel", "(", "label", ",", "hostnames", ",", "owner", "=", "None", ",", "token", "=", "None", ",", "client_index", "=", "None", ")", ":", "if", "client_index", "is", "None", ":", "client_index", "=", "CreateClientIndex", "(", "token", "=", "t...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AFF4ClientIndex.LookupClients
Returns a list of client URNs associated with keywords. Args: keywords: The list of keywords to search by. Returns: A list of client URNs. Raises: ValueError: A string (single keyword) was passed instead of an iterable.
grr/server/grr_response_server/client_index.py
def LookupClients(self, keywords): """Returns a list of client URNs associated with keywords. Args: keywords: The list of keywords to search by. Returns: A list of client URNs. Raises: ValueError: A string (single keyword) was passed instead of an iterable. """ if isinstance...
def LookupClients(self, keywords): """Returns a list of client URNs associated with keywords. Args: keywords: The list of keywords to search by. Returns: A list of client URNs. Raises: ValueError: A string (single keyword) was passed instead of an iterable. """ if isinstance...
[ "Returns", "a", "list", "of", "client", "URNs", "associated", "with", "keywords", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L92-L145
[ "def", "LookupClients", "(", "self", ",", "keywords", ")", ":", "if", "isinstance", "(", "keywords", ",", "string_types", ")", ":", "raise", "ValueError", "(", "\"Keywords should be an iterable, not a string (got %s).\"", "%", "keywords", ")", "start_time", ",", "en...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AFF4ClientIndex.ReadClientPostingLists
Looks up all clients associated with any of the given keywords. Args: keywords: A list of keywords we are interested in. Returns: A dict mapping each keyword to a list of matching clients.
grr/server/grr_response_server/client_index.py
def ReadClientPostingLists(self, keywords): """Looks up all clients associated with any of the given keywords. Args: keywords: A list of keywords we are interested in. Returns: A dict mapping each keyword to a list of matching clients. """ start_time, end_time, filtered_keywords, _ = ...
def ReadClientPostingLists(self, keywords): """Looks up all clients associated with any of the given keywords. Args: keywords: A list of keywords we are interested in. Returns: A dict mapping each keyword to a list of matching clients. """ start_time, end_time, filtered_keywords, _ = ...
[ "Looks", "up", "all", "clients", "associated", "with", "any", "of", "the", "given", "keywords", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L147-L164
[ "def", "ReadClientPostingLists", "(", "self", ",", "keywords", ")", ":", "start_time", ",", "end_time", ",", "filtered_keywords", ",", "_", "=", "self", ".", "_AnalyzeKeywords", "(", "keywords", ")", "# TODO(user): Make keyword index datetime aware so that", "# AsMicros...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AFF4ClientIndex.AnalyzeClient
Finds the client_id and keywords for a client. Args: client: A VFSGRRClient record to find keywords for. Returns: A tuple (client_id, keywords) where client_id is the client identifier and keywords is a list of keywords related to client.
grr/server/grr_response_server/client_index.py
def AnalyzeClient(self, client): """Finds the client_id and keywords for a client. Args: client: A VFSGRRClient record to find keywords for. Returns: A tuple (client_id, keywords) where client_id is the client identifier and keywords is a list of keywords related to client. """ cl...
def AnalyzeClient(self, client): """Finds the client_id and keywords for a client. Args: client: A VFSGRRClient record to find keywords for. Returns: A tuple (client_id, keywords) where client_id is the client identifier and keywords is a list of keywords related to client. """ cl...
[ "Finds", "the", "client_id", "and", "keywords", "for", "a", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L166-L273
[ "def", "AnalyzeClient", "(", "self", ",", "client", ")", ":", "client_id", "=", "self", ".", "_ClientIdFromURN", "(", "client", ".", "urn", ")", "# Start with both the client id itself, and a universal keyword, used to", "# find all clients.", "#", "# TODO(user): Remove the...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AFF4ClientIndex.AddClient
Adds a client to the index. Args: client: A VFSGRRClient record to add or update.
grr/server/grr_response_server/client_index.py
def AddClient(self, client): """Adds a client to the index. Args: client: A VFSGRRClient record to add or update. """ client_id, keywords = self.AnalyzeClient(client) self.AddKeywordsForName(client_id, keywords)
def AddClient(self, client): """Adds a client to the index. Args: client: A VFSGRRClient record to add or update. """ client_id, keywords = self.AnalyzeClient(client) self.AddKeywordsForName(client_id, keywords)
[ "Adds", "a", "client", "to", "the", "index", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L275-L283
[ "def", "AddClient", "(", "self", ",", "client", ")", ":", "client_id", ",", "keywords", "=", "self", ".", "AnalyzeClient", "(", "client", ")", "self", ".", "AddKeywordsForName", "(", "client_id", ",", "keywords", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
AFF4ClientIndex.RemoveClientLabels
Removes all labels for a given client object. Args: client: A VFSGRRClient record.
grr/server/grr_response_server/client_index.py
def RemoveClientLabels(self, client): """Removes all labels for a given client object. Args: client: A VFSGRRClient record. """ keywords = [] for label in client.GetLabelsNames(): keyword = self._NormalizeKeyword(utils.SmartStr(label)) # This might actually delete a keyword with t...
def RemoveClientLabels(self, client): """Removes all labels for a given client object. Args: client: A VFSGRRClient record. """ keywords = [] for label in client.GetLabelsNames(): keyword = self._NormalizeKeyword(utils.SmartStr(label)) # This might actually delete a keyword with t...
[ "Removes", "all", "labels", "for", "a", "given", "client", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L285-L301
[ "def", "RemoveClientLabels", "(", "self", ",", "client", ")", ":", "keywords", "=", "[", "]", "for", "label", "in", "client", ".", "GetLabelsNames", "(", ")", ":", "keyword", "=", "self", ".", "_NormalizeKeyword", "(", "utils", ".", "SmartStr", "(", "lab...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientIndex._AnalyzeKeywords
Extracts a start time from a list of keywords if present.
grr/server/grr_response_server/client_index.py
def _AnalyzeKeywords(self, keywords): """Extracts a start time from a list of keywords if present.""" start_time = rdfvalue.RDFDatetime.Now() - rdfvalue.Duration("180d") filtered_keywords = [] for k in keywords: if k.startswith(self.START_TIME_PREFIX): try: start_time = rdfvalue...
def _AnalyzeKeywords(self, keywords): """Extracts a start time from a list of keywords if present.""" start_time = rdfvalue.RDFDatetime.Now() - rdfvalue.Duration("180d") filtered_keywords = [] for k in keywords: if k.startswith(self.START_TIME_PREFIX): try: start_time = rdfvalue...
[ "Extracts", "a", "start", "time", "from", "a", "list", "of", "keywords", "if", "present", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L355-L373
[ "def", "_AnalyzeKeywords", "(", "self", ",", "keywords", ")", ":", "start_time", "=", "rdfvalue", ".", "RDFDatetime", ".", "Now", "(", ")", "-", "rdfvalue", ".", "Duration", "(", "\"180d\"", ")", "filtered_keywords", "=", "[", "]", "for", "k", "in", "key...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientIndex.LookupClients
Returns a list of client URNs associated with keywords. Args: keywords: The list of keywords to search by. Returns: A list of client URNs. Raises: ValueError: A string (single keyword) was passed instead of an iterable.
grr/server/grr_response_server/client_index.py
def LookupClients(self, keywords): """Returns a list of client URNs associated with keywords. Args: keywords: The list of keywords to search by. Returns: A list of client URNs. Raises: ValueError: A string (single keyword) was passed instead of an iterable. """ if isinstance...
def LookupClients(self, keywords): """Returns a list of client URNs associated with keywords. Args: keywords: The list of keywords to search by. Returns: A list of client URNs. Raises: ValueError: A string (single keyword) was passed instead of an iterable. """ if isinstance...
[ "Returns", "a", "list", "of", "client", "URNs", "associated", "with", "keywords", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L375-L406
[ "def", "LookupClients", "(", "self", ",", "keywords", ")", ":", "if", "isinstance", "(", "keywords", ",", "string_types", ")", ":", "raise", "ValueError", "(", "\"Keywords should be an iterable, not a string (got %s).\"", "%", "keywords", ")", "start_time", ",", "fi...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientIndex.ReadClientPostingLists
Looks up all clients associated with any of the given keywords. Args: keywords: A list of keywords we are interested in. Returns: A dict mapping each keyword to a list of matching clients.
grr/server/grr_response_server/client_index.py
def ReadClientPostingLists(self, keywords): """Looks up all clients associated with any of the given keywords. Args: keywords: A list of keywords we are interested in. Returns: A dict mapping each keyword to a list of matching clients. """ start_time, filtered_keywords = self._Analyze...
def ReadClientPostingLists(self, keywords): """Looks up all clients associated with any of the given keywords. Args: keywords: A list of keywords we are interested in. Returns: A dict mapping each keyword to a list of matching clients. """ start_time, filtered_keywords = self._Analyze...
[ "Looks", "up", "all", "clients", "associated", "with", "any", "of", "the", "given", "keywords", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L408-L421
[ "def", "ReadClientPostingLists", "(", "self", ",", "keywords", ")", ":", "start_time", ",", "filtered_keywords", "=", "self", ".", "_AnalyzeKeywords", "(", "keywords", ")", "return", "data_store", ".", "REL_DB", ".", "ListClientsForKeywords", "(", "filtered_keywords...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientIndex.AnalyzeClient
Finds the client_id and keywords for a client. Args: client: A Client object record to find keywords for. Returns: A list of keywords related to client.
grr/server/grr_response_server/client_index.py
def AnalyzeClient(self, client): """Finds the client_id and keywords for a client. Args: client: A Client object record to find keywords for. Returns: A list of keywords related to client. """ # Start with a universal keyword, used to find all clients. # # TODO(user): Remove t...
def AnalyzeClient(self, client): """Finds the client_id and keywords for a client. Args: client: A Client object record to find keywords for. Returns: A list of keywords related to client. """ # Start with a universal keyword, used to find all clients. # # TODO(user): Remove t...
[ "Finds", "the", "client_id", "and", "keywords", "for", "a", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L423-L508
[ "def", "AnalyzeClient", "(", "self", ",", "client", ")", ":", "# Start with a universal keyword, used to find all clients.", "#", "# TODO(user): Remove the universal keyword once we have a better way", "# to do this, i.e., once we have a storage library which can list all", "# clients direct...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientIndex.AddClient
Adds a client to the index. Args: client: A Client object record.
grr/server/grr_response_server/client_index.py
def AddClient(self, client): """Adds a client to the index. Args: client: A Client object record. """ keywords = self.AnalyzeClient(client) keywords.add(self._NormalizeKeyword(client.client_id)) data_store.REL_DB.AddClientKeywords(client.client_id, keywords)
def AddClient(self, client): """Adds a client to the index. Args: client: A Client object record. """ keywords = self.AnalyzeClient(client) keywords.add(self._NormalizeKeyword(client.client_id)) data_store.REL_DB.AddClientKeywords(client.client_id, keywords)
[ "Adds", "a", "client", "to", "the", "index", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L510-L519
[ "def", "AddClient", "(", "self", ",", "client", ")", ":", "keywords", "=", "self", ".", "AnalyzeClient", "(", "client", ")", "keywords", ".", "add", "(", "self", ".", "_NormalizeKeyword", "(", "client", ".", "client_id", ")", ")", "data_store", ".", "REL...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientIndex.RemoveAllClientLabels
Removes all labels for a given client. Args: client_id: The client_id.
grr/server/grr_response_server/client_index.py
def RemoveAllClientLabels(self, client_id): """Removes all labels for a given client. Args: client_id: The client_id. """ labels_to_remove = set( [l.name for l in data_store.REL_DB.ReadClientLabels(client_id)]) self.RemoveClientLabels(client_id, labels_to_remove)
def RemoveAllClientLabels(self, client_id): """Removes all labels for a given client. Args: client_id: The client_id. """ labels_to_remove = set( [l.name for l in data_store.REL_DB.ReadClientLabels(client_id)]) self.RemoveClientLabels(client_id, labels_to_remove)
[ "Removes", "all", "labels", "for", "a", "given", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L531-L539
[ "def", "RemoveAllClientLabels", "(", "self", ",", "client_id", ")", ":", "labels_to_remove", "=", "set", "(", "[", "l", ".", "name", "for", "l", "in", "data_store", ".", "REL_DB", ".", "ReadClientLabels", "(", "client_id", ")", "]", ")", "self", ".", "Re...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientIndex.RemoveClientLabels
Removes all labels for a given client. Args: client_id: The client_id. labels: A list of labels to remove.
grr/server/grr_response_server/client_index.py
def RemoveClientLabels(self, client_id, labels): """Removes all labels for a given client. Args: client_id: The client_id. labels: A list of labels to remove. """ for label in labels: keyword = self._NormalizeKeyword(label) # This might actually delete a keyword with the same na...
def RemoveClientLabels(self, client_id, labels): """Removes all labels for a given client. Args: client_id: The client_id. labels: A list of labels to remove. """ for label in labels: keyword = self._NormalizeKeyword(label) # This might actually delete a keyword with the same na...
[ "Removes", "all", "labels", "for", "a", "given", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L541-L553
[ "def", "RemoveClientLabels", "(", "self", ",", "client_id", ",", "labels", ")", ":", "for", "label", "in", "labels", ":", "keyword", "=", "self", ".", "_NormalizeKeyword", "(", "label", ")", "# This might actually delete a keyword with the same name as the label (if", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ServerCommunicator.VerifyMessageSignature
Verifies the message list signature. In the server we check that the timestamp is later than the ping timestamp stored with the client. This ensures that client responses can not be replayed. Args: response_comms: The raw response_comms rdfvalue. packed_message_list: The PackedMessageList ...
grr/server/grr_response_server/frontend_lib.py
def VerifyMessageSignature(self, response_comms, packed_message_list, cipher, cipher_verified, api_version, remote_public_key): """Verifies the message list signature. In the server we check that the timestamp is later than the ping timestamp stored with the client. This ensure...
def VerifyMessageSignature(self, response_comms, packed_message_list, cipher, cipher_verified, api_version, remote_public_key): """Verifies the message list signature. In the server we check that the timestamp is later than the ping timestamp stored with the client. This ensure...
[ "Verifies", "the", "message", "list", "signature", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/frontend_lib.py#L85-L191
[ "def", "VerifyMessageSignature", "(", "self", ",", "response_comms", ",", "packed_message_list", ",", "cipher", ",", "cipher_verified", ",", "api_version", ",", "remote_public_key", ")", ":", "if", "(", "not", "cipher_verified", "and", "not", "cipher", ".", "Verif...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RelationalServerCommunicator.VerifyMessageSignature
Verifies the message list signature. In the server we check that the timestamp is later than the ping timestamp stored with the client. This ensures that client responses can not be replayed. Args: response_comms: The raw response_comms rdfvalue. packed_message_list: The PackedMessageList ...
grr/server/grr_response_server/frontend_lib.py
def VerifyMessageSignature(self, response_comms, packed_message_list, cipher, cipher_verified, api_version, remote_public_key): """Verifies the message list signature. In the server we check that the timestamp is later than the ping timestamp stored with the client. This ensure...
def VerifyMessageSignature(self, response_comms, packed_message_list, cipher, cipher_verified, api_version, remote_public_key): """Verifies the message list signature. In the server we check that the timestamp is later than the ping timestamp stored with the client. This ensure...
[ "Verifies", "the", "message", "list", "signature", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/frontend_lib.py#L233-L316
[ "def", "VerifyMessageSignature", "(", "self", ",", "response_comms", ",", "packed_message_list", ",", "cipher", ",", "cipher_verified", ",", "api_version", ",", "remote_public_key", ")", ":", "if", "(", "not", "cipher_verified", "and", "not", "cipher", ".", "Verif...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FrontEndServer.HandleMessageBundles
Processes a queue of messages as passed from the client. We basically dispatch all the GrrMessages in the queue to the task scheduler for backend processing. We then retrieve from the TS the messages destined for this client. Args: request_comms: A ClientCommunication rdfvalue with messages sen...
grr/server/grr_response_server/frontend_lib.py
def HandleMessageBundles(self, request_comms, response_comms): """Processes a queue of messages as passed from the client. We basically dispatch all the GrrMessages in the queue to the task scheduler for backend processing. We then retrieve from the TS the messages destined for this client. Args: ...
def HandleMessageBundles(self, request_comms, response_comms): """Processes a queue of messages as passed from the client. We basically dispatch all the GrrMessages in the queue to the task scheduler for backend processing. We then retrieve from the TS the messages destined for this client. Args: ...
[ "Processes", "a", "queue", "of", "messages", "as", "passed", "from", "the", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/frontend_lib.py#L377-L422
[ "def", "HandleMessageBundles", "(", "self", ",", "request_comms", ",", "response_comms", ")", ":", "messages", ",", "source", ",", "timestamp", "=", "self", ".", "_communicator", ".", "DecodeMessages", "(", "request_comms", ")", "now", "=", "time", ".", "time"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FrontEndServer.DrainTaskSchedulerQueueForClient
Drains the client's Task Scheduler queue. 1) Get all messages in the client queue. 2) Sort these into a set of session_ids. 3) Use data_store.DB.ResolvePrefix() to query all requests. 4) Delete all responses for retransmitted messages (if needed). Args: client: The ClientURN object specifyi...
grr/server/grr_response_server/frontend_lib.py
def DrainTaskSchedulerQueueForClient(self, client, max_count=None): """Drains the client's Task Scheduler queue. 1) Get all messages in the client queue. 2) Sort these into a set of session_ids. 3) Use data_store.DB.ResolvePrefix() to query all requests. 4) Delete all responses for retransmitted me...
def DrainTaskSchedulerQueueForClient(self, client, max_count=None): """Drains the client's Task Scheduler queue. 1) Get all messages in the client queue. 2) Sort these into a set of session_ids. 3) Use data_store.DB.ResolvePrefix() to query all requests. 4) Delete all responses for retransmitted me...
[ "Drains", "the", "client", "s", "Task", "Scheduler", "queue", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/frontend_lib.py#L424-L493
[ "def", "DrainTaskSchedulerQueueForClient", "(", "self", ",", "client", ",", "max_count", "=", "None", ")", ":", "if", "max_count", "is", "None", ":", "max_count", "=", "self", ".", "max_queue_size", "if", "max_count", "<=", "0", ":", "return", "[", "]", "c...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FrontEndServer.EnrolFleetspeakClient
Enrols a Fleetspeak-enabled client for use with GRR. Args: client_id: GRR client-id for the client. Returns: True if the client is new, and actually got enrolled. This method is a no-op if the client already exists (in which case False is returned).
grr/server/grr_response_server/frontend_lib.py
def EnrolFleetspeakClient(self, client_id): """Enrols a Fleetspeak-enabled client for use with GRR. Args: client_id: GRR client-id for the client. Returns: True if the client is new, and actually got enrolled. This method is a no-op if the client already exists (in which case False is re...
def EnrolFleetspeakClient(self, client_id): """Enrols a Fleetspeak-enabled client for use with GRR. Args: client_id: GRR client-id for the client. Returns: True if the client is new, and actually got enrolled. This method is a no-op if the client already exists (in which case False is re...
[ "Enrols", "a", "Fleetspeak", "-", "enabled", "client", "for", "use", "with", "GRR", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/frontend_lib.py#L495-L549
[ "def", "EnrolFleetspeakClient", "(", "self", ",", "client_id", ")", ":", "client_urn", "=", "rdf_client", ".", "ClientURN", "(", "client_id", ")", "# If already enrolled, return.", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "try", ":", "data_st...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FrontEndServer.ReceiveMessagesRelationalFlows
Receives and processes messages for flows stored in the relational db. Args: client_id: The client which sent the messages. messages: A list of GrrMessage RDFValues.
grr/server/grr_response_server/frontend_lib.py
def ReceiveMessagesRelationalFlows(self, client_id, messages): """Receives and processes messages for flows stored in the relational db. Args: client_id: The client which sent the messages. messages: A list of GrrMessage RDFValues. """ now = time.time() unprocessed_msgs = [] message...
def ReceiveMessagesRelationalFlows(self, client_id, messages): """Receives and processes messages for flows stored in the relational db. Args: client_id: The client which sent the messages. messages: A list of GrrMessage RDFValues. """ now = time.time() unprocessed_msgs = [] message...
[ "Receives", "and", "processes", "messages", "for", "flows", "stored", "in", "the", "relational", "db", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/frontend_lib.py#L551-L616
[ "def", "ReceiveMessagesRelationalFlows", "(", "self", ",", "client_id", ",", "messages", ")", ":", "now", "=", "time", ".", "time", "(", ")", "unprocessed_msgs", "=", "[", "]", "message_handler_requests", "=", "[", "]", "dropped_count", "=", "0", "for", "ses...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FrontEndServer.ReceiveMessages
Receives and processes the messages from the source. For each message we update the request object, and place the response in that request's queue. If the request is complete, we send a message to the worker. Args: client_id: The client which sent the messages. messages: A list of GrrMessa...
grr/server/grr_response_server/frontend_lib.py
def ReceiveMessages(self, client_id, messages): """Receives and processes the messages from the source. For each message we update the request object, and place the response in that request's queue. If the request is complete, we send a message to the worker. Args: client_id: The client whic...
def ReceiveMessages(self, client_id, messages): """Receives and processes the messages from the source. For each message we update the request object, and place the response in that request's queue. If the request is complete, we send a message to the worker. Args: client_id: The client whic...
[ "Receives", "and", "processes", "the", "messages", "from", "the", "source", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/frontend_lib.py#L618-L690
[ "def", "ReceiveMessages", "(", "self", ",", "client_id", ",", "messages", ")", ":", "if", "data_store", ".", "RelationalDBEnabled", "(", ")", ":", "return", "self", ".", "ReceiveMessagesRelationalFlows", "(", "client_id", ",", "messages", ")", "now", "=", "tim...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
FrontEndServer.HandleWellKnownFlows
Hands off messages to well known flows.
grr/server/grr_response_server/frontend_lib.py
def HandleWellKnownFlows(self, messages): """Hands off messages to well known flows.""" msgs_by_wkf = {} result = [] for msg in messages: # Regular message - queue it. if msg.response_id != 0: result.append(msg) continue # Well known flows: flow_name = msg.sessio...
def HandleWellKnownFlows(self, messages): """Hands off messages to well known flows.""" msgs_by_wkf = {} result = [] for msg in messages: # Regular message - queue it. if msg.response_id != 0: result.append(msg) continue # Well known flows: flow_name = msg.sessio...
[ "Hands", "off", "messages", "to", "well", "known", "flows", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/frontend_lib.py#L692-L731
[ "def", "HandleWellKnownFlows", "(", "self", ",", "messages", ")", ":", "msgs_by_wkf", "=", "{", "}", "result", "=", "[", "]", "for", "msg", "in", "messages", ":", "# Regular message - queue it.", "if", "msg", ".", "response_id", "!=", "0", ":", "result", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ExecuteCommandFromClient
Executes one of the predefined commands. Args: command: An `ExecuteRequest` object. Yields: `rdf_client_action.ExecuteResponse` objects.
grr/client/grr_response_client/client_actions/standard.py
def ExecuteCommandFromClient(command): """Executes one of the predefined commands. Args: command: An `ExecuteRequest` object. Yields: `rdf_client_action.ExecuteResponse` objects. """ cmd = command.cmd args = command.args time_limit = command.time_limit res = client_utils_common.Execute(cmd, a...
def ExecuteCommandFromClient(command): """Executes one of the predefined commands. Args: command: An `ExecuteRequest` object. Yields: `rdf_client_action.ExecuteResponse` objects. """ cmd = command.cmd args = command.args time_limit = command.time_limit res = client_utils_common.Execute(cmd, a...
[ "Executes", "one", "of", "the", "predefined", "commands", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L203-L229
[ "def", "ExecuteCommandFromClient", "(", "command", ")", ":", "cmd", "=", "command", ".", "cmd", "args", "=", "command", ".", "args", "time_limit", "=", "command", ".", "time_limit", "res", "=", "client_utils_common", ".", "Execute", "(", "cmd", ",", "args", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StatFSFromClient
Call os.statvfs for a given list of paths. Args: args: An `rdf_client_action.StatFSRequest`. Yields: `rdf_client_fs.UnixVolume` instances. Raises: RuntimeError: if called on a Windows system.
grr/client/grr_response_client/client_actions/standard.py
def StatFSFromClient(args): """Call os.statvfs for a given list of paths. Args: args: An `rdf_client_action.StatFSRequest`. Yields: `rdf_client_fs.UnixVolume` instances. Raises: RuntimeError: if called on a Windows system. """ if platform.system() == "Windows": raise RuntimeError("os.stat...
def StatFSFromClient(args): """Call os.statvfs for a given list of paths. Args: args: An `rdf_client_action.StatFSRequest`. Yields: `rdf_client_fs.UnixVolume` instances. Raises: RuntimeError: if called on a Windows system. """ if platform.system() == "Windows": raise RuntimeError("os.stat...
[ "Call", "os", ".", "statvfs", "for", "a", "given", "list", "of", "paths", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L478-L513
[ "def", "StatFSFromClient", "(", "args", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "\"Windows\"", ":", "raise", "RuntimeError", "(", "\"os.statvfs not available on Windows\"", ")", "for", "path", "in", "args", ".", "path_list", ":", "try", ":",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ReadBuffer.Run
Reads a buffer on the client and sends it to the server.
grr/client/grr_response_client/client_actions/standard.py
def Run(self, args): """Reads a buffer on the client and sends it to the server.""" # Make sure we limit the size of our output if args.length > constants.CLIENT_MAX_BUFFER_SIZE: raise RuntimeError("Can not read buffers this large.") try: fd = vfs.VFSOpen(args.pathspec, progress_callback=se...
def Run(self, args): """Reads a buffer on the client and sends it to the server.""" # Make sure we limit the size of our output if args.length > constants.CLIENT_MAX_BUFFER_SIZE: raise RuntimeError("Can not read buffers this large.") try: fd = vfs.VFSOpen(args.pathspec, progress_callback=se...
[ "Reads", "a", "buffer", "on", "the", "client", "and", "sends", "it", "to", "the", "server", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L49-L70
[ "def", "Run", "(", "self", ",", "args", ")", ":", "# Make sure we limit the size of our output", "if", "args", ".", "length", ">", "constants", ".", "CLIENT_MAX_BUFFER_SIZE", ":", "raise", "RuntimeError", "(", "\"Can not read buffers this large.\"", ")", "try", ":", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TransferBuffer.Run
Reads a buffer on the client and sends it to the server.
grr/client/grr_response_client/client_actions/standard.py
def Run(self, args): """Reads a buffer on the client and sends it to the server.""" # Make sure we limit the size of our output if args.length > constants.CLIENT_MAX_BUFFER_SIZE: raise RuntimeError("Can not read buffers this large.") data = vfs.ReadVFS( args.pathspec, args.offset,...
def Run(self, args): """Reads a buffer on the client and sends it to the server.""" # Make sure we limit the size of our output if args.length > constants.CLIENT_MAX_BUFFER_SIZE: raise RuntimeError("Can not read buffers this large.") data = vfs.ReadVFS( args.pathspec, args.offset,...
[ "Reads", "a", "buffer", "on", "the", "client", "and", "sends", "it", "to", "the", "server", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L78-L108
[ "def", "Run", "(", "self", ",", "args", ")", ":", "# Make sure we limit the size of our output", "if", "args", ".", "length", ">", "constants", ".", "CLIENT_MAX_BUFFER_SIZE", ":", "raise", "RuntimeError", "(", "\"Can not read buffers this large.\"", ")", "data", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
HashBuffer.Run
Reads a buffer on the client and sends it to the server.
grr/client/grr_response_client/client_actions/standard.py
def Run(self, args): """Reads a buffer on the client and sends it to the server.""" # Make sure we limit the size of our output if args.length > constants.CLIENT_MAX_BUFFER_SIZE: raise RuntimeError("Can not read buffers this large.") data = vfs.ReadVFS(args.pathspec, args.offset, args.length) ...
def Run(self, args): """Reads a buffer on the client and sends it to the server.""" # Make sure we limit the size of our output if args.length > constants.CLIENT_MAX_BUFFER_SIZE: raise RuntimeError("Can not read buffers this large.") data = vfs.ReadVFS(args.pathspec, args.offset, args.length) ...
[ "Reads", "a", "buffer", "on", "the", "client", "and", "sends", "it", "to", "the", "server", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L116-L130
[ "def", "Run", "(", "self", ",", "args", ")", ":", "# Make sure we limit the size of our output", "if", "args", ".", "length", ">", "constants", ".", "CLIENT_MAX_BUFFER_SIZE", ":", "raise", "RuntimeError", "(", "\"Can not read buffers this large.\"", ")", "data", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ListDirectory.Run
Lists a directory.
grr/client/grr_response_client/client_actions/standard.py
def Run(self, args): """Lists a directory.""" try: directory = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress) except (IOError, OSError) as e: self.SetStatus(rdf_flows.GrrStatus.ReturnedStatus.IOERROR, e) return files = list(directory.ListFiles()) files.sort(key=lambda...
def Run(self, args): """Lists a directory.""" try: directory = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress) except (IOError, OSError) as e: self.SetStatus(rdf_flows.GrrStatus.ReturnedStatus.IOERROR, e) return files = list(directory.ListFiles()) files.sort(key=lambda...
[ "Lists", "a", "directory", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L167-L179
[ "def", "Run", "(", "self", ",", "args", ")", ":", "try", ":", "directory", "=", "vfs", ".", "VFSOpen", "(", "args", ".", "pathspec", ",", "progress_callback", "=", "self", ".", "Progress", ")", "except", "(", "IOError", ",", "OSError", ")", "as", "e"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ExecuteBinaryCommand.WriteBlobToFile
Writes the blob to a file and returns its path.
grr/client/grr_response_client/client_actions/standard.py
def WriteBlobToFile(self, request): """Writes the blob to a file and returns its path.""" # First chunk truncates the file, later chunks append. if request.offset == 0: mode = "w+b" else: mode = "r+b" temp_file = tempfiles.CreateGRRTempFile( filename=request.write_path, mode=mod...
def WriteBlobToFile(self, request): """Writes the blob to a file and returns its path.""" # First chunk truncates the file, later chunks append. if request.offset == 0: mode = "w+b" else: mode = "r+b" temp_file = tempfiles.CreateGRRTempFile( filename=request.write_path, mode=mod...
[ "Writes", "the", "blob", "to", "a", "file", "and", "returns", "its", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L260-L279
[ "def", "WriteBlobToFile", "(", "self", ",", "request", ")", ":", "# First chunk truncates the file, later chunks append.", "if", "request", ".", "offset", "==", "0", ":", "mode", "=", "\"w+b\"", "else", ":", "mode", "=", "\"r+b\"", "temp_file", "=", "tempfiles", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ExecuteBinaryCommand.CleanUp
Removes the temp file.
grr/client/grr_response_client/client_actions/standard.py
def CleanUp(self, path): """Removes the temp file.""" try: if os.path.exists(path): os.remove(path) except (OSError, IOError) as e: logging.info("Failed to remove temporary file %s. Err: %s", path, e)
def CleanUp(self, path): """Removes the temp file.""" try: if os.path.exists(path): os.remove(path) except (OSError, IOError) as e: logging.info("Failed to remove temporary file %s. Err: %s", path, e)
[ "Removes", "the", "temp", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L281-L287
[ "def", "CleanUp", "(", "self", ",", "path", ")", ":", "try", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "os", ".", "remove", "(", "path", ")", "except", "(", "OSError", ",", "IOError", ")", "as", "e", ":", "logging", "....
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ExecuteBinaryCommand.Run
Run.
grr/client/grr_response_client/client_actions/standard.py
def Run(self, args): """Run.""" # Verify the executable blob. args.executable.Verify( config.CONFIG["Client.executable_signing_public_key"]) path = self.WriteBlobToFile(args) # Only actually run the file on the last chunk. if not args.more_data: self.ProcessFile(path, args) ...
def Run(self, args): """Run.""" # Verify the executable blob. args.executable.Verify( config.CONFIG["Client.executable_signing_public_key"]) path = self.WriteBlobToFile(args) # Only actually run the file on the last chunk. if not args.more_data: self.ProcessFile(path, args) ...
[ "Run", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L289-L300
[ "def", "Run", "(", "self", ",", "args", ")", ":", "# Verify the executable blob.", "args", ".", "executable", ".", "Verify", "(", "config", ".", "CONFIG", "[", "\"Client.executable_signing_public_key\"", "]", ")", "path", "=", "self", ".", "WriteBlobToFile", "("...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ExecutePython.Run
Run.
grr/client/grr_response_client/client_actions/standard.py
def Run(self, args): """Run.""" time_start = time.time() args.python_code.Verify( config.CONFIG["Client.executable_signing_public_key"]) # The execed code can assign to this variable if it wants to return data. logging.debug("exec for python code %s", args.python_code.data[0:100]) con...
def Run(self, args): """Run.""" time_start = time.time() args.python_code.Verify( config.CONFIG["Client.executable_signing_public_key"]) # The execed code can assign to this variable if it wants to return data. logging.debug("exec for python code %s", args.python_code.data[0:100]) con...
[ "Run", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L332-L364
[ "def", "Run", "(", "self", ",", "args", ")", ":", "time_start", "=", "time", ".", "time", "(", ")", "args", ".", "python_code", ".", "Verify", "(", "config", ".", "CONFIG", "[", "\"Client.executable_signing_public_key\"", "]", ")", "# The execed code can assig...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Segfault.Run
Does the segfaulting.
grr/client/grr_response_client/client_actions/standard.py
def Run(self, unused_args): """Does the segfaulting.""" if flags.FLAGS.pdb_post_mortem: logging.warning("Segfault action requested :(") print(ctypes.cast(1, ctypes.POINTER(ctypes.c_void_p)).contents) else: logging.warning("Segfault requested but not running in debug mode.")
def Run(self, unused_args): """Does the segfaulting.""" if flags.FLAGS.pdb_post_mortem: logging.warning("Segfault action requested :(") print(ctypes.cast(1, ctypes.POINTER(ctypes.c_void_p)).contents) else: logging.warning("Segfault requested but not running in debug mode.")
[ "Does", "the", "segfaulting", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L390-L396
[ "def", "Run", "(", "self", ",", "unused_args", ")", ":", "if", "flags", ".", "FLAGS", ".", "pdb_post_mortem", ":", "logging", ".", "warning", "(", "\"Segfault action requested :(\"", ")", "print", "(", "ctypes", ".", "cast", "(", "1", ",", "ctypes", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SendFile.Run
Run.
grr/client/grr_response_client/client_actions/standard.py
def Run(self, args): """Run.""" # Open the file. fd = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress) if args.address_family == rdf_client_network.NetworkAddress.Family.INET: family = socket.AF_INET elif args.address_family == rdf_client_network.NetworkAddress.Family.INET6: ...
def Run(self, args): """Run.""" # Open the file. fd = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress) if args.address_family == rdf_client_network.NetworkAddress.Family.INET: family = socket.AF_INET elif args.address_family == rdf_client_network.NetworkAddress.Family.INET6: ...
[ "Run", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L440-L475
[ "def", "Run", "(", "self", ",", "args", ")", ":", "# Open the file.", "fd", "=", "vfs", ".", "VFSOpen", "(", "args", ".", "pathspec", ",", "progress_callback", "=", "self", ".", "Progress", ")", "if", "args", ".", "address_family", "==", "rdf_client_networ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Process.Regions
Returns an iterator over the readable regions for this process.
grr/client/grr_response_client/linux/process.py
def Regions(self, skip_mapped_files=False, skip_shared_regions=False, skip_executable_regions=False, skip_readonly_regions=False): """Returns an iterator over the readable regions for this process.""" try: maps_file = open("/proc/" + str(self.pid) + ...
def Regions(self, skip_mapped_files=False, skip_shared_regions=False, skip_executable_regions=False, skip_readonly_regions=False): """Returns an iterator over the readable regions for this process.""" try: maps_file = open("/proc/" + str(self.pid) + ...
[ "Returns", "an", "iterator", "over", "the", "readable", "regions", "for", "this", "process", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/linux/process.py#L90-L120
[ "def", "Regions", "(", "self", ",", "skip_mapped_files", "=", "False", ",", "skip_shared_regions", "=", "False", ",", "skip_executable_regions", "=", "False", ",", "skip_readonly_regions", "=", "False", ")", ":", "try", ":", "maps_file", "=", "open", "(", "\"/...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CopyFileInZip
Read a file from a ZipFile and write it to a new ZipFile.
grr/client_builder/grr_response_client_builder/build.py
def CopyFileInZip(from_zip, from_name, to_zip, to_name=None, signer=None): """Read a file from a ZipFile and write it to a new ZipFile.""" data = from_zip.read(from_name) if to_name is None: to_name = from_name if signer: logging.debug("Signing %s", from_name) data = signer.SignBuffer(data) to_zip...
def CopyFileInZip(from_zip, from_name, to_zip, to_name=None, signer=None): """Read a file from a ZipFile and write it to a new ZipFile.""" data = from_zip.read(from_name) if to_name is None: to_name = from_name if signer: logging.debug("Signing %s", from_name) data = signer.SignBuffer(data) to_zip...
[ "Read", "a", "file", "from", "a", "ZipFile", "and", "write", "it", "to", "a", "new", "ZipFile", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L1044-L1052
[ "def", "CopyFileInZip", "(", "from_zip", ",", "from_name", ",", "to_zip", ",", "to_name", "=", "None", ",", "signer", "=", "None", ")", ":", "data", "=", "from_zip", ".", "read", "(", "from_name", ")", "if", "to_name", "is", "None", ":", "to_name", "="...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CreateNewZipWithSignedLibs
Copies files from one zip to another, signing all qualifying files.
grr/client_builder/grr_response_client_builder/build.py
def CreateNewZipWithSignedLibs(z_in, z_out, ignore_files=None, signer=None, skip_signing_files=None): """Copies files from one zip to another, signing all qualifying files.""" ignore_files = i...
def CreateNewZipWithSignedLibs(z_in, z_out, ignore_files=None, signer=None, skip_signing_files=None): """Copies files from one zip to another, signing all qualifying files.""" ignore_files = i...
[ "Copies", "files", "from", "one", "zip", "to", "another", "signing", "all", "qualifying", "files", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L1055-L1088
[ "def", "CreateNewZipWithSignedLibs", "(", "z_in", ",", "z_out", ",", "ignore_files", "=", "None", ",", "signer", "=", "None", ",", "skip_signing_files", "=", "None", ")", ":", "ignore_files", "=", "ignore_files", "or", "[", "]", "skip_signing_files", "=", "ski...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SetPeSubsystem
Takes file like obj and returns (offset, value) for the PE subsystem.
grr/client_builder/grr_response_client_builder/build.py
def SetPeSubsystem(fd, console=True): """Takes file like obj and returns (offset, value) for the PE subsystem.""" current_pos = fd.tell() fd.seek(0x3c) # _IMAGE_DOS_HEADER.e_lfanew header_offset = struct.unpack("<I", fd.read(4))[0] # _IMAGE_NT_HEADERS.OptionalHeader.Subsystem ( 0x18 + 0x44) subsystem_offse...
def SetPeSubsystem(fd, console=True): """Takes file like obj and returns (offset, value) for the PE subsystem.""" current_pos = fd.tell() fd.seek(0x3c) # _IMAGE_DOS_HEADER.e_lfanew header_offset = struct.unpack("<I", fd.read(4))[0] # _IMAGE_NT_HEADERS.OptionalHeader.Subsystem ( 0x18 + 0x44) subsystem_offse...
[ "Takes", "file", "like", "obj", "and", "returns", "(", "offset", "value", ")", "for", "the", "PE", "subsystem", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L1091-L1103
[ "def", "SetPeSubsystem", "(", "fd", ",", "console", "=", "True", ")", ":", "current_pos", "=", "fd", ".", "tell", "(", ")", "fd", ".", "seek", "(", "0x3c", ")", "# _IMAGE_DOS_HEADER.e_lfanew", "header_offset", "=", "struct", ".", "unpack", "(", "\"<I\"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BuilderBase.GenerateFile
Generates a file from a template, interpolating config values.
grr/client_builder/grr_response_client_builder/build.py
def GenerateFile(self, input_filename=None, output_filename=None): """Generates a file from a template, interpolating config values.""" if input_filename is None: input_filename = output_filename + ".in" if output_filename[-3:] == ".in": output_filename = output_filename[:-3] logging.debug("...
def GenerateFile(self, input_filename=None, output_filename=None): """Generates a file from a template, interpolating config values.""" if input_filename is None: input_filename = output_filename + ".in" if output_filename[-3:] == ".in": output_filename = output_filename[:-3] logging.debug("...
[ "Generates", "a", "file", "from", "a", "template", "interpolating", "config", "values", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L91-L103
[ "def", "GenerateFile", "(", "self", ",", "input_filename", "=", "None", ",", "output_filename", "=", "None", ")", ":", "if", "input_filename", "is", "None", ":", "input_filename", "=", "output_filename", "+", "\".in\"", "if", "output_filename", "[", "-", "3", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBuilder.MakeBuildDirectory
Prepares the build directory.
grr/client_builder/grr_response_client_builder/build.py
def MakeBuildDirectory(self): """Prepares the build directory.""" # Create the build directory and let pyinstaller loose on it. self.build_dir = config.CONFIG.Get( "PyInstaller.build_dir", context=self.context) self.work_path = config.CONFIG.Get( "PyInstaller.workpath_dir", context=self....
def MakeBuildDirectory(self): """Prepares the build directory.""" # Create the build directory and let pyinstaller loose on it. self.build_dir = config.CONFIG.Get( "PyInstaller.build_dir", context=self.context) self.work_path = config.CONFIG.Get( "PyInstaller.workpath_dir", context=self....
[ "Prepares", "the", "build", "directory", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L124-L133
[ "def", "MakeBuildDirectory", "(", "self", ")", ":", "# Create the build directory and let pyinstaller loose on it.", "self", ".", "build_dir", "=", "config", ".", "CONFIG", ".", "Get", "(", "\"PyInstaller.build_dir\"", ",", "context", "=", "self", ".", "context", ")",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBuilder.BuildWithPyInstaller
Use pyinstaller to build a client package.
grr/client_builder/grr_response_client_builder/build.py
def BuildWithPyInstaller(self): """Use pyinstaller to build a client package.""" self.CleanDirectory( config.CONFIG.Get("PyInstaller.distpath", context=self.context)) logging.info("Copying pyinstaller support files") self.spec_file = os.path.join(self.build_dir, "grr.spec") with open(self....
def BuildWithPyInstaller(self): """Use pyinstaller to build a client package.""" self.CleanDirectory( config.CONFIG.Get("PyInstaller.distpath", context=self.context)) logging.info("Copying pyinstaller support files") self.spec_file = os.path.join(self.build_dir, "grr.spec") with open(self....
[ "Use", "pyinstaller", "to", "build", "a", "client", "package", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L144-L205
[ "def", "BuildWithPyInstaller", "(", "self", ")", ":", "self", ".", "CleanDirectory", "(", "config", ".", "CONFIG", ".", "Get", "(", "\"PyInstaller.distpath\"", ",", "context", "=", "self", ".", "context", ")", ")", "logging", ".", "info", "(", "\"Copying pyi...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBuilder.WriteBuildYaml
Write build spec to fd.
grr/client_builder/grr_response_client_builder/build.py
def WriteBuildYaml(self, fd, build_timestamp=True): """Write build spec to fd.""" output = { "Client.build_environment": rdf_client.Uname.FromCurrentSystem().signature(), "Template.build_type": config.CONFIG.Get("ClientBuilder.build_type", context=self.context), "...
def WriteBuildYaml(self, fd, build_timestamp=True): """Write build spec to fd.""" output = { "Client.build_environment": rdf_client.Uname.FromCurrentSystem().signature(), "Template.build_type": config.CONFIG.Get("ClientBuilder.build_type", context=self.context), "...
[ "Write", "build", "spec", "to", "fd", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L207-L240
[ "def", "WriteBuildYaml", "(", "self", ",", "fd", ",", "build_timestamp", "=", "True", ")", ":", "output", "=", "{", "\"Client.build_environment\"", ":", "rdf_client", ".", "Uname", ".", "FromCurrentSystem", "(", ")", ".", "signature", "(", ")", ",", "\"Templ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBuilder.MakeExecutableTemplate
Create the executable template. The client is built in two phases. First an executable template is created with the client binaries contained inside a zip file. Then the installation package is created by appending the SFX extractor to this template and writing a config file into the zip file. This te...
grr/client_builder/grr_response_client_builder/build.py
def MakeExecutableTemplate(self, output_file=None): """Create the executable template. The client is built in two phases. First an executable template is created with the client binaries contained inside a zip file. Then the installation package is created by appending the SFX extractor to this templat...
def MakeExecutableTemplate(self, output_file=None): """Create the executable template. The client is built in two phases. First an executable template is created with the client binaries contained inside a zip file. Then the installation package is created by appending the SFX extractor to this templat...
[ "Create", "the", "executable", "template", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L245-L262
[ "def", "MakeExecutableTemplate", "(", "self", ",", "output_file", "=", "None", ")", ":", "self", ".", "template_file", "=", "output_file", "or", "config", ".", "CONFIG", ".", "Get", "(", "\"ClientBuilder.template_path\"", ",", "context", "=", "self", ".", "con...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientBuilder.MakeZip
Creates a ZIP archive of the files in the input directory. Args: input_dir: the name of the input directory. output_file: the name of the output ZIP archive without extension.
grr/client_builder/grr_response_client_builder/build.py
def MakeZip(self, input_dir, output_file): """Creates a ZIP archive of the files in the input directory. Args: input_dir: the name of the input directory. output_file: the name of the output ZIP archive without extension. """ logging.info("Generating zip template file at %s", output_file) ...
def MakeZip(self, input_dir, output_file): """Creates a ZIP archive of the files in the input directory. Args: input_dir: the name of the input directory. output_file: the name of the output ZIP archive without extension. """ logging.info("Generating zip template file at %s", output_file) ...
[ "Creates", "a", "ZIP", "archive", "of", "the", "files", "in", "the", "input", "directory", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L264-L276
[ "def", "MakeZip", "(", "self", ",", "input_dir", ",", "output_file", ")", ":", "logging", ".", "info", "(", "\"Generating zip template file at %s\"", ",", "output_file", ")", "basename", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "output_file", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientRepacker.GetClientConfig
Generates the client config file for inclusion in deployable binaries.
grr/client_builder/grr_response_client_builder/build.py
def GetClientConfig(self, context, validate=True, deploy_timestamp=True): """Generates the client config file for inclusion in deployable binaries.""" with utils.TempDirectory() as tmp_dir: # Make sure we write the file in yaml format. filename = os.path.join( tmp_dir, config.CON...
def GetClientConfig(self, context, validate=True, deploy_timestamp=True): """Generates the client config file for inclusion in deployable binaries.""" with utils.TempDirectory() as tmp_dir: # Make sure we write the file in yaml format. filename = os.path.join( tmp_dir, config.CON...
[ "Generates", "the", "client", "config", "file", "for", "inclusion", "in", "deployable", "binaries", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L299-L353
[ "def", "GetClientConfig", "(", "self", ",", "context", ",", "validate", "=", "True", ",", "deploy_timestamp", "=", "True", ")", ":", "with", "utils", ".", "TempDirectory", "(", ")", "as", "tmp_dir", ":", "# Make sure we write the file in yaml format.", "filename",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientRepacker.ValidateEndConfig
Given a generated client config, attempt to check for common errors.
grr/client_builder/grr_response_client_builder/build.py
def ValidateEndConfig(self, config_obj, errors_fatal=True): """Given a generated client config, attempt to check for common errors.""" errors = [] if not config.CONFIG["Client.fleetspeak_enabled"]: location = config_obj.Get("Client.server_urls", context=self.context) if not location: er...
def ValidateEndConfig(self, config_obj, errors_fatal=True): """Given a generated client config, attempt to check for common errors.""" errors = [] if not config.CONFIG["Client.fleetspeak_enabled"]: location = config_obj.Get("Client.server_urls", context=self.context) if not location: er...
[ "Given", "a", "generated", "client", "config", "attempt", "to", "check", "for", "common", "errors", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L355-L397
[ "def", "ValidateEndConfig", "(", "self", ",", "config_obj", ",", "errors_fatal", "=", "True", ")", ":", "errors", "=", "[", "]", "if", "not", "config", ".", "CONFIG", "[", "\"Client.fleetspeak_enabled\"", "]", ":", "location", "=", "config_obj", ".", "Get", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WindowsClientRepacker.ValidateEndConfig
Windows specific config validations.
grr/client_builder/grr_response_client_builder/build.py
def ValidateEndConfig(self, config_obj, errors_fatal=True): """Windows specific config validations.""" errors = super(WindowsClientRepacker, self).ValidateEndConfig( config_obj, errors_fatal=errors_fatal) install_dir = config_obj["Client.install_path"] for path in config_obj["Client.tempdir_roo...
def ValidateEndConfig(self, config_obj, errors_fatal=True): """Windows specific config validations.""" errors = super(WindowsClientRepacker, self).ValidateEndConfig( config_obj, errors_fatal=errors_fatal) install_dir = config_obj["Client.install_path"] for path in config_obj["Client.tempdir_roo...
[ "Windows", "specific", "config", "validations", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L406-L442
[ "def", "ValidateEndConfig", "(", "self", ",", "config_obj", ",", "errors_fatal", "=", "True", ")", ":", "errors", "=", "super", "(", "WindowsClientRepacker", ",", "self", ")", ".", "ValidateEndConfig", "(", "config_obj", ",", "errors_fatal", "=", "errors_fatal",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WindowsClientRepacker.MakeDeployableBinary
Repackage the template zip with the installer.
grr/client_builder/grr_response_client_builder/build.py
def MakeDeployableBinary(self, template_path, output_path): """Repackage the template zip with the installer.""" context = self.context + ["Client Context"] zip_data = io.BytesIO() output_zip = zipfile.ZipFile( zip_data, mode="w", compression=zipfile.ZIP_DEFLATED) z_template = zipfile.ZipF...
def MakeDeployableBinary(self, template_path, output_path): """Repackage the template zip with the installer.""" context = self.context + ["Client Context"] zip_data = io.BytesIO() output_zip = zipfile.ZipFile( zip_data, mode="w", compression=zipfile.ZIP_DEFLATED) z_template = zipfile.ZipF...
[ "Repackage", "the", "template", "zip", "with", "the", "installer", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L444-L500
[ "def", "MakeDeployableBinary", "(", "self", ",", "template_path", ",", "output_path", ")", ":", "context", "=", "self", ".", "context", "+", "[", "\"Client Context\"", "]", "zip_data", "=", "io", ".", "BytesIO", "(", ")", "output_zip", "=", "zipfile", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WindowsClientRepacker._ValidateFleetspeakServiceConfig
Validates a Fleetspeak service config. Checks that the given file is a valid TextFormat representation of a Fleetspeak service config proto. Args: config_path: Path to the config file. Raises: BuildError: If the config is not valid.
grr/client_builder/grr_response_client_builder/build.py
def _ValidateFleetspeakServiceConfig(self, config_path): """Validates a Fleetspeak service config. Checks that the given file is a valid TextFormat representation of a Fleetspeak service config proto. Args: config_path: Path to the config file. Raises: BuildError: If the config is not...
def _ValidateFleetspeakServiceConfig(self, config_path): """Validates a Fleetspeak service config. Checks that the given file is a valid TextFormat representation of a Fleetspeak service config proto. Args: config_path: Path to the config file. Raises: BuildError: If the config is not...
[ "Validates", "a", "Fleetspeak", "service", "config", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L525-L550
[ "def", "_ValidateFleetspeakServiceConfig", "(", "self", ",", "config_path", ")", ":", "with", "open", "(", "config_path", ",", "\"rb\"", ")", "as", "f", ":", "pool", "=", "descriptor_pool", ".", "DescriptorPool", "(", ")", "pool", ".", "AddDescriptor", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WindowsClientRepacker.MakeSelfExtractingZip
Repack the installer into the payload. Args: payload_data: data payload for zip file output_path: filename for the zip output Raises: RuntimeError: if the ClientBuilder.unzipsfx_stub doesn't require admin. Returns: output_path: filename string of zip output file
grr/client_builder/grr_response_client_builder/build.py
def MakeSelfExtractingZip(self, payload_data, output_path): """Repack the installer into the payload. Args: payload_data: data payload for zip file output_path: filename for the zip output Raises: RuntimeError: if the ClientBuilder.unzipsfx_stub doesn't require admin. Returns: ...
def MakeSelfExtractingZip(self, payload_data, output_path): """Repack the installer into the payload. Args: payload_data: data payload for zip file output_path: filename for the zip output Raises: RuntimeError: if the ClientBuilder.unzipsfx_stub doesn't require admin. Returns: ...
[ "Repack", "the", "installer", "into", "the", "payload", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L552-L648
[ "def", "MakeSelfExtractingZip", "(", "self", ",", "payload_data", ",", "output_path", ")", ":", "context", "=", "self", ".", "context", "+", "[", "\"Client Context\"", "]", "src_zip", "=", "zipfile", ".", "ZipFile", "(", "io", ".", "BytesIO", "(", "payload_d...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DarwinClientRepacker.MakeDeployableBinary
This will add the config to the client template.
grr/client_builder/grr_response_client_builder/build.py
def MakeDeployableBinary(self, template_path, output_path): """This will add the config to the client template.""" context = self.context + ["Client Context"] utils.EnsureDirExists(os.path.dirname(output_path)) client_config_data = self.GetClientConfig(context) shutil.copyfile(template_path, output...
def MakeDeployableBinary(self, template_path, output_path): """This will add the config to the client template.""" context = self.context + ["Client Context"] utils.EnsureDirExists(os.path.dirname(output_path)) client_config_data = self.GetClientConfig(context) shutil.copyfile(template_path, output...
[ "This", "will", "add", "the", "config", "to", "the", "client", "template", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L654-L665
[ "def", "MakeDeployableBinary", "(", "self", ",", "template_path", ",", "output_path", ")", ":", "context", "=", "self", ".", "context", "+", "[", "\"Client Context\"", "]", "utils", ".", "EnsureDirExists", "(", "os", ".", "path", ".", "dirname", "(", "output...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
LinuxClientRepacker.GenerateDPKGFiles
Generates the files needed by dpkg-buildpackage.
grr/client_builder/grr_response_client_builder/build.py
def GenerateDPKGFiles(self, template_path): """Generates the files needed by dpkg-buildpackage.""" # Rename the generated binaries to the correct name. template_binary_dir = os.path.join(template_path, "dist/debian/grr-client") package_name = config.CONFIG.Get( "ClientBuilder.package_name", con...
def GenerateDPKGFiles(self, template_path): """Generates the files needed by dpkg-buildpackage.""" # Rename the generated binaries to the correct name. template_binary_dir = os.path.join(template_path, "dist/debian/grr-client") package_name = config.CONFIG.Get( "ClientBuilder.package_name", con...
[ "Generates", "the", "files", "needed", "by", "dpkg", "-", "buildpackage", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L673-L741
[ "def", "GenerateDPKGFiles", "(", "self", ",", "template_path", ")", ":", "# Rename the generated binaries to the correct name.", "template_binary_dir", "=", "os", ".", "path", ".", "join", "(", "template_path", ",", "\"dist/debian/grr-client\"", ")", "package_name", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
LinuxClientRepacker.MakeDeployableBinary
This will add the config to the client template and create a .deb.
grr/client_builder/grr_response_client_builder/build.py
def MakeDeployableBinary(self, template_path, output_path): """This will add the config to the client template and create a .deb.""" buildpackage_binary = "/usr/bin/dpkg-buildpackage" if not os.path.exists(buildpackage_binary): logging.error("dpkg-buildpackage not found, unable to repack client.") ...
def MakeDeployableBinary(self, template_path, output_path): """This will add the config to the client template and create a .deb.""" buildpackage_binary = "/usr/bin/dpkg-buildpackage" if not os.path.exists(buildpackage_binary): logging.error("dpkg-buildpackage not found, unable to repack client.") ...
[ "This", "will", "add", "the", "config", "to", "the", "client", "template", "and", "create", "a", ".", "deb", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L766-L862
[ "def", "MakeDeployableBinary", "(", "self", ",", "template_path", ",", "output_path", ")", ":", "buildpackage_binary", "=", "\"/usr/bin/dpkg-buildpackage\"", "if", "not", "os", ".", "path", ".", "exists", "(", "buildpackage_binary", ")", ":", "logging", ".", "erro...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CentosClientRepacker.MakeDeployableBinary
This will add the config to the client template and create a .rpm.
grr/client_builder/grr_response_client_builder/build.py
def MakeDeployableBinary(self, template_path, output_path): """This will add the config to the client template and create a .rpm.""" rpmbuild_binary = "/usr/bin/rpmbuild" if not os.path.exists(rpmbuild_binary): logging.error("rpmbuild not found, unable to repack client.") return with utils...
def MakeDeployableBinary(self, template_path, output_path): """This will add the config to the client template and create a .rpm.""" rpmbuild_binary = "/usr/bin/rpmbuild" if not os.path.exists(rpmbuild_binary): logging.error("rpmbuild not found, unable to repack client.") return with utils...
[ "This", "will", "add", "the", "config", "to", "the", "client", "template", "and", "create", "a", ".", "rpm", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L872-L1000
[ "def", "MakeDeployableBinary", "(", "self", ",", "template_path", ",", "output_path", ")", ":", "rpmbuild_binary", "=", "\"/usr/bin/rpmbuild\"", "if", "not", "os", ".", "path", ".", "exists", "(", "rpmbuild_binary", ")", ":", "logging", ".", "error", "(", "\"r...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CentosClientRepacker._GenerateFleetspeakConfig
Generates a Fleetspeak config for GRR.
grr/client_builder/grr_response_client_builder/build.py
def _GenerateFleetspeakConfig(self, template_dir, rpm_build_dir): """Generates a Fleetspeak config for GRR.""" source_config = os.path.join( template_dir, "fleetspeak", os.path.basename( config.CONFIG.Get( "ClientBuilder.fleetspeak_config_path", context=self.context))...
def _GenerateFleetspeakConfig(self, template_dir, rpm_build_dir): """Generates a Fleetspeak config for GRR.""" source_config = os.path.join( template_dir, "fleetspeak", os.path.basename( config.CONFIG.Get( "ClientBuilder.fleetspeak_config_path", context=self.context))...
[ "Generates", "a", "Fleetspeak", "config", "for", "GRR", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L1002-L1018
[ "def", "_GenerateFleetspeakConfig", "(", "self", ",", "template_dir", ",", "rpm_build_dir", ")", ":", "source_config", "=", "os", ".", "path", ".", "join", "(", "template_dir", ",", "\"fleetspeak\"", ",", "os", ".", "path", ".", "basename", "(", "config", "....
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CentosClientRepacker._GenerateInitConfigs
Generates init-system configs.
grr/client_builder/grr_response_client_builder/build.py
def _GenerateInitConfigs(self, template_dir, rpm_build_dir): """Generates init-system configs.""" client_name = config.CONFIG.Get("Client.name", context=self.context) initd_target_filename = os.path.join(rpm_build_dir, "etc/init.d", client_name) # Generate init....
def _GenerateInitConfigs(self, template_dir, rpm_build_dir): """Generates init-system configs.""" client_name = config.CONFIG.Get("Client.name", context=self.context) initd_target_filename = os.path.join(rpm_build_dir, "etc/init.d", client_name) # Generate init....
[ "Generates", "init", "-", "system", "configs", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/build.py#L1020-L1041
[ "def", "_GenerateInitConfigs", "(", "self", ",", "template_dir", ",", "rpm_build_dir", ")", ":", "client_name", "=", "config", ".", "CONFIG", ".", "Get", "(", "\"Client.name\"", ",", "context", "=", "self", ".", "context", ")", "initd_target_filename", "=", "o...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
compile_protos
Builds necessary assets from sources.
grr/proto/setup.py
def compile_protos(): """Builds necessary assets from sources.""" # If there's no makefile, we're likely installing from an sdist, # so there's no need to compile the protos (they should be already # compiled). if not os.path.exists(os.path.join(THIS_DIRECTORY, "makefile.py")): return # Only compile pr...
def compile_protos(): """Builds necessary assets from sources.""" # If there's no makefile, we're likely installing from an sdist, # so there's no need to compile the protos (they should be already # compiled). if not os.path.exists(os.path.join(THIS_DIRECTORY, "makefile.py")): return # Only compile pr...
[ "Builds", "necessary", "assets", "from", "sources", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/proto/setup.py#L53-L63
[ "def", "compile_protos", "(", ")", ":", "# If there's no makefile, we're likely installing from an sdist,", "# so there's no need to compile the protos (they should be already", "# compiled).", "if", "not", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.ReadCronJobs
Reads a cronjob from the database.
grr/server/grr_response_server/databases/mem_cronjobs.py
def ReadCronJobs(self, cronjob_ids=None): """Reads a cronjob from the database.""" if cronjob_ids is None: res = [job.Copy() for job in itervalues(self.cronjobs)] else: res = [] for job_id in cronjob_ids: try: res.append(self.cronjobs[job_id].Copy()) except KeyEr...
def ReadCronJobs(self, cronjob_ids=None): """Reads a cronjob from the database.""" if cronjob_ids is None: res = [job.Copy() for job in itervalues(self.cronjobs)] else: res = [] for job_id in cronjob_ids: try: res.append(self.cronjobs[job_id].Copy()) except KeyEr...
[ "Reads", "a", "cronjob", "from", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L23-L41
[ "def", "ReadCronJobs", "(", "self", ",", "cronjob_ids", "=", "None", ")", ":", "if", "cronjob_ids", "is", "None", ":", "res", "=", "[", "job", ".", "Copy", "(", ")", "for", "job", "in", "itervalues", "(", "self", ".", "cronjobs", ")", "]", "else", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.UpdateCronJob
Updates run information for an existing cron job.
grr/server/grr_response_server/databases/mem_cronjobs.py
def UpdateCronJob(self, cronjob_id, last_run_status=db.Database.unchanged, last_run_time=db.Database.unchanged, current_run_id=db.Database.unchanged, state=db.Database.unchanged, forced_run_requested=...
def UpdateCronJob(self, cronjob_id, last_run_status=db.Database.unchanged, last_run_time=db.Database.unchanged, current_run_id=db.Database.unchanged, state=db.Database.unchanged, forced_run_requested=...
[ "Updates", "run", "information", "for", "an", "existing", "cron", "job", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L44-L65
[ "def", "UpdateCronJob", "(", "self", ",", "cronjob_id", ",", "last_run_status", "=", "db", ".", "Database", ".", "unchanged", ",", "last_run_time", "=", "db", ".", "Database", ".", "unchanged", ",", "current_run_id", "=", "db", ".", "Database", ".", "unchang...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.EnableCronJob
Enables a cronjob.
grr/server/grr_response_server/databases/mem_cronjobs.py
def EnableCronJob(self, cronjob_id): """Enables a cronjob.""" job = self.cronjobs.get(cronjob_id) if job is None: raise db.UnknownCronJobError("Cron job %s not known." % cronjob_id) job.enabled = True
def EnableCronJob(self, cronjob_id): """Enables a cronjob.""" job = self.cronjobs.get(cronjob_id) if job is None: raise db.UnknownCronJobError("Cron job %s not known." % cronjob_id) job.enabled = True
[ "Enables", "a", "cronjob", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L68-L73
[ "def", "EnableCronJob", "(", "self", ",", "cronjob_id", ")", ":", "job", "=", "self", ".", "cronjobs", ".", "get", "(", "cronjob_id", ")", "if", "job", "is", "None", ":", "raise", "db", ".", "UnknownCronJobError", "(", "\"Cron job %s not known.\"", "%", "c...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.DisableCronJob
Disables a cronjob.
grr/server/grr_response_server/databases/mem_cronjobs.py
def DisableCronJob(self, cronjob_id): """Disables a cronjob.""" job = self.cronjobs.get(cronjob_id) if job is None: raise db.UnknownCronJobError("Cron job %s not known." % cronjob_id) job.enabled = False
def DisableCronJob(self, cronjob_id): """Disables a cronjob.""" job = self.cronjobs.get(cronjob_id) if job is None: raise db.UnknownCronJobError("Cron job %s not known." % cronjob_id) job.enabled = False
[ "Disables", "a", "cronjob", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L76-L81
[ "def", "DisableCronJob", "(", "self", ",", "cronjob_id", ")", ":", "job", "=", "self", ".", "cronjobs", ".", "get", "(", "cronjob_id", ")", "if", "job", "is", "None", ":", "raise", "db", ".", "UnknownCronJobError", "(", "\"Cron job %s not known.\"", "%", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.DeleteCronJob
Deletes a cronjob along with all its runs.
grr/server/grr_response_server/databases/mem_cronjobs.py
def DeleteCronJob(self, cronjob_id): """Deletes a cronjob along with all its runs.""" if cronjob_id not in self.cronjobs: raise db.UnknownCronJobError("Cron job %s not known." % cronjob_id) del self.cronjobs[cronjob_id] try: del self.cronjob_leases[cronjob_id] except KeyError: pass...
def DeleteCronJob(self, cronjob_id): """Deletes a cronjob along with all its runs.""" if cronjob_id not in self.cronjobs: raise db.UnknownCronJobError("Cron job %s not known." % cronjob_id) del self.cronjobs[cronjob_id] try: del self.cronjob_leases[cronjob_id] except KeyError: pass...
[ "Deletes", "a", "cronjob", "along", "with", "all", "its", "runs", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L84-L94
[ "def", "DeleteCronJob", "(", "self", ",", "cronjob_id", ")", ":", "if", "cronjob_id", "not", "in", "self", ".", "cronjobs", ":", "raise", "db", ".", "UnknownCronJobError", "(", "\"Cron job %s not known.\"", "%", "cronjob_id", ")", "del", "self", ".", "cronjobs...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.LeaseCronJobs
Leases all available cron jobs.
grr/server/grr_response_server/databases/mem_cronjobs.py
def LeaseCronJobs(self, cronjob_ids=None, lease_time=None): """Leases all available cron jobs.""" leased_jobs = [] now = rdfvalue.RDFDatetime.Now() expiration_time = now + lease_time for job in itervalues(self.cronjobs): if cronjob_ids and job.cron_job_id not in cronjob_ids: continue...
def LeaseCronJobs(self, cronjob_ids=None, lease_time=None): """Leases all available cron jobs.""" leased_jobs = [] now = rdfvalue.RDFDatetime.Now() expiration_time = now + lease_time for job in itervalues(self.cronjobs): if cronjob_ids and job.cron_job_id not in cronjob_ids: continue...
[ "Leases", "all", "available", "cron", "jobs", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L97-L115
[ "def", "LeaseCronJobs", "(", "self", ",", "cronjob_ids", "=", "None", ",", "lease_time", "=", "None", ")", ":", "leased_jobs", "=", "[", "]", "now", "=", "rdfvalue", ".", "RDFDatetime", ".", "Now", "(", ")", "expiration_time", "=", "now", "+", "lease_tim...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.ReturnLeasedCronJobs
Makes leased cron jobs available for leasing again.
grr/server/grr_response_server/databases/mem_cronjobs.py
def ReturnLeasedCronJobs(self, jobs): """Makes leased cron jobs available for leasing again.""" errored_jobs = [] for returned_job in jobs: existing_lease = self.cronjob_leases.get(returned_job.cron_job_id) if existing_lease is None: errored_jobs.append(returned_job) continue ...
def ReturnLeasedCronJobs(self, jobs): """Makes leased cron jobs available for leasing again.""" errored_jobs = [] for returned_job in jobs: existing_lease = self.cronjob_leases.get(returned_job.cron_job_id) if existing_lease is None: errored_jobs.append(returned_job) continue ...
[ "Makes", "leased", "cron", "jobs", "available", "for", "leasing", "again", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L118-L137
[ "def", "ReturnLeasedCronJobs", "(", "self", ",", "jobs", ")", ":", "errored_jobs", "=", "[", "]", "for", "returned_job", "in", "jobs", ":", "existing_lease", "=", "self", ".", "cronjob_leases", ".", "get", "(", "returned_job", ".", "cron_job_id", ")", "if", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.WriteCronJobRun
Stores a cron job run object in the database.
grr/server/grr_response_server/databases/mem_cronjobs.py
def WriteCronJobRun(self, run_object): """Stores a cron job run object in the database.""" if run_object.cron_job_id not in self.cronjobs: raise db.UnknownCronJobError("Job with id %s not found." % run_object.cron_job_id) clone = run_object.Copy() clone.timestam...
def WriteCronJobRun(self, run_object): """Stores a cron job run object in the database.""" if run_object.cron_job_id not in self.cronjobs: raise db.UnknownCronJobError("Job with id %s not found." % run_object.cron_job_id) clone = run_object.Copy() clone.timestam...
[ "Stores", "a", "cron", "job", "run", "object", "in", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L139-L147
[ "def", "WriteCronJobRun", "(", "self", ",", "run_object", ")", ":", "if", "run_object", ".", "cron_job_id", "not", "in", "self", ".", "cronjobs", ":", "raise", "db", ".", "UnknownCronJobError", "(", "\"Job with id %s not found.\"", "%", "run_object", ".", "cron_...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.ReadCronJobRuns
Reads all cron job runs for a given job id.
grr/server/grr_response_server/databases/mem_cronjobs.py
def ReadCronJobRuns(self, job_id): """Reads all cron job runs for a given job id.""" runs = [ run for run in itervalues(self.cronjob_runs) if run.cron_job_id == job_id ] return sorted(runs, key=lambda run: run.started_at, reverse=True)
def ReadCronJobRuns(self, job_id): """Reads all cron job runs for a given job id.""" runs = [ run for run in itervalues(self.cronjob_runs) if run.cron_job_id == job_id ] return sorted(runs, key=lambda run: run.started_at, reverse=True)
[ "Reads", "all", "cron", "job", "runs", "for", "a", "given", "job", "id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L149-L155
[ "def", "ReadCronJobRuns", "(", "self", ",", "job_id", ")", ":", "runs", "=", "[", "run", "for", "run", "in", "itervalues", "(", "self", ".", "cronjob_runs", ")", "if", "run", ".", "cron_job_id", "==", "job_id", "]", "return", "sorted", "(", "runs", ","...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.ReadCronJobRun
Reads a single cron job run from the db.
grr/server/grr_response_server/databases/mem_cronjobs.py
def ReadCronJobRun(self, job_id, run_id): """Reads a single cron job run from the db.""" for run in itervalues(self.cronjob_runs): if run.cron_job_id == job_id and run.run_id == run_id: return run raise db.UnknownCronJobRunError( "Run with job id %s and run id %s not found." % (job_id,...
def ReadCronJobRun(self, job_id, run_id): """Reads a single cron job run from the db.""" for run in itervalues(self.cronjob_runs): if run.cron_job_id == job_id and run.run_id == run_id: return run raise db.UnknownCronJobRunError( "Run with job id %s and run id %s not found." % (job_id,...
[ "Reads", "a", "single", "cron", "job", "run", "from", "the", "db", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L157-L163
[ "def", "ReadCronJobRun", "(", "self", ",", "job_id", ",", "run_id", ")", ":", "for", "run", "in", "itervalues", "(", "self", ".", "cronjob_runs", ")", ":", "if", "run", ".", "cron_job_id", "==", "job_id", "and", "run", ".", "run_id", "==", "run_id", ":...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBCronJobMixin.DeleteOldCronJobRuns
Deletes cron job runs for a given job id.
grr/server/grr_response_server/databases/mem_cronjobs.py
def DeleteOldCronJobRuns(self, cutoff_timestamp): """Deletes cron job runs for a given job id.""" deleted = 0 for run in list(itervalues(self.cronjob_runs)): if run.timestamp < cutoff_timestamp: del self.cronjob_runs[(run.cron_job_id, run.run_id)] deleted += 1 return deleted
def DeleteOldCronJobRuns(self, cutoff_timestamp): """Deletes cron job runs for a given job id.""" deleted = 0 for run in list(itervalues(self.cronjob_runs)): if run.timestamp < cutoff_timestamp: del self.cronjob_runs[(run.cron_job_id, run.run_id)] deleted += 1 return deleted
[ "Deletes", "cron", "job", "runs", "for", "a", "given", "job", "id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L165-L173
[ "def", "DeleteOldCronJobRuns", "(", "self", ",", "cutoff_timestamp", ")", ":", "deleted", "=", "0", "for", "run", "in", "list", "(", "itervalues", "(", "self", ".", "cronjob_runs", ")", ")", ":", "if", "run", ".", "timestamp", "<", "cutoff_timestamp", ":",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UploadSignedConfigBlob
Upload a signed blob into the datastore. Args: content: File content to upload. aff4_path: aff4 path to upload to. client_context: The configuration contexts to use. limit: The maximum size of the chunk to use. token: A security token. Raises: IOError: On failure to write.
grr/server/grr_response_server/maintenance_utils.py
def UploadSignedConfigBlob(content, aff4_path, client_context=None, limit=None, token=None): """Upload a signed blob into the datastore. Args: content: File content to upload. aff4_path: aff4 path to...
def UploadSignedConfigBlob(content, aff4_path, client_context=None, limit=None, token=None): """Upload a signed blob into the datastore. Args: content: File content to upload. aff4_path: aff4 path to...
[ "Upload", "a", "signed", "blob", "into", "the", "datastore", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/maintenance_utils.py#L40-L83
[ "def", "UploadSignedConfigBlob", "(", "content", ",", "aff4_path", ",", "client_context", "=", "None", ",", "limit", "=", "None", ",", "token", "=", "None", ")", ":", "if", "limit", "is", "None", ":", "limit", "=", "config", ".", "CONFIG", "[", "\"Datast...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RotateServerKey
This function creates and installs a new server key. Note that - Clients might experience intermittent connection problems after the server keys rotated. - It's not possible to go back to an earlier key. Clients that see a new certificate will remember the cert's serial number and refuse to accept ...
grr/server/grr_response_server/maintenance_utils.py
def RotateServerKey(cn=u"grr", keylength=4096): """This function creates and installs a new server key. Note that - Clients might experience intermittent connection problems after the server keys rotated. - It's not possible to go back to an earlier key. Clients that see a new certificate will rememb...
def RotateServerKey(cn=u"grr", keylength=4096): """This function creates and installs a new server key. Note that - Clients might experience intermittent connection problems after the server keys rotated. - It's not possible to go back to an earlier key. Clients that see a new certificate will rememb...
[ "This", "function", "creates", "and", "installs", "a", "new", "server", "key", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/maintenance_utils.py#L86-L133
[ "def", "RotateServerKey", "(", "cn", "=", "u\"grr\"", ",", "keylength", "=", "4096", ")", ":", "ca_certificate", "=", "config", ".", "CONFIG", "[", "\"CA.certificate\"", "]", "ca_private_key", "=", "config", ".", "CONFIG", "[", "\"PrivateKeys.ca_key\"", "]", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RelDBChecker._CheckAccess
Checks access to a given subject by a given user.
grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py
def _CheckAccess(self, username, subject_id, approval_type): """Checks access to a given subject by a given user.""" precondition.AssertType(subject_id, Text) cache_key = (username, subject_id, approval_type) try: self.acl_cache.Get(cache_key) stats_collector_instance.Get().IncrementCounter...
def _CheckAccess(self, username, subject_id, approval_type): """Checks access to a given subject by a given user.""" precondition.AssertType(subject_id, Text) cache_key = (username, subject_id, approval_type) try: self.acl_cache.Get(cache_key) stats_collector_instance.Get().IncrementCounter...
[ "Checks", "access", "to", "a", "given", "subject", "by", "a", "given", "user", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py#L64-L96
[ "def", "_CheckAccess", "(", "self", ",", "username", ",", "subject_id", ",", "approval_type", ")", ":", "precondition", ".", "AssertType", "(", "subject_id", ",", "Text", ")", "cache_key", "=", "(", "username", ",", "subject_id", ",", "approval_type", ")", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RelDBChecker.CheckClientAccess
Checks whether a given user can access given client.
grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py
def CheckClientAccess(self, username, client_id): """Checks whether a given user can access given client.""" self._CheckAccess( username, str(client_id), rdf_objects.ApprovalRequest.ApprovalType.APPROVAL_TYPE_CLIENT)
def CheckClientAccess(self, username, client_id): """Checks whether a given user can access given client.""" self._CheckAccess( username, str(client_id), rdf_objects.ApprovalRequest.ApprovalType.APPROVAL_TYPE_CLIENT)
[ "Checks", "whether", "a", "given", "user", "can", "access", "given", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py#L98-L102
[ "def", "CheckClientAccess", "(", "self", ",", "username", ",", "client_id", ")", ":", "self", ".", "_CheckAccess", "(", "username", ",", "str", "(", "client_id", ")", ",", "rdf_objects", ".", "ApprovalRequest", ".", "ApprovalType", ".", "APPROVAL_TYPE_CLIENT", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RelDBChecker.CheckHuntAccess
Checks whether a given user can access given hunt.
grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py
def CheckHuntAccess(self, username, hunt_id): """Checks whether a given user can access given hunt.""" self._CheckAccess( username, str(hunt_id), rdf_objects.ApprovalRequest.ApprovalType.APPROVAL_TYPE_HUNT)
def CheckHuntAccess(self, username, hunt_id): """Checks whether a given user can access given hunt.""" self._CheckAccess( username, str(hunt_id), rdf_objects.ApprovalRequest.ApprovalType.APPROVAL_TYPE_HUNT)
[ "Checks", "whether", "a", "given", "user", "can", "access", "given", "hunt", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py#L104-L109
[ "def", "CheckHuntAccess", "(", "self", ",", "username", ",", "hunt_id", ")", ":", "self", ".", "_CheckAccess", "(", "username", ",", "str", "(", "hunt_id", ")", ",", "rdf_objects", ".", "ApprovalRequest", ".", "ApprovalType", ".", "APPROVAL_TYPE_HUNT", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RelDBChecker.CheckCronJobAccess
Checks whether a given user can access given cron job.
grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py
def CheckCronJobAccess(self, username, cron_job_id): """Checks whether a given user can access given cron job.""" self._CheckAccess( username, str(cron_job_id), rdf_objects.ApprovalRequest.ApprovalType.APPROVAL_TYPE_CRON_JOB)
def CheckCronJobAccess(self, username, cron_job_id): """Checks whether a given user can access given cron job.""" self._CheckAccess( username, str(cron_job_id), rdf_objects.ApprovalRequest.ApprovalType.APPROVAL_TYPE_CRON_JOB)
[ "Checks", "whether", "a", "given", "user", "can", "access", "given", "cron", "job", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py#L111-L116
[ "def", "CheckCronJobAccess", "(", "self", ",", "username", ",", "cron_job_id", ")", ":", "self", ".", "_CheckAccess", "(", "username", ",", "str", "(", "cron_job_id", ")", ",", "rdf_objects", ".", "ApprovalRequest", ".", "ApprovalType", ".", "APPROVAL_TYPE_CRON_...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RelDBChecker.CheckIfCanStartClientFlow
Checks whether a given user can start a given flow.
grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py
def CheckIfCanStartClientFlow(self, username, flow_name): """Checks whether a given user can start a given flow.""" del username # Unused. flow_cls = flow.GRRFlow.GetPlugin(flow_name) if not flow_cls.category: raise access_control.UnauthorizedAccess( "Flow %s can't be started via the ...
def CheckIfCanStartClientFlow(self, username, flow_name): """Checks whether a given user can start a given flow.""" del username # Unused. flow_cls = flow.GRRFlow.GetPlugin(flow_name) if not flow_cls.category: raise access_control.UnauthorizedAccess( "Flow %s can't be started via the ...
[ "Checks", "whether", "a", "given", "user", "can", "start", "a", "given", "flow", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py#L118-L126
[ "def", "CheckIfCanStartClientFlow", "(", "self", ",", "username", ",", "flow_name", ")", ":", "del", "username", "# Unused.", "flow_cls", "=", "flow", ".", "GRRFlow", ".", "GetPlugin", "(", "flow_name", ")", "if", "not", "flow_cls", ".", "category", ":", "ra...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RelDBChecker.CheckIfUserIsAdmin
Checks whether the user is an admin.
grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py
def CheckIfUserIsAdmin(self, username): """Checks whether the user is an admin.""" user_obj = data_store.REL_DB.ReadGRRUser(username) if user_obj.user_type != user_obj.UserType.USER_TYPE_ADMIN: raise access_control.UnauthorizedAccess("User %s is not an admin." % ...
def CheckIfUserIsAdmin(self, username): """Checks whether the user is an admin.""" user_obj = data_store.REL_DB.ReadGRRUser(username) if user_obj.user_type != user_obj.UserType.USER_TYPE_ADMIN: raise access_control.UnauthorizedAccess("User %s is not an admin." % ...
[ "Checks", "whether", "the", "user", "is", "an", "admin", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_call_router_with_approval_checks.py#L128-L134
[ "def", "CheckIfUserIsAdmin", "(", "self", ",", "username", ")", ":", "user_obj", "=", "data_store", ".", "REL_DB", ".", "ReadGRRUser", "(", "username", ")", "if", "user_obj", ".", "user_type", "!=", "user_obj", ".", "UserType", ".", "USER_TYPE_ADMIN", ":", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Condition.Artifacts
Whether the conditions applies, modulo host data. Args: os_name: An OS string. cpe: A CPE string. label: A label string. Returns: True if os_name, cpe or labels match. Empty values are ignored.
grr/server/grr_response_server/check_lib/triggers.py
def Artifacts(self, os_name=None, cpe=None, label=None): """Whether the conditions applies, modulo host data. Args: os_name: An OS string. cpe: A CPE string. label: A label string. Returns: True if os_name, cpe or labels match. Empty values are ignored. """ hit = lambda x: ...
def Artifacts(self, os_name=None, cpe=None, label=None): """Whether the conditions applies, modulo host data. Args: os_name: An OS string. cpe: A CPE string. label: A label string. Returns: True if os_name, cpe or labels match. Empty values are ignored. """ hit = lambda x: ...
[ "Whether", "the", "conditions", "applies", "modulo", "host", "data", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/triggers.py#L88-L101
[ "def", "Artifacts", "(", "self", ",", "os_name", "=", "None", ",", "cpe", "=", "None", ",", "label", "=", "None", ")", ":", "hit", "=", "lambda", "x", ":", "x", "[", "0", "]", "==", "x", "[", "1", "]", "or", "not", "x", "[", "0", "]", "seq"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Condition.Search
Whether the condition contains the specified values. Args: artifact: A string identifier for the artifact. os_name: An OS string. cpe: A CPE string. label: A label string. Returns: True if the values match the non-empty query attributes. Empty query attributes are ignored i...
grr/server/grr_response_server/check_lib/triggers.py
def Search(self, artifact, os_name=None, cpe=None, label=None): """Whether the condition contains the specified values. Args: artifact: A string identifier for the artifact. os_name: An OS string. cpe: A CPE string. label: A label string. Returns: True if the values match the...
def Search(self, artifact, os_name=None, cpe=None, label=None): """Whether the condition contains the specified values. Args: artifact: A string identifier for the artifact. os_name: An OS string. cpe: A CPE string. label: A label string. Returns: True if the values match the...
[ "Whether", "the", "condition", "contains", "the", "specified", "values", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/triggers.py#L103-L119
[ "def", "Search", "(", "self", ",", "artifact", ",", "os_name", "=", "None", ",", "cpe", "=", "None", ",", "label", "=", "None", ")", ":", "hit", "=", "lambda", "x", ":", "x", "[", "0", "]", "==", "x", "[", "1", "]", "or", "not", "x", "[", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Triggers._Register
Map functions that should be called if the condition applies.
grr/server/grr_response_server/check_lib/triggers.py
def _Register(self, conditions, callback): """Map functions that should be called if the condition applies.""" for condition in conditions: registered = self._registry.setdefault(condition, []) if callback and callback not in registered: registered.append(callback)
def _Register(self, conditions, callback): """Map functions that should be called if the condition applies.""" for condition in conditions: registered = self._registry.setdefault(condition, []) if callback and callback not in registered: registered.append(callback)
[ "Map", "functions", "that", "should", "be", "called", "if", "the", "condition", "applies", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/triggers.py#L132-L137
[ "def", "_Register", "(", "self", ",", "conditions", ",", "callback", ")", ":", "for", "condition", "in", "conditions", ":", "registered", "=", "self", ".", "_registry", ".", "setdefault", "(", "condition", ",", "[", "]", ")", "if", "callback", "and", "ca...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Triggers.Add
Add criteria for a check. Args: artifact: An artifact name. target: A tuple of artifact necessary to process the data. callback: Entities that should be called if the condition matches.
grr/server/grr_response_server/check_lib/triggers.py
def Add(self, artifact=None, target=None, callback=None): """Add criteria for a check. Args: artifact: An artifact name. target: A tuple of artifact necessary to process the data. callback: Entities that should be called if the condition matches. """ # Cases where a target field is un...
def Add(self, artifact=None, target=None, callback=None): """Add criteria for a check. Args: artifact: An artifact name. target: A tuple of artifact necessary to process the data. callback: Entities that should be called if the condition matches. """ # Cases where a target field is un...
[ "Add", "criteria", "for", "a", "check", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/triggers.py#L139-L160
[ "def", "Add", "(", "self", ",", "artifact", "=", "None", ",", "target", "=", "None", ",", "callback", "=", "None", ")", ":", "# Cases where a target field is undefined or empty need special handling.", "# Repeated field helper in target yields results, so expand this out into a...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Triggers.Update
Adds existing triggers to this set, optionally rebuilding the registry. Used to aggregate trigger methods from Probes to Methods to Checks. Args: other: Another Triggers object. callback: Registers all the updated triggers to the specified function.
grr/server/grr_response_server/check_lib/triggers.py
def Update(self, other, callback): """Adds existing triggers to this set, optionally rebuilding the registry. Used to aggregate trigger methods from Probes to Methods to Checks. Args: other: Another Triggers object. callback: Registers all the updated triggers to the specified function. ""...
def Update(self, other, callback): """Adds existing triggers to this set, optionally rebuilding the registry. Used to aggregate trigger methods from Probes to Methods to Checks. Args: other: Another Triggers object. callback: Registers all the updated triggers to the specified function. ""...
[ "Adds", "existing", "triggers", "to", "this", "set", "optionally", "rebuilding", "the", "registry", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/triggers.py#L162-L172
[ "def", "Update", "(", "self", ",", "other", ",", "callback", ")", ":", "self", ".", "conditions", ".", "update", "(", "other", ".", "conditions", ")", "self", ".", "_Register", "(", "other", ".", "conditions", ",", "callback", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74