return in finally can swallow exceptions #5520
Labels
bug
provider/aws
Issues/PRs related with the AWS provider
python
Pull requests that update Python code
severity/low
Bug won't result in any noticeable breakdown of the execution.
Steps to Reproduce
Inspection of source code
Expected behavior
Avoid return in finally.
Actual Result with Screenshots or Logs
There are several places in your code (listed below) where there is a
return
statement in afinally
block, which would swallow any in-flight exception.This means that if an unhandled exception (including a
BaseException
such asKeyboardInterrupt
) is raised from thetry
body, or any exception is raised from one of theexcept:
clauses, it will not propagate on as expected.See also https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions.
prowler/prowler/lib/check/custom_checks_metadata.py
Line 132 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 151 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 184 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 203 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 215 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 283 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 320 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 338 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 692 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 730 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 761 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_service.py
Line 836 in 93d2579
prowler/prowler/providers/aws/services/iam/iam_user_two_active_access_key/iam_user_two_active_access_key.py
Line 38 in 93d2579
How did you install Prowler?
NA
Environment Resource
NA
OS used
NA
Prowler version
master branch
Pip version
NA
Context
No response
The text was updated successfully, but these errors were encountered: