Skip to content

Commit e84237d

Browse files
committed
Changes to not catch exception related to coding errors
1 parent f81839b commit e84237d

11 files changed

Lines changed: 87 additions & 3 deletions

File tree

plaso/engine/single_process.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def __init__(self):
3333
self._processing_configuration = None
3434
self._status_update_callback = None
3535

36+
# pylint: disable=missing-raises-doc
3637
def _ProcessPathSpec(self, extraction_worker, parser_mediator, path_spec):
3738
"""Processes a path specification.
3839
@@ -49,10 +50,16 @@ def _ProcessPathSpec(self, extraction_worker, parser_mediator, path_spec):
4950
excluded_find_specs = (
5051
self.collection_filters_helper.excluded_file_system_find_specs)
5152

53+
# pylint: disable=try-except-raise
5254
try:
5355
extraction_worker.ProcessPathSpec(
5456
parser_mediator, path_spec, excluded_find_specs=excluded_find_specs)
5557

58+
# Raise on coding errors.
59+
except (AttributeError, ImportError, NameError, TypeError,
60+
UnboundLocalError):
61+
raise
62+
5663
except KeyboardInterrupt:
5764
self._abort = True
5865

plaso/multi_processing/analysis_process.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def _Main(self):
147147

148148
storage_writer.WriteTaskStart()
149149

150+
# pylint: disable=try-except-raise
150151
try:
151152
logger.debug(
152153
'{0!s} (PID: {1:d}) started monitoring event queue.'.format(
@@ -178,6 +179,11 @@ def _Main(self):
178179

179180
self._analysis_mediator.ProduceAnalysisReport(self._analysis_plugin)
180181

182+
# Raise on coding errors.
183+
except (AttributeError, ImportError, NameError, TypeError,
184+
UnboundLocalError):
185+
raise
186+
181187
# All exceptions need to be caught here to prevent the process
182188
# from being killed by an uncaught exception.
183189
except Exception as exception: # pylint: disable=broad-except

plaso/multi_processing/worker_process.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def _Main(self):
168168

169169
self._status = definitions.STATUS_INDICATOR_RUNNING
170170

171+
# pylint: disable=try-except-raise
171172
try:
172173
logger.debug('{0!s} (PID: {1:d}) started monitoring task queue.'.format(
173174
self._name, self._pid))
@@ -189,6 +190,11 @@ def _Main(self):
189190
logger.debug('{0!s} (PID: {1:d}) stopped monitoring task queue.'.format(
190191
self._name, self._pid))
191192

193+
# Raise on coding errors.
194+
except (AttributeError, ImportError, NameError, TypeError,
195+
UnboundLocalError):
196+
raise
197+
192198
# All exceptions need to be caught here to prevent the process
193199
# from being killed by an uncaught exception.
194200
except Exception as exception: # pylint: disable=broad-except
@@ -228,6 +234,7 @@ def _Main(self):
228234
except errors.QueueAlreadyClosed:
229235
logger.error('Queue for {0:s} was already closed.'.format(self.name))
230236

237+
# pylint: disable=missing-raises-doc
231238
def _ProcessPathSpec(self, extraction_worker, parser_mediator, path_spec):
232239
"""Processes a path specification.
233240
@@ -244,10 +251,16 @@ def _ProcessPathSpec(self, extraction_worker, parser_mediator, path_spec):
244251
excluded_find_specs = (
245252
self._collection_filters_helper.excluded_file_system_find_specs)
246253

254+
# pylint: disable=try-except-raise
247255
try:
248256
extraction_worker.ProcessPathSpec(
249257
parser_mediator, path_spec, excluded_find_specs=excluded_find_specs)
250258

259+
# Raise on coding errors.
260+
except (AttributeError, ImportError, NameError, TypeError,
261+
UnboundLocalError):
262+
raise
263+
251264
except dfvfs_errors.CacheFullError:
252265
# TODO: signal engine of failure.
253266
self._abort = True

plaso/parsers/esedb.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def GetFormatSpecification(cls):
6060
format_specification.AddNewSignature(b'\xef\xcd\xab\x89', offset=4)
6161
return format_specification
6262

