docstring stringlengths 52 499 | function stringlengths 67 35.2k | __index_level_0__ int64 52.6k 1.16M |
|---|---|---|
Parses and validates the signature.
Args:
value_data (bytes): value data.
Returns:
int: format type or None if format could not be determined.
Raises:
ParseError: if the value data could not be parsed. | def _CheckSignature(self, value_data):
signature_map = self._GetDataTypeMap('uint32le')
try:
signature = self._ReadStructureFromByteStream(
value_data, 0, signature_map)
except (ValueError, errors.ParseError) as exception:
raise errors.ParseError(
'Unable to parse signa... | 288,119 |
Parses the cached entry structure common for Windows 2003, Vista and 7.
Args:
value_data (bytes): value data.
cached_entry_offset (int): offset of the first cached entry data
relative to the start of the value data.
Returns:
appcompatcache_cached_entry_2003_common: cached entry str... | def _ParseCommon2003CachedEntry(self, value_data, cached_entry_offset):
data_type_map = self._GetDataTypeMap(
'appcompatcache_cached_entry_2003_common')
try:
cached_entry = self._ReadStructureFromByteStream(
value_data[cached_entry_offset:], cached_entry_offset, data_type_map)
... | 288,121 |
Parses a Windows XP cached entry.
Args:
value_data (bytes): value data.
cached_entry_offset (int): offset of the first cached entry data
relative to the start of the value data.
Returns:
AppCompatCacheCachedEntry: cached entry.
Raises:
ParseError: if the value data could... | def _ParseCachedEntryXP(self, value_data, cached_entry_offset):
try:
cached_entry = self._ReadStructureFromByteStream(
value_data[cached_entry_offset:], cached_entry_offset,
self._cached_entry_data_type_map)
except (ValueError, errors.ParseError) as exception:
raise errors.P... | 288,122 |
Parses a Windows 2003 cached entry.
Args:
value_data (bytes): value data.
cached_entry_offset (int): offset of the first cached entry data
relative to the start of the value data.
Returns:
AppCompatCacheCachedEntry: cached entry.
Raises:
ParseError: if the value data cou... | def _ParseCachedEntry2003(self, value_data, cached_entry_offset):
try:
cached_entry = self._ReadStructureFromByteStream(
value_data[cached_entry_offset:], cached_entry_offset,
self._cached_entry_data_type_map)
except (ValueError, errors.ParseError) as exception:
raise error... | 288,123 |
Parses a Windows Vista cached entry.
Args:
value_data (bytes): value data.
cached_entry_offset (int): offset of the first cached entry data
relative to the start of the value data.
Returns:
AppCompatCacheCachedEntry: cached entry.
Raises:
ParseError: if the value data co... | def _ParseCachedEntryVista(self, value_data, cached_entry_offset):
try:
cached_entry = self._ReadStructureFromByteStream(
value_data[cached_entry_offset:], cached_entry_offset,
self._cached_entry_data_type_map)
except (ValueError, errors.ParseError) as exception:
raise error... | 288,124 |
Parses a Windows 8.0 or 8.1 cached entry.
Args:
value_data (bytes): value data.
cached_entry_offset (int): offset of the first cached entry data
relative to the start of the value data.
Returns:
AppCompatCacheCachedEntry: cached entry.
Raises:
ParseError: if the value da... | def _ParseCachedEntry8(self, value_data, cached_entry_offset):
try:
cached_entry = self._ReadStructureFromByteStream(
value_data[cached_entry_offset:], cached_entry_offset,
self._cached_entry_data_type_map)
except (ValueError, errors.ParseError) as exception:
raise errors.Pa... | 288,125 |
Parses the header.
Args:
format_type (int): format type.
value_data (bytes): value data.
Returns:
AppCompatCacheHeader: header.
Raises:
ParseError: if the value data could not be parsed. | def _ParseHeader(self, format_type, value_data):
data_type_map_name = self._HEADER_DATA_TYPE_MAP_NAMES.get(format_type, None)
if not data_type_map_name:
raise errors.ParseError(
'Unsupported format type: {0:d}'.format(format_type))
data_type_map = self._GetDataTypeMap(data_type_map_nam... | 288,126 |
Extracts events from a Windows Registry key.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
Raises:
ParseError: if the value data could not ... | def ExtractEvents(self, parser_mediator, registry_key, **kwargs):
value = registry_key.GetValueByName('AppCompatCache')
if not value:
return
value_data = value.data
value_data_size = len(value.data)
format_type = self._CheckSignature(value_data)
if not format_type:
parser_medi... | 288,127 |
Determines the formatted message strings for an event object.
Args:
formatter_mediator (FormatterMediator): mediates the interactions between
formatters and other components, such as storage and Windows EventLog
resources.
event (EventObject): event.
Returns:
tuple(str, s... | def GetMessages(self, formatter_mediator, event):
regvalue = getattr(event, 'regvalue', {})
# Loop over all the registry value names in the service key.
for service_value_name in regvalue.keys():
# A temporary variable so we can refer to this long name more easily.
service_enums = human_rea... | 288,128 |
Returns the deserialized content of a plist as a dictionary object.
Args:
file_object (dfvfs.FileIO): a file-like object to parse.
Returns:
dict[str, object]: contents of the plist.
Raises:
UnableToParseFile: when the file cannot be parsed. | def GetTopLevel(self, file_object):
try:
top_level_object = biplist.readPlist(file_object)
except (biplist.InvalidPlistException,
biplist.NotBinaryPlistException) as exception:
raise errors.UnableToParseFile(
'Unable to parse plist with error: {0!s}'.format(exception))
... | 288,129 |
Parses a plist file-like object.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
file_object (dfvfs.FileIO): a file-like object.
Raises:
UnableToParseFile: when the file cannot be parsed. | def ParseFileObject(self, parser_mediator, file_object):
filename = parser_mediator.GetFilename()
file_size = file_object.get_size()
if file_size <= 0:
raise errors.UnableToParseFile(
'File size: {0:d} bytes is less equal 0.'.format(file_size))
# 50MB is 10x larger than any plist ... | 288,130 |
Updates the number of event reports.
Args:
number_of_consumed_reports (int): total number of event reports consumed
by the process.
number_of_produced_reports (int): total number of event reports produced
by the process.
Returns:
bool: True if either number of event repor... | def UpdateNumberOfEventReports(
self, number_of_consumed_reports, number_of_produced_reports):
consumed_reports_delta = 0
if number_of_consumed_reports is not None:
if number_of_consumed_reports < self.number_of_consumed_reports:
raise ValueError(
'Number of consumed reports... | 288,132 |
Updates the number of events.
Args:
number_of_consumed_events (int): total number of events consumed by
the process.
number_of_produced_events (int): total number of events produced by
the process.
Returns:
bool: True if either number of events has increased.
Raises:... | def UpdateNumberOfEvents(
self, number_of_consumed_events, number_of_produced_events):
consumed_events_delta = 0
if number_of_consumed_events is not None:
if number_of_consumed_events < self.number_of_consumed_events:
raise ValueError(
'Number of consumed events smaller than... | 288,133 |
Updates the number of event sources.
Args:
number_of_consumed_sources (int): total number of event sources consumed
by the process.
number_of_produced_sources (int): total number of event sources produced
by the process.
Returns:
bool: True if either number of event sourc... | def UpdateNumberOfEventSources(
self, number_of_consumed_sources, number_of_produced_sources):
consumed_sources_delta = 0
if number_of_consumed_sources is not None:
if number_of_consumed_sources < self.number_of_consumed_sources:
raise ValueError(
'Number of consumed sources... | 288,134 |
Updates the number of event tags.
Args:
number_of_consumed_event_tags (int): total number of event tags consumed
by the process.
number_of_produced_event_tags (int): total number of event tags produced
by the process.
Returns:
bool: True if either number of event tags has... | def UpdateNumberOfEventTags(
self, number_of_consumed_event_tags, number_of_produced_event_tags):
consumed_event_tags_delta = 0
if number_of_consumed_event_tags is not None:
if number_of_consumed_event_tags < self.number_of_consumed_event_tags:
raise ValueError(
'Number of c... | 288,135 |
Updates the number of warnings.
Args:
number_of_consumed_warnings (int): total number of warnings consumed by
the process.
number_of_produced_warnings (int): total number of warnings produced by
the process.
Returns:
bool: True if either number of warnings has increased.
... | def UpdateNumberOfWarnings(
self, number_of_consumed_warnings, number_of_produced_warnings):
consumed_warnings_delta = 0
if number_of_consumed_warnings is not None:
if number_of_consumed_warnings < self.number_of_consumed_warnings:
raise ValueError(
'Number of consumed warni... | 288,136 |
Determines the formatted message strings for an event object.
Args:
formatter_mediator (FormatterMediator): mediates the interactions
between formatters and other components, such as storage and Windows
EventLog resources.
event (EventObject): event.
Returns:
tuple(str, s... | def GetMessages(self, formatter_mediator, event):
if self.DATA_TYPE != event.data_type:
raise errors.WrongFormatter('Unsupported data type: {0:s}.'.format(
event.data_type))
event_values = event.CopyToDict()
http_headers = event_values.get('http_headers', None)
if http_headers:
... | 288,144 |
Initializes a Windows Registry key filter.
Args:
key_path (str): key path. | def __init__(self, key_path):
super(WindowsRegistryKeyPathFilter, self).__init__()
key_path.rstrip('\\')
self._key_path = key_path
key_path = key_path.upper()
self._key_path_upper = key_path
self._wow64_key_path = None
self._wow64_key_path_upper = None
if key_path.startswith(sel... | 288,145 |
Determines if a Windows Registry key matches the filter.
Args:
registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
Returns:
bool: True if the keys match. | def Match(self, registry_key):
key_path = registry_key.path.upper()
if self._key_path_prefix and self._key_path_suffix:
if (key_path.startswith(self._key_path_prefix) and
key_path.endswith(self._key_path_suffix)):
key_path_segment = key_path[
len(self._key_path_prefix):... | 288,147 |
Initializes a Windows Registry key filter.
Args:
key_path_prefix (str): the key path prefix. | def __init__(self, key_path_prefix):
super(WindowsRegistryKeyPathPrefixFilter, self).__init__()
self._key_path_prefix = key_path_prefix | 288,148 |
Initializes a Windows Registry key filter.
Args:
key_path_suffix (str): the key path suffix. | def __init__(self, key_path_suffix):
super(WindowsRegistryKeyPathSuffixFilter, self).__init__()
self._key_path_suffix = key_path_suffix | 288,149 |
Initializes a Windows Registry key filter.
Args:
value_names (list[str]): name of values that should be present in the key. | def __init__(self, value_names):
super(WindowsRegistryKeyWithValuesFilter, self).__init__()
self._value_names = frozenset(value_names) | 288,150 |
Determines if a Windows Registry key matches the filter.
Args:
registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
Returns:
bool: True if the keys match. | def Match(self, registry_key):
value_names = frozenset([
registry_value.name for registry_value in registry_key.GetValues()])
return self._value_names.issubset(value_names) | 288,151 |
Processes a Windows Registry key or value.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
Raises:
ValueError: If the Windows Registry key is... | def Process(self, parser_mediator, registry_key, **kwargs):
if registry_key is None:
raise ValueError('Windows Registry key is not set.')
# This will raise if unhandled keyword arguments are passed.
super(WindowsRegistryPlugin, self).Process(parser_mediator, **kwargs)
self.ExtractEvents(par... | 288,152 |
Updates the parser chain and processes a Windows Registry key or value.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
Raises:
ValueError: I... | def UpdateChainAndProcess(self, parser_mediator, registry_key, **kwargs):
parser_mediator.AppendToParserChain(self)
try:
self.Process(parser_mediator, registry_key, **kwargs)
finally:
parser_mediator.PopFromParserChain() | 288,153 |
Retrieves the date and time from a FILETIME timestamp.
Args:
filetime (int): FILETIME timestamp.
Returns:
dfdatetime.DateTimeValues: date and time. | def _GetDateTime(self, filetime):
if filetime == 0:
return dfdatetime_semantic_time.SemanticTime('Not set')
return dfdatetime_filetime.Filetime(timestamp=filetime) | 288,157 |
Extract data from a NFTS $MFT attribute.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
mft_entry (pyfsntfs.file_entry): MFT entry.
mft_attribute (pyfsntfs.attribute): MFT attribute. | def _ParseMFTAttribute(self, parser_mediator, mft_entry, mft_attribute):
if mft_entry.is_empty() or mft_entry.base_record_file_reference != 0:
return
if mft_attribute.attribute_type in [
self._MFT_ATTRIBUTE_STANDARD_INFORMATION,
self._MFT_ATTRIBUTE_FILE_NAME]:
file_attribute_f... | 288,158 |
Extracts data from a NFTS $MFT entry.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
mft_entry (pyfsntfs.file_entry): MFT entry. | def _ParseMFTEntry(self, parser_mediator, mft_entry):
for attribute_index in range(0, mft_entry.number_of_attributes):
try:
mft_attribute = mft_entry.get_attribute(attribute_index)
self._ParseMFTAttribute(parser_mediator, mft_entry, mft_attribute)
except IOError as exception:
... | 288,159 |
Parses a NTFS $MFT metadata 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. | def ParseFileObject(self, parser_mediator, file_object):
mft_metadata_file = pyfsntfs.mft_metadata_file()
try:
mft_metadata_file.open_file_object(file_object)
except IOError as exception:
parser_mediator.ProduceExtractionWarning(
'unable to open file with error: {0!s}'.format(exc... | 288,160 |
Parses an USN change journal.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
usn_change_journal (pyfsntsfs.usn_change_journal): USN change journal.
Raises:
ParseError: if an USN change journal record ca... | def _ParseUSNChangeJournal(self, parser_mediator, usn_change_journal):
if not usn_change_journal:
return
usn_record_map = self._GetDataTypeMap('usn_record_v2')
usn_record_data = usn_change_journal.read_usn_record()
while usn_record_data:
current_offset = usn_change_journal.get_offset(... | 288,161 |
Parses a NTFS $UsnJrnl metadata 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. | def ParseFileObject(self, parser_mediator, file_object):
volume = pyfsntfs.volume()
try:
volume.open_file_object(file_object)
except IOError as exception:
parser_mediator.ProduceExtractionWarning(
'unable to open NTFS volume with error: {0!s}'.format(exception))
try:
us... | 288,162 |
Initializes the parser.
Args:
origin (str): origin of the event. | def __init__(self, origin):
super(ShellItemsParser, self).__init__()
self._origin = origin
self._path_segments = [] | 288,163 |
Parses a shell item.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
shell_item (pyfwsi.item): shell item. | def _ParseShellItem(self, parser_mediator, shell_item):
path_segment = self._ParseShellItemPathSegment(shell_item)
self._path_segments.append(path_segment)
event_data = shell_item_events.ShellItemFileEntryEventData()
event_data.origin = self._origin
event_data.shell_item_path = self.CopyToPath... | 288,164 |
Parses a shell item path segment.
Args:
shell_item (pyfwsi.item): shell item.
Returns:
str: shell item path segment. | def _ParseShellItemPathSegment(self, shell_item):
path_segment = None
if isinstance(shell_item, pyfwsi.root_folder):
description = shell_folder_ids.DESCRIPTIONS.get(
shell_item.shell_folder_identifier, None)
if description:
path_segment = description
else:
path... | 288,165 |
Parses the shell items from the byte stream.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
byte_stream (bytes): shell items data.
parent_path_segments (Optional[list[str]]): parent shell item path
... | def ParseByteStream(
self, parser_mediator, byte_stream, parent_path_segments=None,
codepage='cp1252'):
if parent_path_segments and isinstance(parent_path_segments, list):
self._path_segments = list(parent_path_segments)
else:
self._path_segments = []
shell_item_list = pyfwsi.i... | 288,167 |
Initializes an event data attribute container.
Args:
data_type (Optional[str]): event data type indicator. | def __init__(self, data_type=DATA_TYPE):
super(SyslogLineEventData, self).__init__(data_type=data_type)
self.body = None
self.hostname = None
self.pid = None
self.reporter = None
self.severity = None | 288,168 |
Updates the year to use for events, based on last observed month.
Args:
mediator (ParserMediator): mediates the interactions between
parsers and other components, such as storage and abort signals.
month (int): month observed by the parser, where January is 1. | def _UpdateYear(self, mediator, month):
if not self._year_use:
self._year_use = mediator.GetEstimatedYear()
if not self._maximum_year:
self._maximum_year = mediator.GetLatestYear()
if not self._last_month:
self._last_month = month
return
# Some syslog daemons allow out-of-... | 288,171 |
Enables parser plugins.
Args:
plugin_includes (list[str]): names of the plugins to enable, where None
or an empty list represents all plugins. Note that the default plugin
is handled separately. | def EnablePlugins(self, plugin_includes):
super(SyslogParser, self).EnablePlugins(plugin_includes)
self._plugin_by_reporter = {}
for plugin in self._plugins:
self._plugin_by_reporter[plugin.REPORTER] = plugin | 288,172 |
Parses a matching entry.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
key (str): name of the parsed structure.
structure (pyparsing.ParseResults): elements parsed from the file.
Raises:
ParseErr... | def ParseRecord(self, parser_mediator, key, structure):
if key not in self._SUPPORTED_KEYS:
raise errors.ParseError(
'Unable to parse record, unknown structure: {0:s}'.format(key))
if key == 'chromeos_syslog_line':
date_time = dfdatetime_time_elements.TimeElementsInMicroseconds()
... | 288,173 |
Verifies that this is a syslog-formatted file.
Args:
parser_mediator (ParserMediator): mediates interactions between
parsers and other components, such as storage and dfvfs.
lines (str): one or more lines from the text file.
Returns:
bool: True if this is the correct parser, False ... | def VerifyStructure(self, parser_mediator, lines):
return (re.match(self._VERIFICATION_REGEX, lines) or
re.match(self._CHROMEOS_VERIFICATION_REGEX, lines)) is not None | 288,174 |
Pushes an event onto the heap.
Args:
event (EventObject): event. | def PushEvent(self, event):
event_string = event.GetAttributeValuesString()
heap_values = (event.timestamp, event.timestamp_desc, event_string, event)
heapq.heappush(self._heap, heap_values) | 288,176 |
Pushes a serialized event onto the heap.
Args:
timestamp (int): event timestamp, which contains the number of
micro seconds since January 1, 1970, 00:00:00 UTC.
event_data (bytes): serialized event. | def PushEvent(self, timestamp, event_data):
heap_values = (timestamp, event_data)
heapq.heappush(self._heap, heap_values)
self.data_size += len(event_data) | 288,179 |
Adds an user account.
Args:
user_account (UserAccountArtifact): user account artifact.
session_identifier (Optional[str])): session identifier, where
CURRENT_SESSION represents the active session.
Raises:
KeyError: if the user account already exists. | def AddUserAccount(self, user_account, session_identifier=CURRENT_SESSION):
if session_identifier not in self._user_accounts:
self._user_accounts[session_identifier] = {}
user_accounts = self._user_accounts[session_identifier]
if user_account.identifier in user_accounts:
raise KeyError('Us... | 288,182 |
Adds an environment variable.
Args:
environment_variable (EnvironmentVariableArtifact): environment variable
artifact.
Raises:
KeyError: if the environment variable already exists. | def AddEnvironmentVariable(self, environment_variable):
name = environment_variable.name.upper()
if name in self._environment_variables:
raise KeyError('Environment variable: {0:s} already exists.'.format(
environment_variable.name))
self._environment_variables[name] = environment_vari... | 288,183 |
Retrieves an environment variable.
Args:
name (str): name of the environment variable.
Returns:
EnvironmentVariableArtifact: environment variable artifact or None
if there was no value set for the given name. | def GetEnvironmentVariable(self, name):
name = name.upper()
return self._environment_variables.get(name, None) | 288,184 |
Retrieves the hostname related to the event.
If the hostname is not stored in the event it is determined based
on the preprocessing information that is stored inside the storage file.
Args:
session_identifier (Optional[str])): session identifier, where
CURRENT_SESSION represents the active... | def GetHostname(self, session_identifier=CURRENT_SESSION):
hostname_artifact = self._hostnames.get(session_identifier, None)
if not hostname_artifact:
return ''
return hostname_artifact.name or '' | 288,185 |
Retrieves the knowledge base as a system configuration artifact.
Args:
session_identifier (Optional[str])): session identifier, where
CURRENT_SESSION represents the active session.
Returns:
SystemConfigurationArtifact: system configuration artifact. | def GetSystemConfigurationArtifact(self, session_identifier=CURRENT_SESSION):
system_configuration = artifacts.SystemConfigurationArtifact()
system_configuration.code_page = self.GetValue(
'codepage', default_value=self._codepage)
system_configuration.hostname = self._hostnames.get(
s... | 288,187 |
Retrieves the username based on an user identifier.
Args:
user_identifier (str): user identifier, either a UID or SID.
session_identifier (Optional[str])): session identifier, where
CURRENT_SESSION represents the active session.
Returns:
str: username. | def GetUsernameByIdentifier(
self, user_identifier, session_identifier=CURRENT_SESSION):
user_accounts = self._user_accounts.get(session_identifier, {})
user_account = user_accounts.get(user_identifier, None)
if not user_account:
return ''
return user_account.username or '' | 288,188 |
Retrieves a username for a specific path.
This is determining if a specific path is within a user's directory and
returning the username of the user if so.
Args:
path (str): path.
Returns:
str: username or None if the path does not appear to be within a user's
directory. | def GetUsernameForPath(self, path):
path = path.lower()
user_accounts = self._user_accounts.get(self.CURRENT_SESSION, {})
for user_account in iter(user_accounts.values()):
if not user_account.user_directory:
continue
user_directory = user_account.user_directory.lower()
if pa... | 288,189 |
Retrieves a value by identifier.
Args:
identifier (str): case insensitive unique identifier for the value.
default_value (object): default value.
Returns:
object: value or default value if not available.
Raises:
TypeError: if the identifier is not a string type. | def GetValue(self, identifier, default_value=None):
if not isinstance(identifier, py2to3.STRING_TYPES):
raise TypeError('Identifier not a string type.')
identifier = identifier.lower()
return self._values.get(identifier, default_value) | 288,190 |
Reads the knowledge base values from a system configuration artifact.
Note that this overwrites existing values in the knowledge base.
Args:
system_configuration (SystemConfigurationArtifact): system configuration
artifact.
session_identifier (Optional[str])): session identifier, where
... | def ReadSystemConfigurationArtifact(
self, system_configuration, session_identifier=CURRENT_SESSION):
if system_configuration.code_page:
try:
self.SetCodepage(system_configuration.code_page)
except ValueError:
logger.warning(
'Unsupported codepage: {0:s}, defaultin... | 288,191 |
Sets the codepage.
Args:
codepage (str): codepage.
Raises:
ValueError: if the codepage is not supported. | def SetCodepage(self, codepage):
try:
codecs.getencoder(codepage)
self._codepage = codepage
except LookupError:
raise ValueError('Unsupported codepage: {0:s}'.format(codepage)) | 288,192 |
Sets an environment variable.
Args:
environment_variable (EnvironmentVariableArtifact): environment variable
artifact. | def SetEnvironmentVariable(self, environment_variable):
name = environment_variable.name.upper()
self._environment_variables[name] = environment_variable | 288,193 |
Sets the time zone.
Args:
time_zone (str): time zone.
Raises:
ValueError: if the timezone is not supported. | def SetTimeZone(self, time_zone):
try:
self._time_zone = pytz.timezone(time_zone)
except (AttributeError, pytz.UnknownTimeZoneError):
raise ValueError('Unsupported timezone: {0!s}'.format(time_zone)) | 288,194 |
Sets a value by identifier.
Args:
identifier (str): case insensitive unique identifier for the value.
value (object): value.
Raises:
TypeError: if the identifier is not a string type. | def SetValue(self, identifier, value):
if not isinstance(identifier, py2to3.STRING_TYPES):
raise TypeError('Identifier not a string type.')
identifier = identifier.lower()
self._values[identifier] = value | 288,195 |
Creates the analysis plugins.
Args:
options (argparse.Namespace): command line arguments.
Returns:
dict[str, AnalysisPlugin]: analysis plugins and their names. | def _CreateAnalysisPlugins(self, options):
if not self._analysis_plugins:
return {}
analysis_plugins = (
analysis_manager.AnalysisPluginManager.GetPluginObjects(
self._analysis_plugins))
for analysis_plugin in analysis_plugins.values():
helpers_manager.ArgumentHelperMa... | 288,196 |
Creates the output module.
Args:
options (argparse.Namespace): command line arguments.
Returns:
OutputModule: output module.
Raises:
RuntimeError: if the output module cannot be created. | def _CreateOutputModule(self, options):
formatter_mediator = formatters_mediator.FormatterMediator(
data_location=self._data_location)
try:
formatter_mediator.SetPreferredLanguageIdentifier(
self._preferred_language)
except (KeyError, TypeError) as exception:
raise Runtim... | 288,201 |
Initializes a fake attribute container identifier.
Args:
attribute_values_hash (int): hash value of the attribute values. | def __init__(self, attribute_values_hash):
super(FakeIdentifier, self).__init__()
self.attribute_values_hash = attribute_values_hash | 288,207 |
Initializes a serialized stream attribute container identifier.
Args:
stream_number (int): number of the serialized attribute container stream.
entry_index (int): number of the serialized event within the stream. | def __init__(self, stream_number, entry_index):
super(SerializedStreamIdentifier, self).__init__()
self.entry_index = entry_index
self.stream_number = stream_number | 288,208 |
Initializes a SQL table attribute container identifier.
Args:
name (str): name of the table.
row_identifier (int): unique identifier of the row in the table. | def __init__(self, name, row_identifier):
super(SQLTableIdentifier, self).__init__()
self.name = name
self.row_identifier = row_identifier | 288,210 |
Extracts events from a Windows Registry key.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
registry_key (dfwinreg.WinRegistryKey): Windows Registry key. | def ExtractEvents(self, parser_mediator, registry_key, **kwargs):
event_data = windows_events.WindowsRegistryEventData()
event_data.key_path = registry_key.path
event_data.offset = registry_key.offset
event_data.urls = self.URLS
values_dict = {}
for registry_value in registry_key.GetValues... | 288,212 |
Check if it is a valid Apple account plist file name.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
plist_name (str): name of the plist.
top_level (dict[str, object]): plist top-level key. | def Process(self, parser_mediator, plist_name, top_level, **kwargs):
if not plist_name.startswith(self.PLIST_PATH):
raise errors.WrongPlistPlugin(self.NAME, plist_name)
super(AppleAccountPlugin, self).Process(
parser_mediator, plist_name=self.PLIST_PATH, top_level=top_level) | 288,213 |
Extracts relevant Apple Account entries.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
match (Optional[dict[str: object]]): keys extracted from PLIST_KEYS. | def GetEntries(self, parser_mediator, match=None, **unused_kwargs):
accounts = match.get('Accounts', {})
for name_account, account in iter(accounts.items()):
first_name = account.get('FirstName', '<FirstName>')
last_name = account.get('LastName', '<LastName>')
general_description = '{0:s}... | 288,214 |
Adds command line arguments the helper supports to an argument group.
This function takes an argument parser or an argument group object and adds
to it all the command line arguments this helper supports.
Args:
argument_group (argparse._ArgumentGroup|argparse.ArgumentParser):
argparse grou... | def AddArguments(cls, argument_group):
shared_4n6time_output.Shared4n6TimeOutputArgumentsHelper.AddArguments(
argument_group)
MySQL4n6TimeDatabaseArgumentsHelper.AddArguments(argument_group) | 288,215 |
Parses and validates options.
Args:
options (argparse.Namespace): parser options.
output_module (OutputModule): output module to configure.
Raises:
BadConfigObject: when the output module object is of the wrong type. | def ParseOptions(cls, options, output_module):
if not isinstance(output_module, mysql_4n6time.MySQL4n6TimeOutputModule):
raise errors.BadConfigObject(
'Output module is not an instance of MySQL4n6TimeOutputModule')
MySQL4n6TimeDatabaseArgumentsHelper.ParseOptions(options, output_module)
... | 288,216 |
Extracts events from a Terminal Server Client Windows Registry key.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
registry_key (dfwinreg.WinRegistryKey): Windows Registry key. | def ExtractEvents(self, parser_mediator, registry_key, **kwargs):
mru_values_dict = {}
for subkey in registry_key.GetSubkeys():
username_value = subkey.GetValueByName('UsernameHint')
if (username_value and username_value.data and
username_value.DataIsString()):
username = use... | 288,217 |
Parses a bencoded file-like object.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
file_object (dfvfs.FileIO): a file-like object.
Raises:
UnableToParseFile: when the file cannot be parsed. | def ParseFileObject(self, parser_mediator, file_object):
file_object.seek(0, os.SEEK_SET)
header = file_object.read(2)
if not self.BENCODE_RE.match(header):
raise errors.UnableToParseFile('Not a valid Bencoded file.')
file_object.seek(0, os.SEEK_SET)
try:
data_object = bencode.bdec... | 288,218 |
Parse header lines and store appropriate attributes.
['Logging started.', 'Version=', '17.0.2011.0627',
[2013, 7, 25], 16, 3, 23, 291, 'StartLocalTime', '<details>']
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvf... | def _ParseHeader(self, parser_mediator, structure):
try:
date_time = dfdatetime_time_elements.TimeElementsInMilliseconds(
time_elements_tuple=structure.header_date_time)
except ValueError:
parser_mediator.ProduceExtractionWarning(
'invalid date time value: {0!s}'.format(stru... | 288,221 |
Parses a logline and store appropriate attributes.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
structure (pyparsing.ParseResults): structure of tokens derived from
a line of a text file. | def _ParseLine(self, parser_mediator, structure):
# TODO: Verify if date and time value is locale dependent.
month, day_of_month, year, hours, minutes, seconds, milliseconds = (
structure.date_time)
year += 2000
time_elements_tuple = (
year, month, day_of_month, hours, minutes, sec... | 288,222 |
Parse each record structure and return an EventObject if applicable.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
key (str): identifier of the structure of tokens.
structure (pyparsing.ParseResults): struc... | def ParseRecord(self, parser_mediator, key, structure):
if key not in ('header', 'logline'):
raise errors.ParseError(
'Unable to parse record, unknown structure: {0:s}'.format(key))
if key == 'logline':
self._ParseLine(parser_mediator, structure)
elif key == 'header':
self... | 288,223 |
Verify that this file is a SkyDrive log file.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
lines (str): one or more lines from the text file.
Returns:
bool: True if this is the correct parser, False o... | def VerifyStructure(self, parser_mediator, lines):
try:
structure = self._SDF_HEADER.parseString(lines)
except pyparsing.ParseException:
logger.debug('Not a SkyDrive log file')
return False
try:
dfdatetime_time_elements.TimeElementsInMilliseconds(
time_elements_tuple=... | 288,224 |
Parse a logline and store appropriate attributes.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
structure (pyparsing.ParseResults): structure of tokens derived from
a line of a text file. | def _ParseLogline(self, parser_mediator, structure):
# TODO: Verify if date and time value is locale dependent.
month, day_of_month, year, hours, minutes, seconds, milliseconds = (
structure.date_time)
time_elements_tuple = (
year, month, day_of_month, hours, minutes, seconds, millisec... | 288,226 |
Parse an isolated header line and store appropriate attributes.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
structure (pyparsing.ParseResults): structure of tokens derived from
a line of a text file. | def _ParseNoHeaderSingleLine(self, parser_mediator, structure):
if not self._last_event_data:
logger.debug('SkyDrive, found isolated line with no previous events')
return
event_data = SkyDriveOldLogEventData()
event_data.offset = self._last_event_data.offset
event_data.text = structure... | 288,227 |
Parse each record structure and return an EventObject if applicable.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
key (str): identifier of the structure of tokens.
structure (pyparsing.ParseResults): struc... | def ParseRecord(self, parser_mediator, key, structure):
if key not in ('logline', 'no_header_single_line'):
raise errors.ParseError(
'Unable to parse record, unknown structure: {0:s}'.format(key))
if key == 'logline':
self._ParseLogline(parser_mediator, structure)
elif key == 'n... | 288,228 |
Verify that this file is a SkyDrive old 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:
bool: True if the line is in the expected format, False if no... | def VerifyStructure(self, parser_mediator, line):
try:
structure = self._LINE.parseString(line)
except pyparsing.ParseException:
logger.debug('Not a SkyDrive old log file')
return False
day_of_month, month, year, hours, minutes, seconds, milliseconds = (
structure.date_time)
... | 288,229 |
Parses a Video row.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
query (str): query that created the row.
row (sqlite3.Row): row. | def ParseVideoRow(self, parser_mediator, query, row, **unused_kwargs):
query_hash = hash(query)
event_data = KodiVideoEventData()
event_data.filename = self._GetRowValue(query_hash, row, 'strFilename')
event_data.play_count = self._GetRowValue(query_hash, row, 'playCount')
event_data.query = q... | 288,231 |
Parses and validates options.
Args:
options (argparse.Namespace): parser options.
configuration_object (CLITool): object to be configured by the argument
helper.
Raises:
BadConfigObject: when the configuration object is of the wrong type. | def ParseOptions(cls, options, configuration_object):
if not isinstance(configuration_object, tools.CLITool):
raise errors.BadConfigObject(
'Configuration object is not an instance of CLITool')
parsers = cls._ParseStringOption(options, 'parsers', default_value='')
parsers = parsers.rep... | 288,232 |
Copies attributes from a session completion.
Args:
session_completion (SessionCompletion): session completion attribute
container.
Raises:
ValueError: if the identifier of the session completion does not match
that of the session. | def CopyAttributesFromSessionCompletion(self, session_completion):
if self.identifier != session_completion.identifier:
raise ValueError('Session identifier mismatch.')
self.aborted = session_completion.aborted
if session_completion.analysis_reports_counter:
self.analysis_reports_counter ... | 288,234 |
Initializes a session completion attribute container.
Args:
identifier (Optional[str]): unique identifier of the session.
The identifier should match that of the corresponding
session start information. | def __init__(self, identifier=None):
super(SessionCompletion, self).__init__()
self.aborted = False
self.analysis_reports_counter = None
self.event_labels_counter = None
self.identifier = identifier
self.parsers_counter = None
self.timestamp = None | 288,237 |
Initializes a session start attribute container.
Args:
identifier (Optional[str]): unique identifier of the session.
The identifier should match that of the corresponding
session completion information. | def __init__(self, identifier=None):
super(SessionStart, self).__init__()
self.artifact_filters = None
self.command_line_arguments = None
self.debug_mode = False
self.enabled_parser_names = None
self.filter_file = None
self.identifier = identifier
self.parser_filter_expression = Non... | 288,238 |
Parses a numeric command line argument.
Args:
options (argparse.Namespace): parser options.
argument_name (str): name of the command line argument.
default_value (Optional[int]): default value of the command line argument.
Returns:
int: command line argument value or the default value ... | def _ParseNumericOption(cls, options, argument_name, default_value=None):
argument_value = getattr(options, argument_name, None)
if argument_value is None:
return default_value
if not isinstance(argument_value, py2to3.INTEGER_TYPES):
raise errors.BadConfigOption(
'Unsupported opt... | 288,239 |
Parses a string command line argument.
Args:
options (argparse.Namespace): parser options.
argument_name (str): name of the command line argument.
default_value (Optional[str]): default value of the command line argument.
Returns:
str: command line argument value or the default value i... | def _ParseStringOption(cls, options, argument_name, default_value=None):
argument_value = getattr(options, argument_name, None)
if argument_value is None:
return default_value
if isinstance(argument_value, py2to3.BYTES_TYPE):
encoding = sys.stdin.encoding
# Note that sys.stdin.encod... | 288,240 |
Parses a DLS page header from a file-like object.
Args:
file_object (file): file-like object to read the header from.
page_offset (int): offset of the start of the page header, relative
to the start of the file.
Returns:
tuple: containing:
dls_page_header: parsed record st... | def _ParseDLSPageHeader(self, file_object, page_offset):
page_header_map = self._GetDataTypeMap('dls_page_header')
try:
page_header, page_size = self._ReadStructureFromFileObject(
file_object, page_offset, page_header_map)
except (ValueError, errors.ParseError) as exception:
rais... | 288,243 |
Builds an FseventsdData object from a parsed structure.
Args:
record (dls_record_v1|dls_record_v2): parsed record structure.
Returns:
FseventsdEventData: event data attribute container. | def _BuildEventData(self, record):
event_data = FseventsdEventData()
event_data.path = record.path
event_data.flags = record.event_flags
event_data.event_identifier = record.event_identifier
# Node identifier is only set in DLS V2 records.
event_data.node_identifier = getattr(record, 'node_... | 288,244 |
Parses an fseventsd file.
Args:
parser_mediator (ParserMediator): parser mediator.
file_object (dfvfs.FileIO): a file-like object.
Raises:
UnableToParseFile: when the header cannot be parsed. | def ParseFileObject(self, parser_mediator, file_object):
page_header_map = self._GetDataTypeMap('dls_page_header')
try:
page_header, file_offset = self._ReadStructureFromFileObject(
file_object, 0, page_header_map)
except (ValueError, errors.ParseError) as exception:
raise errors... | 288,246 |
Parses a document versions row.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
query (str): query that created the row.
row (sqlite3.Row): row. | def DocumentVersionsRow(
self, parser_mediator, query, row, **unused_kwargs):
query_hash = hash(query)
# version_path = "PerUser/UserID/xx/client_id/version_file"
# where PerUser and UserID are a real directories.
version_path = self._GetRowValue(query_hash, row, 'version_path')
path = s... | 288,248 |
Parses an utmp file-like object.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
file_object (dfvfs.FileIO): a file-like object.
Raises:
UnableToParseFile: when the file cannot be parsed. | def ParseFileObject(self, parser_mediator, file_object):
file_offset = 0
try:
timestamp, event_data = self._ReadEntry(
parser_mediator, file_object, file_offset)
except errors.ParseError as exception:
raise errors.UnableToParseFile(
'Unable to parse first utmp entry wit... | 288,251 |
Parses an Opera typed history 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:
UnableToParseFile: when the file cannot be parsed. | def ParseFileObject(self, parser_mediator, file_object):
data = file_object.read(self._HEADER_READ_SIZE)
if not data.startswith(b'<?xml'):
raise errors.UnableToParseFile(
'Not an Opera typed history file [not a XML]')
_, _, data = data.partition(b'\n')
if not data.startswith(b'<typ... | 288,254 |
Parses an Opera global history record.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
text_file_object (dfvfs.TextFile): text file.
Returns:
bool: True if the record was successfully parsed. | def _ParseRecord(self, parser_mediator, text_file_object):
try:
title = text_file_object.readline()
except UnicodeDecodeError:
parser_mediator.ProduceExtractionWarning(
'unable to read and decode title')
return False
if not title:
return False
try:
url = te... | 288,256 |
Parses and validates an Opera global history record.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
text_file_object (dfvfs.TextFile): text file.
Returns:
bool: True if the record was successfully parse... | def _ParseAndValidateRecord(self, parser_mediator, text_file_object):
try:
title = text_file_object.readline(size=self._MAXIMUM_LINE_SIZE)
url = text_file_object.readline(size=self._MAXIMUM_LINE_SIZE)
timestamp = text_file_object.readline(size=self._MAXIMUM_LINE_SIZE)
popularity_index =... | 288,257 |
Parses an Opera global history 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:
UnableToParseFile: when the file cannot be parsed. | def ParseFileObject(self, parser_mediator, file_object):
encoding = self._ENCODING or parser_mediator.codepage
text_file_object = text_file.TextFile(file_object, encoding=encoding)
if not self._ParseAndValidateRecord(parser_mediator, text_file_object):
raise errors.UnableToParseFile(
'U... | 288,258 |
Parses the original filename.
Args:
file_object (FileIO): file-like object.
format_version (int): format version.
Returns:
str: filename or None on error.
Raises:
ParseError: if the original filename cannot be read. | def _ParseOriginalFilename(self, file_object, format_version):
file_offset = file_object.tell()
if format_version == 1:
data_type_map = self._GetDataTypeMap(
'recycle_bin_metadata_utf16le_string')
else:
data_type_map = self._GetDataTypeMap(
'recycle_bin_metadata_utf16le... | 288,260 |
Parses a Windows Recycle.Bin metadata ($I) 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:
UnableToParseFile: when the file cannot ... | def ParseFileObject(self, parser_mediator, file_object):
# We may have to rely on filenames since this header is very generic.
# TODO: Rethink this and potentially make a better test.
filename = parser_mediator.GetFilename()
if not filename.startswith('$I'):
raise errors.UnableToParseFile('F... | 288,261 |
Parses an INFO-2 record.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
file_object (dfvfs.FileIO): file-like object.
record_offset (int): record offset.
record_size (int): record size.
Raises:
... | def _ParseInfo2Record(
self, parser_mediator, file_object, record_offset, record_size):
record_data = self._ReadData(file_object, record_offset, record_size)
record_map = self._GetDataTypeMap('recycler_info2_file_entry')
try:
record = self._ReadStructureFromByteStream(
record_da... | 288,262 |
Parses a Windows Recycler INFO2 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:
UnableToParseFile: when the file cannot be parsed. | def ParseFileObject(self, parser_mediator, file_object):
# Since this header value is really generic it is hard not to use filename
# as an indicator too.
# TODO: Rethink this and potentially make a better test.
filename = parser_mediator.GetFilename()
if not filename.startswith('INFO2'):
... | 288,263 |
Initializes the CLI tool object.
Args:
input_reader (Optional[InputReader]): input reader, where None indicates
that the stdin input reader should be used.
output_writer (Optional[OutputWriter]): output writer, where None
indicates that the stdout output writer should be used. | def __init__(self, input_reader=None, output_writer=None):
super(StorageMediaTool, self).__init__(
input_reader=input_reader, output_writer=output_writer)
self._custom_artifacts_path = None
self._artifact_definitions_path = None
self._artifact_filters = None
self._credentials = []
s... | 288,264 |
Adds a credential configuration.
Args:
path_spec (dfvfs.PathSpec): path specification.
credential_type (str): credential type.
credential_data (bytes): credential data. | def _AddCredentialConfiguration(
self, path_spec, credential_type, credential_data):
credential_configuration = configurations.CredentialConfiguration(
credential_data=credential_data, credential_type=credential_type,
path_spec=path_spec)
self._credential_configurations.append(creden... | 288,265 |
Represents a number of bytes as a human readable string.
Args:
size (int): size in bytes.
Returns:
str: human readable string of the size. | def _FormatHumanReadableSize(self, size):
magnitude_1000 = 0
size_1000 = float(size)
while size_1000 >= 1000:
size_1000 /= 1000
magnitude_1000 += 1
magnitude_1024 = 0
size_1024 = float(size)
while size_1024 >= 1024:
size_1024 /= 1024
magnitude_1024 += 1
size_st... | 288,266 |
Determines the APFS volume identifiers.
Args:
scan_node (dfvfs.SourceScanNode): scan node.
Returns:
list[str]: APFS volume identifiers.
Raises:
SourceScannerError: if the format of or within the source is not
supported or the the scan node is invalid.
UserAbort: if the u... | def _GetAPFSVolumeIdentifiers(self, scan_node):
if not scan_node or not scan_node.path_spec:
raise errors.SourceScannerError('Invalid scan node.')
volume_system = apfs_volume_system.APFSVolumeSystem()
volume_system.Open(scan_node.path_spec)
volume_identifiers = self._source_scanner.GetVolum... | 288,267 |
Determines the VSS store identifiers.
Args:
scan_node (dfvfs.SourceScanNode): scan node.
Returns:
list[str]: VSS store identifiers.
Raises:
SourceScannerError: if the format of or within the source is not
supported or the scan node is invalid.
UserAbort: if the user requ... | def _GetVSSStoreIdentifiers(self, scan_node):
if not scan_node or not scan_node.path_spec:
raise errors.SourceScannerError('Invalid scan node.')
volume_system = vshadow_volume_system.VShadowVolumeSystem()
volume_system.Open(scan_node.path_spec)
volume_identifiers = self._source_scanner.GetV... | 288,269 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.