You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If a caller gives an incorrect JSON file path to the Attck constructor then this is silently ignored. This will likely lead to later runtime exceptions that are hard to diagnose.
Traceback (most recent call last):
File "./err.py", line 5, in <module>
print(len(attck.enterprise.actors))
File "/home/mjc/github/pyattck/pyattck/enterprise/enterprise.py", line 292, in actors
for group in self.__attck['objects']:
TypeError: 'NoneType' object is not subscriptable
Expected behavior
The standard exception FileNotFoundError should be propagated from the call to open(). Instead, it is hidden from the caller by _read_from_disk() in configuration.py. I see two issues (anti-patterns) here:
Check-then-open: just try to open the path as a file.
Ignoring all subsequent exceptions (except: pass): remove.
Small PR attached for this one file issue. I lost a couple of hours to this (path with dash instead of underscore, arg!).
There are many other occurrences of except: pass or except: return None throughout the project. Almost all of those could/should be improved. I don't have the context for the original author's decision so difficult to say what they were expecting might fail. Example from technique.py:
Describe the bug
If a caller gives an incorrect JSON file path to the
Attck
constructor then this is silently ignored. This will likely lead to later runtime exceptions that are hard to diagnose.To Reproduce
err.py
:Running this produces error at the last line:
Expected behavior
The standard exception
FileNotFoundError
should be propagated from the call toopen()
. Instead, it is hidden from the caller by_read_from_disk()
inconfiguration.py
. I see two issues (anti-patterns) here:except: pass
): remove.The text was updated successfully, but these errors were encountered: