_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q25800
FormatSpecificationStore.AddNewSpecification
train
def AddNewSpecification(self, identifier): """Adds a new format specification. Args: identifier (str): format identifier, which should be unique for the store. Returns: FormatSpecification: format specification. Raises: KeyError: if the store already contains a specification with ...
python
{ "resource": "" }
q25801
FormatSpecificationStore.AddSpecification
train
def AddSpecification(self, specification): """Adds a format specification. Args: specification (FormatSpecification): format specification. Raises: KeyError: if the store already contains a specification with the same identifier. """ if specification.identifier in self....
python
{ "resource": "" }
q25802
IPodPlugin.GetEntries
train
def GetEntries(self, parser_mediator, match=None, **unused_kwargs): """Extract device information from the iPod plist. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. match (Optional[dict[str: object]]): keys e...
python
{ "resource": "" }
q25803
OutputMediator.GetEventFormatter
train
def GetEventFormatter(self, event): """Retrieves the event formatter for a specific event type. Args: event (EventObject): event. Returns:
python
{ "resource": "" }
q25804
OutputMediator.GetFormattedMessages
train
def GetFormattedMessages(self, event): """Retrieves the formatted messages related to the event. Args: event (EventObject): event. Returns: tuple: containing: str: full message string or None if no event formatter was found. str: short message string or None if no event format...
python
{ "resource": "" }
q25805
OutputMediator.GetFormattedSources
train
def GetFormattedSources(self, event): """Retrieves the formatted sources related to the event. Args: event (EventObject): event. Returns: tuple: containing: str: full source string or None if no event formatter was found. str: short source string or None if no event formatter ...
python
{ "resource": "" }
q25806
OutputMediator.GetMACBRepresentation
train
def GetMACBRepresentation(self, event): """Retrieves the MACB representation. Args: event (EventObject): event. Returns: str: MACB representation. """ data_type = getattr(event, 'data_type', None) if not data_type: return '....' # The filestat parser is somewhat limited....
python
{ "resource": "" }
q25807
OutputMediator.GetMACBRepresentationFromDescriptions
train
def GetMACBRepresentationFromDescriptions(self, timestamp_descriptions): """Determines the MACB representation from the timestamp descriptions. MACB representation is a shorthand for representing one or more of modification, access, change, birth timestamp descriptions as the letters "MACB" or a "." if...
python
{ "resource": "" }
q25808
OutputMediator.GetUsername
train
def GetUsername(self, event, default_username='-'): """Retrieves the username related to the event. Args: event (EventObject): event. default_username (Optional[str]): default username. Returns: str: username. """ username = getattr(event, 'username', None) if username and us...
python
{ "resource": "" }
q25809
OutputMediator.SetTimezone
train
def SetTimezone(self, timezone): """Sets the timezone. Args: timezone (str): timezone. Raises: ValueError: if the timezone is not supported.
python
{ "resource": "" }
q25810
AttributeContainersManager.DeregisterAttributeContainer
train
def DeregisterAttributeContainer(cls, attribute_container_class): """Deregisters an attribute container class. The attribute container classes are identified based on their lower case container type. Args: attribute_container_class (type): attribute container class. Raises: KeyError: ...
python
{ "resource": "" }
q25811
SyslogPlugin.Process
train
def Process(self, parser_mediator, date_time, syslog_tokens, **kwargs): """Processes the data structure produced by the parser. Args: parser_mediator (ParserMediator): mediates the interactions between parsers and other components, such as storage and abort signals. date_time (dfdatetime....
python
{ "resource": "" }
q25812
FSEventsdEventFormatter._GetFlagValues
train
def _GetFlagValues(self, flags): """Determines which events are indicated by a set of fsevents flags. Args: flags (int): fsevents record flags. Returns: str: a comma separated string containing descriptions of the flag values stored in an fsevents record. """ event_types = []...
python
{ "resource": "" }
q25813
DefaultOLECFPlugin._ParseItem
train
def _ParseItem(self, parser_mediator, olecf_item): """Parses an OLECF item. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. olecf_item (pyolecf.item): OLECF item. Returns: bool: True if an event was ...
python
{ "resource": "" }
q25814
TaggingFile.GetEventTaggingRules
train
def GetEventTaggingRules(self): """Retrieves the event tagging rules from the tagging file. Returns: dict[str, FilterObject]: tagging rules, that consists of one or more filter objects per label. Raises: TaggingFileError: if a filter expression cannot be compiled. """ tagging...
python
{ "resource": "" }
q25815
CupsIppParser._GetStringValue
train
def _GetStringValue(self, data_dict, name, default_value=None): """Retrieves a specific string value from the data dict. Args: data_dict (dict[str, list[str]): values per name. name (str): name of the value to retrieve. default_value (Optional[object]): value to return if the name has no valu...
python
{ "resource": "" }
q25816
CupsIppParser._ParseAttribute
train
def _ParseAttribute(self, file_object): """Parses a CUPS IPP attribute from a file-like object. Args: file_object (dfvfs.FileIO): file-like object. Returns: tuple[str, object]: attribute name and value. Raises: ParseError: if the attribute cannot be parsed. """ file_offset =...
python
{ "resource": "" }
q25817
CupsIppParser._ParseAttributesGroup
train
def _ParseAttributesGroup(self, file_object): """Parses a CUPS IPP attributes group from a file-like object. Args: file_object (dfvfs.FileIO): file-like object. Yields: tuple[str, object]: attribute name and value. Raises: ParseError: if the attributes group cannot be parsed. ""...
python
{ "resource": "" }
q25818
CupsIppParser._ParseBooleanValue
train
def _ParseBooleanValue(self, byte_stream): """Parses a boolean value. Args: byte_stream (bytes): byte stream. Returns: bool: boolean value. Raises: ParseError: when the boolean value cannot be parsed. """ if byte_stream == b'\x00':
python
{ "resource": "" }
q25819
CupsIppParser._ParseDateTimeValue
train
def _ParseDateTimeValue(self, byte_stream, file_offset): """Parses a CUPS IPP RFC2579 date-time value from a byte stream. Args: byte_stream (bytes): byte stream. file_offset (int): offset of the attribute data relative to the start of the file-like object. Returns: dfdatetime.R...
python
{ "resource": "" }
q25820
CupsIppParser._ParseIntegerValue
train
def _ParseIntegerValue(self, byte_stream, file_offset): """Parses an integer value. Args: byte_stream (bytes): byte stream. file_offset (int): offset of the attribute data relative to the start of the file-like object. Returns: int: integer value. Raises: ParseError:...
python
{ "resource": "" }
q25821
CupsIppParser._ParseHeader
train
def _ParseHeader(self, parser_mediator, file_object): """Parses a CUPS IPP header from a file-like object. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. file_object (dfvfs.FileIO): file-like object. Rais...
python
{ "resource": "" }
q25822
CupsIppParser.ParseFileObject
train
def ParseFileObject(self, parser_mediator, file_object): """Parses a CUPS IPP file-like object. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. file_object (dfvfs.FileIO): file-like object. Raises: U...
python
{ "resource": "" }
q25823
AnalysisPlugin._CreateEventTag
train
def _CreateEventTag(self, event, comment, labels): """Creates an event tag. Args: event (EventObject): event to tag. comment (str): event tag comment. labels (list[str]): event tag labels. Returns: EventTag: the event tag.
python
{ "resource": "" }
q25824
HashTaggingAnalysisPlugin._HandleHashAnalysis
train
def _HandleHashAnalysis(self, hash_analysis): """Deals with the results of the analysis of a hash. This method ensures that labels are generated for the hash, then tags all events derived from files with that hash. Args: hash_analysis (HashAnalysis): hash analysis plugin's results for a given ...
python
{ "resource": "" }
q25825
HashTaggingAnalysisPlugin._EnsureRequesterStarted
train
def _EnsureRequesterStarted(self): """Checks if the analyzer is running and starts it
python
{ "resource": "" }
q25826
HashTaggingAnalysisPlugin.ExamineEvent
train
def ExamineEvent(self, mediator, event): """Evaluates whether an event contains the right data for a hash lookup. Args: mediator (AnalysisMediator): mediates interactions between analysis plugins and other components, such as storage and dfvfs. event (EventObject): event. """ self...
python
{ "resource": "" }
q25827
HashTaggingAnalysisPlugin._ContinueReportCompilation
train
def _ContinueReportCompilation(self): """Determines if the plugin should continue trying to compile the report. Returns: bool: True if the plugin should continue, False otherwise. """ analyzer_alive = self._analyzer.is_alive() hash_queue_has_tasks = self.hash_queue.unfinished_tasks
python
{ "resource": "" }
q25828
HashTaggingAnalysisPlugin._LogProgressUpdateIfReasonable
train
def _LogProgressUpdateIfReasonable(self): """Prints a progress update if enough time has passed.""" next_log_time = ( self._time_of_last_status_log + self.SECONDS_BETWEEN_STATUS_LOG_MESSAGES) current_time = time.time() if current_time < next_log_time: return completion_time = t...
python
{ "resource": "" }
q25829
HashTaggingAnalysisPlugin.EstimateTimeRemaining
train
def EstimateTimeRemaining(self): """Estimates how long until all hashes have been analyzed. Returns: int: estimated number of seconds until all hashes have been analyzed. """ number_of_hashes = self.hash_queue.qsize() hashes_per_batch = self._analyzer.hashes_per_batch wait_time_per_batch ...
python
{ "resource": "" }
q25830
HashAnalyzer._GetHashes
train
def _GetHashes(self, target_queue, max_hashes): """Retrieves a list of items from a queue. Args: target_queue (Queue.queue): queue to retrieve hashes from. max_hashes (int): maximum number of items to retrieve from the target_queue. Returns: list[object]: list of at most max_ha...
python
{ "resource": "" }
q25831
HashAnalyzer.run
train
def run(self): """The method called by the threading library to start the thread.""" while not self._abort: hashes = self._GetHashes(self._hash_queue, self.hashes_per_batch) if hashes: time_before_analysis = time.time() hash_analyses = self.Analyze(hashes) current_time = time...
python
{ "resource": "" }
q25832
HashAnalyzer.SetLookupHash
train
def SetLookupHash(self, lookup_hash): """Sets the hash to query. Args: lookup_hash (str): name of the hash attribute to look up. Raises: ValueError: if the lookup hash is not supported.
python
{ "resource": "" }
q25833
HTTPHashAnalyzer._CheckPythonVersionAndDisableWarnings
train
def _CheckPythonVersionAndDisableWarnings(self): """Checks python version, and disables SSL warnings. urllib3 will warn on each HTTPS request made by older versions of Python. Rather than spamming the user, we print one warning message, then disable warnings in urllib3. """ if self._checked_for...
python
{ "resource": "" }
q25834
HTTPHashAnalyzer.MakeRequestAndDecodeJSON
train
def MakeRequestAndDecodeJSON(self, url, method, **kwargs): """Make a HTTP request and decode the results as JSON. Args: url (str): URL to make a request to. method (str): HTTP method to used to make the request. GET and POST are supported. kwargs: parameters to the requests .get() o...
python
{ "resource": "" }
q25835
ApplicationUsagePlugin.ParseApplicationUsageRow
train
def ParseApplicationUsageRow( self, parser_mediator, query, row, **unused_kwargs): """Parses an application usage row. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. query (str): query that created the r...
python
{ "resource": "" }
q25836
EventExtractionWorker._AnalyzeDataStream
train
def _AnalyzeDataStream(self, mediator, file_entry, data_stream_name): """Analyzes the contents of a specific data stream of a file entry. The results of the analyzers are set in the parser mediator as attributes that are added to produced event objects. Note that some file systems allow directories to ...
python
{ "resource": "" }
q25837
EventExtractionWorker._AnalyzeFileObject
train
def _AnalyzeFileObject(self, mediator, file_object): """Processes a file-like object with analyzers. Args: mediator (ParserMediator): mediates the interactions between parsers and other components, such as storage and abort signals. file_object (dfvfs.FileIO): file-like object to process....
python
{ "resource": "" }
q25838
EventExtractionWorker._CanSkipDataStream
train
def _CanSkipDataStream(self, file_entry, data_stream): """Determines if analysis and extraction of a data stream can be skipped. This is used to prevent Plaso trying to run analyzers or extract content from a pipe or socket it encounters while processing a mounted filesystem. Args: file_entry (d...
python
{ "resource": "" }
q25839
EventExtractionWorker._CanSkipContentExtraction
train
def _CanSkipContentExtraction(self, file_entry): """Determines if content extraction of a file entry can be skipped. Args: file_entry (dfvfs.FileEntry): file entry of which to determine content extraction can be skipped. Returns: bool: True if content extraction can be skipped. "...
python
{ "resource": "" }
q25840
EventExtractionWorker._ExtractContentFromDataStream
train
def _ExtractContentFromDataStream( self, mediator, file_entry, data_stream_name): """Extracts content from a data stream. Args: mediator (ParserMediator): mediates the interactions between parsers and other components, such as storage and abort signals. file_entry (dfvfs.FileEntry):...
python
{ "resource": "" }
q25841
EventExtractionWorker._ExtractMetadataFromFileEntry
train
def _ExtractMetadataFromFileEntry(self, mediator, file_entry, data_stream): """Extracts metadata from a file entry. Args: mediator (ParserMediator): mediates the interactions between parsers and other components, such as storage and abort signals. file_entry (dfvfs.FileEntry): file entry ...
python
{ "resource": "" }
q25842
EventExtractionWorker._IsMetadataFile
train
def _IsMetadataFile(self, file_entry): """Determines if the file entry is a metadata file. Args: file_entry (dfvfs.FileEntry): a file entry object. Returns: bool: True if the file entry is a metadata file.
python
{ "resource": "" }
q25843
EventExtractionWorker._ProcessDirectory
train
def _ProcessDirectory(self, mediator, file_entry): """Processes a directory file entry. Args: mediator (ParserMediator): mediates the interactions between parsers and other components, such as storage and abort signals. file_entry (dfvfs.FileEntry): file entry of the directory. """ ...
python
{ "resource": "" }
q25844
EventExtractionWorker._ProcessFileEntry
train
def _ProcessFileEntry(self, mediator, file_entry): """Processes a file entry. Args: mediator (ParserMediator): mediates the interactions between parsers and other components, such as storage and abort signals. file_entry (dfvfs.FileEntry): file entry. """ display_name = mediator.G...
python
{ "resource": "" }
q25845
EventExtractionWorker._ProcessFileEntryDataStream
train
def _ProcessFileEntryDataStream(self, mediator, file_entry, data_stream): """Processes a specific data stream of a file entry. Args: mediator (ParserMediator): mediates the interactions between parsers and other components, such as storage and abort signals. file_entry (dfvfs.FileEntry): ...
python
{ "resource": "" }
q25846
EventExtractionWorker._ProcessMetadataFile
train
def _ProcessMetadataFile(self, mediator, file_entry): """Processes a metadata file. Args: mediator (ParserMediator): mediates the interactions between parsers and other components, such as storage and abort signals. file_entry (dfvfs.FileEntry): file entry
python
{ "resource": "" }
q25847
EventExtractionWorker._SetHashers
train
def _SetHashers(self, hasher_names_string): """Sets the hasher names. Args: hasher_names_string (str): comma separated names of the hashers to enable, where 'none' disables the hashing analyzer.
python
{ "resource": "" }
q25848
EventExtractionWorker._SetYaraRules
train
def _SetYaraRules(self, yara_rules_string): """Sets the Yara rules. Args: yara_rules_string (str): unparsed Yara rule definitions. """ if not yara_rules_string: return
python
{ "resource": "" }
q25849
EventExtractionWorker.SetExtractionConfiguration
train
def SetExtractionConfiguration(self, configuration): """Sets the extraction configuration settings. Args: configuration (ExtractionConfiguration): extraction configuration. """ self._hasher_file_size_limit = configuration.hasher_file_size_limit self._SetHashers(configuration.hasher_names_stri...
python
{ "resource": "" }
q25850
MacAppFirewallParser.VerifyStructure
train
def VerifyStructure(self, parser_mediator, line): """Verify that this file is a Mac AppFirewall log file. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. line (str): line from a text file. Returns: b...
python
{ "resource": "" }
q25851
EventExtractor._CheckParserCanProcessFileEntry
train
def _CheckParserCanProcessFileEntry(self, parser, file_entry): """Determines if a parser can process a file entry. Args: file_entry (dfvfs.FileEntry): file entry.
python
{ "resource": "" }
q25852
EventExtractor._GetSignatureMatchParserNames
train
def _GetSignatureMatchParserNames(self, file_object): """Determines if a file-like object matches one of the known signatures. Args: file_object (file): file-like object whose contents will be checked for known signatures. Returns: list[str]: parser names for which the contents of th...
python
{ "resource": "" }
q25853
EventExtractor._InitializeParserObjects
train
def _InitializeParserObjects(self, parser_filter_expression=None): """Initializes the parser objects. Args: parser_filter_expression (Optional[str]): the parser filter expression, None represents all parsers and plugins. The parser filter expression is a comma separated value string ...
python
{ "resource": "" }
q25854
EventExtractor._ParseDataStreamWithParser
train
def _ParseDataStreamWithParser( self, parser_mediator, parser, file_entry, data_stream_name): """Parses a data stream of a file entry with a specific parser. Args: parser_mediator (ParserMediator): parser mediator. parser (BaseParser): parser. file_entry (dfvfs.FileEntry): file entry. ...
python
{ "resource": "" }
q25855
EventExtractor._ParseFileEntryWithParser
train
def _ParseFileEntryWithParser( self, parser_mediator, parser, file_entry, file_object=None): """Parses a file entry with a specific parser. Args: parser_mediator (ParserMediator): parser mediator. parser (BaseParser): parser. file_entry (dfvfs.FileEntry): file entry. file_object (...
python
{ "resource": "" }
q25856
EventExtractor._ParseFileEntryWithParsers
train
def _ParseFileEntryWithParsers( self, parser_mediator, parser_names, file_entry, file_object=None): """Parses a file entry with a specific parsers. Args: parser_mediator (ParserMediator): parser mediator. parser_names (list[str]): names of parsers. file_entry (dfvfs.FileEntry): file ent...
python
{ "resource": "" }
q25857
EventExtractor.ParseDataStream
train
def ParseDataStream(self, parser_mediator, file_entry, data_stream_name): """Parses a data stream of a file entry with the enabled parsers. Args: parser_mediator (ParserMediator): parser mediator. file_entry (dfvfs.FileEntry): file entry. data_stream_name (str): data stream name. Raises:...
python
{ "resource": "" }
q25858
EventExtractor.ParseMetadataFile
train
def ParseMetadataFile( self, parser_mediator, file_entry, data_stream_name): """Parses a metadata file. Args: parser_mediator (ParserMediator): parser mediator. file_entry (dfvfs.FileEntry): file entry. data_stream_name (str): data stream name. """ parent_path_spec = getattr(fil...
python
{ "resource": "" }
q25859
PathSpecExtractor._CalculateNTFSTimeHash
train
def _CalculateNTFSTimeHash(self, file_entry): """Calculates an MD5 from the date and time value of a NTFS file entry. Args: file_entry (dfvfs.FileEntry): file entry. Returns: str: hexadecimal representation of the MD5 hash value of the date and time values of the file entry. """ ...
python
{ "resource": "" }
q25860
PathSpecExtractor._ExtractPathSpecsFromDirectory
train
def _ExtractPathSpecsFromDirectory(self, file_entry, depth=0): """Extracts path specification from a directory. Args: file_entry (dfvfs.FileEntry): file entry that refers to the directory. depth (Optional[int]): current depth where 0 represents the file system root. Yields: dfv...
python
{ "resource": "" }
q25861
PathSpecExtractor._ExtractPathSpecsFromFile
train
def _ExtractPathSpecsFromFile(self, file_entry): """Extracts path specification from a file. Args: file_entry (dfvfs.FileEntry): file entry that refers to the file. Yields: dfvfs.PathSpec: path specification of a file entry found in the file. """ produced_main_path_spec = False for...
python
{ "resource": "" }
q25862
PathSpecExtractor._ExtractPathSpecsFromFileSystem
train
def _ExtractPathSpecsFromFileSystem( self, path_spec, find_specs=None, recurse_file_system=True, resolver_context=None): """Extracts path specification from a file system within a specific source. Args: path_spec (dfvfs.PathSpec): path specification of the root of the file system. ...
python
{ "resource": "" }
q25863
OLECFPropertySetStream._GetValueAsObject
train
def _GetValueAsObject(self, property_value): """Retrieves the property value as a Python object. Args: property_value (pyolecf.property_value): OLECF property value. Returns: object: property value as a Python object. """ if property_value.type == pyolecf.value_types.BOOLEAN: ret...
python
{ "resource": "" }
q25864
OLECFPropertySetStream._ReadPropertySet
train
def _ReadPropertySet(self, property_set): """Reads properties from a property set. Args: property_set (pyolecf.property_set): OLECF property set. """ # Combine the values of multiple property sections # but do not override properties that are already set. for property_section in property_...
python
{ "resource": "" }
q25865
OLECFPropertySetStream.GetEventData
train
def GetEventData(self, data_type): """Retrieves the properties as event data. Args: data_type (str): event data type. Returns: EventData: event data. """ event_data = events.EventData(data_type=data_type) for property_name, property_value in iter(self._properties.items()): if
python
{ "resource": "" }
q25866
DocumentSummaryInformationOLECFPlugin.Process
train
def Process(self, parser_mediator, root_item=None, **kwargs): """Parses a document summary information OLECF item. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. root_item (Optional[pyolecf.item]): root item o...
python
{ "resource": "" }
q25867
SummaryInformationOLECFPlugin.Process
train
def Process(self, parser_mediator, root_item=None, **kwargs): """Parses a summary information OLECF item. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. root_item (Optional[pyolecf.item]): root item of the OLE...
python
{ "resource": "" }
q25868
ArtifactDefinitionsFilterHelper.CheckKeyCompatibility
train
def CheckKeyCompatibility(cls, key_path): """Checks if a Windows Registry key path is supported by dfWinReg. Args: key_path (str): path of the Windows Registry key. Returns: bool: True if key is compatible or
python
{ "resource": "" }
q25869
ArtifactDefinitionsFilterHelper.BuildFindSpecs
train
def BuildFindSpecs(self, artifact_filter_names, environment_variables=None): """Builds find specifications from artifact definitions. Args: artifact_filter_names (list[str]): names of artifact definitions that are used for filtering file system and Windows Registry key paths. environment_...
python
{ "resource": "" }
q25870
ArtifactDefinitionsFilterHelper._BuildFindSpecsFromArtifact
train
def _BuildFindSpecsFromArtifact(self, definition, environment_variables): """Builds find specifications from an artifact definition. Args: definition (artifacts.ArtifactDefinition): artifact definition. environment_variables (list[EnvironmentVariableArtifact]): environment variables. ...
python
{ "resource": "" }
q25871
ArtifactDefinitionsFilterHelper._BuildFindSpecsFromGroupName
train
def _BuildFindSpecsFromGroupName(self, group_name, environment_variables): """Builds find specifications from a artifact group name. Args: group_name (str): artifact group name. environment_variables (list[str]): environment variable attributes used to dynamically populate environment var...
python
{ "resource": "" }
q25872
ArtifactDefinitionsFilterHelper._BuildFindSpecsFromFileSourcePath
train
def _BuildFindSpecsFromFileSourcePath( self, source_path, path_separator, environment_variables, user_accounts): """Builds find specifications from a file source type. Args: source_path (str): file system path defined by the source. path_separator (str): file system path segment separator. ...
python
{ "resource": "" }
q25873
ArtifactDefinitionsFilterHelper._BuildFindSpecsFromRegistrySourceKey
train
def _BuildFindSpecsFromRegistrySourceKey(self, key_path): """Build find specifications from a Windows Registry source type. Args: key_path (str): Windows Registry key path defined by the source. Returns: list[dfwinreg.FindSpec]: find specifications for the Windows Registry source typ...
python
{ "resource": "" }
q25874
ChromeExtensionPlugin._GetChromeWebStorePage
train
def _GetChromeWebStorePage(self, extension_identifier): """Retrieves the page for the extension from the Chrome store website. Args: extension_identifier (str): Chrome extension identifier. Returns: str: page content or None. """ web_store_url = self._WEB_STORE_URL.format(xid=extension...
python
{ "resource": "" }
q25875
ChromeExtensionPlugin._GetPathSegmentSeparator
train
def _GetPathSegmentSeparator(self, path): """Given a path give back the path separator as a best guess. Args: path (str): path. Returns: str: path segment separator. """ if path.startswith('\\') or path[1:].startswith(':\\'): return '\\' if path.startswith('/'):
python
{ "resource": "" }
q25876
ChromeExtensionPlugin._GetTitleFromChromeWebStore
train
def _GetTitleFromChromeWebStore(self, extension_identifier): """Retrieves the name of the extension from the Chrome store website. Args: extension_identifier (str): Chrome extension identifier. Returns: str: name of the extension or None. """ # Check if we have already looked this exte...
python
{ "resource": "" }
q25877
PlasoValueExpander._GetMessage
train
def _GetMessage(self, event_object): """Returns a properly formatted message string. Args: event_object: the event object (instance od EventObject). Returns: A formatted message string. """ # TODO: move this somewhere where the mediator can be instantiated once. formatter_mediator ...
python
{ "resource": "" }
q25878
PlasoValueExpander._GetSources
train
def _GetSources(self, event_object): """Returns properly formatted source strings. Args: event_object: the event object (instance od EventObject). """ try: source_short, source_long = ( formatters_manager.FormattersManager.GetSourceStrings(event_object))
python
{ "resource": "" }
q25879
PlasoExpression.Compile
train
def Compile(self, filter_implementation): """Compiles the filter implementation. Args: filter_implementation: a filter object (instance of objectfilter.TODO). Returns: A filter operator (instance of TODO). Raises: ParserError: if an unknown operator is provided. """ self.att...
python
{ "resource": "" }
q25880
TimeRangeCache.SetLowerTimestamp
train
def SetLowerTimestamp(cls, timestamp): """Sets the lower bound timestamp.""" if not hasattr(cls, '_lower'): cls._lower = timestamp
python
{ "resource": "" }
q25881
TimeRangeCache.SetUpperTimestamp
train
def SetUpperTimestamp(cls, timestamp): """Sets the upper bound timestamp.""" if not hasattr(cls, '_upper'): cls._upper = timestamp
python
{ "resource": "" }
q25882
TimeRangeCache.GetTimeRange
train
def GetTimeRange(cls): """Return the first and last timestamp of filter range.""" first = getattr(cls, '_lower', 0) last =
python
{ "resource": "" }
q25883
SophosAVLogParser.VerifyStructure
train
def VerifyStructure(self, parser_mediator, line): """Verify that this file is a Sophos Anti-Virus log file. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfVFS. line (str): line from a text file. Returns: ...
python
{ "resource": "" }
q25884
OpenXMLPlugin._GetPropertyValue
train
def _GetPropertyValue(self, parser_mediator, properties, property_name): """Retrieves a property value. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. properties (dict[str, object]): properties. property...
python
{ "resource": "" }
q25885
OpenXMLPlugin._FormatPropertyName
train
def _FormatPropertyName(self, property_name): """Formats a camel case property name as snake case. Args: property_name (str): property name in camel case. Returns: str: property name in snake case. """ # TODO: Add Unicode support.
python
{ "resource": "" }
q25886
OpenXMLPlugin._ParsePropertiesXMLFile
train
def _ParsePropertiesXMLFile(self, xml_data): """Parses a properties XML file. Args: xml_data (bytes): data of a _rels/.rels XML file. Returns: dict[str, object]: properties. Raises: zipfile.BadZipfile: if the properties XML file cannot be read. """ xml_root = ElementTree.fro...
python
{ "resource": "" }
q25887
OpenXMLPlugin.InspectZipFile
train
def InspectZipFile(self, parser_mediator, zip_file): """Parses an OXML file-like object. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. zip_file (zipfile.ZipFile): the zip file containing OXML content. It is ...
python
{ "resource": "" }
q25888
AttributeContainer.CopyFromDict
train
def CopyFromDict(self, attributes): """Copies the attribute container from a dictionary. Args: attributes (dict[str, object]): attribute values per name. """ for attribute_name, attribute_value in attributes.items():
python
{ "resource": "" }
q25889
AttributeContainer.GetAttributeNames
train
def GetAttributeNames(self): """Retrieves the names of all attributes. Returns: list[str]: attribute names. """ attribute_names = [] for attribute_name in iter(self.__dict__.keys()): # Not using startswith
python
{ "resource": "" }
q25890
AttributeContainer.GetAttributes
train
def GetAttributes(self): """Retrieves the attribute names and values. Attributes that are set to None are ignored. Yields: tuple[str, object]: attribute name and value. """ for attribute_name, attribute_value in iter(self.__dict__.items()):
python
{ "resource": "" }
q25891
AttributeContainer.GetAttributeValuesString
train
def GetAttributeValuesString(self): """Retrieves a comparable string of the attribute values. Returns: str: comparable string of the attribute values. """ attributes = [] for attribute_name, attribute_value in sorted(self.__dict__.items()): # Not using startswith to improve performance....
python
{ "resource": "" }
q25892
ZeroMQQueue._SendItem
train
def _SendItem(self, zmq_socket, item, block=True): """Attempts to send an item to a ZeroMQ socket. Args: zmq_socket (zmq.Socket): used to the send the item. item (object): sent on the queue. Will be pickled prior to sending. block (Optional[bool]): whether the push should be performed in bloc...
python
{ "resource": "" }
q25893
ZeroMQQueue._ReceiveItemOnActivity
train
def _ReceiveItemOnActivity(self, zmq_socket): """Attempts to receive an item from a ZeroMQ socket. Args: zmq_socket (zmq.Socket): used to the receive the item. Returns: object: item from the socket. Raises: QueueEmpty: if no item could be received within the timeout. zmq.error...
python
{ "resource": "" }
q25894
ZeroMQQueue._SetSocketTimeouts
train
def _SetSocketTimeouts(self): """Sets the timeouts for socket send and receive.""" # Note that timeout must be an integer value. If timeout is a float # it appears that zmq will not enforce the timeout. timeout = int(self.timeout_seconds * 1000) receive_timeout = min(
python
{ "resource": "" }
q25895
ZeroMQQueue._CreateZMQSocket
train
def _CreateZMQSocket(self): """Creates a ZeroMQ socket.""" logger.debug('Creating socket for {0:s}'.format(self.name)) if not self._zmq_context: self._zmq_context = zmq.Context() # The terminate and close threading events need to be created when the # socket is opened. Threading events are u...
python
{ "resource": "" }
q25896
ZeroMQBufferedQueue._CreateZMQSocket
train
def _CreateZMQSocket(self): """Creates a ZeroMQ socket as well as a regular queue and a thread.""" super(ZeroMQBufferedQueue, self)._CreateZMQSocket() if not self._zmq_thread: thread_name = '{0:s}_zmq_responder'.format(self.name)
python
{ "resource": "" }
q25897
ZeroMQBufferedReplyQueue._ZeroMQResponder
train
def _ZeroMQResponder(self, source_queue): """Listens for requests and replies to clients. Args: source_queue (Queue.queue): queue to use to pull items from. Raises: RuntimeError: if closed or terminate event is missing. """ if not self._closed_event or not self._terminate_event: ...
python
{ "resource": "" }
q25898
OutputManager.DeregisterOutput
train
def DeregisterOutput(cls, output_class): """Deregisters an output class. The output classes are identified based on their NAME attribute. Args: output_class (type): output module class. Raises: KeyError: if output class is not set for the corresponding data type. """ output_class_...
python
{ "resource": "" }
q25899
OutputManager.GetDisabledOutputClasses
train
def GetDisabledOutputClasses(cls): """Retrieves the disabled output classes and its associated name. Yields: tuple[str, type]: output module name and class. """
python
{ "resource": "" }