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
GetRawDevice
Resolve the raw device that contains the path.
grr/client/grr_response_client/client_utils_osx.py
def GetRawDevice(path): """Resolve the raw device that contains the path.""" device_map = GetMountpoints() path = utils.SmartUnicode(path) mount_point = path = utils.NormalizePath(path, "/") result = rdf_paths.PathSpec(pathtype=rdf_paths.PathSpec.PathType.OS) # Assign the most specific mount point to the...
def GetRawDevice(path): """Resolve the raw device that contains the path.""" device_map = GetMountpoints() path = utils.SmartUnicode(path) mount_point = path = utils.NormalizePath(path, "/") result = rdf_paths.PathSpec(pathtype=rdf_paths.PathSpec.PathType.OS) # Assign the most specific mount point to the...
[ "Resolve", "the", "raw", "device", "that", "contains", "the", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx.py#L189-L215
[ "def", "GetRawDevice", "(", "path", ")", ":", "device_map", "=", "GetMountpoints", "(", ")", "path", "=", "utils", ".", "SmartUnicode", "(", "path", ")", "mount_point", "=", "path", "=", "utils", ".", "NormalizePath", "(", "path", ",", "\"/\"", ")", "res...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InstallDriver
Calls into the IOKit to load a kext by file-system path. Apple kext API doco here: http://developer.apple.com/library/mac/#documentation/IOKit/Reference/ KextManager_header_reference/Reference/reference.html Args: kext_path: Absolute or relative POSIX path to the kext. Raises: OSError: On fai...
grr/client/grr_response_client/client_utils_osx.py
def InstallDriver(kext_path): """Calls into the IOKit to load a kext by file-system path. Apple kext API doco here: http://developer.apple.com/library/mac/#documentation/IOKit/Reference/ KextManager_header_reference/Reference/reference.html Args: kext_path: Absolute or relative POSIX path to the k...
def InstallDriver(kext_path): """Calls into the IOKit to load a kext by file-system path. Apple kext API doco here: http://developer.apple.com/library/mac/#documentation/IOKit/Reference/ KextManager_header_reference/Reference/reference.html Args: kext_path: Absolute or relative POSIX path to the k...
[ "Calls", "into", "the", "IOKit", "to", "load", "a", "kext", "by", "file", "-", "system", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx.py#L218-L241
[ "def", "InstallDriver", "(", "kext_path", ")", ":", "km", "=", "objc", ".", "KextManager", "(", ")", "cf_kext_path", "=", "km", ".", "PyStringToCFString", "(", "kext_path", ")", "kext_url", "=", "km", ".", "dll", ".", "CFURLCreateWithFileSystemPath", "(", "o...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UninstallDriver
Calls into the IOKit to unload a kext by its name. Args: bundle_name: The bundle identifier of the kernel extension as defined in Info.plist field CFBundleIdentifier. Returns: The error code from the library call. objc.OS_SUCCESS if successfull.
grr/client/grr_response_client/client_utils_osx.py
def UninstallDriver(bundle_name): """Calls into the IOKit to unload a kext by its name. Args: bundle_name: The bundle identifier of the kernel extension as defined in Info.plist field CFBundleIdentifier. Returns: The error code from the library call. objc.OS_SUCCESS if successfull. """...
def UninstallDriver(bundle_name): """Calls into the IOKit to unload a kext by its name. Args: bundle_name: The bundle identifier of the kernel extension as defined in Info.plist field CFBundleIdentifier. Returns: The error code from the library call. objc.OS_SUCCESS if successfull. """...
[ "Calls", "into", "the", "IOKit", "to", "unload", "a", "kext", "by", "its", "name", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx.py#L244-L258
[ "def", "UninstallDriver", "(", "bundle_name", ")", ":", "km", "=", "objc", ".", "KextManager", "(", ")", "cf_bundle_name", "=", "km", ".", "PyStringToCFString", "(", "bundle_name", ")", "status", "=", "km", ".", "iokit", ".", "KextManagerUnloadKextWithIdentifier...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ValidatePathInfos
Validates a sequence of path infos.
grr/server/grr_response_server/databases/db.py
def _ValidatePathInfos(path_infos): """Validates a sequence of path infos.""" precondition.AssertIterableType(path_infos, rdf_objects.PathInfo) validated = set() for path_info in path_infos: _ValidatePathInfo(path_info) path_key = (path_info.path_type, path_info.GetPathID()) if path_key in validat...
def _ValidatePathInfos(path_infos): """Validates a sequence of path infos.""" precondition.AssertIterableType(path_infos, rdf_objects.PathInfo) validated = set() for path_info in path_infos: _ValidatePathInfo(path_info) path_key = (path_info.path_type, path_info.GetPathID()) if path_key in validat...
[ "Validates", "a", "sequence", "of", "path", "infos", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L4062-L4081
[ "def", "_ValidatePathInfos", "(", "path_infos", ")", ":", "precondition", ".", "AssertIterableType", "(", "path_infos", ",", "rdf_objects", ".", "PathInfo", ")", "validated", "=", "set", "(", ")", "for", "path_info", "in", "path_infos", ":", "_ValidatePathInfo", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ValidateTimeRange
Parses a timerange argument and always returns non-None timerange.
grr/server/grr_response_server/databases/db.py
def _ValidateTimeRange(timerange): """Parses a timerange argument and always returns non-None timerange.""" if len(timerange) != 2: raise ValueError("Timerange should be a sequence with 2 items.") (start, end) = timerange precondition.AssertOptionalType(start, rdfvalue.RDFDatetime) precondition.AssertOpt...
def _ValidateTimeRange(timerange): """Parses a timerange argument and always returns non-None timerange.""" if len(timerange) != 2: raise ValueError("Timerange should be a sequence with 2 items.") (start, end) = timerange precondition.AssertOptionalType(start, rdfvalue.RDFDatetime) precondition.AssertOpt...
[ "Parses", "a", "timerange", "argument", "and", "always", "returns", "non", "-", "None", "timerange", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L4104-L4111
[ "def", "_ValidateTimeRange", "(", "timerange", ")", ":", "if", "len", "(", "timerange", ")", "!=", "2", ":", "raise", "ValueError", "(", "\"Timerange should be a sequence with 2 items.\"", ")", "(", "start", ",", "end", ")", "=", "timerange", "precondition", "."...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ValidateClosedTimeRange
Checks that a time-range has both start and end timestamps set.
grr/server/grr_response_server/databases/db.py
def _ValidateClosedTimeRange(time_range): """Checks that a time-range has both start and end timestamps set.""" time_range_start, time_range_end = time_range _ValidateTimestamp(time_range_start) _ValidateTimestamp(time_range_end) if time_range_start > time_range_end: raise ValueError("Invalid time-range: ...
def _ValidateClosedTimeRange(time_range): """Checks that a time-range has both start and end timestamps set.""" time_range_start, time_range_end = time_range _ValidateTimestamp(time_range_start) _ValidateTimestamp(time_range_end) if time_range_start > time_range_end: raise ValueError("Invalid time-range: ...
[ "Checks", "that", "a", "time", "-", "range", "has", "both", "start", "and", "end", "timestamps", "set", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L4114-L4122
[ "def", "_ValidateClosedTimeRange", "(", "time_range", ")", ":", "time_range_start", ",", "time_range_end", "=", "time_range", "_ValidateTimestamp", "(", "time_range_start", ")", "_ValidateTimestamp", "(", "time_range_end", ")", "if", "time_range_start", ">", "time_range_e...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.WriteClientMetadata
Write metadata about the client. Updates one or more client metadata fields for the given client_id. Any of the data fields can be left as None, and in this case are not changed. Args: client_id: A GRR client id string, e.g. "C.ea3b2b71840d6fa7". certificate: If set, should be an rdfvalues.cry...
grr/server/grr_response_server/databases/db.py
def WriteClientMetadata(self, client_id, certificate=None, fleetspeak_enabled=None, first_seen=None, last_ping=None, last_clock=None, last...
def WriteClientMetadata(self, client_id, certificate=None, fleetspeak_enabled=None, first_seen=None, last_ping=None, last_clock=None, last...
[ "Write", "metadata", "about", "the", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L568-L599
[ "def", "WriteClientMetadata", "(", "self", ",", "client_id", ",", "certificate", "=", "None", ",", "fleetspeak_enabled", "=", "None", ",", "first_seen", "=", "None", ",", "last_ping", "=", "None", ",", "last_clock", "=", "None", ",", "last_ip", "=", "None", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.ReadClientMetadata
Reads the ClientMetadata record for a single client. Args: client_id: A GRR client id string, e.g. "C.ea3b2b71840d6fa7". Returns: An rdfvalues.object.ClientMetadata object. Raises: UnknownClientError: if no client with corresponding id was found.
grr/server/grr_response_server/databases/db.py
def ReadClientMetadata(self, client_id): """Reads the ClientMetadata record for a single client. Args: client_id: A GRR client id string, e.g. "C.ea3b2b71840d6fa7". Returns: An rdfvalues.object.ClientMetadata object. Raises: UnknownClientError: if no client with corresponding id was...
def ReadClientMetadata(self, client_id): """Reads the ClientMetadata record for a single client. Args: client_id: A GRR client id string, e.g. "C.ea3b2b71840d6fa7". Returns: An rdfvalues.object.ClientMetadata object. Raises: UnknownClientError: if no client with corresponding id was...
[ "Reads", "the", "ClientMetadata", "record", "for", "a", "single", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L629-L645
[ "def", "ReadClientMetadata", "(", "self", ",", "client_id", ")", ":", "result", "=", "self", ".", "MultiReadClientMetadata", "(", "[", "client_id", "]", ")", "try", ":", "return", "result", "[", "client_id", "]", "except", "KeyError", ":", "raise", "UnknownC...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.ReadClientFullInfo
Reads full client information for a single client. Args: client_id: A GRR client id string, e.g. "C.ea3b2b71840d6fa7". Returns: A `ClientFullInfo` instance for given client. Raises: UnknownClientError: if no client with such id was found.
grr/server/grr_response_server/databases/db.py
def ReadClientFullInfo(self, client_id): """Reads full client information for a single client. Args: client_id: A GRR client id string, e.g. "C.ea3b2b71840d6fa7". Returns: A `ClientFullInfo` instance for given client. Raises: UnknownClientError: if no client with such id was found. ...
def ReadClientFullInfo(self, client_id): """Reads full client information for a single client. Args: client_id: A GRR client id string, e.g. "C.ea3b2b71840d6fa7". Returns: A `ClientFullInfo` instance for given client. Raises: UnknownClientError: if no client with such id was found. ...
[ "Reads", "full", "client", "information", "for", "a", "single", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L702-L718
[ "def", "ReadClientFullInfo", "(", "self", ",", "client_id", ")", ":", "result", "=", "self", ".", "MultiReadClientFullInfo", "(", "[", "client_id", "]", ")", "try", ":", "return", "result", "[", "client_id", "]", "except", "KeyError", ":", "raise", "UnknownC...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.IterateAllClientsFullInfo
Iterates over all available clients and yields full info protobufs. Args: min_last_ping: If not None, only the clients with last-ping timestamps newer than (or equal to) min_last_ping will be returned. batch_size: Always reads <batch_size> client full infos at a time. Yields: An rdfv...
grr/server/grr_response_server/databases/db.py
def IterateAllClientsFullInfo(self, min_last_ping=None, batch_size=50000): """Iterates over all available clients and yields full info protobufs. Args: min_last_ping: If not None, only the clients with last-ping timestamps newer than (or equal to) min_last_ping will be returned. batch_size:...
def IterateAllClientsFullInfo(self, min_last_ping=None, batch_size=50000): """Iterates over all available clients and yields full info protobufs. Args: min_last_ping: If not None, only the clients with last-ping timestamps newer than (or equal to) min_last_ping will be returned. batch_size:...
[ "Iterates", "over", "all", "available", "clients", "and", "yields", "full", "info", "protobufs", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1230-L1246
[ "def", "IterateAllClientsFullInfo", "(", "self", ",", "min_last_ping", "=", "None", ",", "batch_size", "=", "50000", ")", ":", "all_client_ids", "=", "self", ".", "ReadAllClientIDs", "(", "min_last_ping", "=", "min_last_ping", ")", "for", "batch", "in", "collect...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.IterateAllClientSnapshots
Iterates over all available clients and yields client snapshot objects. Args: min_last_ping: If provided, only snapshots for clients with last-ping timestamps newer than (or equal to) the given value will be returned. batch_size: Always reads <batch_size> snapshots at a time. Yields: ...
grr/server/grr_response_server/databases/db.py
def IterateAllClientSnapshots(self, min_last_ping=None, batch_size=50000): """Iterates over all available clients and yields client snapshot objects. Args: min_last_ping: If provided, only snapshots for clients with last-ping timestamps newer than (or equal to) the given value will be returned. ...
def IterateAllClientSnapshots(self, min_last_ping=None, batch_size=50000): """Iterates over all available clients and yields client snapshot objects. Args: min_last_ping: If provided, only snapshots for clients with last-ping timestamps newer than (or equal to) the given value will be returned. ...
[ "Iterates", "over", "all", "available", "clients", "and", "yields", "client", "snapshot", "objects", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1248-L1265
[ "def", "IterateAllClientSnapshots", "(", "self", ",", "min_last_ping", "=", "None", ",", "batch_size", "=", "50000", ")", ":", "all_client_ids", "=", "self", ".", "ReadAllClientIDs", "(", "min_last_ping", "=", "min_last_ping", ")", "for", "batch", "in", "collect...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.ListChildPathInfos
Lists path info records that correspond to children of given path. Args: client_id: An identifier string for a client. path_type: A type of a path to retrieve path information for. components: A tuple of path components of a path to retrieve child path information for. timestamp: If...
grr/server/grr_response_server/databases/db.py
def ListChildPathInfos(self, client_id, path_type, components, timestamp=None): """Lists path info records that correspond to children of given path. Args: client_id: An identifier string for a client. path_type: A type of a path to retrieve path information for. comp...
def ListChildPathInfos(self, client_id, path_type, components, timestamp=None): """Lists path info records that correspond to children of given path. Args: client_id: An identifier string for a client. path_type: A type of a path to retrieve path information for. comp...
[ "Lists", "path", "info", "records", "that", "correspond", "to", "children", "of", "given", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1303-L1319
[ "def", "ListChildPathInfos", "(", "self", ",", "client_id", ",", "path_type", ",", "components", ",", "timestamp", "=", "None", ")", ":", "return", "self", ".", "ListDescendentPathInfos", "(", "client_id", ",", "path_type", ",", "components", ",", "max_depth", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.InitPathInfos
Initializes a collection of path info records for a client. Unlike `WritePathInfo`, this method clears stat and hash histories of paths associated with path info records. This method is intended to be used only in the data migration scripts. Args: client_id: A client identifier for which the pat...
grr/server/grr_response_server/databases/db.py
def InitPathInfos(self, client_id, path_infos): """Initializes a collection of path info records for a client. Unlike `WritePathInfo`, this method clears stat and hash histories of paths associated with path info records. This method is intended to be used only in the data migration scripts. Args:...
def InitPathInfos(self, client_id, path_infos): """Initializes a collection of path info records for a client. Unlike `WritePathInfo`, this method clears stat and hash histories of paths associated with path info records. This method is intended to be used only in the data migration scripts. Args:...
[ "Initializes", "a", "collection", "of", "path", "info", "records", "for", "a", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1364-L1376
[ "def", "InitPathInfos", "(", "self", ",", "client_id", ",", "path_infos", ")", ":", "self", ".", "ClearPathHistory", "(", "client_id", ",", "path_infos", ")", "self", ".", "WritePathInfos", "(", "client_id", ",", "path_infos", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.WritePathStatHistory
Writes a collection of `StatEntry` observed for particular path. Args: client_path: A `ClientPath` instance. stat_entries: A dictionary with timestamps as keys and `StatEntry` instances as values.
grr/server/grr_response_server/databases/db.py
def WritePathStatHistory(self, client_path, stat_entries): """Writes a collection of `StatEntry` observed for particular path. Args: client_path: A `ClientPath` instance. stat_entries: A dictionary with timestamps as keys and `StatEntry` instances as values. """ client_path_history ...
def WritePathStatHistory(self, client_path, stat_entries): """Writes a collection of `StatEntry` observed for particular path. Args: client_path: A `ClientPath` instance. stat_entries: A dictionary with timestamps as keys and `StatEntry` instances as values. """ client_path_history ...
[ "Writes", "a", "collection", "of", "StatEntry", "observed", "for", "particular", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1419-L1431
[ "def", "WritePathStatHistory", "(", "self", ",", "client_path", ",", "stat_entries", ")", ":", "client_path_history", "=", "ClientPathHistory", "(", ")", "for", "timestamp", ",", "stat_entry", "in", "iteritems", "(", "stat_entries", ")", ":", "client_path_history", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.WritePathHashHistory
Writes a collection of `Hash` observed for particular path. Args: client_path: A `ClientPath` instance. hash_entries: A dictionary with timestamps as keys and `Hash` instances as values.
grr/server/grr_response_server/databases/db.py
def WritePathHashHistory(self, client_path, hash_entries): """Writes a collection of `Hash` observed for particular path. Args: client_path: A `ClientPath` instance. hash_entries: A dictionary with timestamps as keys and `Hash` instances as values. """ client_path_history = ClientPa...
def WritePathHashHistory(self, client_path, hash_entries): """Writes a collection of `Hash` observed for particular path. Args: client_path: A `ClientPath` instance. hash_entries: A dictionary with timestamps as keys and `Hash` instances as values. """ client_path_history = ClientPa...
[ "Writes", "a", "collection", "of", "Hash", "observed", "for", "particular", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1433-L1445
[ "def", "WritePathHashHistory", "(", "self", ",", "client_path", ",", "hash_entries", ")", ":", "client_path_history", "=", "ClientPathHistory", "(", ")", "for", "timestamp", ",", "hash_entry", "in", "iteritems", "(", "hash_entries", ")", ":", "client_path_history", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.ReadPathInfoHistory
Reads a collection of hash and stat entry for given path. Args: client_id: An identifier string for a client. path_type: A type of a path to retrieve path history for. components: A tuple of path components corresponding to path to retrieve information for. Returns: A list of `...
grr/server/grr_response_server/databases/db.py
def ReadPathInfoHistory(self, client_id, path_type, components): """Reads a collection of hash and stat entry for given path. Args: client_id: An identifier string for a client. path_type: A type of a path to retrieve path history for. components: A tuple of path components corresponding to p...
def ReadPathInfoHistory(self, client_id, path_type, components): """Reads a collection of hash and stat entry for given path. Args: client_id: An identifier string for a client. path_type: A type of a path to retrieve path history for. components: A tuple of path components corresponding to p...
[ "Reads", "a", "collection", "of", "hash", "and", "stat", "entry", "for", "given", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1462-L1475
[ "def", "ReadPathInfoHistory", "(", "self", ",", "client_id", ",", "path_type", ",", "components", ")", ":", "histories", "=", "self", ".", "ReadPathInfosHistories", "(", "client_id", ",", "path_type", ",", "[", "components", "]", ")", "return", "histories", "[...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.UpdateCronJob
Updates run information for an existing cron job. Args: cronjob_id: The id of the cron job to update. last_run_status: A CronJobRunStatus object. last_run_time: The last time a run was started for this cron job. current_run_id: The id of the currently active run. state: The state dict...
grr/server/grr_response_server/databases/db.py
def UpdateCronJob(self, cronjob_id, last_run_status=unchanged, last_run_time=unchanged, current_run_id=unchanged, state=unchanged, forced_run_requested=unchanged): """Updates run information for a...
def UpdateCronJob(self, cronjob_id, last_run_status=unchanged, last_run_time=unchanged, current_run_id=unchanged, state=unchanged, forced_run_requested=unchanged): """Updates run information for a...
[ "Updates", "run", "information", "for", "an", "existing", "cron", "job", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1707-L1727
[ "def", "UpdateCronJob", "(", "self", ",", "cronjob_id", ",", "last_run_status", "=", "unchanged", ",", "last_run_time", "=", "unchanged", ",", "current_run_id", "=", "unchanged", ",", "state", "=", "unchanged", ",", "forced_run_requested", "=", "unchanged", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.UpdateFlow
Updates flow objects in the database. Args: client_id: The client id on which this flow is running. flow_id: The id of the flow to update. flow_obj: An updated rdf_flow_objects.Flow object. flow_state: An update rdf_flow_objects.Flow.FlowState value. client_crash_info: A rdf_client.Cl...
grr/server/grr_response_server/databases/db.py
def UpdateFlow(self, client_id, flow_id, flow_obj=unchanged, flow_state=unchanged, client_crash_info=unchanged, pending_termination=unchanged, processing_on=unchanged, processing_since...
def UpdateFlow(self, client_id, flow_id, flow_obj=unchanged, flow_state=unchanged, client_crash_info=unchanged, pending_termination=unchanged, processing_on=unchanged, processing_since...
[ "Updates", "flow", "objects", "in", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1982-L2006
[ "def", "UpdateFlow", "(", "self", ",", "client_id", ",", "flow_id", ",", "flow_obj", "=", "unchanged", ",", "flow_state", "=", "unchanged", ",", "client_crash_info", "=", "unchanged", ",", "pending_termination", "=", "unchanged", ",", "processing_on", "=", "unch...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Database.UpdateHuntObject
Updates the hunt object by applying the update function. Each keyword argument when set to None, means that that corresponding value shouldn't be updated. Args: hunt_id: Id of the hunt to be updated. duration: A maximum allowed running time duration of the flow. client_rate: Number corre...
grr/server/grr_response_server/databases/db.py
def UpdateHuntObject(self, hunt_id, duration=None, client_rate=None, client_limit=None, hunt_state=None, hunt_state_comment=None, start_time=None, ...
def UpdateHuntObject(self, hunt_id, duration=None, client_rate=None, client_limit=None, hunt_state=None, hunt_state_comment=None, start_time=None, ...
[ "Updates", "the", "hunt", "object", "by", "applying", "the", "update", "function", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L2379-L2403
[ "def", "UpdateHuntObject", "(", "self", ",", "hunt_id", ",", "duration", "=", "None", ",", "client_rate", "=", "None", ",", "client_limit", "=", "None", ",", "hunt_state", "=", "None", ",", "hunt_state_comment", "=", "None", ",", "start_time", "=", "None", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DatabaseValidationWrapper.UpdateHuntObject
Updates the hunt object by applying the update function.
grr/server/grr_response_server/databases/db.py
def UpdateHuntObject(self, hunt_id, duration=None, client_rate=None, client_limit=None, hunt_state=None, hunt_state_comment=None, start_time=None, ...
def UpdateHuntObject(self, hunt_id, duration=None, client_rate=None, client_limit=None, hunt_state=None, hunt_state_comment=None, start_time=None, ...
[ "Updates", "the", "hunt", "object", "by", "applying", "the", "update", "function", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L3770-L3798
[ "def", "UpdateHuntObject", "(", "self", ",", "hunt_id", ",", "duration", "=", "None", ",", "client_rate", "=", "None", ",", "client_limit", "=", "None", ",", "hunt_state", "=", "None", ",", "hunt_state_comment", "=", "None", ",", "start_time", "=", "None", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_WorkerThread.ProcessTask
Processes the tasks.
grr/server/grr_response_server/threadpool.py
def ProcessTask(self, target, args, name, queueing_time): """Processes the tasks.""" if self.pool.name: time_in_queue = time.time() - queueing_time stats_collector_instance.Get().RecordEvent( _QUEUEING_TIME_METRIC, time_in_queue, fields=[self.pool.name]) start_time = time.time() ...
def ProcessTask(self, target, args, name, queueing_time): """Processes the tasks.""" if self.pool.name: time_in_queue = time.time() - queueing_time stats_collector_instance.Get().RecordEvent( _QUEUEING_TIME_METRIC, time_in_queue, fields=[self.pool.name]) start_time = time.time() ...
[ "Processes", "the", "tasks", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L108-L132
[ "def", "ProcessTask", "(", "self", ",", "target", ",", "args", ",", "name", ",", "queueing_time", ")", ":", "if", "self", ".", "pool", ".", "name", ":", "time_in_queue", "=", "time", ".", "time", "(", ")", "-", "queueing_time", "stats_collector_instance", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_WorkerThread._RemoveFromPool
Remove ourselves from the pool. Returns: True if removal was possible, and False if it was not possible.
grr/server/grr_response_server/threadpool.py
def _RemoveFromPool(self): """Remove ourselves from the pool. Returns: True if removal was possible, and False if it was not possible. """ with self.pool.lock: # Pool is shutting down, we can't interfere. if not self.pool.started: return False # Keep a minimum number o...
def _RemoveFromPool(self): """Remove ourselves from the pool. Returns: True if removal was possible, and False if it was not possible. """ with self.pool.lock: # Pool is shutting down, we can't interfere. if not self.pool.started: return False # Keep a minimum number o...
[ "Remove", "ourselves", "from", "the", "pool", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L134-L153
[ "def", "_RemoveFromPool", "(", "self", ")", ":", "with", "self", ".", "pool", ".", "lock", ":", "# Pool is shutting down, we can't interfere.", "if", "not", "self", ".", "pool", ".", "started", ":", "return", "False", "# Keep a minimum number of threads in the pool.",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_WorkerThread.run
This overrides the Thread.run method. This method checks in an endless loop if new tasks are available in the queue and processes them.
grr/server/grr_response_server/threadpool.py
def run(self): """This overrides the Thread.run method. This method checks in an endless loop if new tasks are available in the queue and processes them. """ while True: if self.pool.name: self.idle = True try: # Wait 60 seconds for a message, otherwise exit. This ensur...
def run(self): """This overrides the Thread.run method. This method checks in an endless loop if new tasks are available in the queue and processes them. """ while True: if self.pool.name: self.idle = True try: # Wait 60 seconds for a message, otherwise exit. This ensur...
[ "This", "overrides", "the", "Thread", ".", "run", "method", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L155-L192
[ "def", "run", "(", "self", ")", ":", "while", "True", ":", "if", "self", ".", "pool", ".", "name", ":", "self", ".", "idle", "=", "True", "try", ":", "# Wait 60 seconds for a message, otherwise exit. This ensures that the", "# threadpool will be trimmed down when load...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ThreadPool.Factory
Creates a new thread pool with the given name. If the thread pool of this name already exist, we just return the existing one. This allows us to have different pools with different characteristics used by different parts of the code, at the same time. Args: name: The name of the required pool. ...
grr/server/grr_response_server/threadpool.py
def Factory(cls, name, min_threads, max_threads=None): """Creates a new thread pool with the given name. If the thread pool of this name already exist, we just return the existing one. This allows us to have different pools with different characteristics used by different parts of the code, at the same...
def Factory(cls, name, min_threads, max_threads=None): """Creates a new thread pool with the given name. If the thread pool of this name already exist, we just return the existing one. This allows us to have different pools with different characteristics used by different parts of the code, at the same...
[ "Creates", "a", "new", "thread", "pool", "with", "the", "given", "name", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L222-L244
[ "def", "Factory", "(", "cls", ",", "name", ",", "min_threads", ",", "max_threads", "=", "None", ")", ":", "with", "cls", ".", "factory_lock", ":", "result", "=", "cls", ".", "POOLS", ".", "get", "(", "name", ")", "if", "result", "is", "None", ":", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ThreadPool.Start
This starts the worker threads.
grr/server/grr_response_server/threadpool.py
def Start(self): """This starts the worker threads.""" if not self.started: self.started = True for _ in range(self.min_threads): self._AddWorker()
def Start(self): """This starts the worker threads.""" if not self.started: self.started = True for _ in range(self.min_threads): self._AddWorker()
[ "This", "starts", "the", "worker", "threads", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L309-L314
[ "def", "Start", "(", "self", ")", ":", "if", "not", "self", ".", "started", ":", "self", ".", "started", "=", "True", "for", "_", "in", "range", "(", "self", ".", "min_threads", ")", ":", "self", ".", "_AddWorker", "(", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ThreadPool.Stop
This stops all the worker threads.
grr/server/grr_response_server/threadpool.py
def Stop(self, join_timeout=600): """This stops all the worker threads.""" if not self.started: logging.warning("Tried to stop a thread pool that was not running.") return # Remove all workers from the pool. workers = list(itervalues(self._workers)) self._workers = {} self._workers_...
def Stop(self, join_timeout=600): """This stops all the worker threads.""" if not self.started: logging.warning("Tried to stop a thread pool that was not running.") return # Remove all workers from the pool. workers = list(itervalues(self._workers)) self._workers = {} self._workers_...
[ "This", "stops", "all", "the", "worker", "threads", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L331-L361
[ "def", "Stop", "(", "self", ",", "join_timeout", "=", "600", ")", ":", "if", "not", "self", ".", "started", ":", "logging", ".", "warning", "(", "\"Tried to stop a thread pool that was not running.\"", ")", "return", "# Remove all workers from the pool.", "workers", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ThreadPool.AddTask
Adds a task to be processed later. Args: target: A callable which should be processed by one of the workers. args: A tuple of arguments to target. name: The name of this task. Used to identify tasks in the log. blocking: If True we block until the task is finished, otherwise we raise ...
grr/server/grr_response_server/threadpool.py
def AddTask(self, target, args=(), name="Unnamed task", blocking=True, inline=True): """Adds a task to be processed later. Args: target: A callable which should be processed by one of the workers. args: A tuple of arguments to ta...
def AddTask(self, target, args=(), name="Unnamed task", blocking=True, inline=True): """Adds a task to be processed later. Args: target: A callable which should be processed by one of the workers. args: A tuple of arguments to ta...
[ "Adds", "a", "task", "to", "be", "processed", "later", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L363-L453
[ "def", "AddTask", "(", "self", ",", "target", ",", "args", "=", "(", ")", ",", "name", "=", "\"Unnamed task\"", ",", "blocking", "=", "True", ",", "inline", "=", "True", ")", ":", "if", "not", "self", ".", "started", ":", "raise", "ThreadPoolNotStarted...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ThreadPool.Join
Waits until all outstanding tasks are completed.
grr/server/grr_response_server/threadpool.py
def Join(self): """Waits until all outstanding tasks are completed.""" for _ in range(self.JOIN_TIMEOUT_DECISECONDS): if self._queue.empty() and not self.busy_threads: return time.sleep(0.1) raise ValueError("Timeout during Join() for threadpool %s." % self.name)
def Join(self): """Waits until all outstanding tasks are completed.""" for _ in range(self.JOIN_TIMEOUT_DECISECONDS): if self._queue.empty() and not self.busy_threads: return time.sleep(0.1) raise ValueError("Timeout during Join() for threadpool %s." % self.name)
[ "Waits", "until", "all", "outstanding", "tasks", "are", "completed", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L458-L466
[ "def", "Join", "(", "self", ")", ":", "for", "_", "in", "range", "(", "self", ".", "JOIN_TIMEOUT_DECISECONDS", ")", ":", "if", "self", ".", "_queue", ".", "empty", "(", ")", "and", "not", "self", ".", "busy_threads", ":", "return", "time", ".", "slee...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BatchConverter.Convert
Converts given collection to exported values. This method uses a threadpool to do the conversion in parallel. It blocks for up to one hour until everything is converted. Args: values: Iterable object with values to convert. start_index: Start from this index in the collection. end_index:...
grr/server/grr_response_server/threadpool.py
def Convert(self, values, start_index=0, end_index=None): """Converts given collection to exported values. This method uses a threadpool to do the conversion in parallel. It blocks for up to one hour until everything is converted. Args: values: Iterable object with values to convert. start...
def Convert(self, values, start_index=0, end_index=None): """Converts given collection to exported values. This method uses a threadpool to do the conversion in parallel. It blocks for up to one hour until everything is converted. Args: values: Iterable object with values to convert. start...
[ "Converts", "given", "collection", "to", "exported", "values", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L539-L579
[ "def", "Convert", "(", "self", ",", "values", ",", "start_index", "=", "0", ",", "end_index", "=", "None", ")", ":", "if", "not", "values", ":", "return", "try", ":", "total_batch_count", "=", "len", "(", "values", ")", "//", "self", ".", "batch_size",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SpawnProcess
Spawns a process.
grr/client_builder/grr_response_client_builder/client_build.py
def SpawnProcess(popen_args, passwd=None): """Spawns a process.""" if passwd is not None: # We send the password via pipe to avoid creating a process with the # password as an argument that will get logged on some systems. p = subprocess.Popen(popen_args, stdin=subprocess.PIPE) p.communicate(input=p...
def SpawnProcess(popen_args, passwd=None): """Spawns a process.""" if passwd is not None: # We send the password via pipe to avoid creating a process with the # password as an argument that will get logged on some systems. p = subprocess.Popen(popen_args, stdin=subprocess.PIPE) p.communicate(input=p...
[ "Spawns", "a", "process", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/client_build.py#L239-L250
[ "def", "SpawnProcess", "(", "popen_args", ",", "passwd", "=", "None", ")", ":", "if", "passwd", "is", "not", "None", ":", "# We send the password via pipe to avoid creating a process with the", "# password as an argument that will get logged on some systems.", "p", "=", "subp...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GetClientConfig
Write client config to filename.
grr/client_builder/grr_response_client_builder/client_build.py
def GetClientConfig(filename): """Write client config to filename.""" config_lib.SetPlatformArchContext() config_lib.ParseConfigCommandLine() context = list(grr_config.CONFIG.context) context.append("Client Context") deployer = build.ClientRepacker() # Disable timestamping so we can get a reproducible and...
def GetClientConfig(filename): """Write client config to filename.""" config_lib.SetPlatformArchContext() config_lib.ParseConfigCommandLine() context = list(grr_config.CONFIG.context) context.append("Client Context") deployer = build.ClientRepacker() # Disable timestamping so we can get a reproducible and...
[ "Write", "client", "config", "to", "filename", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/client_build.py#L387-L400
[ "def", "GetClientConfig", "(", "filename", ")", ":", "config_lib", ".", "SetPlatformArchContext", "(", ")", "config_lib", ".", "ParseConfigCommandLine", "(", ")", "context", "=", "list", "(", "grr_config", ".", "CONFIG", ".", "context", ")", "context", ".", "a...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
main
Launch the appropriate builder.
grr/client_builder/grr_response_client_builder/client_build.py
def main(args): """Launch the appropriate builder.""" grr_config.CONFIG.AddContext(contexts.CLIENT_BUILD_CONTEXT) if args.subparser_name == "generate_client_config": # We don't need a full init to just build a config. GetClientConfig(args.client_config_output) return # TODO(user): Find out if add...
def main(args): """Launch the appropriate builder.""" grr_config.CONFIG.AddContext(contexts.CLIENT_BUILD_CONTEXT) if args.subparser_name == "generate_client_config": # We don't need a full init to just build a config. GetClientConfig(args.client_config_output) return # TODO(user): Find out if add...
[ "Launch", "the", "appropriate", "builder", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/client_build.py#L403-L486
[ "def", "main", "(", "args", ")", ":", "grr_config", ".", "CONFIG", ".", "AddContext", "(", "contexts", ".", "CLIENT_BUILD_CONTEXT", ")", "if", "args", ".", "subparser_name", "==", "\"generate_client_config\"", ":", "# We don't need a full init to just build a config.", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TemplateBuilder.GetBuilder
Get instance of builder class based on flags.
grr/client_builder/grr_response_client_builder/client_build.py
def GetBuilder(self, context, fleetspeak_service_config): """Get instance of builder class based on flags.""" try: if "Target:Darwin" in context: return builders.DarwinClientBuilder( context=context, fleetspeak_service_config=fleetspeak_service_config) elif "Target:Wi...
def GetBuilder(self, context, fleetspeak_service_config): """Get instance of builder class based on flags.""" try: if "Target:Darwin" in context: return builders.DarwinClientBuilder( context=context, fleetspeak_service_config=fleetspeak_service_config) elif "Target:Wi...
[ "Get", "instance", "of", "builder", "class", "based", "on", "flags", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/client_build.py#L179-L196
[ "def", "GetBuilder", "(", "self", ",", "context", ",", "fleetspeak_service_config", ")", ":", "try", ":", "if", "\"Target:Darwin\"", "in", "context", ":", "return", "builders", ".", "DarwinClientBuilder", "(", "context", "=", "context", ",", "fleetspeak_service_co...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TemplateBuilder.BuildTemplate
Find template builder and call it.
grr/client_builder/grr_response_client_builder/client_build.py
def BuildTemplate(self, context=None, output=None, fleetspeak_service_config=None): """Find template builder and call it.""" context = context or [] context.append("Arch:%s" % self.GetArch()) # Platform context has common platform settings, Tar...
def BuildTemplate(self, context=None, output=None, fleetspeak_service_config=None): """Find template builder and call it.""" context = context or [] context.append("Arch:%s" % self.GetArch()) # Platform context has common platform settings, Tar...
[ "Find", "template", "builder", "and", "call", "it", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/client_build.py#L213-L236
[ "def", "BuildTemplate", "(", "self", ",", "context", "=", "None", ",", "output", "=", "None", ",", "fleetspeak_service_config", "=", "None", ")", ":", "context", "=", "context", "or", "[", "]", "context", ".", "append", "(", "\"Arch:%s\"", "%", "self", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MultiTemplateRepacker.GetOutputDir
Add the repack config filename onto the base output directory. This allows us to repack lots of different configs to the same installer name and still be able to distinguish them. Args: base_dir: output directory string config_filename: the secondary config filename string Returns: ...
grr/client_builder/grr_response_client_builder/client_build.py
def GetOutputDir(self, base_dir, config_filename): """Add the repack config filename onto the base output directory. This allows us to repack lots of different configs to the same installer name and still be able to distinguish them. Args: base_dir: output directory string config_filename:...
def GetOutputDir(self, base_dir, config_filename): """Add the repack config filename onto the base output directory. This allows us to repack lots of different configs to the same installer name and still be able to distinguish them. Args: base_dir: output directory string config_filename:...
[ "Add", "the", "repack", "config", "filename", "onto", "the", "base", "output", "directory", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/client_build.py#L264-L278
[ "def", "GetOutputDir", "(", "self", ",", "base_dir", ",", "config_filename", ")", ":", "return", "os", ".", "path", ".", "join", "(", "base_dir", ",", "os", ".", "path", ".", "basename", "(", "config_filename", ".", "replace", "(", "\".yaml\"", ",", "\"\...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MultiTemplateRepacker.RepackTemplates
Call repacker in a subprocess.
grr/client_builder/grr_response_client_builder/client_build.py
def RepackTemplates(self, repack_configs, templates, output_dir, config=None, sign=False, signed_template=False): """Call repacker in a subprocess.""" pool = multiprocessing.Pool(p...
def RepackTemplates(self, repack_configs, templates, output_dir, config=None, sign=False, signed_template=False): """Call repacker in a subprocess.""" pool = multiprocessing.Pool(p...
[ "Call", "repacker", "in", "a", "subprocess", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/client_build.py#L296-L384
[ "def", "RepackTemplates", "(", "self", ",", "repack_configs", ",", "templates", ",", "output_dir", ",", "config", "=", "None", ",", "sign", "=", "False", ",", "signed_template", "=", "False", ")", ":", "pool", "=", "multiprocessing", ".", "Pool", "(", "pro...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientInit
Run all startup routines for the client.
grr/client/grr_response_client/client_startup.py
def ClientInit(): """Run all startup routines for the client.""" metric_metadata = client_metrics.GetMetadata() metric_metadata.extend(communicator.GetMetricMetadata()) stats_collector_instance.Set( default_stats_collector.DefaultStatsCollector(metric_metadata)) config_lib.SetPlatformArchContext() co...
def ClientInit(): """Run all startup routines for the client.""" metric_metadata = client_metrics.GetMetadata() metric_metadata.extend(communicator.GetMetricMetadata()) stats_collector_instance.Set( default_stats_collector.DefaultStatsCollector(metric_metadata)) config_lib.SetPlatformArchContext() co...
[ "Run", "all", "startup", "routines", "for", "the", "client", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_startup.py#L19-L36
[ "def", "ClientInit", "(", ")", ":", "metric_metadata", "=", "client_metrics", ".", "GetMetadata", "(", ")", "metric_metadata", ".", "extend", "(", "communicator", ".", "GetMetricMetadata", "(", ")", ")", "stats_collector_instance", ".", "Set", "(", "default_stats_...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SysctlCmdParser.Parse
Parse the sysctl output.
grr/core/grr_response_core/lib/parsers/linux_sysctl_parser.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the sysctl output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) result = rdf_protodict.AttributedDict() # The KeyValueParser generates an ordered d...
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the sysctl output.""" _ = stderr, time_taken, args, knowledge_base # Unused. self.CheckReturn(cmd, return_val) result = rdf_protodict.AttributedDict() # The KeyValueParser generates an ordered d...
[ "Parse", "the", "sysctl", "output", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_sysctl_parser.py#L50-L63
[ "def", "Parse", "(", "self", ",", "cmd", ",", "args", ",", "stdout", ",", "stderr", ",", "return_val", ",", "time_taken", ",", "knowledge_base", ")", ":", "_", "=", "stderr", ",", "time_taken", ",", "args", ",", "knowledge_base", "# Unused.", "self", "."...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CurrentControlSetKBParser.Parse
Parse the key currentcontrolset output.
grr/core/grr_response_core/lib/parsers/windows_registry_parser.py
def Parse(self, stat, unused_knowledge_base): """Parse the key currentcontrolset output.""" value = stat.registry_data.GetValue() if not str(value).isdigit() or int(value) > 999 or int(value) < 0: raise parser.ParseError( "Invalid value for CurrentControlSet key %s" % value) yield rdfva...
def Parse(self, stat, unused_knowledge_base): """Parse the key currentcontrolset output.""" value = stat.registry_data.GetValue() if not str(value).isdigit() or int(value) > 999 or int(value) < 0: raise parser.ParseError( "Invalid value for CurrentControlSet key %s" % value) yield rdfva...
[ "Parse", "the", "key", "currentcontrolset", "output", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/windows_registry_parser.py#L37-L45
[ "def", "Parse", "(", "self", ",", "stat", ",", "unused_knowledge_base", ")", ":", "value", "=", "stat", ".", "registry_data", ".", "GetValue", "(", ")", "if", "not", "str", "(", "value", ")", ".", "isdigit", "(", ")", "or", "int", "(", "value", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WinEnvironmentParser.Parse
Expand any variables in the value.
grr/core/grr_response_core/lib/parsers/windows_registry_parser.py
def Parse(self, stat, knowledge_base): """Expand any variables in the value.""" value = stat.registry_data.GetValue() if not value: raise parser.ParseError("Invalid value for key %s" % stat.pathspec.path) value = artifact_utils.ExpandWindowsEnvironmentVariables( value, knowledge_base) ...
def Parse(self, stat, knowledge_base): """Expand any variables in the value.""" value = stat.registry_data.GetValue() if not value: raise parser.ParseError("Invalid value for key %s" % stat.pathspec.path) value = artifact_utils.ExpandWindowsEnvironmentVariables( value, knowledge_base) ...
[ "Expand", "any", "variables", "in", "the", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/windows_registry_parser.py#L61-L69
[ "def", "Parse", "(", "self", ",", "stat", ",", "knowledge_base", ")", ":", "value", "=", "stat", ".", "registry_data", ".", "GetValue", "(", ")", "if", "not", "value", ":", "raise", "parser", ".", "ParseError", "(", "\"Invalid value for key %s\"", "%", "st...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WinSystemDriveParser.Parse
Parses a SystemDrive environment variable.
grr/core/grr_response_core/lib/parsers/windows_registry_parser.py
def Parse(self, stat, _): """Parses a SystemDrive environment variable.""" if isinstance(stat, rdf_client_fs.StatEntry): value = stat.registry_data.GetValue() elif isinstance(stat, rdfvalue.RDFString): value = stat if not value: raise parser.ParseError("Invalid value for key %s" % stat...
def Parse(self, stat, _): """Parses a SystemDrive environment variable.""" if isinstance(stat, rdf_client_fs.StatEntry): value = stat.registry_data.GetValue() elif isinstance(stat, rdfvalue.RDFString): value = stat if not value: raise parser.ParseError("Invalid value for key %s" % stat...
[ "Parses", "a", "SystemDrive", "environment", "variable", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/windows_registry_parser.py#L78-L92
[ "def", "Parse", "(", "self", ",", "stat", ",", "_", ")", ":", "if", "isinstance", "(", "stat", ",", "rdf_client_fs", ".", "StatEntry", ")", ":", "value", "=", "stat", ".", "registry_data", ".", "GetValue", "(", ")", "elif", "isinstance", "(", "stat", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WinUserSids.Parse
Parse each returned registry value.
grr/core/grr_response_core/lib/parsers/windows_registry_parser.py
def Parse(self, stat, knowledge_base): """Parse each returned registry value.""" _ = knowledge_base # Unused. sid_str = stat.pathspec.Dirname().Basename() if SID_RE.match(sid_str): kb_user = rdf_client.User() kb_user.sid = sid_str if stat.pathspec.Basename() == "ProfileImagePath": ...
def Parse(self, stat, knowledge_base): """Parse each returned registry value.""" _ = knowledge_base # Unused. sid_str = stat.pathspec.Dirname().Basename() if SID_RE.match(sid_str): kb_user = rdf_client.User() kb_user.sid = sid_str if stat.pathspec.Basename() == "ProfileImagePath": ...
[ "Parse", "each", "returned", "registry", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/windows_registry_parser.py#L161-L185
[ "def", "Parse", "(", "self", ",", "stat", ",", "knowledge_base", ")", ":", "_", "=", "knowledge_base", "# Unused.", "sid_str", "=", "stat", ".", "pathspec", ".", "Dirname", "(", ")", ".", "Basename", "(", ")", "if", "SID_RE", ".", "match", "(", "sid_st...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WinUserSpecialDirs.ParseMultiple
Parse each returned registry value.
grr/core/grr_response_core/lib/parsers/windows_registry_parser.py
def ParseMultiple(self, stats, knowledge_base): """Parse each returned registry value.""" user_dict = {} for stat in stats: sid_str = stat.pathspec.path.split("/", 3)[2] if SID_RE.match(sid_str): if sid_str not in user_dict: user_dict[sid_str] = rdf_client.User(sid=sid_str) ...
def ParseMultiple(self, stats, knowledge_base): """Parse each returned registry value.""" user_dict = {} for stat in stats: sid_str = stat.pathspec.path.split("/", 3)[2] if SID_RE.match(sid_str): if sid_str not in user_dict: user_dict[sid_str] = rdf_client.User(sid=sid_str) ...
[ "Parse", "each", "returned", "registry", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/windows_registry_parser.py#L225-L251
[ "def", "ParseMultiple", "(", "self", ",", "stats", ",", "knowledge_base", ")", ":", "user_dict", "=", "{", "}", "for", "stat", "in", "stats", ":", "sid_str", "=", "stat", ".", "pathspec", ".", "path", ".", "split", "(", "\"/\"", ",", "3", ")", "[", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WinServicesParser.ParseMultiple
Parse Service registry keys and return WindowsServiceInformation.
grr/core/grr_response_core/lib/parsers/windows_registry_parser.py
def ParseMultiple(self, stats, knowledge_base): """Parse Service registry keys and return WindowsServiceInformation.""" _ = knowledge_base services = {} field_map = { "Description": "description", "DisplayName": "display_name", "Group": "group_name", "DriverPackageId": "d...
def ParseMultiple(self, stats, knowledge_base): """Parse Service registry keys and return WindowsServiceInformation.""" _ = knowledge_base services = {} field_map = { "Description": "description", "DisplayName": "display_name", "Group": "group_name", "DriverPackageId": "d...
[ "Parse", "Service", "registry", "keys", "and", "return", "WindowsServiceInformation", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/windows_registry_parser.py#L280-L335
[ "def", "ParseMultiple", "(", "self", ",", "stats", ",", "knowledge_base", ")", ":", "_", "=", "knowledge_base", "services", "=", "{", "}", "field_map", "=", "{", "\"Description\"", ":", "\"description\"", ",", "\"DisplayName\"", ":", "\"display_name\"", ",", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WinTimezoneParser.Parse
Convert the timezone to Olson format.
grr/core/grr_response_core/lib/parsers/windows_registry_parser.py
def Parse(self, stat, knowledge_base): """Convert the timezone to Olson format.""" _ = knowledge_base value = stat.registry_data.GetValue() result = ZONE_LIST.get(value.strip()) if not result: yield rdfvalue.RDFString("Unknown (%s)" % value.strip()) yield rdfvalue.RDFString(result)
def Parse(self, stat, knowledge_base): """Convert the timezone to Olson format.""" _ = knowledge_base value = stat.registry_data.GetValue() result = ZONE_LIST.get(value.strip()) if not result: yield rdfvalue.RDFString("Unknown (%s)" % value.strip()) yield rdfvalue.RDFString(result)
[ "Convert", "the", "timezone", "to", "Olson", "format", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/windows_registry_parser.py#L344-L352
[ "def", "Parse", "(", "self", ",", "stat", ",", "knowledge_base", ")", ":", "_", "=", "knowledge_base", "value", "=", "stat", ".", "registry_data", ".", "GetValue", "(", ")", "result", "=", "ZONE_LIST", ".", "get", "(", "value", ".", "strip", "(", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ResponseToApprovalsWithGrants
Converts a generator with approval rows into ApprovalRequest objects.
grr/server/grr_response_server/databases/mysql_users.py
def _ResponseToApprovalsWithGrants(response): """Converts a generator with approval rows into ApprovalRequest objects.""" prev_triplet = None cur_approval_request = None for (approval_id_int, approval_timestamp, approval_request_bytes, grantor_username, grant_timestamp) in response: cur_triplet = (a...
def _ResponseToApprovalsWithGrants(response): """Converts a generator with approval rows into ApprovalRequest objects.""" prev_triplet = None cur_approval_request = None for (approval_id_int, approval_timestamp, approval_request_bytes, grantor_username, grant_timestamp) in response: cur_triplet = (a...
[ "Converts", "a", "generator", "with", "approval", "rows", "into", "ApprovalRequest", "objects", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L24-L52
[ "def", "_ResponseToApprovalsWithGrants", "(", "response", ")", ":", "prev_triplet", "=", "None", "cur_approval_request", "=", "None", "for", "(", "approval_id_int", ",", "approval_timestamp", ",", "approval_request_bytes", ",", "grantor_username", ",", "grant_timestamp", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.WriteGRRUser
Writes user object for a user with a given name.
grr/server/grr_response_server/databases/mysql_users.py
def WriteGRRUser(self, username, password=None, ui_mode=None, canary_mode=None, user_type=None, cursor=None): """Writes user object for a user with a given name.""" values = {"username": username, ...
def WriteGRRUser(self, username, password=None, ui_mode=None, canary_mode=None, user_type=None, cursor=None): """Writes user object for a user with a given name.""" values = {"username": username, ...
[ "Writes", "user", "object", "for", "a", "user", "with", "a", "given", "name", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L59-L89
[ "def", "WriteGRRUser", "(", "self", ",", "username", ",", "password", "=", "None", ",", "ui_mode", "=", "None", ",", "canary_mode", "=", "None", ",", "user_type", "=", "None", ",", "cursor", "=", "None", ")", ":", "values", "=", "{", "\"username\"", ":...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin._RowToGRRUser
Creates a GRR user object from a database result row.
grr/server/grr_response_server/databases/mysql_users.py
def _RowToGRRUser(self, row): """Creates a GRR user object from a database result row.""" username, password, ui_mode, canary_mode, user_type = row result = rdf_objects.GRRUser( username=username, ui_mode=ui_mode, canary_mode=canary_mode, user_type=user_type) if password...
def _RowToGRRUser(self, row): """Creates a GRR user object from a database result row.""" username, password, ui_mode, canary_mode, user_type = row result = rdf_objects.GRRUser( username=username, ui_mode=ui_mode, canary_mode=canary_mode, user_type=user_type) if password...
[ "Creates", "a", "GRR", "user", "object", "from", "a", "database", "result", "row", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L91-L103
[ "def", "_RowToGRRUser", "(", "self", ",", "row", ")", ":", "username", ",", "password", ",", "ui_mode", ",", "canary_mode", ",", "user_type", "=", "row", "result", "=", "rdf_objects", ".", "GRRUser", "(", "username", "=", "username", ",", "ui_mode", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.ReadGRRUser
Reads a user object corresponding to a given name.
grr/server/grr_response_server/databases/mysql_users.py
def ReadGRRUser(self, username, cursor=None): """Reads a user object corresponding to a given name.""" cursor.execute( "SELECT username, password, ui_mode, canary_mode, user_type " "FROM grr_users WHERE username_hash = %s", [mysql_utils.Hash(username)]) row = cursor.fetchone() if row is...
def ReadGRRUser(self, username, cursor=None): """Reads a user object corresponding to a given name.""" cursor.execute( "SELECT username, password, ui_mode, canary_mode, user_type " "FROM grr_users WHERE username_hash = %s", [mysql_utils.Hash(username)]) row = cursor.fetchone() if row is...
[ "Reads", "a", "user", "object", "corresponding", "to", "a", "given", "name", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L106-L116
[ "def", "ReadGRRUser", "(", "self", ",", "username", ",", "cursor", "=", "None", ")", ":", "cursor", ".", "execute", "(", "\"SELECT username, password, ui_mode, canary_mode, user_type \"", "\"FROM grr_users WHERE username_hash = %s\"", ",", "[", "mysql_utils", ".", "Hash",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.ReadGRRUsers
Reads GRR users with optional pagination, sorted by username.
grr/server/grr_response_server/databases/mysql_users.py
def ReadGRRUsers(self, offset=0, count=None, cursor=None): """Reads GRR users with optional pagination, sorted by username.""" if count is None: count = 18446744073709551615 # 2^64-1, as suggested by MySQL docs cursor.execute( "SELECT username, password, ui_mode, canary_mode, user_type " ...
def ReadGRRUsers(self, offset=0, count=None, cursor=None): """Reads GRR users with optional pagination, sorted by username.""" if count is None: count = 18446744073709551615 # 2^64-1, as suggested by MySQL docs cursor.execute( "SELECT username, password, ui_mode, canary_mode, user_type " ...
[ "Reads", "GRR", "users", "with", "optional", "pagination", "sorted", "by", "username", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L119-L128
[ "def", "ReadGRRUsers", "(", "self", ",", "offset", "=", "0", ",", "count", "=", "None", ",", "cursor", "=", "None", ")", ":", "if", "count", "is", "None", ":", "count", "=", "18446744073709551615", "# 2^64-1, as suggested by MySQL docs", "cursor", ".", "exec...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.DeleteGRRUser
Deletes the user and all related metadata with the given username.
grr/server/grr_response_server/databases/mysql_users.py
def DeleteGRRUser(self, username, cursor=None): """Deletes the user and all related metadata with the given username.""" cursor.execute("DELETE FROM grr_users WHERE username_hash = %s", (mysql_utils.Hash(username),)) if cursor.rowcount == 0: raise db.UnknownGRRUserError(username)
def DeleteGRRUser(self, username, cursor=None): """Deletes the user and all related metadata with the given username.""" cursor.execute("DELETE FROM grr_users WHERE username_hash = %s", (mysql_utils.Hash(username),)) if cursor.rowcount == 0: raise db.UnknownGRRUserError(username)
[ "Deletes", "the", "user", "and", "all", "related", "metadata", "with", "the", "given", "username", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L137-L143
[ "def", "DeleteGRRUser", "(", "self", ",", "username", ",", "cursor", "=", "None", ")", ":", "cursor", ".", "execute", "(", "\"DELETE FROM grr_users WHERE username_hash = %s\"", ",", "(", "mysql_utils", ".", "Hash", "(", "username", ")", ",", ")", ")", "if", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.WriteApprovalRequest
Writes an approval request object.
grr/server/grr_response_server/databases/mysql_users.py
def WriteApprovalRequest(self, approval_request, cursor=None): """Writes an approval request object.""" # Copy the approval_request to ensure we don't modify the source object. approval_request = approval_request.Copy() # Generate random approval id. approval_id_int = random.UInt64() grants = a...
def WriteApprovalRequest(self, approval_request, cursor=None): """Writes an approval request object.""" # Copy the approval_request to ensure we don't modify the source object. approval_request = approval_request.Copy() # Generate random approval id. approval_id_int = random.UInt64() grants = a...
[ "Writes", "an", "approval", "request", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L146-L180
[ "def", "WriteApprovalRequest", "(", "self", ",", "approval_request", ",", "cursor", "=", "None", ")", ":", "# Copy the approval_request to ensure we don't modify the source object.", "approval_request", "=", "approval_request", ".", "Copy", "(", ")", "# Generate random approv...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin._GrantApproval
Grants approval for a given request.
grr/server/grr_response_server/databases/mysql_users.py
def _GrantApproval(self, requestor_username, approval_id, grantor_username, cursor): """Grants approval for a given request.""" grant_args = { "username_hash": mysql_utils.Hash(requestor_username), "approval_id": approval_id, "grantor_username_hash": mysql_utils.Hash...
def _GrantApproval(self, requestor_username, approval_id, grantor_username, cursor): """Grants approval for a given request.""" grant_args = { "username_hash": mysql_utils.Hash(requestor_username), "approval_id": approval_id, "grantor_username_hash": mysql_utils.Hash...
[ "Grants", "approval", "for", "a", "given", "request", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L182-L194
[ "def", "_GrantApproval", "(", "self", ",", "requestor_username", ",", "approval_id", ",", "grantor_username", ",", "cursor", ")", ":", "grant_args", "=", "{", "\"username_hash\"", ":", "mysql_utils", ".", "Hash", "(", "requestor_username", ")", ",", "\"approval_id...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.GrantApproval
Grants approval for a given request using given username.
grr/server/grr_response_server/databases/mysql_users.py
def GrantApproval(self, requestor_username, approval_id, grantor_username, cursor=None): """Grants approval for a given request using given username.""" self._GrantApproval( requestor_username, _ApprovalIDToInt(approval_id),...
def GrantApproval(self, requestor_username, approval_id, grantor_username, cursor=None): """Grants approval for a given request using given username.""" self._GrantApproval( requestor_username, _ApprovalIDToInt(approval_id),...
[ "Grants", "approval", "for", "a", "given", "request", "using", "given", "username", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L197-L205
[ "def", "GrantApproval", "(", "self", ",", "requestor_username", ",", "approval_id", ",", "grantor_username", ",", "cursor", "=", "None", ")", ":", "self", ".", "_GrantApproval", "(", "requestor_username", ",", "_ApprovalIDToInt", "(", "approval_id", ")", ",", "g...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.ReadApprovalRequest
Reads an approval request object with a given id.
grr/server/grr_response_server/databases/mysql_users.py
def ReadApprovalRequest(self, requestor_username, approval_id, cursor=None): """Reads an approval request object with a given id.""" query = (""" SELECT ar.approval_id, UNIX_TIMESTAMP(ar.timestamp), ar.approval_request, u.username, UNIX_TIMEST...
def ReadApprovalRequest(self, requestor_username, approval_id, cursor=None): """Reads an approval request object with a given id.""" query = (""" SELECT ar.approval_id, UNIX_TIMESTAMP(ar.timestamp), ar.approval_request, u.username, UNIX_TIMEST...
[ "Reads", "an", "approval", "request", "object", "with", "a", "given", "id", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L208-L251
[ "def", "ReadApprovalRequest", "(", "self", ",", "requestor_username", ",", "approval_id", ",", "cursor", "=", "None", ")", ":", "query", "=", "(", "\"\"\"\n SELECT\n ar.approval_id,\n UNIX_TIMESTAMP(ar.timestamp),\n ar.approval_request,\n ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.ReadApprovalRequests
Reads approval requests of a given type for a given user.
grr/server/grr_response_server/databases/mysql_users.py
def ReadApprovalRequests(self, requestor_username, approval_type, subject_id=None, include_expired=False, cursor=None): """Reads approval requests of a given type for a given user."...
def ReadApprovalRequests(self, requestor_username, approval_type, subject_id=None, include_expired=False, cursor=None): """Reads approval requests of a given type for a given user."...
[ "Reads", "approval", "requests", "of", "a", "given", "type", "for", "a", "given", "user", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L254-L289
[ "def", "ReadApprovalRequests", "(", "self", ",", "requestor_username", ",", "approval_type", ",", "subject_id", "=", "None", ",", "include_expired", "=", "False", ",", "cursor", "=", "None", ")", ":", "query", "=", "\"\"\"\n SELECT\n ar.approval_id,\...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.WriteUserNotification
Writes a notification for a given user.
grr/server/grr_response_server/databases/mysql_users.py
def WriteUserNotification(self, notification, cursor=None): """Writes a notification for a given user.""" # Copy the notification to ensure we don't modify the source object. args = { "username_hash": mysql_utils.Hash(notification.username), "notification_state": int(...
def WriteUserNotification(self, notification, cursor=None): """Writes a notification for a given user.""" # Copy the notification to ensure we don't modify the source object. args = { "username_hash": mysql_utils.Hash(notification.username), "notification_state": int(...
[ "Writes", "a", "notification", "for", "a", "given", "user", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L292-L309
[ "def", "WriteUserNotification", "(", "self", ",", "notification", ",", "cursor", "=", "None", ")", ":", "# Copy the notification to ensure we don't modify the source object.", "args", "=", "{", "\"username_hash\"", ":", "mysql_utils", ".", "Hash", "(", "notification", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.ReadUserNotifications
Reads notifications scheduled for a user within a given timerange.
grr/server/grr_response_server/databases/mysql_users.py
def ReadUserNotifications(self, username, state=None, timerange=None, cursor=None): """Reads notifications scheduled for a user within a given timerange.""" query = ("SELECT UNIX_TIMESTAMP(timestamp)...
def ReadUserNotifications(self, username, state=None, timerange=None, cursor=None): """Reads notifications scheduled for a user within a given timerange.""" query = ("SELECT UNIX_TIMESTAMP(timestamp)...
[ "Reads", "notifications", "scheduled", "for", "a", "user", "within", "a", "given", "timerange", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L312-L351
[ "def", "ReadUserNotifications", "(", "self", ",", "username", ",", "state", "=", "None", ",", "timerange", "=", "None", ",", "cursor", "=", "None", ")", ":", "query", "=", "(", "\"SELECT UNIX_TIMESTAMP(timestamp), \"", "\" notification_state, notification \"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBUsersMixin.UpdateUserNotifications
Updates existing user notification objects.
grr/server/grr_response_server/databases/mysql_users.py
def UpdateUserNotifications(self, username, timestamps, state=None, cursor=None): """Updates existing user notification objects.""" query = ("UPDATE user_notification " "SET noti...
def UpdateUserNotifications(self, username, timestamps, state=None, cursor=None): """Updates existing user notification objects.""" query = ("UPDATE user_notification " "SET noti...
[ "Updates", "existing", "user", "notification", "objects", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_users.py#L354-L371
[ "def", "UpdateUserNotifications", "(", "self", ",", "username", ",", "timestamps", ",", "state", "=", "None", ",", "cursor", "=", "None", ")", ":", "query", "=", "(", "\"UPDATE user_notification \"", "\"SET notification_state = %s \"", "\"WHERE username_hash = %s\"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SplitIntoComponents
Splits strings into space-separated components. The difference between SplitIntoComponents and .split(" ") is that the former tries to respect single and double quotes and strip them using lexical rules typically used in command line interpreters. Args: str_in: Source string to be split into components. ...
grr/core/grr_response_core/path_detection/core.py
def SplitIntoComponents(str_in): """Splits strings into space-separated components. The difference between SplitIntoComponents and .split(" ") is that the former tries to respect single and double quotes and strip them using lexical rules typically used in command line interpreters. Args: str_in: Source...
def SplitIntoComponents(str_in): """Splits strings into space-separated components. The difference between SplitIntoComponents and .split(" ") is that the former tries to respect single and double quotes and strip them using lexical rules typically used in command line interpreters. Args: str_in: Source...
[ "Splits", "strings", "into", "space", "-", "separated", "components", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/path_detection/core.py#L13-L37
[ "def", "SplitIntoComponents", "(", "str_in", ")", ":", "if", "str_in", ".", "startswith", "(", "(", "\"\\\"\"", ",", "\"'\"", ")", ")", ":", "return", "shlex", ".", "split", "(", "str_in", ")", "else", ":", "components", "=", "str_in", ".", "split", "(...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Detector.Detect
Detects paths in a given string. Args: str_in: String where the paths should be detected. Returns: A list of paths (as strings) detected inside the given string.
grr/core/grr_response_core/path_detection/core.py
def Detect(self, str_in): """Detects paths in a given string. Args: str_in: String where the paths should be detected. Returns: A list of paths (as strings) detected inside the given string. """ components = SplitIntoComponents(str_in) extracted_paths = set() for extractor in...
def Detect(self, str_in): """Detects paths in a given string. Args: str_in: String where the paths should be detected. Returns: A list of paths (as strings) detected inside the given string. """ components = SplitIntoComponents(str_in) extracted_paths = set() for extractor in...
[ "Detects", "paths", "in", "a", "given", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/path_detection/core.py#L97-L121
[ "def", "Detect", "(", "self", ",", "str_in", ")", ":", "components", "=", "SplitIntoComponents", "(", "str_in", ")", "extracted_paths", "=", "set", "(", ")", "for", "extractor", "in", "self", ".", "extractors", ":", "extracted_paths", ".", "update", "(", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Init
Register all known vfs handlers to open a pathspec types.
grr/client/grr_response_client/vfs.py
def Init(): """Register all known vfs handlers to open a pathspec types.""" VFS_HANDLERS.clear() _VFS_VIRTUALROOTS.clear() vfs_virtualroots = config.CONFIG["Client.vfs_virtualroots"] VFS_HANDLERS[files.File.supported_pathtype] = files.File VFS_HANDLERS[files.TempFile.supported_pathtype] = files.TempFile ...
def Init(): """Register all known vfs handlers to open a pathspec types.""" VFS_HANDLERS.clear() _VFS_VIRTUALROOTS.clear() vfs_virtualroots = config.CONFIG["Client.vfs_virtualroots"] VFS_HANDLERS[files.File.supported_pathtype] = files.File VFS_HANDLERS[files.TempFile.supported_pathtype] = files.TempFile ...
[ "Register", "all", "known", "vfs", "handlers", "to", "open", "a", "pathspec", "types", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs.py#L40-L76
[ "def", "Init", "(", ")", ":", "VFS_HANDLERS", ".", "clear", "(", ")", "_VFS_VIRTUALROOTS", ".", "clear", "(", ")", "vfs_virtualroots", "=", "config", ".", "CONFIG", "[", "\"Client.vfs_virtualroots\"", "]", "VFS_HANDLERS", "[", "files", ".", "File", ".", "sup...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
VFSOpen
Expands pathspec to return an expanded Path. A pathspec is a specification of how to access the file by recursively opening each part of the path by different drivers. For example the following pathspec: pathtype: OS path: "/dev/sda1" nested_path { pathtype: TSK path: "/home/image2.img" nested...
grr/client/grr_response_client/vfs.py
def VFSOpen(pathspec, progress_callback = None ): """Expands pathspec to return an expanded Path. A pathspec is a specification of how to access the file by recursively opening each part of the path by different drivers. For example the following pathspec: pathtype: OS path: "/dev/s...
def VFSOpen(pathspec, progress_callback = None ): """Expands pathspec to return an expanded Path. A pathspec is a specification of how to access the file by recursively opening each part of the path by different drivers. For example the following pathspec: pathtype: OS path: "/dev/s...
[ "Expands", "pathspec", "to", "return", "an", "expanded", "Path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs.py#L79-L206
[ "def", "VFSOpen", "(", "pathspec", ",", "progress_callback", "=", "None", ")", ":", "# Initialize the dictionary of VFS handlers lazily, if not yet done.", "if", "not", "VFS_HANDLERS", ":", "Init", "(", ")", "fd", "=", "None", "# Adjust the pathspec in case we are using a v...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
VFSMultiOpen
Opens multiple files specified by given path-specs. See documentation for `VFSOpen` for more information. Args: pathspecs: A list of pathspec instances of files to open. progress_callback: A callback function to call to notify about progress Returns: A context manager yielding file-like objects.
grr/client/grr_response_client/vfs.py
def VFSMultiOpen(pathspecs, progress_callback=None): """Opens multiple files specified by given path-specs. See documentation for `VFSOpen` for more information. Args: pathspecs: A list of pathspec instances of files to open. progress_callback: A callback function to call to notify about progress Ret...
def VFSMultiOpen(pathspecs, progress_callback=None): """Opens multiple files specified by given path-specs. See documentation for `VFSOpen` for more information. Args: pathspecs: A list of pathspec instances of files to open. progress_callback: A callback function to call to notify about progress Ret...
[ "Opens", "multiple", "files", "specified", "by", "given", "path", "-", "specs", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs.py#L209-L224
[ "def", "VFSMultiOpen", "(", "pathspecs", ",", "progress_callback", "=", "None", ")", ":", "precondition", ".", "AssertIterableType", "(", "pathspecs", ",", "rdf_paths", ".", "PathSpec", ")", "vfs_open", "=", "functools", ".", "partial", "(", "VFSOpen", ",", "p...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ReadVFS
Read from the VFS and return the contents. Args: pathspec: path to read from offset: number of bytes to skip length: number of bytes to read progress_callback: A callback to indicate that the open call is still working but needs more time. Returns: VFS file contents
grr/client/grr_response_client/vfs.py
def ReadVFS(pathspec, offset, length, progress_callback=None): """Read from the VFS and return the contents. Args: pathspec: path to read from offset: number of bytes to skip length: number of bytes to read progress_callback: A callback to indicate that the open call is still working but need...
def ReadVFS(pathspec, offset, length, progress_callback=None): """Read from the VFS and return the contents. Args: pathspec: path to read from offset: number of bytes to skip length: number of bytes to read progress_callback: A callback to indicate that the open call is still working but need...
[ "Read", "from", "the", "VFS", "and", "return", "the", "contents", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs.py#L227-L242
[ "def", "ReadVFS", "(", "pathspec", ",", "offset", ",", "length", ",", "progress_callback", "=", "None", ")", ":", "fd", "=", "VFSOpen", "(", "pathspec", ",", "progress_callback", "=", "progress_callback", ")", "fd", ".", "Seek", "(", "offset", ")", "return...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Writer.WriteRow
Writes a single row to the underlying buffer. Args: values: A list of string values to be inserted into the CSV output.
grr/core/grr_response_core/lib/util/compat/csv.py
def WriteRow(self, values): """Writes a single row to the underlying buffer. Args: values: A list of string values to be inserted into the CSV output. """ precondition.AssertIterableType(values, text) if compatibility.PY2: self._csv.writerow([value.encode("utf-8") for value in values])...
def WriteRow(self, values): """Writes a single row to the underlying buffer. Args: values: A list of string values to be inserted into the CSV output. """ precondition.AssertIterableType(values, text) if compatibility.PY2: self._csv.writerow([value.encode("utf-8") for value in values])...
[ "Writes", "a", "single", "row", "to", "the", "underlying", "buffer", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compat/csv.py#L88-L99
[ "def", "WriteRow", "(", "self", ",", "values", ")", ":", "precondition", ".", "AssertIterableType", "(", "values", ",", "text", ")", "if", "compatibility", ".", "PY2", ":", "self", ".", "_csv", ".", "writerow", "(", "[", "value", ".", "encode", "(", "\...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DictWriter.WriteRow
Writes a single row to the underlying buffer. Args: values: A dictionary mapping column names to values to be inserted into the CSV output.
grr/core/grr_response_core/lib/util/compat/csv.py
def WriteRow(self, values): """Writes a single row to the underlying buffer. Args: values: A dictionary mapping column names to values to be inserted into the CSV output. """ precondition.AssertDictType(values, text, text) row = [] for column in self._columns: try: ...
def WriteRow(self, values): """Writes a single row to the underlying buffer. Args: values: A dictionary mapping column names to values to be inserted into the CSV output. """ precondition.AssertDictType(values, text, text) row = [] for column in self._columns: try: ...
[ "Writes", "a", "single", "row", "to", "the", "underlying", "buffer", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compat/csv.py#L135-L153
[ "def", "WriteRow", "(", "self", ",", "values", ")", ":", "precondition", ".", "AssertDictType", "(", "values", ",", "text", ",", "text", ")", "row", "=", "[", "]", "for", "column", "in", "self", ".", "_columns", ":", "try", ":", "value", "=", "values...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiCronJob._IsCronJobFailing
Returns True if the last run failed.
grr/server/grr_response_server/gui/api_plugins/cron.py
def _IsCronJobFailing(self, cron_job): """Returns True if the last run failed.""" status = cron_job.Get(cron_job.Schema.LAST_RUN_STATUS) if status is None: return False return status.status != rdf_cronjobs.CronJobRunStatus.Status.OK
def _IsCronJobFailing(self, cron_job): """Returns True if the last run failed.""" status = cron_job.Get(cron_job.Schema.LAST_RUN_STATUS) if status is None: return False return status.status != rdf_cronjobs.CronJobRunStatus.Status.OK
[ "Returns", "True", "if", "the", "last", "run", "failed", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/cron.py#L76-L82
[ "def", "_IsCronJobFailing", "(", "self", ",", "cron_job", ")", ":", "status", "=", "cron_job", ".", "Get", "(", "cron_job", ".", "Schema", ".", "LAST_RUN_STATUS", ")", "if", "status", "is", "None", ":", "return", "False", "return", "status", ".", "status",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiCronJobRun.InitFromApiFlow
Shortcut method for easy legacy cron jobs support.
grr/server/grr_response_server/gui/api_plugins/cron.py
def InitFromApiFlow(self, f, cron_job_id=None): """Shortcut method for easy legacy cron jobs support.""" if f.flow_id: self.run_id = f.flow_id elif f.urn: self.run_id = f.urn.Basename() self.started_at = f.started_at self.cron_job_id = cron_job_id flow_state_enum = api_plugins_flow....
def InitFromApiFlow(self, f, cron_job_id=None): """Shortcut method for easy legacy cron jobs support.""" if f.flow_id: self.run_id = f.flow_id elif f.urn: self.run_id = f.urn.Basename() self.started_at = f.started_at self.cron_job_id = cron_job_id flow_state_enum = api_plugins_flow....
[ "Shortcut", "method", "for", "easy", "legacy", "cron", "jobs", "support", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/cron.py#L218-L249
[ "def", "InitFromApiFlow", "(", "self", ",", "f", ",", "cron_job_id", "=", "None", ")", ":", "if", "f", ".", "flow_id", ":", "self", ".", "run_id", "=", "f", ".", "flow_id", "elif", "f", ".", "urn", ":", "self", ".", "run_id", "=", "f", ".", "urn"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDB._ParseTimeRange
Parses a timerange argument and always returns non-None timerange.
grr/server/grr_response_server/databases/mem.py
def _ParseTimeRange(self, timerange): """Parses a timerange argument and always returns non-None timerange.""" if timerange is None: timerange = (None, None) from_time, to_time = timerange if not from_time: from_time = rdfvalue.RDFDatetime().FromSecondsSinceEpoch(0) if not to_time: ...
def _ParseTimeRange(self, timerange): """Parses a timerange argument and always returns non-None timerange.""" if timerange is None: timerange = (None, None) from_time, to_time = timerange if not from_time: from_time = rdfvalue.RDFDatetime().FromSecondsSinceEpoch(0) if not to_time: ...
[ "Parses", "a", "timerange", "argument", "and", "always", "returns", "non", "-", "None", "timerange", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem.py#L125-L137
[ "def", "_ParseTimeRange", "(", "self", ",", "timerange", ")", ":", "if", "timerange", "is", "None", ":", "timerange", "=", "(", "None", ",", "None", ")", "from_time", ",", "to_time", "=", "timerange", "if", "not", "from_time", ":", "from_time", "=", "rdf...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDB._DeepCopy
Creates an object copy by serializing/deserializing it. RDFStruct.Copy() doesn't deep-copy repeated fields which may lead to hard to catch bugs. Args: obj: RDFValue to be copied. Returns: A deep copy of the passed RDFValue.
grr/server/grr_response_server/databases/mem.py
def _DeepCopy(self, obj): """Creates an object copy by serializing/deserializing it. RDFStruct.Copy() doesn't deep-copy repeated fields which may lead to hard to catch bugs. Args: obj: RDFValue to be copied. Returns: A deep copy of the passed RDFValue. """ precondition.AssertT...
def _DeepCopy(self, obj): """Creates an object copy by serializing/deserializing it. RDFStruct.Copy() doesn't deep-copy repeated fields which may lead to hard to catch bugs. Args: obj: RDFValue to be copied. Returns: A deep copy of the passed RDFValue. """ precondition.AssertT...
[ "Creates", "an", "object", "copy", "by", "serializing", "/", "deserializing", "it", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem.py#L139-L153
[ "def", "_DeepCopy", "(", "self", ",", "obj", ")", ":", "precondition", ".", "AssertType", "(", "obj", ",", "rdfvalue", ".", "RDFValue", ")", "return", "obj", ".", "__class__", ".", "FromSerializedString", "(", "obj", ".", "SerializeToString", "(", ")", ")"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBEventMixin.ReadAPIAuditEntries
Returns audit entries stored in the database.
grr/server/grr_response_server/databases/mem_events.py
def ReadAPIAuditEntries(self, username=None, router_method_names=None, min_timestamp=None, max_timestamp=None): """Returns audit entries stored in the database.""" results = [] for entry in self.api_audi...
def ReadAPIAuditEntries(self, username=None, router_method_names=None, min_timestamp=None, max_timestamp=None): """Returns audit entries stored in the database.""" results = [] for entry in self.api_audi...
[ "Returns", "audit", "entries", "stored", "in", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_events.py#L17-L41
[ "def", "ReadAPIAuditEntries", "(", "self", ",", "username", "=", "None", ",", "router_method_names", "=", "None", ",", "min_timestamp", "=", "None", ",", "max_timestamp", "=", "None", ")", ":", "results", "=", "[", "]", "for", "entry", "in", "self", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBEventMixin.CountAPIAuditEntriesByUserAndDay
Returns audit entry counts grouped by user and calendar day.
grr/server/grr_response_server/databases/mem_events.py
def CountAPIAuditEntriesByUserAndDay(self, min_timestamp=None, max_timestamp=None): """Returns audit entry counts grouped by user and calendar day.""" results = collections.Counter() for entry in self.api_audit_entries: if m...
def CountAPIAuditEntriesByUserAndDay(self, min_timestamp=None, max_timestamp=None): """Returns audit entry counts grouped by user and calendar day.""" results = collections.Counter() for entry in self.api_audit_entries: if m...
[ "Returns", "audit", "entry", "counts", "grouped", "by", "user", "and", "calendar", "day", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_events.py#L44-L60
[ "def", "CountAPIAuditEntriesByUserAndDay", "(", "self", ",", "min_timestamp", "=", "None", ",", "max_timestamp", "=", "None", ")", ":", "results", "=", "collections", ".", "Counter", "(", ")", "for", "entry", "in", "self", ".", "api_audit_entries", ":", "if", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InMemoryDBEventMixin.WriteAPIAuditEntry
Writes an audit entry to the database.
grr/server/grr_response_server/databases/mem_events.py
def WriteAPIAuditEntry(self, entry): """Writes an audit entry to the database.""" copy = entry.Copy() copy.timestamp = rdfvalue.RDFDatetime.Now() self.api_audit_entries.append(copy)
def WriteAPIAuditEntry(self, entry): """Writes an audit entry to the database.""" copy = entry.Copy() copy.timestamp = rdfvalue.RDFDatetime.Now() self.api_audit_entries.append(copy)
[ "Writes", "an", "audit", "entry", "to", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_events.py#L63-L67
[ "def", "WriteAPIAuditEntry", "(", "self", ",", "entry", ")", ":", "copy", "=", "entry", ".", "Copy", "(", ")", "copy", ".", "timestamp", "=", "rdfvalue", ".", "RDFDatetime", ".", "Now", "(", ")", "self", ".", "api_audit_entries", ".", "append", "(", "c...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApplyPluginToMultiTypeCollection
Applies instant output plugin to a multi-type collection. Args: plugin: InstantOutputPlugin instance. output_collection: MultiTypeCollection instance. source_urn: If not None, override source_urn for collection items. This has to be used when exporting flow results - their GrrMessages don't have ...
grr/server/grr_response_server/instant_output_plugin.py
def ApplyPluginToMultiTypeCollection(plugin, output_collection, source_urn=None): """Applies instant output plugin to a multi-type collection. Args: plugin: InstantOutputPlugin instance. output_collection: MultiTypeCollection instance. source_urn: If not None, overr...
def ApplyPluginToMultiTypeCollection(plugin, output_collection, source_urn=None): """Applies instant output plugin to a multi-type collection. Args: plugin: InstantOutputPlugin instance. output_collection: MultiTypeCollection instance. source_urn: If not None, overr...
[ "Applies", "instant", "output", "plugin", "to", "a", "multi", "-", "type", "collection", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/instant_output_plugin.py#L278-L312
[ "def", "ApplyPluginToMultiTypeCollection", "(", "plugin", ",", "output_collection", ",", "source_urn", "=", "None", ")", ":", "for", "chunk", "in", "plugin", ".", "Start", "(", ")", ":", "yield", "chunk", "for", "stored_type_name", "in", "sorted", "(", "output...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApplyPluginToTypedCollection
Applies instant output plugin to a collection of results. Args: plugin: InstantOutputPlugin instance. type_names: List of type names (strings) to be processed. fetch_fn: Function that takes a type name as an argument and returns available items (FlowResult) corresponding to this type. Items are ...
grr/server/grr_response_server/instant_output_plugin.py
def ApplyPluginToTypedCollection(plugin, type_names, fetch_fn): """Applies instant output plugin to a collection of results. Args: plugin: InstantOutputPlugin instance. type_names: List of type names (strings) to be processed. fetch_fn: Function that takes a type name as an argument and returns a...
def ApplyPluginToTypedCollection(plugin, type_names, fetch_fn): """Applies instant output plugin to a collection of results. Args: plugin: InstantOutputPlugin instance. type_names: List of type names (strings) to be processed. fetch_fn: Function that takes a type name as an argument and returns a...
[ "Applies", "instant", "output", "plugin", "to", "a", "collection", "of", "results", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/instant_output_plugin.py#L315-L343
[ "def", "ApplyPluginToTypedCollection", "(", "plugin", ",", "type_names", ",", "fetch_fn", ")", ":", "for", "chunk", "in", "plugin", ".", "Start", "(", ")", ":", "yield", "chunk", "def", "GetValues", "(", "tn", ")", ":", "for", "v", "in", "fetch_fn", "(",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InstantOutputPlugin.output_file_name
Name of the file where plugin's output should be written to.
grr/server/grr_response_server/instant_output_plugin.py
def output_file_name(self): """Name of the file where plugin's output should be written to.""" safe_path = re.sub(r":|/", "_", self.source_urn.Path().lstrip("/")) return "results_%s%s" % (safe_path, self.output_file_extension)
def output_file_name(self): """Name of the file where plugin's output should be written to.""" safe_path = re.sub(r":|/", "_", self.source_urn.Path().lstrip("/")) return "results_%s%s" % (safe_path, self.output_file_extension)
[ "Name", "of", "the", "file", "where", "plugin", "s", "output", "should", "be", "written", "to", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/instant_output_plugin.py#L66-L70
[ "def", "output_file_name", "(", "self", ")", ":", "safe_path", "=", "re", ".", "sub", "(", "r\":|/\"", ",", "\"_\"", ",", "self", ".", "source_urn", ".", "Path", "(", ")", ".", "lstrip", "(", "\"/\"", ")", ")", "return", "\"results_%s%s\"", "%", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InstantOutputPluginWithExportConversion._GetMetadataForClients
Fetches metadata for a given list of clients.
grr/server/grr_response_server/instant_output_plugin.py
def _GetMetadataForClients(self, client_urns): """Fetches metadata for a given list of clients.""" result = {} metadata_to_fetch = set() for urn in client_urns: try: result[urn] = self._cached_metadata[urn] except KeyError: metadata_to_fetch.add(urn) if metadata_to_fet...
def _GetMetadataForClients(self, client_urns): """Fetches metadata for a given list of clients.""" result = {} metadata_to_fetch = set() for urn in client_urns: try: result[urn] = self._cached_metadata[urn] except KeyError: metadata_to_fetch.add(urn) if metadata_to_fet...
[ "Fetches", "metadata", "for", "a", "given", "list", "of", "clients", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/instant_output_plugin.py#L115-L157
[ "def", "_GetMetadataForClients", "(", "self", ",", "client_urns", ")", ":", "result", "=", "{", "}", "metadata_to_fetch", "=", "set", "(", ")", "for", "urn", "in", "client_urns", ":", "try", ":", "result", "[", "urn", "]", "=", "self", ".", "_cached_meta...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InstantOutputPluginWithExportConversion._GenerateSingleTypeIteration
Yields responses of a given type only. _GenerateSingleTypeIteration iterates through converted_responses and only yields responses of the same type. The type is either popped from next_types or inferred from the first item of converted_responses. The type is added to a set of processed_types. Alon...
grr/server/grr_response_server/instant_output_plugin.py
def _GenerateSingleTypeIteration(self, next_types, processed_types, converted_responses): """Yields responses of a given type only. _GenerateSingleTypeIteration iterates through converted_responses and only yields responses of the same type. The type is either popped from...
def _GenerateSingleTypeIteration(self, next_types, processed_types, converted_responses): """Yields responses of a given type only. _GenerateSingleTypeIteration iterates through converted_responses and only yields responses of the same type. The type is either popped from...
[ "Yields", "responses", "of", "a", "given", "type", "only", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/instant_output_plugin.py#L184-L229
[ "def", "_GenerateSingleTypeIteration", "(", "self", ",", "next_types", ",", "processed_types", ",", "converted_responses", ")", ":", "if", "not", "next_types", ":", "current_type", "=", "None", "else", ":", "current_type", "=", "next_types", ".", "pop", "(", ")"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
InstantOutputPluginWithExportConversion._GenerateConvertedValues
Generates converted values using given converter from given messages. Groups values in batches of BATCH_SIZE size and applies the converter to each batch. Args: converter: ExportConverter instance. grr_messages: An iterable (a generator is assumed) with GRRMessage values. Yields: Va...
grr/server/grr_response_server/instant_output_plugin.py
def _GenerateConvertedValues(self, converter, grr_messages): """Generates converted values using given converter from given messages. Groups values in batches of BATCH_SIZE size and applies the converter to each batch. Args: converter: ExportConverter instance. grr_messages: An iterable (a...
def _GenerateConvertedValues(self, converter, grr_messages): """Generates converted values using given converter from given messages. Groups values in batches of BATCH_SIZE size and applies the converter to each batch. Args: converter: ExportConverter instance. grr_messages: An iterable (a...
[ "Generates", "converted", "values", "using", "given", "converter", "from", "given", "messages", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/instant_output_plugin.py#L231-L253
[ "def", "_GenerateConvertedValues", "(", "self", ",", "converter", ",", "grr_messages", ")", ":", "for", "batch", "in", "collection", ".", "Batch", "(", "grr_messages", ",", "self", ".", "BATCH_SIZE", ")", ":", "metadata_items", "=", "self", ".", "_GetMetadataF...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ParseCategorizedPath
Parses a categorized path string into type and list of components.
grr/server/grr_response_server/rdfvalues/objects.py
def ParseCategorizedPath(path): """Parses a categorized path string into type and list of components.""" components = tuple(component for component in path.split("/") if component) if components[0:2] == ("fs", "os"): return PathInfo.PathType.OS, components[2:] elif components[0:2] == ("fs", "tsk"): retu...
def ParseCategorizedPath(path): """Parses a categorized path string into type and list of components.""" components = tuple(component for component in path.split("/") if component) if components[0:2] == ("fs", "os"): return PathInfo.PathType.OS, components[2:] elif components[0:2] == ("fs", "tsk"): retu...
[ "Parses", "a", "categorized", "path", "string", "into", "type", "and", "list", "of", "components", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L511-L523
[ "def", "ParseCategorizedPath", "(", "path", ")", ":", "components", "=", "tuple", "(", "component", "for", "component", "in", "path", ".", "split", "(", "\"/\"", ")", "if", "component", ")", "if", "components", "[", "0", ":", "2", "]", "==", "(", "\"fs...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ToCategorizedPath
Translates a path type and a list of components to a categorized path.
grr/server/grr_response_server/rdfvalues/objects.py
def ToCategorizedPath(path_type, components): """Translates a path type and a list of components to a categorized path.""" try: prefix = { PathInfo.PathType.OS: ("fs", "os"), PathInfo.PathType.TSK: ("fs", "tsk"), PathInfo.PathType.REGISTRY: ("registry",), PathInfo.PathType.TEMP: ...
def ToCategorizedPath(path_type, components): """Translates a path type and a list of components to a categorized path.""" try: prefix = { PathInfo.PathType.OS: ("fs", "os"), PathInfo.PathType.TSK: ("fs", "tsk"), PathInfo.PathType.REGISTRY: ("registry",), PathInfo.PathType.TEMP: ...
[ "Translates", "a", "path", "type", "and", "a", "list", "of", "components", "to", "a", "categorized", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L526-L538
[ "def", "ToCategorizedPath", "(", "path_type", ",", "components", ")", ":", "try", ":", "prefix", "=", "{", "PathInfo", ".", "PathType", ".", "OS", ":", "(", "\"fs\"", ",", "\"os\"", ")", ",", "PathInfo", ".", "PathType", ".", "TSK", ":", "(", "\"fs\"",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientSnapshot.GetGRRVersionString
Returns the client installation-name and GRR version as a string.
grr/server/grr_response_server/rdfvalues/objects.py
def GetGRRVersionString(self): """Returns the client installation-name and GRR version as a string.""" client_info = self.startup_info.client_info client_name = client_info.client_description or client_info.client_name if client_info.client_version > 0: client_version = str(client_info.client_vers...
def GetGRRVersionString(self): """Returns the client installation-name and GRR version as a string.""" client_info = self.startup_info.client_info client_name = client_info.client_description or client_info.client_name if client_info.client_version > 0: client_version = str(client_info.client_vers...
[ "Returns", "the", "client", "installation", "-", "name", "and", "GRR", "version", "as", "a", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L87-L95
[ "def", "GetGRRVersionString", "(", "self", ")", ":", "client_info", "=", "self", ".", "startup_info", ".", "client_info", "client_name", "=", "client_info", ".", "client_description", "or", "client_info", ".", "client_name", "if", "client_info", ".", "client_version...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientSnapshot.GetMacAddresses
MAC addresses from all interfaces.
grr/server/grr_response_server/rdfvalues/objects.py
def GetMacAddresses(self): """MAC addresses from all interfaces.""" result = set() for interface in self.interfaces: if (interface.mac_address and interface.mac_address != b"\x00" * len(interface.mac_address)): result.add(Text(interface.mac_address.human_readable_address)) return...
def GetMacAddresses(self): """MAC addresses from all interfaces.""" result = set() for interface in self.interfaces: if (interface.mac_address and interface.mac_address != b"\x00" * len(interface.mac_address)): result.add(Text(interface.mac_address.human_readable_address)) return...
[ "MAC", "addresses", "from", "all", "interfaces", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L97-L104
[ "def", "GetMacAddresses", "(", "self", ")", ":", "result", "=", "set", "(", ")", "for", "interface", "in", "self", ".", "interfaces", ":", "if", "(", "interface", ".", "mac_address", "and", "interface", ".", "mac_address", "!=", "b\"\\x00\"", "*", "len", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientSnapshot.GetIPAddresses
IP addresses from all interfaces.
grr/server/grr_response_server/rdfvalues/objects.py
def GetIPAddresses(self): """IP addresses from all interfaces.""" result = [] filtered_ips = ["127.0.0.1", "::1", "fe80::1"] for interface in self.interfaces: for address in interface.addresses: if address.human_readable_address not in filtered_ips: result.append(Text(address.hu...
def GetIPAddresses(self): """IP addresses from all interfaces.""" result = [] filtered_ips = ["127.0.0.1", "::1", "fe80::1"] for interface in self.interfaces: for address in interface.addresses: if address.human_readable_address not in filtered_ips: result.append(Text(address.hu...
[ "IP", "addresses", "from", "all", "interfaces", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L106-L115
[ "def", "GetIPAddresses", "(", "self", ")", ":", "result", "=", "[", "]", "filtered_ips", "=", "[", "\"127.0.0.1\"", ",", "\"::1\"", ",", "\"fe80::1\"", "]", "for", "interface", "in", "self", ".", "interfaces", ":", "for", "address", "in", "interface", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ClientSnapshot.GetSummary
Gets a client summary object. Returns: rdf_client.ClientSummary Raises: ValueError: on bad cloud type
grr/server/grr_response_server/rdfvalues/objects.py
def GetSummary(self): """Gets a client summary object. Returns: rdf_client.ClientSummary Raises: ValueError: on bad cloud type """ summary = rdf_client.ClientSummary() summary.client_id = self.client_id summary.timestamp = self.timestamp summary.system_info.release = self.o...
def GetSummary(self): """Gets a client summary object. Returns: rdf_client.ClientSummary Raises: ValueError: on bad cloud type """ summary = rdf_client.ClientSummary() summary.client_id = self.client_id summary.timestamp = self.timestamp summary.system_info.release = self.o...
[ "Gets", "a", "client", "summary", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L117-L162
[ "def", "GetSummary", "(", "self", ")", ":", "summary", "=", "rdf_client", ".", "ClientSummary", "(", ")", "summary", ".", "client_id", "=", "self", ".", "client_id", "summary", ".", "timestamp", "=", "self", ".", "timestamp", "summary", ".", "system_info", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PathInfo.GetParent
Constructs a path info corresponding to the parent of current path. The root path (represented by an empty list of components, corresponds to `/` on Unix-like systems) does not have a parent. Returns: Instance of `rdf_objects.PathInfo` or `None` if parent does not exist.
grr/server/grr_response_server/rdfvalues/objects.py
def GetParent(self): """Constructs a path info corresponding to the parent of current path. The root path (represented by an empty list of components, corresponds to `/` on Unix-like systems) does not have a parent. Returns: Instance of `rdf_objects.PathInfo` or `None` if parent does not exist. ...
def GetParent(self): """Constructs a path info corresponding to the parent of current path. The root path (represented by an empty list of components, corresponds to `/` on Unix-like systems) does not have a parent. Returns: Instance of `rdf_objects.PathInfo` or `None` if parent does not exist. ...
[ "Constructs", "a", "path", "info", "corresponding", "to", "the", "parent", "of", "current", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L428-L443
[ "def", "GetParent", "(", "self", ")", ":", "if", "self", ".", "root", ":", "return", "None", "return", "PathInfo", "(", "components", "=", "self", ".", "components", "[", ":", "-", "1", "]", ",", "path_type", "=", "self", ".", "path_type", ",", "dire...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PathInfo.GetAncestors
Yields all ancestors of a path. The ancestors are returned in order from closest to the farthest one. Yields: Instances of `rdf_objects.PathInfo`.
grr/server/grr_response_server/rdfvalues/objects.py
def GetAncestors(self): """Yields all ancestors of a path. The ancestors are returned in order from closest to the farthest one. Yields: Instances of `rdf_objects.PathInfo`. """ current = self while True: current = current.GetParent() if current is None: return ...
def GetAncestors(self): """Yields all ancestors of a path. The ancestors are returned in order from closest to the farthest one. Yields: Instances of `rdf_objects.PathInfo`. """ current = self while True: current = current.GetParent() if current is None: return ...
[ "Yields", "all", "ancestors", "of", "a", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L445-L458
[ "def", "GetAncestors", "(", "self", ")", ":", "current", "=", "self", "while", "True", ":", "current", "=", "current", ".", "GetParent", "(", ")", "if", "current", "is", "None", ":", "return", "yield", "current" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
PathInfo.UpdateFrom
Merge path info records. Merges src into self. Args: src: An rdfvalues.objects.PathInfo record, will be merged into self. Raises: ValueError: If src does not represent the same path.
grr/server/grr_response_server/rdfvalues/objects.py
def UpdateFrom(self, src): """Merge path info records. Merges src into self. Args: src: An rdfvalues.objects.PathInfo record, will be merged into self. Raises: ValueError: If src does not represent the same path. """ if not isinstance(src, PathInfo): raise TypeError("expected...
def UpdateFrom(self, src): """Merge path info records. Merges src into self. Args: src: An rdfvalues.objects.PathInfo record, will be merged into self. Raises: ValueError: If src does not represent the same path. """ if not isinstance(src, PathInfo): raise TypeError("expected...
[ "Merge", "path", "info", "records", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L460-L485
[ "def", "UpdateFrom", "(", "self", ",", "src", ")", ":", "if", "not", "isinstance", "(", "src", ",", "PathInfo", ")", ":", "raise", "TypeError", "(", "\"expected `%s` but got `%s`\"", "%", "(", "PathInfo", ",", "type", "(", "src", ")", ")", ")", "if", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
VfsFileReference.ToURN
Converts a reference into an URN.
grr/server/grr_response_server/rdfvalues/objects.py
def ToURN(self): """Converts a reference into an URN.""" if self.path_type in [PathInfo.PathType.OS, PathInfo.PathType.TSK]: return rdfvalue.RDFURN(self.client_id).Add("fs").Add( self.path_type.name.lower()).Add("/".join(self.path_components)) elif self.path_type == PathInfo.PathType.REGIST...
def ToURN(self): """Converts a reference into an URN.""" if self.path_type in [PathInfo.PathType.OS, PathInfo.PathType.TSK]: return rdfvalue.RDFURN(self.client_id).Add("fs").Add( self.path_type.name.lower()).Add("/".join(self.path_components)) elif self.path_type == PathInfo.PathType.REGIST...
[ "Converts", "a", "reference", "into", "an", "URN", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L573-L586
[ "def", "ToURN", "(", "self", ")", ":", "if", "self", ".", "path_type", "in", "[", "PathInfo", ".", "PathType", ".", "OS", ",", "PathInfo", ".", "PathType", ".", "TSK", "]", ":", "return", "rdfvalue", ".", "RDFURN", "(", "self", ".", "client_id", ")",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
VfsFileReference.ToPath
Converts a reference into a VFS file path.
grr/server/grr_response_server/rdfvalues/objects.py
def ToPath(self): """Converts a reference into a VFS file path.""" if self.path_type == PathInfo.PathType.OS: return os.path.join("fs", "os", *self.path_components) elif self.path_type == PathInfo.PathType.TSK: return os.path.join("fs", "tsk", *self.path_components) elif self.path_type == P...
def ToPath(self): """Converts a reference into a VFS file path.""" if self.path_type == PathInfo.PathType.OS: return os.path.join("fs", "os", *self.path_components) elif self.path_type == PathInfo.PathType.TSK: return os.path.join("fs", "tsk", *self.path_components) elif self.path_type == P...
[ "Converts", "a", "reference", "into", "a", "VFS", "file", "path", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L588-L600
[ "def", "ToPath", "(", "self", ")", ":", "if", "self", ".", "path_type", "==", "PathInfo", ".", "PathType", ".", "OS", ":", "return", "os", ".", "path", ".", "join", "(", "\"fs\"", ",", "\"os\"", ",", "*", "self", ".", "path_components", ")", "elif", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
LogInit
Configure the logging subsystem.
grr/client/grr_response_client/client_logging.py
def LogInit(): """Configure the logging subsystem.""" logging.debug("Initializing client logging subsystem.") # The root logger. logger = logging.getLogger() memory_handlers = [ m for m in logger.handlers if m.__class__.__name__ == "PreLoggingMemoryHandler" ] # Clear all handers. logger.ha...
def LogInit(): """Configure the logging subsystem.""" logging.debug("Initializing client logging subsystem.") # The root logger. logger = logging.getLogger() memory_handlers = [ m for m in logger.handlers if m.__class__.__name__ == "PreLoggingMemoryHandler" ] # Clear all handers. logger.ha...
[ "Configure", "the", "logging", "subsystem", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_logging.py#L132-L150
[ "def", "LogInit", "(", ")", ":", "logging", ".", "debug", "(", "\"Initializing client logging subsystem.\"", ")", "# The root logger.", "logger", "=", "logging", ".", "getLogger", "(", ")", "memory_handlers", "=", "[", "m", "for", "m", "in", "logger", ".", "ha...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UpdateClientsFromFleetspeak
Updates ApiClient records to include info from Fleetspeak.
grr/server/grr_response_server/gui/api_plugins/client.py
def UpdateClientsFromFleetspeak(clients): """Updates ApiClient records to include info from Fleetspeak.""" if not fleetspeak_connector.CONN or not fleetspeak_connector.CONN.outgoing: # FS not configured, or an outgoing connection is otherwise unavailable. return id_map = {} for client in clients: if...
def UpdateClientsFromFleetspeak(clients): """Updates ApiClient records to include info from Fleetspeak.""" if not fleetspeak_connector.CONN or not fleetspeak_connector.CONN.outgoing: # FS not configured, or an outgoing connection is otherwise unavailable. return id_map = {} for client in clients: if...
[ "Updates", "ApiClient", "records", "to", "include", "info", "from", "Fleetspeak", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/client.py#L53-L70
[ "def", "UpdateClientsFromFleetspeak", "(", "clients", ")", ":", "if", "not", "fleetspeak_connector", ".", "CONN", "or", "not", "fleetspeak_connector", ".", "CONN", ".", "outgoing", ":", "# FS not configured, or an outgoing connection is otherwise unavailable.", "return", "i...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ApiRemoveClientsLabelsHandler.RemoveClientLabels
Removes labels with given names from a given client object.
grr/server/grr_response_server/gui/api_plugins/client.py
def RemoveClientLabels(self, client, labels_names): """Removes labels with given names from a given client object.""" affected_owners = set() for label in client.GetLabels(): if label.name in labels_names and label.owner != "GRR": affected_owners.add(label.owner) for owner in affected_ow...
def RemoveClientLabels(self, client, labels_names): """Removes labels with given names from a given client object.""" affected_owners = set() for label in client.GetLabels(): if label.name in labels_names and label.owner != "GRR": affected_owners.add(label.owner) for owner in affected_ow...
[ "Removes", "labels", "with", "given", "names", "from", "a", "given", "client", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/client.py#L825-L834
[ "def", "RemoveClientLabels", "(", "self", ",", "client", ",", "labels_names", ")", ":", "affected_owners", "=", "set", "(", ")", "for", "label", "in", "client", ".", "GetLabels", "(", ")", ":", "if", "label", ".", "name", "in", "labels_names", "and", "la...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Timeseries._NormalizeTime
Normalize a time to be an int measured in microseconds.
grr/server/grr_response_server/timeseries.py
def _NormalizeTime(self, time): """Normalize a time to be an int measured in microseconds.""" if isinstance(time, rdfvalue.RDFDatetime): return time.AsMicrosecondsSinceEpoch() if isinstance(time, rdfvalue.Duration): return time.microseconds return int(time)
def _NormalizeTime(self, time): """Normalize a time to be an int measured in microseconds.""" if isinstance(time, rdfvalue.RDFDatetime): return time.AsMicrosecondsSinceEpoch() if isinstance(time, rdfvalue.Duration): return time.microseconds return int(time)
[ "Normalize", "a", "time", "to", "be", "an", "int", "measured", "in", "microseconds", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L38-L44
[ "def", "_NormalizeTime", "(", "self", ",", "time", ")", ":", "if", "isinstance", "(", "time", ",", "rdfvalue", ".", "RDFDatetime", ")", ":", "return", "time", ".", "AsMicrosecondsSinceEpoch", "(", ")", "if", "isinstance", "(", "time", ",", "rdfvalue", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Timeseries.Append
Adds value at timestamp. Values must be added in order of increasing timestamp. Args: value: An observed value. timestamp: The timestamp at which value was observed. Raises: RuntimeError: If timestamp is smaller than the previous timstamp.
grr/server/grr_response_server/timeseries.py
def Append(self, value, timestamp): """Adds value at timestamp. Values must be added in order of increasing timestamp. Args: value: An observed value. timestamp: The timestamp at which value was observed. Raises: RuntimeError: If timestamp is smaller than the previous timstamp. ...
def Append(self, value, timestamp): """Adds value at timestamp. Values must be added in order of increasing timestamp. Args: value: An observed value. timestamp: The timestamp at which value was observed. Raises: RuntimeError: If timestamp is smaller than the previous timstamp. ...
[ "Adds", "value", "at", "timestamp", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L46-L62
[ "def", "Append", "(", "self", ",", "value", ",", "timestamp", ")", ":", "timestamp", "=", "self", ".", "_NormalizeTime", "(", "timestamp", ")", "if", "self", ".", "data", "and", "timestamp", "<", "self", ".", "data", "[", "-", "1", "]", "[", "1", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Timeseries.MultiAppend
Adds multiple value<->timestamp pairs. Args: value_timestamp_pairs: Tuples of (value, timestamp).
grr/server/grr_response_server/timeseries.py
def MultiAppend(self, value_timestamp_pairs): """Adds multiple value<->timestamp pairs. Args: value_timestamp_pairs: Tuples of (value, timestamp). """ for value, timestamp in value_timestamp_pairs: self.Append(value, timestamp)
def MultiAppend(self, value_timestamp_pairs): """Adds multiple value<->timestamp pairs. Args: value_timestamp_pairs: Tuples of (value, timestamp). """ for value, timestamp in value_timestamp_pairs: self.Append(value, timestamp)
[ "Adds", "multiple", "value<", "-", ">", "timestamp", "pairs", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L64-L71
[ "def", "MultiAppend", "(", "self", ",", "value_timestamp_pairs", ")", ":", "for", "value", ",", "timestamp", "in", "value_timestamp_pairs", ":", "self", ".", "Append", "(", "value", ",", "timestamp", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Timeseries.FilterRange
Filter the series to lie between start_time and stop_time. Removes all values of the series which are outside of some time range. Args: start_time: If set, timestamps before start_time will be dropped. stop_time: If set, timestamps at or past stop_time will be dropped.
grr/server/grr_response_server/timeseries.py
def FilterRange(self, start_time=None, stop_time=None): """Filter the series to lie between start_time and stop_time. Removes all values of the series which are outside of some time range. Args: start_time: If set, timestamps before start_time will be dropped. stop_time: If set, timestamps at ...
def FilterRange(self, start_time=None, stop_time=None): """Filter the series to lie between start_time and stop_time. Removes all values of the series which are outside of some time range. Args: start_time: If set, timestamps before start_time will be dropped. stop_time: If set, timestamps at ...
[ "Filter", "the", "series", "to", "lie", "between", "start_time", "and", "stop_time", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L73-L89
[ "def", "FilterRange", "(", "self", ",", "start_time", "=", "None", ",", "stop_time", "=", "None", ")", ":", "start_time", "=", "self", ".", "_NormalizeTime", "(", "start_time", ")", "stop_time", "=", "self", ".", "_NormalizeTime", "(", "stop_time", ")", "s...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Timeseries.Normalize
Normalize the series to have a fixed period over a fixed time range. Supports two modes, depending on the type of data: NORMALIZE_MODE_GAUGE: support gauge values. If multiple original data points lie within an output interval, the output value is an average of the original data point. if n...
grr/server/grr_response_server/timeseries.py
def Normalize(self, period, start_time, stop_time, mode=NORMALIZE_MODE_GAUGE): """Normalize the series to have a fixed period over a fixed time range. Supports two modes, depending on the type of data: NORMALIZE_MODE_GAUGE: support gauge values. If multiple original data points lie within an out...
def Normalize(self, period, start_time, stop_time, mode=NORMALIZE_MODE_GAUGE): """Normalize the series to have a fixed period over a fixed time range. Supports two modes, depending on the type of data: NORMALIZE_MODE_GAUGE: support gauge values. If multiple original data points lie within an out...
[ "Normalize", "the", "series", "to", "have", "a", "fixed", "period", "over", "a", "fixed", "time", "range", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L91-L153
[ "def", "Normalize", "(", "self", ",", "period", ",", "start_time", ",", "stop_time", ",", "mode", "=", "NORMALIZE_MODE_GAUGE", ")", ":", "period", "=", "self", ".", "_NormalizeTime", "(", "period", ")", "start_time", "=", "self", ".", "_NormalizeTime", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Timeseries.MakeIncreasing
Makes the time series increasing. Assumes that series is based on a counter which is occasionally reset, and using this assumption converts the sequence to estimate the total number of counts which occurred. NOTE: Could give inacurate numbers in either of the following cases: 1) Multiple resets oc...
grr/server/grr_response_server/timeseries.py
def MakeIncreasing(self): """Makes the time series increasing. Assumes that series is based on a counter which is occasionally reset, and using this assumption converts the sequence to estimate the total number of counts which occurred. NOTE: Could give inacurate numbers in either of the following...
def MakeIncreasing(self): """Makes the time series increasing. Assumes that series is based on a counter which is occasionally reset, and using this assumption converts the sequence to estimate the total number of counts which occurred. NOTE: Could give inacurate numbers in either of the following...
[ "Makes", "the", "time", "series", "increasing", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L155-L175
[ "def", "MakeIncreasing", "(", "self", ")", ":", "offset", "=", "0", "last_value", "=", "None", "for", "p", "in", "self", ".", "data", ":", "if", "last_value", "and", "last_value", ">", "p", "[", "0", "]", ":", "# Assume that it was only reset once.", "offs...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74