text
stringlengths
81
112k
Writes flow output plugin log entries for a given flow. def WriteFlowLogEntries(self, entries): """Writes flow output plugin log entries for a given flow.""" flow_ids = [(e.client_id, e.flow_id) for e in entries] for f in flow_ids: if f not in self.flows: raise db.AtLeastOneUnknownFlowError(f...
Reads flow log entries of a given flow using given query options. def ReadFlowLogEntries(self, client_id, flow_id, offset, count, with_substring=None): """Reads flow log entries of a given f...
Returns number of flow log entries of a given flow. def CountFlowLogEntries(self, client_id, flow_id): """Returns number of flow log entries of a given flow.""" return len(self.ReadFlowLogEntries(client_id, flow_id, 0, sys.maxsize))
Reads flow output plugin log entries. def ReadFlowOutputPluginLogEntries(self, client_id, flow_id, output_plugin_id, offset, count, ...
Returns number of flow output plugin log entries of a given flow. def CountFlowOutputPluginLogEntries(self, client_id, flow_id, output_plugin_id, with_type=None): ...
See db.Database. def WriteSignedBinaryReferences(self, binary_id, references): """See db.Database.""" self.signed_binary_references[_SignedBinaryKeyFromID(binary_id)] = ( references.Copy(), rdfvalue.RDFDatetime.Now())
See db.Database. def ReadSignedBinaryReferences( self, binary_id ): """See db.Database.""" binary_key = _SignedBinaryKeyFromID(binary_id) try: references, timestamp = self.signed_binary_references[binary_key] except KeyError: raise db.UnknownSignedBinaryError(binary_id) return r...
Returns a mapping of SQLite column names to Converter objects. def _GetSqliteSchema(self, proto_struct_class, prefix=""): """Returns a mapping of SQLite column names to Converter objects.""" schema = collections.OrderedDict() for type_info in proto_struct_class.type_infos: if type_info.__class__ is r...
Converts a dict of RDF values into a SQL-ready form. def _ConvertToCanonicalSqlDict(self, schema, raw_dict, prefix=""): """Converts a dict of RDF values into a SQL-ready form.""" flattened_dict = {} for k, v in iteritems(raw_dict): if isinstance(v, dict): flattened_dict.update( se...
Copies rows from the given db into the output file then deletes them. def _FlushAllRows(self, db_connection, table_name): """Copies rows from the given db into the output file then deletes them.""" for sql in db_connection.iterdump(): if (sql.startswith("CREATE TABLE") or sql.startswith("BEGIN ...
Dumps the given aff4object into a yaml representation. def YamlDumper(aff4object): """Dumps the given aff4object into a yaml representation.""" aff4object.Flush() result = {} for attribute, values in iteritems(aff4object.synced_attributes): result[attribute.predicate] = [] for value in values: #...
Load an AFF4 object from a serialized YAML representation. def YamlLoader(string): """Load an AFF4 object from a serialized YAML representation.""" representation = yaml.Parse(string) result_cls = aff4.FACTORY.AFF4Object(representation["aff4_class"]) aff4_attributes = {} for predicate, values in iteritems(re...
Builds ExportedMetadata object for a given client id and ClientFullInfo. def GetMetadata(client_id, client_full_info): """Builds ExportedMetadata object for a given client id and ClientFullInfo.""" metadata = ExportedMetadata() last_snapshot = None if client_full_info.HasField("last_snapshot"): last_snap...
Builds ExportedMetadata object for a given client id. Note: This is a legacy aff4-only implementation. TODO(user): deprecate as soon as REL_DB migration is done. Args: client: RDFURN of a client or VFSGRRClient object itself. token: Security token. Returns: ExportedMetadata object with metadata o...
Converts a set of RDFValues into a set of export-friendly RDFValues. Args: metadata_value_pairs: Tuples of (metadata, rdf_value), where metadata is an instance of ExportedMetadata and rdf_value is an RDFValue subclass instance to be exported. token: Security token. options: rdfvalue.ExportOpt...
Converts a set of RDFValues into a set of export-friendly RDFValues. Args: default_metadata: export.ExportedMetadata instance with basic information about where the values come from. This metadata will be passed to exporters. values: Values to convert. They should be of the same type. token: ...
Returns all converters that take given value as an input value. def GetConvertersByClass(value_cls): """Returns all converters that take given value as an input value.""" try: return ExportConverter.converters_cache[value_cls] except KeyError: results = [ cls for cls in itervalues(Exp...
Generates flattened RDFValue class definition for the given value. def MakeFlatRDFClass(self, value): """Generates flattened RDFValue class definition for the given value.""" def Flatten(self, metadata, value_to_flatten): if metadata: self.metadata = metadata for desc in value_to_flatten....
Parses signed certificate data and updates result rdfvalue. def ParseSignedData(signed_data, result): """Parses signed certificate data and updates result rdfvalue.""" try: auth_data except NameError: # Verify_sigs is not available so we can't parse signatures. If you want # this function...
Parses Hash rdfvalue into ExportedFile's fields. def ParseFileHash(hash_obj, result): """Parses Hash rdfvalue into ExportedFile's fields.""" if hash_obj.HasField("md5"): result.hash_md5 = str(hash_obj.md5) if hash_obj.HasField("sha1"): result.hash_sha1 = str(hash_obj.sha1) if hash_obj.Has...
Converts StatEntry to ExportedFile. Does nothing if StatEntry corresponds to a registry entry and not to a file. Args: metadata: ExportedMetadata to be used for conversion. stat_entry: StatEntry to be converted. token: Security token. Returns: List or generator with resulting RDFV...
Filter out registry keys to operate on files. def _RemoveRegistryKeys(self, metadata_value_pairs): """Filter out registry keys to operate on files.""" filtered_pairs = [] for metadata, stat_entry in metadata_value_pairs: # Ignore registry keys. if stat_entry.pathspec.pathtype != rdf_paths.PathS...
Open files all at once if necessary. def _OpenFilesForRead(self, metadata_value_pairs, token): """Open files all at once if necessary.""" aff4_paths = [ result.AFF4Path(metadata.client_urn) for metadata, result in metadata_value_pairs ] fds = aff4.FACTORY.MultiOpen(aff4_paths, mode="r",...
Add file content from aff4_object to result. def _ExportFileContent(self, aff4_object, result): """Add file content from aff4_object to result.""" if self.options.export_files_contents: try: result.content = aff4_object.Read(self.MAX_CONTENT_SIZE) result.content_sha256 = hashlib.sha256(re...
Converts a batch of StatEntry value to ExportedFile values at once. Args: metadata_value_pairs: a list or a generator of tuples (metadata, value), where metadata is ExportedMetadata to be used for conversion and value is a StatEntry to be converted. token: Security token: Yields: ...
Converts StatEntry to ExportedRegistryKey. Does nothing if StatEntry corresponds to a file and not a registry entry. Args: metadata: ExportedMetadata to be used for conversion. stat_entry: StatEntry to be converted. token: Security token. Returns: List or generator with resulting ...
Converts NetworkConnection to ExportedNetworkConnection. def Convert(self, metadata, conn, token=None): """Converts NetworkConnection to ExportedNetworkConnection.""" result = ExportedNetworkConnection( metadata=metadata, family=conn.family, type=conn.type, local_address=conn.l...
Converts Process to ExportedProcess. def Convert(self, metadata, process, token=None): """Converts Process to ExportedProcess.""" result = ExportedProcess( metadata=metadata, pid=process.pid, ppid=process.ppid, name=process.name, exe=process.exe, cmdline=" ".joi...
Converts Process to ExportedNetworkConnection. def Convert(self, metadata, process, token=None): """Converts Process to ExportedNetworkConnection.""" conn_converter = NetworkConnectionToExportedNetworkConnectionConverter( options=self.options) return conn_converter.BatchConvert( [(metadata...
Converts Process to ExportedOpenFile. def Convert(self, metadata, process, token=None): """Converts Process to ExportedOpenFile.""" for f in process.open_files: yield ExportedOpenFile(metadata=metadata, pid=process.pid, path=f)
Converts Interface to ExportedNetworkInterfaces. def Convert(self, metadata, interface, token=None): """Converts Interface to ExportedNetworkInterfaces.""" ip4_addresses = [] ip6_addresses = [] for addr in interface.addresses: if addr.address_type == addr.Family.INET: ip4_addresses.append...
Converts DNSClientConfiguration to ExportedDNSClientConfiguration. def Convert(self, metadata, config, token=None): """Converts DNSClientConfiguration to ExportedDNSClientConfiguration.""" result = ExportedDNSClientConfiguration( metadata=metadata, dns_servers=" ".join(config.dns_server), ...
Converts ClientSummary to ExportedNetworkInterfaces. def Convert(self, metadata, client_summary, token=None): """Converts ClientSummary to ExportedNetworkInterfaces.""" for interface in client_summary.interfaces: yield super(ClientSummaryToExportedNetworkInterfaceConverter, self).Conver...
Separate files, registry keys, grep matches. def _SeparateTypes(self, metadata_value_pairs): """Separate files, registry keys, grep matches.""" registry_pairs = [] file_pairs = [] match_pairs = [] for metadata, result in metadata_value_pairs: if (result.stat_entry.pathspec.pathtype == ...
Converts GrrMessage into a set of RDFValues. Args: metadata: ExportedMetadata to be used for conversion. grr_message: GrrMessage to be converted. token: Security token. Returns: List or generator with resulting RDFValues. def Convert(self, metadata, grr_message, token=None): """Co...
Converts a batch of GrrMessages into a set of RDFValues at once. Args: metadata_value_pairs: a list or a generator of tuples (metadata, value), where metadata is ExportedMetadata to be used for conversion and value is a GrrMessage to be converted. token: Security token. Returns: ...
Convert batch of FileStoreHashs. def BatchConvert(self, metadata_value_pairs, token=None): """Convert batch of FileStoreHashs.""" urns = [urn for metadata, urn in metadata_value_pairs] urns_dict = dict((urn, metadata) for metadata, urn in metadata_value_pairs) results = [] for hash_urn, client_fi...
Converts a single CheckResult. Args: metadata: ExportedMetadata to be used for conversion. checkresult: CheckResult to be converted. token: Security token. Yields: Resulting ExportedCheckResult. Empty list is a valid result and means that conversion wasn't possible. def Convert(...
Converts original result via given converter.. def GetExportedResult(self, original_result, converter, metadata=None, token=None): """Converts original result via given converter..""" exported_results = list( ...
Checks if given RDFValue is a registry StatEntry. def IsRegistryStatEntry(self, original_result): """Checks if given RDFValue is a registry StatEntry.""" return (original_result.pathspec.pathtype == rdf_paths.PathSpec.PathType.REGISTRY)
Checks if given RDFValue is a file StatEntry. def IsFileStatEntry(self, original_result): """Checks if given RDFValue is a file StatEntry.""" return (original_result.pathspec.pathtype in [ rdf_paths.PathSpec.PathType.OS, rdf_paths.PathSpec.PathType.TSK ])
Converts a single ArtifactFilesDownloaderResult. def Convert(self, metadata, value, token=None): """Converts a single ArtifactFilesDownloaderResult.""" for r in self.BatchConvert([(metadata, value)], token=token): yield r
Convert a single YaraProcessScanMatch. def Convert(self, metadata, yara_match, token=None): """Convert a single YaraProcessScanMatch.""" conv = ProcessToExportedProcessConverter(options=self.options) process = list( conv.Convert(ExportedMetadata(), yara_match.process, token=token))[0] seen_ru...
Creates a dynamic RDF proto struct class for given osquery table. The fields of the proto will correspond to the columns of the table. Args: table: An osquery table for which the class is about to be generated. Returns: A class object corresponding to the given table. def _RDFClass(cls, tabl...
Returns the path from a client action response as a string. Args: response: A client action response. pathspec_attribute: Specifies the field which stores the pathspec. Returns: The path as a string or None if no path is found. def _ExtractPath(response, pathspec_attribute=None): """Returns the pat...
Returns an `CollectedArtifact` rdf object for the requested artifact. def _CollectArtifact(self, artifact, apply_parsers): """Returns an `CollectedArtifact` rdf object for the requested artifact.""" artifact_result = rdf_artifacts.CollectedArtifact(name=artifact.name) if apply_parsers: parser_factor...
Set values in the knowledge base based on responses. def UpdateKnowledgeBase(self, response, provides): """Set values in the knowledge base based on responses.""" if isinstance(response, rdf_anomaly.Anomaly): return if isinstance(response, rdf_client.User): self.knowledge_base.MergeOrAddUser(...
Iterates through sources yielding action responses. def _ProcessSources(self, sources, parser_factory): """Iterates through sources yielding action responses.""" for source in sources: for action, request in self._ParseSourceType(source): yield self._RunClientAction(action, request, parser_factor...
Runs the client action with the request and parses the result. def _RunClientAction(self, action, request, parser_factory, path_type): """Runs the client action with the request and parses the result.""" responses = list(action(request)) if parser_factory is None: return responses # parse the...
Calls the correct processing function for the given source. def _ParseSourceType(self, source): """Calls the correct processing function for the given source.""" type_name = rdf_artifacts.ArtifactSource.SourceType switch = { type_name.COMMAND: self._ProcessCommandSource, type_name.DIRECTORY...
Glob for paths in the registry. def _ProcessRegistryKeySource(self, source): """Glob for paths in the registry.""" keys = source.base_source.attributes.get("keys", []) if not keys: return interpolated_paths = artifact_utils.InterpolateListKbAttributes( input_list=keys, knowledge_...
Find files fulfilling regex conditions. def _ProcessGrepSource(self, source): """Find files fulfilling regex conditions.""" attributes = source.base_source.attributes paths = artifact_utils.InterpolateListKbAttributes( attributes["paths"], self.knowledge_base, self.ignore_interpolation_erro...
Get artifact responses, extract paths and send corresponding files. def _ProcessArtifactFilesSource(self, source): """Get artifact responses, extract paths and send corresponding files.""" if source.path_type != rdf_paths.PathSpec.PathType.OS: raise ValueError("Only supported path type is OS.") # T...
Glob paths and return StatEntry objects. def _ProcessFileSource(self, source): """Glob paths and return StatEntry objects.""" if source.path_type != rdf_paths.PathSpec.PathType.OS: raise ValueError("Only supported path type is OS.") paths = artifact_utils.InterpolateListKbAttributes( source...
Prepare a request for calling the execute command action. def _ProcessCommandSource(self, source): """Prepare a request for calling the execute command action.""" action = standard.ExecuteCommandFromClient request = rdf_client_action.ExecuteRequest( cmd=source.base_source.attributes["cmd"], ...
Write metadata about the client. def WriteClientMetadata(self, client_id, certificate=None, fleetspeak_enabled=None, first_seen=None, last_ping=None, last_clock=No...
Reads ClientMetadata records for a list of clients. def MultiReadClientMetadata(self, client_ids, cursor=None): """Reads ClientMetadata records for a list of clients.""" ids = [db_utils.ClientIDToInt(client_id) for client_id in client_ids] query = ("SELECT client_id, fleetspeak_enabled, certificate, " ...
Write new client snapshot. def WriteClientSnapshot(self, snapshot, cursor=None): """Write new client snapshot.""" insert_history_query = ( "INSERT INTO client_snapshot_history(client_id, timestamp, " "client_snapshot) VALUES (%s, FROM_UNIXTIME(%s), %s)") insert_startup_query = ( "IN...
Reads the latest client snapshots for a list of clients. def MultiReadClientSnapshot(self, client_ids, cursor=None): """Reads the latest client snapshots for a list of clients.""" int_ids = [db_utils.ClientIDToInt(cid) for cid in client_ids] query = ( "SELECT h.client_id, h.client_snapshot, UNIX_TI...
Reads the full history for a particular client. def ReadClientSnapshotHistory(self, client_id, timerange=None, cursor=None): """Reads the full history for a particular client.""" client_id_int = db_utils.ClientIDToInt(client_id) query = ("SELECT sn.client_snapshot, st.startup_info, " " ...
Writes the full history for a particular client. def WriteClientSnapshotHistory(self, clients, cursor=None): """Writes the full history for a particular client.""" client_id = clients[0].client_id latest_timestamp = max(client.timestamp for client in clients) query = "" params = { "client_...
Writes a new client startup record. def WriteClientStartupInfo(self, client_id, startup_info, cursor=None): """Writes a new client startup record.""" query = """ SET @now = NOW(6); INSERT INTO client_startup_history (client_id, timestamp, startup_info) VALUES (%(client_id)s, @now, %(startup_i...
Reads the latest client startup record for a single client. def ReadClientStartupInfo(self, client_id, cursor=None): """Reads the latest client startup record for a single client.""" query = ( "SELECT startup_info, UNIX_TIMESTAMP(timestamp) " "FROM clients, client_startup_history " "WHE...
Reads the full startup history for a particular client. def ReadClientStartupInfoHistory(self, client_id, timerange=None, cursor=None): """Reads the full startup history for a particular client.""" client_id_int = db_utils.ClientIDToInt(client_id) query = ("SELECT start...
Creates a ClientFullInfo object from a database response. def _ResponseToClientsFullInfo(self, response): """Creates a ClientFullInfo object from a database response.""" c_full_info = None prev_cid = None for row in response: (cid, fs, crt, ping, clk, ip, foreman, first, last_client_ts, la...
Reads full client information for a list of clients. def MultiReadClientFullInfo(self, client_ids, min_last_ping=None, cursor=None): """Reads full client information for a list of clients.""" if not client_ids: return {} query = ( "SELECT " "c.client_id,...
Reads client ids for all clients in the database. def ReadClientLastPings(self, min_last_ping=None, max_last_ping=None, fleetspeak_enabled=None, cursor=None): """Reads client ids for all clients in the database....
Associates the provided keywords with the client. def AddClientKeywords(self, client_id, keywords, cursor=None): """Associates the provided keywords with the client.""" cid = db_utils.ClientIDToInt(client_id) keywords = set(keywords) args = [(cid, mysql_utils.Hash(kw), kw) for kw in keywords] args ...
Removes the association of a particular client to a keyword. def RemoveClientKeyword(self, client_id, keyword, cursor=None): """Removes the association of a particular client to a keyword.""" cursor.execute( "DELETE FROM client_keywords " "WHERE client_id = %s AND keyword_hash = %s", [d...
Lists the clients associated with keywords. def ListClientsForKeywords(self, keywords, start_time=None, cursor=None): """Lists the clients associated with keywords.""" keywords = set(keywords) hash_to_kw = {mysql_utils.Hash(kw): kw for kw in keywords} result = {kw: [] for kw in keywords} query = "...
Attaches a list of user labels to a client. def AddClientLabels(self, client_id, owner, labels, cursor=None): """Attaches a list of user labels to a client.""" cid = db_utils.ClientIDToInt(client_id) labels = set(labels) args = [(cid, mysql_utils.Hash(owner), owner, label) for label in labels] args...
Reads the user labels for a list of clients. def MultiReadClientLabels(self, client_ids, cursor=None): """Reads the user labels for a list of clients.""" int_ids = [db_utils.ClientIDToInt(cid) for cid in client_ids] query = ("SELECT client_id, owner_username, label " "FROM client_labels " ...
Removes a list of user labels from a given client. def RemoveClientLabels(self, client_id, owner, labels, cursor=None): """Removes a list of user labels from a given client.""" query = ("DELETE FROM client_labels " "WHERE client_id = %s AND owner_username_hash = %s " "AND label IN ({...
Reads the user labels for a list of clients. def ReadAllClientLabels(self, cursor=None): """Reads the user labels for a list of clients.""" cursor.execute("SELECT DISTINCT owner_username, label FROM client_labels") result = [] for owner, label in cursor.fetchall(): result.append(rdf_objects.Cli...
Writes a new client crash record. def WriteClientCrashInfo(self, client_id, crash_info, cursor=None): """Writes a new client crash record.""" query = """ SET @now = NOW(6); INSERT INTO client_crash_history (client_id, timestamp, crash_info) VALUES (%(client_id)s, @now, %(crash_info)s); U...
Reads the latest client crash record for a single client. def ReadClientCrashInfo(self, client_id, cursor=None): """Reads the latest client crash record for a single client.""" cursor.execute( "SELECT UNIX_TIMESTAMP(timestamp), crash_info " "FROM clients, client_crash_history WHERE " "c...
Reads the full crash history for a particular client. def ReadClientCrashInfoHistory(self, client_id, cursor=None): """Reads the full crash history for a particular client.""" cursor.execute( "SELECT UNIX_TIMESTAMP(timestamp), crash_info " "FROM client_crash_history WHERE " "client_cras...
Stores a ClientStats instance. def WriteClientStats(self, client_id, stats, cursor=None): """Stores a ClientStats instance.""" try: cursor.execute( """ INSERT INTO client_stats (client_id, payload, timestamp) ...
Reads ClientStats for a given client and time range. def ReadClientStats(self, client_id, min_timestamp, max_timestamp, cursor=None): """Reads ClientStats for a given client and time range.""" cursor.execute( """ ...
Deletes ClientStats older than a given timestamp. def DeleteOldClientStats(self, yield_after_count, retention_time ): """Deletes ClientStats older than a given timestamp.""" yielded = False while True: deleted_count = self._DeleteClientStats( ...
Deletes up to `limit` ClientStats older than `retention_time`. def _DeleteClientStats(self, limit, retention_time, cursor=None): """Deletes up to `limit` ClientStats older than `retention_time`.""" cursor.execute( "DELETE FROM c...
Returns client-activity metrics for a given statistic. Args: statistic: The name of the statistic, which should also be a column in the 'clients' table. day_buckets: A set of n-day-active buckets. cursor: MySQL cursor for executing queries. def _CountClientStatisticByLabel(self, statisti...
Parses string path component to an `PathComponent` instance. Args: item: A path component string to be parsed. opts: A `PathOpts` object. Returns: `PathComponent` instance corresponding to given path fragment. Raises: ValueError: If the path item contains a recursive component fragment but ...
Parses given path into a stream of `PathComponent` instances. Args: path: A path to be parsed. opts: An `PathOpts` object. Yields: `PathComponent` instances corresponding to the components of the given path. Raises: ValueError: If path contains more than one recursive component. def ParsePath(...
Applies all expansion mechanisms to the given path. Args: path: A path to expand. opts: A `PathOpts` object. Yields: All paths possible to obtain from a given path by performing expansions. def ExpandPath(path, opts=None): """Applies all expansion mechanisms to the given path. Args: path: A ...
Performs group expansion on a given path. For example, given path `foo/{bar,baz}/{quux,norf}` this method will yield `foo/bar/quux`, `foo/bar/norf`, `foo/baz/quux`, `foo/baz/norf`. Args: path: A path to expand. Yields: Paths that can be obtained from given path by expanding groups. def ExpandGroups(...
Performs glob expansion on a given path. Path can contain regular glob elements (such as `**`, `*`, `?`, `[a-z]`). For example, having files `foo`, `bar`, `baz` glob expansion of `ba?` will yield `bar` and `baz`. Args: path: A path to expand. opts: A `PathOpts` object. Returns: Generator over a...
Returns children of a given directory. This function is intended to be used by the `PathComponent` subclasses to get initial list of potential children that then need to be filtered according to the rules of a specific component. Args: dirpath: A path to the directory. pathtype: The pathtype to use. ...
Gather open network connection stats. Args: args: An `rdf_client_action.ListNetworkConnectionArgs` instance. Yields: `rdf_client_network.NetworkConnection` instances. def ListNetworkConnectionsFromClient(args): """Gather open network connection stats. Args: args: An `rdf_client_action.ListNetwor...
Iterates over contents of the intrusive linked list of `ifaddrs`. Args: ifaddrs: A pointer to the first node of `ifaddrs` linked list. Can be NULL. Yields: Instances of `Ifaddr`. def IterIfaddrs(ifaddrs): """Iterates over contents of the intrusive linked list of `ifaddrs`. Args: ifaddrs: A point...
Parses contents of the intrusive linked list of `ifaddrs`. Args: ifaddrs: A pointer to the first node of `ifaddrs` linked list. Can be NULL. Returns: An iterator over instances of `rdf_client_network.Interface`. def ParseIfaddrs(ifaddrs): """Parses contents of the intrusive linked list of `ifaddrs`. ...
Enumerate all MAC addresses. def EnumerateInterfacesFromClient(args): """Enumerate all MAC addresses.""" del args # Unused libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) ifa = Ifaddrs() p_ifa = ctypes.pointer(ifa) libc.getifaddrs(ctypes.pointer(p_ifa)) for iface in ParseIfaddrs(p_ifa): ...
List all local filesystems mounted on this system. def EnumerateFilesystemsFromClient(args): """List all local filesystems mounted on this system.""" del args # Unused. for fs_struct in client_utils_osx.GetFileSystems(): yield rdf_client_fs.Filesystem( device=fs_struct.f_mntfromname, mount_p...
Create the Service protobuf. Args: job: Launchdjobdict from servicemanagement framework. Returns: sysinfo_pb2.OSXServiceInformation proto def CreateServiceProto(job): """Create the Service protobuf. Args: job: Launchdjobdict from servicemanagement framework. Returns: sysinfo_pb2.OSXServic...
Get running launchd jobs. Args: args: Unused. Yields: `rdf_client.OSXServiceInformation` instances. Raises: UnsupportedOSVersionError: for OS X earlier than 10.6. def OSXEnumerateRunningServicesFromClient(args): """Get running launchd jobs. Args: args: Unused. Yields: `rdf_client...
This kills us with no cleanups. def Run(self, unused_arg): """This kills us with no cleanups.""" logging.debug("Disabling service") msg = "Service disabled." if hasattr(sys, "frozen"): grr_binary = os.path.abspath(sys.executable) elif __file__: grr_binary = os.path.abspath(__file__) ...
Sets up remote debugging using pydevd, connecting to localhost:`port`. def _start_remote_debugging(port): """Sets up remote debugging using pydevd, connecting to localhost:`port`.""" try: print("Connecting to remote debugger on localhost:{}.".format(port)) import pydevd # pylint: disable=g-import-not-at-t...
This installer extracts a config file from the .pkg file. def ExtractConfig(self): """This installer extracts a config file from the .pkg file.""" logging.info("Extracting config file from .pkg.") pkg_path = os.environ.get("PACKAGE_PATH", None) if pkg_path is None: logging.error("Could not locate...
Yields all flows for the given client_id and time range. Args: client_id: client URN min_create_time: minimum creation time (inclusive) token: acl token Yields: flow_objects.Flow objects def _LoadFlows(self, client_id, min_create_time, token): """Yields all flows for the given client_id ...
Enforce DailyFlowRequestLimit and FlowDuplicateInterval. Look at the flows that have run on this client recently and check we aren't exceeding our limits. Raises if limits will be exceeded by running the specified flow. Args: client_id: client URN user: username string flow_name: flo...