Skip to content

Commit

Permalink
Merge pull request #170 from obsidianforensics/issue-169
Browse files Browse the repository at this point in the history
Add more exception handling to address issues raised in #169
  • Loading branch information
obsidianforensics authored Apr 28, 2024
2 parents 76b5a17 + 14825ff commit 9a5657c
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions pyhindsight/browsers/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ def get_downloads(self, path, database, version, row_type):
self.artifacts_counts[database + '_downloads'] = 'Failed'
log.error(f' - Couldn\'t open {os.path.join(path, database)}')

except sqlite3.OperationalError as e:
self.artifacts_counts[database + '_downloads'] = 'Failed'
log.error(f' - Couldn\'t read "downloads" from {os.path.join(path, database)}; {e}')

def decrypt_cookie(self, encrypted_value):
"""Decryption based on work by Nathan Henrie and Jordan Wright as well as Chromium source:
- Mac/Linux: http://n8henrie.com/2014/05/decrypt-chrome-cookies-with-python/
Expand Down Expand Up @@ -1102,24 +1106,29 @@ def get_extensions(self, path, dir_name):
selected_version = None
decoded_manifest = None

# Connect to manifest.json in the latest version directory
for version in sorted(ext_vers, reverse=True, key=lambda x: int(x.split('.', maxsplit=1)[0])):
manifest_path = os.path.join(ext_vers_listing, version, 'manifest.json')
try:
with open(manifest_path, encoding='utf-8', errors='replace') as f:
decoded_manifest = json.loads(f.read())
selected_version = version
break
except (IOError, json.JSONDecodeError) as e:
log.error(f' - Error opening {manifest_path} for extension {app_id}; {e}')
try:
# Connect to manifest.json in the latest version directory
for version in sorted(ext_vers, reverse=True, key=lambda x: int(x.split('.', maxsplit=1)[0])):
manifest_path = os.path.join(ext_vers_listing, version, 'manifest.json')
try:
with open(manifest_path, encoding='utf-8', errors='replace') as f:
decoded_manifest = json.loads(f.read())
selected_version = version
break
except (IOError, json.JSONDecodeError) as e:
log.error(f' - Error opening {manifest_path} for extension {app_id}; {e}')
continue

if not decoded_manifest:
log.error(f' - Error opening manifest info for extension {app_id}')
continue

if not decoded_manifest:
log.error(f' - Error opening manifest info for extension {app_id}')
continue
name = None
description = None

name = None
description = None
except Exception as e:
log.error(f' - Error reading manifest info for extension {app_id}; {e}')
continue

try:
if decoded_manifest['name'].startswith('__'):
Expand Down

0 comments on commit 9a5657c

Please sign in to comment.