63+
# pylint: disable=missing-raises-doc
6364
def ParseFileObject(self, parser_mediator, file_object):
6465
"""Parses an ESE database file-like object.
6566
@@ -79,6 +80,7 @@ def ParseFileObject(self, parser_mediator, file_object):
7980

8081
# Compare the list of available plugin objects.
8182
cache = ESEDBCache()
83+
8284
try:
8385
table_names = frozenset(self._GetTableNames(esedb_file))
8486

@@ -89,10 +91,16 @@ def ParseFileObject(self, parser_mediator, file_object):
8991
if not plugin.required_tables.issubset(table_names):
9092
continue
9193

94+
# pylint: disable=try-except-raise
9295
try:
9396
plugin.UpdateChainAndProcess(
9497
parser_mediator, cache=cache, database=esedb_file)
9598

99+
# Raise on coding errors.
100+
except (AttributeError, ImportError, NameError, TypeError,
101+
UnboundLocalError):
102+
raise
103+
96104
except Exception as exception: # pylint: disable=broad-except
97105
parser_mediator.ProduceExtractionWarning((
98106
'plugin: {0:s} unable to parse ESE database with error: '

plaso/parsers/esedb_plugins/interface.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ def _GetRecordValue(self, record, value_entry):
220220
return long_value.get_data()
221221
return record.get_value_data(value_entry)
222222

223+
# pylint: disable=missing-raises-doc
223224
def _GetRecordValues(
224225
self, parser_mediator, table_name, record, value_mappings=None):
225226
"""Retrieves the values from the record.
@@ -260,10 +261,16 @@ def _GetRecordValues(
260261
self.NAME, value_callback_method, column_name, table_name))
261262

262263
if value_callback:
264+
# pylint: disable=try-except-raise
263265
try:
264266
value_data = record.get_value_data(value_entry)
265267
value = value_callback(value_data)
266268

269+
# Raise on coding errors.
270+
except (AttributeError, ImportError, NameError, TypeError,
271+
UnboundLocalError):
272+
raise
273+
267274
except Exception as exception: # pylint: disable=broad-except
268275
logger.error(exception)
269276
value = None

plaso/parsers/olecf.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def GetFormatSpecification(cls):
4141

4242
return format_specification
4343

44+
# pylint: disable=missing-raises-doc
4445
def ParseFileObject(self, parser_mediator, file_object):
4546
"""Parses an OLE Compound File (OLECF) file-like object.
4647
@@ -81,19 +82,31 @@ def ParseFileObject(self, parser_mediator, file_object):
8182
if not plugin.REQUIRED_ITEMS.issubset(item_names):
8283
continue
8384

85+
# pylint: disable=try-except-raise
8486
try:
8587
plugin.UpdateChainAndProcess(parser_mediator, root_item=root_item)
8688

89+
# Raise on coding errors.
90+
except (AttributeError, ImportError, NameError, TypeError,
91+
UnboundLocalError):
92+
raise
93+
8794
except Exception as exception: # pylint: disable=broad-except
8895
parser_mediator.ProduceExtractionWarning((
8996
'plugin: {0:s} unable to parse OLECF file with error: '
9097
'{1!s}').format(plugin.NAME, exception))
9198

9299
if self._default_plugin and not parser_mediator.abort:
100+
# pylint: disable=try-except-raise
93101
try:
94102
self._default_plugin.UpdateChainAndProcess(
95103
parser_mediator, root_item=root_item)
96104

105+
# Raise on coding errors.
106+
except (AttributeError, ImportError, NameError, TypeError,
107+
UnboundLocalError):
108+
raise
109+
97110
except Exception as exception: # pylint: disable=broad-except
98111
parser_mediator.ProduceExtractionWarning((
99112
'plugin: {0:s} unable to parse OLECF file with error: '

plaso/parsers/safari_cookies.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def _ParsePage(self, parser_mediator, file_offset, page_data):
113113

114114
self._ParseRecord(parser_mediator, page_data, record_offset)
115115

116+
# pylint: disable=missing-raises-doc
116117
def _ParseRecord(self, parser_mediator, page_data, record_offset):
117118
"""Parses a record from the page data.
118119
@@ -178,11 +179,17 @@ def _ParseRecord(self, parser_mediator, page_data, record_offset):
178179
if event_data.cookie_name != plugin.COOKIE_NAME:
179180
continue
180181

182+
# pylint: disable=try-except-raise
181183
try:
182184
plugin.UpdateChainAndProcess(
183185
parser_mediator, cookie_name=event_data.cookie_name,
184186
cookie_data=event_data.cookie_value, url=event_data.url)
185187

