Skip to content

Commit 9750bc3

Browse files
committed
Changes to not catch exception related to coding errors
1 parent 5157939 commit 9750bc3

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
@@ -145,6 +145,7 @@ def _Main(self):
145145

146146
storage_writer.WriteTaskStart()
147147

148+
# pylint: disable=try-except-raise
148149
try:
149150
logger.debug(
150151
'{0!s} (PID: {1:d}) started monitoring event queue.'.format(
@@ -179,6 +180,11 @@ def _Main(self):
179180

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

183+
# Raise on coding errors.
184+
except (AttributeError, ImportError, NameError, TypeError,
185+
UnboundLocalError):
186+
raise
187+
182188
# All exceptions need to be caught here to prevent the process
183189
# from being killed by an uncaught exception.
184190
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
@@ -380,6 +380,7 @@ def GetFormatSpecification(cls):
380380
format_specification.AddNewSignature(b'SQLite format 3', offset=0)
381381
return format_specification
382382

383+
# pylint: disable=missing-raises-doc
383384
def ParseFileEntry(self, parser_mediator, file_entry):
384385
"""Parses a SQLite database file entry.
385386
@@ -428,11 +429,17 @@ def ParseFileEntry(self, parser_mediator, file_entry):
428429
parser_mediator.SetFileEntry(file_entry)
429430
parser_mediator.AddEventAttribute('schema_match', schema_match)
430431

432+
# pylint: disable=try-except-raise
431433
try:
432434
plugin.UpdateChainAndProcess(
433435
parser_mediator, cache=cache, database=database,
434436
database_wal=database_wal, wal_file_entry=wal_file_entry)
435437

438+
# Raise on coding errors.
439+
except (AttributeError, ImportError, NameError, TypeError,
440+
UnboundLocalError):
441+
raise
442+
436443
except Exception as exception: # pylint: disable=broad-except
437444
parser_mediator.ProduceExtractionWarning((
438445
'plugin: {0:s} unable to parse SQLite database with error: '
@@ -454,6 +461,11 @@ def ParseFileEntry(self, parser_mediator, file_entry):
454461
parser_mediator, cache=cache, database=database,
455462
database_wal=database_wal, wal_file_entry=wal_file_entry)
456463

464+
# Raise on coding errors.
465+
except (AttributeError, ImportError, NameError, TypeError,
466+
UnboundLocalError):
467+
raise
468+
457469
except Exception as exception: # pylint: disable=broad-except
458470
parser_mediator.ProduceExtractionWarning((
459471
'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
@@ -102,6 +102,7 @@ def __init__(self):
102102
self._cookie_plugins = (
103103
cookie_plugins_manager.CookiePluginsManager.GetPlugins())
104104

105+
# pylint: disable=missing-raises-doc
105106
def ParseCookieRow(self, parser_mediator, query, row, **unused_kwargs):
106107
"""Parses a cookie row.
107108
@@ -165,11 +166,17 @@ def ParseCookieRow(self, parser_mediator, query, row, **unused_kwargs):
165166
if cookie_name != plugin.COOKIE_NAME:
166167
continue
167168

169+
# pylint: disable=try-except-raise
168170
try:
169171
plugin.UpdateChainAndProcess(
170172
parser_mediator, cookie_data=cookie_data, cookie_name=cookie_name,
171173
url=url)
172174

175+
# Raise on coding errors.
176+
except (AttributeError, ImportError, NameError, TypeError,
177+
UnboundLocalError):
178+
raise
179+
173180
except Exception as exception: # pylint: disable=broad-except
174181
parser_mediator.ProduceExtractionWarning(
175182
'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
@@ -89,6 +89,7 @@ def _HashRow(cls, row):
8989

9090
return hash(' '.join(values))
9191

92+
# pylint: disable=missing-raises-doc
9293
def _ParseQuery(self, parser_mediator, database, query, callback, cache):
9394
"""Queries a database and parses the results.
9495
@@ -118,9 +119,15 @@ def _ParseQuery(self, parser_mediator, database, query, callback, cache):
118119
if row_hash in row_cache:
119120
continue
120121

122+
# pylint: disable=try-except-raise
121123
try:
122124
callback(parser_mediator, query, row, cache=cache, database=database)
123125

126+
# Raise on coding errors.
127+
except (AttributeError, ImportError, NameError, TypeError,
128+
UnboundLocalError):
129+
raise
130+
124131
except Exception as exception: # pylint: disable=broad-except
125132
parser_mediator.ProduceExtractionWarning((
126133
'unable to parse row: {0:d} with callback: {1:s} on database '

0 commit comments

Comments
 (0)