Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
studiawan committed Nov 27, 2024
1 parent c7afb24 commit e37adb7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 67 deletions.
88 changes: 44 additions & 44 deletions plaso/parsers/sqlite_plugins/ios_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ class IOSAccounts(events.EventData):
"""iOS accounts event data.
Attributes:
date (dfdatetime.DateTimeValues): date and time the account
date (dfdatetime.DateTimeValues): date and time the account
was created.
account_type (str): account type.
username (str): user name.
identifier (str): identifier.
owning_bundle_id (str): owning bundle identifier of the app
owning_bundle_id (str): owning bundle identifier of the app
managing the account.
"""

DATA_TYPE = 'ios:accounts:account'

def __init__(self):
"""Initializes event data."""
super(IOSAccounts, self).__init__(data_type=self.DATA_TYPE)
self.date = None
self.account_type = None
self.username = None
self.identifier = None
self.owning_bundle_id = None
"""Initializes event data."""
super(IOSAccounts, self).__init__(data_type=self.DATA_TYPE)
self.date = None
self.account_type = None
self.username = None
self.identifier = None
self.owning_bundle_id = None

class IOSAccountsPlugin(interface.SQLitePlugin):
"""SQLite parser plugin for iOS accounts (Accounts3.db) database files."""
Expand Down Expand Up @@ -74,47 +74,47 @@ class IOSAccountsPlugin(interface.SQLitePlugin):
REQUIRES_SCHEMA_MATCH = False

def _GetTimeRowValue(self, query_hash, row, value_name):
"""Retrieves a date and time value from the row.
"""Retrieves a date and time value from the row.
Args:
query_hash (int): hash of the query, that uniquely
identifies the query that produced the row.
row (sqlite3.Row): row.
value_name (str): name of the value.
Args:
query_hash (int): hash of the query, that uniquely
identifies the query that produced the row.
row (sqlite3.Row): row.
value_name (str): name of the value.
Returns:
dfdatetime.CocoaTime: date and time value or None if not available.
"""
timestamp = self._GetRowValue(query_hash, row, value_name)
if timestamp is None:
return None
Returns:
dfdatetime.CocoaTime: date and time value or None if not available.
"""
timestamp = self._GetRowValue(query_hash, row, value_name)
if timestamp is None:
return None

return dfdatetime_cocoa_time.CocoaTime(timestamp=timestamp)
return dfdatetime_cocoa_time.CocoaTime(timestamp=timestamp)

# pylint: disable=unused-argument
def ParseAccountRow(
self, parser_mediator, query, row, **unused_kwargs):
"""Parses an account 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.
"""
query_hash = hash(query)

event_data = IOSAccounts()
event_data.date = self._GetTimeRowValue(query_hash, row, 'ZDATE')
event_data.account_type = self._GetRowValue(query_hash,
row, 'ZACCOUNTTYPEDESCRIPTION')
event_data.username = self._GetRowValue(query_hash, row, 'ZUSERNAME')
event_data.identifier = self._GetRowValue(query_hash, row,
'ZIDENTIFIER')
event_data.owning_bundle_id = self._GetRowValue(query_hash, row,
'ZOWNINGBUNDLEID')

parser_mediator.ProduceEventData(event_data)
self, parser_mediator, query, row, **unused_kwargs):
"""Parses an account 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.
"""
query_hash = hash(query)

event_data = IOSAccounts()
event_data.date = self._GetTimeRowValue(query_hash, row, 'ZDATE')
event_data.account_type = self._GetRowValue(query_hash,
row, 'ZACCOUNTTYPEDESCRIPTION')
event_data.username = self._GetRowValue(query_hash, row, 'ZUSERNAME')
event_data.identifier = self._GetRowValue(query_hash, row,
'ZIDENTIFIER')
event_data.owning_bundle_id = self._GetRowValue(query_hash, row,
'ZOWNINGBUNDLEID')

parser_mediator.ProduceEventData(event_data)


sqlite.SQLiteParser.RegisterPlugin(IOSAccountsPlugin)
46 changes: 23 additions & 23 deletions tests/parsers/sqlite_plugins/ios_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,34 @@


class IOSAccountsPluginTest(test_lib.SQLitePluginTestCase):
"""Tests for the SQLite parser plugin for iOS accounts database files."""
"""Tests for the SQLite parser plugin for iOS accounts database files."""

def testParse(self):
"""Tests the ParseAccountRow method."""
plugin = ios_accounts.IOSAccountsPlugin()
storage_writer = self._ParseDatabaseFileWithPlugin(
['Accounts3.sqlite'], plugin)
def testParse(self):
"""Tests the ParseAccountRow method."""
plugin = ios_accounts.IOSAccountsPlugin()
storage_writer = self._ParseDatabaseFileWithPlugin(
['Accounts3.sqlite'], plugin)

number_of_event_data = storage_writer.GetNumberOfAttributeContainers(
'event_data')
self.assertEqual(number_of_event_data, 18)
number_of_event_data = storage_writer.GetNumberOfAttributeContainers(
'event_data')
self.assertEqual(number_of_event_data, 18)

number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
'extraction_warning')
self.assertEqual(number_of_warnings, 0)
number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
'extraction_warning')
self.assertEqual(number_of_warnings, 0)

expected_event_values = {
'date': '2020-03-21T21:47:57.068197+00:00',
'account_type': 'iCloud',
'identifier': '1589F4EC-8F6C-4F37-929F-C6F121B36A59',
'owning_bundle_id': 'com.apple.purplebuddy',
'username': '[email protected]'
}
expected_event_values = {
'date': '2020-03-21T21:47:57.068197+00:00',
'account_type': 'iCloud',
'identifier': '1589F4EC-8F6C-4F37-929F-C6F121B36A59',
'owning_bundle_id': 'com.apple.purplebuddy',
'username': '[email protected]'
}

event_data = storage_writer.GetAttributeContainerByIndex(
'event_data', 3)
self.CheckEventData(event_data, expected_event_values)
event_data = storage_writer.GetAttributeContainerByIndex(
'event_data', 3)
self.CheckEventData(event_data, expected_event_values)


if __name__ == '__main__':
unittest.main()
unittest.main()

0 comments on commit e37adb7

Please sign in to comment.