Skip to content

Files

Latest commit

 

History

History
36 lines (26 loc) · 882 Bytes

B110.md

File metadata and controls

36 lines (26 loc) · 882 Bytes

Pattern: A pass in the except block

Issue: -

Description

This pattern is considered bad practice in general, but also represents a potential security issue. A larger than normal volume of errors from a service can indicate an attempt is being made to disrupt or interfere with it. Thus errors should, at the very least, be logged.

There are rare situations where it is desirable to suppress errors, but this is typically done with specific exception types, rather than the base Exception class (or no type).

Example of insecure code:

try:
  do_some_stuff()
except Exception:
  pass

Example of secure code:

try:
  do_some_stuff()
except ZeroDivisionError:
  pass

Further Reading