188+
# Raise on coding errors.
189+
except (AttributeError, ImportError, NameError, TypeError,
190+
UnboundLocalError):
191+
raise
192+
186193
except Exception as exception: # pylint: disable=broad-except
187194
parser_mediator.ProduceExtractionWarning(
188195
'plugin: {0:s} unable to parse cookie with error: {1!s}'.format(

plaso/parsers/sqlite.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ def GetFormatSpecification(cls):
415415
format_specification.AddNewSignature(b'SQLite format 3', offset=0)
416416
return format_specification
417417

418+
# pylint: disable=missing-raises-doc
418419
def ParseFileEntry(self, parser_mediator, file_entry):
419420
"""Parses a SQLite database file entry.
420421
@@ -464,11 +465,17 @@ def ParseFileEntry(self, parser_mediator, file_entry):
464465
parser_mediator.SetFileEntry(file_entry)
465466
parser_mediator.AddEventAttribute('schema_match', schema_match)
466467

468+
# pylint: disable=try-except-raise
467469
try:
468470
plugin.UpdateChainAndProcess(
469471
parser_mediator, cache=cache, database=database,
470472
database_wal=database_wal, wal_file_entry=wal_file_entry)
471473

474+
# Raise on coding errors.
475+
except (AttributeError, ImportError, NameError, TypeError,
476+
UnboundLocalError):
477+
raise
478+
472479
except Exception as exception: # pylint: disable=broad-except
473480
parser_mediator.ProduceExtractionWarning((
474481
'plugin: {0:s} unable to parse SQLite database with error: '
@@ -490,6 +497,11 @@ def ParseFileEntry(self, parser_mediator, file_entry):
490497
parser_mediator, cache=cache, database=database,
491498
database_wal=database_wal, wal_file_entry=wal_file_entry)
492499

500+
# Raise on coding errors.
501+
except (AttributeError, ImportError, NameError, TypeError,
502+
UnboundLocalError):
503+
raise
504+
493505
except Exception as exception: # pylint: disable=broad-except
494506
parser_mediator.ProduceExtractionWarning((
495507
'plugin: {0:s} unable to parse SQLite database and WAL with '

plaso/parsers/sqlite_plugins/chrome_cookies.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def __init__(self):
7171
self._cookie_plugins = (
7272
cookie_plugins_manager.CookiePluginsManager.GetPlugins())
7373

74+
# pylint: disable=missing-raises-doc
7475
def ParseCookieRow(self, parser_mediator, query, row, **unused_kwargs):
7576
"""Parses a cookie row.
7677
@@ -134,11 +135,17 @@ def ParseCookieRow(self, parser_mediator, query, row, **unused_kwargs):
134135
if cookie_name != plugin.COOKIE_NAME:
135136
continue
136137

138+
# pylint: disable=try-except-raise
137139
try:
138140
plugin.UpdateChainAndProcess(
139141
parser_mediator, cookie_data=cookie_data, cookie_name=cookie_name,
140142
url=url)
141143

144+
# Raise on coding errors.
145+
except (AttributeError, ImportError, NameError, TypeError,
146+
UnboundLocalError):
147+
raise
148+
142149
except Exception as exception: # pylint: disable=broad-except
143150
parser_mediator.ProduceExtractionWarning(
144151
'plugin: {0:s} unable to parse cookie with error: {1!s}'.format(

plaso/parsers/sqlite_plugins/interface.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def _HashRow(cls, row):
9595

9696
return hash(' '.join(values))
9797

98+
# pylint: disable=missing-raises-doc
9899
def _ParseQuery(self, parser_mediator, database, query, callback, cache):
99100
"""Queries a database and parses the results.
100101
@@ -124,9 +125,15 @@ def _ParseQuery(self, parser_mediator, database, query, callback, cache):
124125
if row_hash in row_cache:
125126
continue
126127

128+
# pylint: disable=try-except-raise
127129
try:
128130
callback(parser_mediator, query, row, cache=cache, database=database)
129131

132+
# Raise on coding errors.
133+
except (AttributeError, ImportError, NameError, TypeError,
134+
UnboundLocalError):
135+
raise
136+
130137
except Exception as exception: # pylint: disable=broad-except
131138
parser_mediator.ProduceExtractionWarning((
132139
'unable to parse row: {0:d} with callback: {1:s} on database '

0 commit comments

Comments
 (0)