Description
An except block containing only pass suppresses the exception and lets execution continue.
Potential impact
A failed security check may go unnoticed. Missing diagnostic information can delay investigation.
Remediation
Catch specific exceptions when you can recover from them. Otherwise record the failure and return it to the caller or re-raise the exception.
Examples
Before
python
try:
value = values[0]
except IndexError:
pass
After
python
try:
value = values[0]
except IndexError:
logger.exception("missing value")
raise
If values[0] raises IndexError, logger.exception records the exception details and the bare raise re-raises it.